201025_02
authorhgs
Tue, 13 Jul 2010 04:01:20 +0530
changeset 47 d316aecb87fd
parent 46 b9b00b134b0d
child 49 c34c36d1c835
201025_02
applicationmanagement/BWINS/ApplicationManagementu.def
applicationmanagement/RfsPlugin/group/RfsAppMgmtPlugin.mmp
applicationmanagement/RfsPlugin/group/bld.inf
applicationmanagement/RfsPlugin/inc/RfsAppMgmtPlugin.h
applicationmanagement/RfsPlugin/src/102073BF.rss
applicationmanagement/RfsPlugin/src/Proxy.cpp
applicationmanagement/RfsPlugin/src/RfsAppMgmtPlugin.cpp
applicationmanagement/amadapter2/group/amadapter.mmp
applicationmanagement/amadapter2/group/bld.inf
applicationmanagement/amadapter2/inc/amadapter.h
applicationmanagement/amadapter2/inc/nsmldmiapmatcher.h
applicationmanagement/amadapter2/inc/nsmldmuri.h
applicationmanagement/amadapter2/rom/amadapter.iby
applicationmanagement/amadapter2/src/amadapter.cpp
applicationmanagement/amadapter2/src/amadapter.rss
applicationmanagement/amadapter2/src/nsmldmiapmatcher.cpp
applicationmanagement/amadapter2/src/nsmldmuri.cpp
applicationmanagement/applicationmanagement.pro
applicationmanagement/cenrep/keys_application_management.xls
applicationmanagement/client/BWINS/applicationmanagementclientu.def
applicationmanagement/client/BWINS/applicationmanagementu.def
applicationmanagement/client/eabi/applicationmanagementclientu.def
applicationmanagement/client/eabi/applicationmanagementu.def
applicationmanagement/client/group/ApplicationManagementClient.mmp
applicationmanagement/client/group/bld.inf
applicationmanagement/client/src/ApplicationManagementClient.cpp
applicationmanagement/conf/application_management.confml
applicationmanagement/conf/application_management_200267FB.crml
applicationmanagement/eabi/ApplicationManagementu.def
applicationmanagement/group/bld.inf
applicationmanagement/inc/ApplicationManagementClient.h
applicationmanagement/inc/ApplicationManagementClientServer.h
applicationmanagement/inc/ApplicationManagementCommon.h
applicationmanagement/inc/ApplicationManagementConst.h
applicationmanagement/inc/ApplicationManagementRfs.h
applicationmanagement/inc/amprivateCRKeys.h
applicationmanagement/inc/ampskeys.h
applicationmanagement/inc/debug.h
applicationmanagement/omascomoadapter/group/bld.inf
applicationmanagement/omascomoadapter/group/omascomoadapter.mmp
applicationmanagement/omascomoadapter/inc/nsmldmiapmatcher.h
applicationmanagement/omascomoadapter/inc/nsmldmuri.h
applicationmanagement/omascomoadapter/inc/omascomoadapter.h
applicationmanagement/omascomoadapter/inc/omascomoadapterdb.h
applicationmanagement/omascomoadapter/src/20021335.SPD
applicationmanagement/omascomoadapter/src/20021335.txt
applicationmanagement/omascomoadapter/src/nsmldmiapmatcher.cpp
applicationmanagement/omascomoadapter/src/nsmldmuri.cpp
applicationmanagement/omascomoadapter/src/omascomoadapter.cpp
applicationmanagement/omascomoadapter/src/omascomoadapter.rss
applicationmanagement/omascomoadapter/src/omascomoadapterdb.cpp
applicationmanagement/options/BWINS/AMInstallOptionsu.def
applicationmanagement/options/eabi/AMInstallOptionsu.def
applicationmanagement/options/group/AMInstallOptions.mmp
applicationmanagement/options/group/bld.inf
applicationmanagement/options/group/instopts_def.xml
applicationmanagement/options/inc/aminstalloptions.h
applicationmanagement/options/inc/aminstalloptionsint.h
applicationmanagement/options/rom/aminstalloptions.iby
applicationmanagement/options/src/AMInstallOptions.cpp
applicationmanagement/rom/1020781C.txt
applicationmanagement/rom/appmgmt.iby
applicationmanagement/server/conf/applicationmanagement.qrc
applicationmanagement/server/conf/downloaddialog.docml
applicationmanagement/server/conf/error_notes.docml
applicationmanagement/server/conf/installdialog.docml
applicationmanagement/server/conf/qgn_prop_sml_http.svg
applicationmanagement/server/conf/sample.docml
applicationmanagement/server/group/200267FB.txt
applicationmanagement/server/inc/AMAppHideUtil.h
applicationmanagement/server/inc/AMDeploymentComponent.h
applicationmanagement/server/inc/AMDownloadStore.h
applicationmanagement/server/inc/AMDownloaddb.h
applicationmanagement/server/inc/AMPreInstallApp.h
applicationmanagement/server/inc/ApplicationManagementJavaUtility.h
applicationmanagement/server/inc/ApplicationManagementServer.h
applicationmanagement/server/inc/ApplicationManagementUtility.h
applicationmanagement/server/inc/ApplicationManagementUtilityFactory.h
applicationmanagement/server/inc/PlatformSecurityPolicies.h
applicationmanagement/server/inc/ServicePluginLogger.h
applicationmanagement/server/inc/amdeploymentcomponent.inl
applicationmanagement/server/inc/amdeploymentcomponentdata.h
applicationmanagement/server/inc/amsmlhelper.h
applicationmanagement/server/inc/amstorage.h
applicationmanagement/server/inc/amview.h
applicationmanagement/server/inc/amwaitprogdialog.h
applicationmanagement/server/inc/appmgmtdownloadmgr.h
applicationmanagement/server/inc/appmgmtnotifier.h
applicationmanagement/server/inc/appmgmtprogdialog.h
applicationmanagement/server/inc/nsmldmiapmatcher.h
applicationmanagement/server/inc/nsmldmuri.h
applicationmanagement/server/server.pro
applicationmanagement/server/src/1020781C.SPD
applicationmanagement/server/src/1020781C.txt
applicationmanagement/server/src/200267FB.SPD
applicationmanagement/server/src/AMAppHideUtil.cpp
applicationmanagement/server/src/AMDeploymentComponent.cpp
applicationmanagement/server/src/AMDeploymentComponentData.cpp
applicationmanagement/server/src/AMDownloadStore.cpp
applicationmanagement/server/src/AMDownloaddb.cpp
applicationmanagement/server/src/AMPreInstallApp.cpp
applicationmanagement/server/src/AMSmlHelper.cpp
applicationmanagement/server/src/ApplicationManagementJavaUtility.cpp
applicationmanagement/server/src/ApplicationManagementJavaUtilityFactory.cpp
applicationmanagement/server/src/ApplicationManagementServer.cpp
applicationmanagement/server/src/ApplicationManagementUtility.cpp
applicationmanagement/server/src/ApplicationManagementUtilityFactory.cpp
applicationmanagement/server/src/amstorage.cpp
applicationmanagement/server/src/amview.cpp
applicationmanagement/server/src/amwaitprogdialog.cpp
applicationmanagement/server/src/appmgmtdownloadmgr.cpp
applicationmanagement/server/src/appmgmtnotifier.cpp
applicationmanagement/server/src/appmgmtprogdialog.cpp
applicationmanagement/server/src/main.cpp
applicationmanagement/server/src/nsmldmiapmatcher.cpp
applicationmanagement/server/src/nsmldmuri.cpp
applicationmanagement/tsrc/tarmappmng/BWINS/amtestu.def
applicationmanagement/tsrc/tarmappmng/conf/amtest.cfg
applicationmanagement/tsrc/tarmappmng/data/dmtestmappings.txt
applicationmanagement/tsrc/tarmappmng/data/testhbuf_S60_3_X_v_1_0_0.SISx
applicationmanagement/tsrc/tarmappmng/data/verysilent_c_en.xml
applicationmanagement/tsrc/tarmappmng/eabi/amtestu.def
applicationmanagement/tsrc/tarmappmng/group/amtest.mmp
applicationmanagement/tsrc/tarmappmng/group/amtest.pkg
applicationmanagement/tsrc/tarmappmng/group/bld.inf
applicationmanagement/tsrc/tarmappmng/inc/TestDmDDFObject.h
applicationmanagement/tsrc/tarmappmng/inc/amtest.h
applicationmanagement/tsrc/tarmappmng/inc/dmatest.h
applicationmanagement/tsrc/tarmappmng/init/amtest.ini
applicationmanagement/tsrc/tarmappmng/src/TestDmDDFObject.cpp
applicationmanagement/tsrc/tarmappmng/src/amtest.cpp
applicationmanagement/tsrc/tarmappmng/src/amtestBlocks.cpp
applicationmanagement/tsrc/tarmappmng/src/dmatest.cpp
clientprovisioning/cpqtsp/cpqtsp.pro
clientprovisioning/cpqtsp/inc/CWPSaver.h
clientprovisioning/cpqtsp/src/CWPSaver.cpp
devicecontrol.pro
devicemgmtdialogsplugin/devicemanagementnotifierdevman.qrc
devicemgmtdialogsplugin/devicemgmtdialogsplugin.pro
devicemgmtdialogsplugin/inc/devicemanagementnotifierutils.h
devicemgmtdialogsplugin/inc/fotadevicedialogs.h
devicemgmtdialogsplugin/resources/error_notes.docml
devicemgmtdialogsplugin/resources/fotainformativedialog.docml
devicemgmtdialogsplugin/resources/fotaresumeupdate.docml
devicemgmtdialogsplugin/resources/fotasoftkeydialog.docml
devicemgmtdialogsplugin/resources/fotasoftkeysdialog.docml
devicemgmtdialogsplugin/src/devicemanagementnotifierplugin.cpp
devicemgmtdialogsplugin/src/devicemanagementnotifierutils.cpp
devicemgmtdialogsplugin/src/fotadevicedialogs.cpp
devicemgmtdialogsplugin/src/syncmlconnectnotifier.cpp
devicemgmtindicatorsplugin/devicemgmtindicatorsplugin.pro
devicemgmtindicatorsplugin/inc/dmindicator.h
devicemgmtindicatorsplugin/inc/dmindicatorsplugin.h
devicemgmtindicatorsplugin/inc/dmpronoteindicators.h
devicemgmtindicatorsplugin/inc/tarmtrustindicator.h
devicemgmtindicatorsplugin/resources/message1.svg
devicemgmtindicatorsplugin/resources/qtg_small_smiley_kissing.svg
devicemgmtindicatorsplugin/rom/dmindicatorsplugin.iby
devicemgmtindicatorsplugin/src/dmindicator.cpp
devicemgmtindicatorsplugin/src/dmindicatorsplugin.cpp
devicemgmtindicatorsplugin/src/dmpronoteindicators.cpp
devicemgmtindicatorsplugin/src/tarmtrustindicator.cpp
deviceupdatesui/deviceupdates/deviceupdates.pro
deviceupdatesui/deviceupdates/inc/DeviceUpdateDebug.h
deviceupdatesui/deviceupdates/inc/deviceupdatemoniter.h
deviceupdatesui/deviceupdates/inc/deviceupdatemoniterobserver.h
deviceupdatesui/deviceupdates/inc/dmadvancedview.h
deviceupdatesui/deviceupdates/inc/dmfotaview.h
deviceupdatesui/deviceupdates/inc/dminforetrieval.h
deviceupdatesui/deviceupdates/inc/nsmldmsynchandler.h
deviceupdatesui/deviceupdates/inc/serversettingsview.h
deviceupdatesui/deviceupdates/inc/settingsdataformcustomitem.h
deviceupdatesui/deviceupdates/src/deviceupdatemoniter.cpp
deviceupdatesui/deviceupdates/src/dmadvancedview.cpp
deviceupdatesui/deviceupdates/src/dmfotaview.cpp
deviceupdatesui/deviceupdates/src/dminforetrieval.cpp
deviceupdatesui/deviceupdates/src/nsmldmsynchandler.cpp
deviceupdatesui/deviceupdates/src/serversettingsview.cpp
deviceupdatesui/deviceupdates/src/settingsdataformcustomitem.cpp
group/bld.inf
omacpadapters/MbxNbrAdapter/Data/10207281.rss
omacpadapters/MbxNbrAdapter/Data/WPMbxNbrAdapterResource.rss
omacpadapters/MbxNbrAdapter/Group/MbxNbrAdapter.mmp
omacpadapters/MbxNbrAdapter/Group/bld.inf
omacpadapters/MbxNbrAdapter/Inc/MbxNbrAdapter.h
omacpadapters/MbxNbrAdapter/Src/MbxNbrAdapter.cpp
omacpadapters/MbxNbrAdapter/Src/MbxNbrAdapterGroupProxy.cpp
omacpadapters/MbxNbrAdapter/loc/MailboxAdapter.loc
omacpadapters/StreamingAdapter/Data/101F85CB.rss
omacpadapters/StreamingAdapter/Data/WPStreamingAdapterResource.rss
omacpadapters/StreamingAdapter/Group/StreamingAdapter.mmp
omacpadapters/StreamingAdapter/Group/bld.inf
omacpadapters/StreamingAdapter/Inc/StreamingAdapter.h
omacpadapters/StreamingAdapter/Src/Streamingadapter.cpp
omacpadapters/StreamingAdapter/Src/StreamingadapterGroupProxy.cpp
omacpadapters/StreamingAdapter/loc/StreamingAdapter.loc
omacpadapters/WAPAdapter/Data/101F84DC.rss
omacpadapters/WAPAdapter/Data/WPWAPAdapterResource.rss
omacpadapters/WAPAdapter/Group/WPWAPAdapter.mmp
omacpadapters/WAPAdapter/Group/bld.inf
omacpadapters/WAPAdapter/Inc/CWPWAPAdapterBase.h
omacpadapters/WAPAdapter/Inc/CWPWAPBookmarkItem.h
omacpadapters/WAPAdapter/Inc/CWPWAPBrowserAdapter.h
omacpadapters/WAPAdapter/Inc/CWPWAPBrowserItem.h
omacpadapters/WAPAdapter/Inc/CWPWAPItemBAse.h
omacpadapters/WAPAdapter/Inc/CWPWAPMMSAdapter.h
omacpadapters/WAPAdapter/Inc/CWPWAPMMSItem.h
omacpadapters/WAPAdapter/Inc/MWPWAPItemBase.h
omacpadapters/WAPAdapter/Inc/WPWAPDebug.h
omacpadapters/WAPAdapter/Inc/WPWAPItemFactory.h
omacpadapters/WAPAdapter/Inc/WPWAPUtil.h
omacpadapters/WAPAdapter/Src/CWPWAPAdapterBase.cpp
omacpadapters/WAPAdapter/Src/CWPWAPBookmarkItem.cpp
omacpadapters/WAPAdapter/Src/CWPWAPBrowserAdapter.cpp
omacpadapters/WAPAdapter/Src/CWPWAPBrowserItem.cpp
omacpadapters/WAPAdapter/Src/CWPWAPItemBAse.cpp
omacpadapters/WAPAdapter/Src/CWPWAPMMSAdapter.cpp
omacpadapters/WAPAdapter/Src/CWPWAPMMSItem.cpp
omacpadapters/WAPAdapter/Src/WPWAPAdapterGroupProxy.cpp
omacpadapters/WAPAdapter/Src/WPWAPAdapterMain.cpp
omacpadapters/WAPAdapter/Src/WPWAPItemFactory.cpp
omacpadapters/WAPAdapter/Src/WPWAPUtil.cpp
omacpadapters/accesspointadapter/Inc/CWPAPAccesspointItem.h
omacpadapters/accesspointadapter/Inc/CWPAPAdapter.h
omacpadapters/accesspointadapter/Inc/CWPAPItemBase.h
omacpadapters/accesspointadapter/Inc/CWPAPLogicalProxy.h
omacpadapters/accesspointadapter/Inc/CWPAPNapdef.h
omacpadapters/accesspointadapter/Inc/CWPAPPhysicalProxy.h
omacpadapters/accesspointadapter/Inc/CWPAPPort.h
omacpadapters/accesspointadapter/Inc/ProvisioningDebug.h
omacpadapters/accesspointadapter/Inc/WPAPAdapter.pan
omacpadapters/accesspointadapter/Inc/WPAPDefs.h
omacpadapters/accesspointadapter/Inc/WPAPSharedDataKeys.h
omacpadapters/accesspointadapter/Inc/WPAPUtil.h
omacpadapters/accesspointadapter/Src/CWPAPAccesspointItem.cpp
omacpadapters/accesspointadapter/Src/CWPAPAdapter.cpp
omacpadapters/accesspointadapter/Src/CWPAPItemBase.cpp
omacpadapters/accesspointadapter/Src/CWPAPLogicalProxy.cpp
omacpadapters/accesspointadapter/Src/CWPAPNapdef.cpp
omacpadapters/accesspointadapter/Src/CWPAPPhysicalProxy.cpp
omacpadapters/accesspointadapter/Src/CWPAPPort.cpp
omacpadapters/accesspointadapter/Src/CWPLog.cpp
omacpadapters/accesspointadapter/Src/CWPLog.h
omacpadapters/accesspointadapter/Src/CWPLogDef.h
omacpadapters/accesspointadapter/Src/WPAPAdapterGroupProxy.cpp
omacpadapters/accesspointadapter/Src/WPAPAdapterPanics.cpp
omacpadapters/accesspointadapter/Src/WPAPUtil.cpp
omacpadapters/accesspointadapter/group/101F84D8.rss
omacpadapters/accesspointadapter/group/WPAPAdapter.mmp
omacpadapters/accesspointadapter/group/WPAPAdapterResource.rss
omacpadapters/accesspointadapter/group/bld.inf
omacpadapters/accesspointadapter/loc/WPAPAdapter.loc
omacpadapters/accesspointadapter/rom/WPAPAdapter.iby
omacpadapters/accesspointadapter/rom/WPAPAdapterResources.iby
omacpadapters/bld/ProvisioningDebug.h
omacpadapters/bld/ProvisioningUIDs.h
omacpadapters/bld/bld.inf
omacpadapters/rom/ProvisioningAdapter.iby
omacpadapters/rom/ProvisioningAdapterResources.iby
omadcmoadapters/extmemctrl/data/2002132B.rss
omadcmoadapters/extmemctrl/group/bld.inf
omadcmoadapters/extmemctrl/group/extmemctrldcmoadapter.mmp
omadcmoadapters/extmemctrl/inc/extmemctrldcmoadapter.h
omadcmoadapters/extmemctrl/src/extmemctrldcmoadapter.cpp
omadcmoadapters/extmemctrl/src/extmemctrldcmoadapterproxy.cpp
omadcmoadapters/group/bld.inf
omadcmoadapters/rom/omadcmoadapters.iby
omadcmoadapters/wlanctrl/data/wlanctrldcmoadapter.rss
omadcmoadapters/wlanctrl/group/bld.inf
omadcmoadapters/wlanctrl/group/wlanctrldcmoadapter.mmp
omadcmoadapters/wlanctrl/inc/wlanctrldcmoadapter.h
omadcmoadapters/wlanctrl/src/wlanctrldcmoadapter.cpp
omadcmoadapters/wlanctrl/src/wlanctrldcmoadapterproxy.cpp
omadmadapters/bld/bld.inf
omadmadapters/dcmodmadapter/data/dcmodmadapter.rss
omadmadapters/dcmodmadapter/group/bld.inf
omadmadapters/dcmodmadapter/group/dcmodmadapter.mmp
omadmadapters/dcmodmadapter/inc/dcmodmadapter.h
omadmadapters/dcmodmadapter/src/dcmodmadapter.cpp
omadmadapters/dcmodmadapter/src/dcmodmadaptermain.cpp
omadmadapters/fota/bld/bld.inf
omadmadapters/fota/bld/nsmldmfotaadapter.mmp
omadmadapters/fota/conf/fotaadapter.confml
omadmadapters/fota/conf/fotaadapter_101F9A08.crml
omadmadapters/fota/inc/FotaSrvDebug.h
omadmadapters/fota/inc/fotaadapterCRKeys.h
omadmadapters/fota/inc/nsmldmfotaadapter.h
omadmadapters/fota/inc/nsmldmfotaadapterdb.h
omadmadapters/fota/src/101F9A02.SPD
omadmadapters/fota/src/nsmldmfotaadapter.cpp
omadmadapters/fota/src/nsmldmfotaadapter.rss
omadmadapters/fota/src/nsmldmfotaadapterdb.cpp
omadmadapters/nsmldminternet/group/bld.inf
omadmadapters/nsmldminternet/group/nsmlinternetadapter.mmp
omadmadapters/nsmldminternet/inc/NSmlInternetAdapter.h
omadmadapters/nsmldminternet/inc/NSmlWLanAdapter.h
omadmadapters/nsmldminternet/inc/NSmlWlanSettings.h
omadmadapters/nsmldminternet/rom/nsmlinternetadapter.iby
omadmadapters/nsmldminternet/src/NSmlInternetAdapter.cpp
omadmadapters/nsmldminternet/src/NSmlInternetAdapter.rss
omadmadapters/nsmldminternet/src/NSmlWLanAdapter.cpp
omadmadapters/nsmldminternet/src/NSmlWlanSettings.cpp
omadmadapters/rom/omadmadapters.iby
omadmadapters/syncmldm12/src/NSmlDmSettingsAdapter12.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/BWINS/ApplicationManagementu.def	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,27 @@
+EXPORTS
+	?ActivateL@RApplicationManagement@NApplicationManagement@@QBEXK@Z @ 1 NONAME ; void NApplicationManagement::RApplicationManagement::ActivateL(unsigned long) const
+	?Close@RAppMgmtRfs@@QAEXXZ @ 2 NONAME ; void RAppMgmtRfs::Close(void)
+	?Close@RApplicationManagement@NApplicationManagement@@QAEXXZ @ 3 NONAME ; void NApplicationManagement::RApplicationManagement::Close(void)
+	?Connect@RAppMgmtRfs@@QAEHXZ @ 4 NONAME ; int RAppMgmtRfs::Connect(void)
+	?Connect@RApplicationManagement@NApplicationManagement@@QAEHABVTCertInfo@@@Z @ 5 NONAME ; int NApplicationManagement::RApplicationManagement::Connect(class TCertInfo const &)
+	?Connect@RApplicationManagement@NApplicationManagement@@QAEHXZ @ 6 NONAME ; int NApplicationManagement::RApplicationManagement::Connect(void)
+	?DeactivateL@RApplicationManagement@NApplicationManagement@@QBEXK@Z @ 7 NONAME ; void NApplicationManagement::RApplicationManagement::DeactivateL(unsigned long) const
+	?DeliverL@RApplicationManagement@NApplicationManagement@@QBEKABV?$TBuf8@$0BAA@@@@Z @ 8 NONAME ; unsigned long NApplicationManagement::RApplicationManagement::DeliverL(class TBuf8<256> const &) const
+	?DeploymentComponent@RApplicationManagement@NApplicationManagement@@QBEHKAAUTDeploymentComponent@2@@Z @ 9 NONAME ; int NApplicationManagement::RApplicationManagement::DeploymentComponent(unsigned long, struct NApplicationManagement::TDeploymentComponent &) const
+	?DeploymentComponentDataL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@AAVCBufBase@@@Z @ 10 NONAME ; void NApplicationManagement::RApplicationManagement::DeploymentComponentDataL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class CBufBase &) const
+	?DeploymentComponentDataSizeL@RApplicationManagement@NApplicationManagement@@QBEHKABW4TDeplCompAttrType@2@@Z @ 11 NONAME ; int NApplicationManagement::RApplicationManagement::DeploymentComponentDataSizeL(unsigned long, enum NApplicationManagement::TDeplCompAttrType const &) const
+	?DeploymentComponentIdsL@RApplicationManagement@NApplicationManagement@@QBEHAAV?$RArray@K@@W4TDeploymentComponentState@2@@Z @ 12 NONAME ; int NApplicationManagement::RApplicationManagement::DeploymentComponentIdsL(class RArray<unsigned long> &, enum NApplicationManagement::TDeploymentComponentState) const
+	?DeploymentComponentUserIdL@RApplicationManagement@NApplicationManagement@@QBEXKAAV?$TBuf8@$0BAA@@@@Z @ 13 NONAME ; void NApplicationManagement::RApplicationManagement::DeploymentComponentUserIdL(unsigned long, class TBuf8<256> &) const
+	?DownloadL@RApplicationManagement@NApplicationManagement@@QBEKABV?$TBuf8@$0BAA@@@@Z @ 14 NONAME ; unsigned long NApplicationManagement::RApplicationManagement::DownloadL(class TBuf8<256> const &) const
+	?InstallL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeploymentComponentState@2@@Z @ 15 NONAME ; void NApplicationManagement::RApplicationManagement::InstallL(unsigned long, enum NApplicationManagement::TDeploymentComponentState) const
+	?PerformRfsL@RAppMgmtRfs@@QBEXXZ @ 16 NONAME ; void RAppMgmtRfs::PerformRfsL(void) const
+	?RemoveL@RApplicationManagement@NApplicationManagement@@QBEXK@Z @ 17 NONAME ; void NApplicationManagement::RApplicationManagement::RemoveL(unsigned long) const
+	?StartDownloadL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDownloadTarget@2@@Z @ 18 NONAME ; void NApplicationManagement::RApplicationManagement::StartDownloadL(unsigned long, enum NApplicationManagement::TDownloadTarget) const
+	?StateChangeComplete@RApplicationManagement@NApplicationManagement@@QBEHK@Z @ 19 NONAME ; int NApplicationManagement::RApplicationManagement::StateChangeComplete(unsigned long) const
+	?StateChangingDCIdsL@RApplicationManagement@NApplicationManagement@@QBEHAAV?$RArray@K@@@Z @ 20 NONAME ; int NApplicationManagement::RApplicationManagement::StateChangingDCIdsL(class RArray<unsigned long> &) const
+	?UpdateDeploymentComponentDataL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@ABVTDesC8@@1@Z @ 21 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateDeploymentComponentDataL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class TDesC8 const &, class TDesC8 const &) const
+	?UpdateDeploymentComponentL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@ABVTDesC8@@@Z @ 22 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateDeploymentComponentL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class TDesC8 const &) const
+	?UpdateL@RApplicationManagement@NApplicationManagement@@QBEXKK@Z @ 23 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateL(unsigned long, unsigned long) const
+	?DeploymentComponentTempInstFile@RApplicationManagement@NApplicationManagement@@QBEXKAAVRFile@@ABW4TDeplCompAttrType@2@@Z @ 24 NONAME ; void NApplicationManagement::RApplicationManagement::DeploymentComponentTempInstFile(unsigned long, class RFile &, enum NApplicationManagement::TDeplCompAttrType const &) const
+	?UpdateDeploymentComponentStreamedDataL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@ABVTDesC8@@@Z @ 25 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateDeploymentComponentStreamedDataL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class TDesC8 const &) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/RfsPlugin/group/RfsAppMgmtPlugin.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,51 @@
+/*
+* 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: Implementation of applicationmanagement components
+*
+*
+*/
+
+
+// To get the APP_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+
+TARGET         rfsappmgmtplugin.dll
+TARGETTYPE	   PLUGIN
+CAPABILITY	   CAP_ECOM_PLUGIN
+VENDORID	     VID_DEFAULT
+UID            0x10009D8D 0x102073BF
+
+SOURCEPATH     ../src
+SOURCE         RfsAppMgmtPlugin.cpp 
+SOURCE         Proxy.cpp
+
+START RESOURCE 102073BF.rss
+TARGET rfsappmgmtplugin.rsc
+LANGUAGE_IDS
+END
+
+
+
+USERINCLUDE     ../inc
+USERINCLUDE	    ../../inc
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+LIBRARY 	      euser.lib       // Base library
+LIBRARY 	      ecom.lib	    // ECom library
+LIBRARY 	      applicationmanagement.lib
+LIBRARY 	      flogger.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/RfsPlugin/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,29 @@
+/*
+* 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 RFS AppMgmt
+*    	plugin
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_MMPFILES
+../group/RfsAppMgmtPlugin.mmp
+
+
+PRJ_TESTMMPFILES
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/RfsPlugin/inc/RfsAppMgmtPlugin.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,86 @@
+/*
+* 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: Implementation of applicationmanagement components
+*  
+*
+*/
+
+
+
+#ifndef RFSAPPMGMTPLUGIN_H
+#define RFSAPPMGMTPLUGIN_H
+
+//  INCLUDES
+#include <e32base.h>
+
+#include "rfsPlugin.h"
+
+// CLASS DECLARATION
+
+class CRfsAppMgmtPlugin: public CRFSPlugin
+    {
+public:
+
+    /**
+    * Two-phased constructor.
+	* @param	aInitParams initial parameters
+    */
+    static CRfsAppMgmtPlugin* NewL(TAny* aInitParams);
+
+    /**
+    * Destructor.
+    */
+    virtual ~CRfsAppMgmtPlugin();
+
+    /**
+    * 
+	* @param
+    */
+    void RestoreFactorySettingsL( const TRfsReason aType );
+
+    /**
+    * 
+	* @param
+    */
+    void GetScriptL( const TRfsReason aType, TDes& aPath );
+
+    /**
+    * 
+	* @param
+    */
+    void ExecuteCustomCommandL( const TRfsReason aType, TDesC& aCommand );
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CRfsAppMgmtPlugin();
+
+    /**
+    * Constructor.
+    * @param	aInitParams initial parameters
+	*/
+	CRfsAppMgmtPlugin(TAny* aInitParams);
+
+    /**
+    * Constructor
+    */
+    void ConstructL();
+    };
+
+
+
+#endif      // RFSAPPMGMTPLUGIN_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/RfsPlugin/src/102073BF.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 1020 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 applicationmanagement components
+*
+*
+*/
+
+
+#include "registryinfo.rh"
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+	{
+	// UID for the DLL
+	dll_uid = 0x102073BF;
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of interface that is implemented
+			interface_uid = 0x102073BB;
+			implementations = 
+				{
+				// Info for CSrcsBTConnection
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102073C0;
+					version_no = 1;
+					display_name = "RFS AppMgmt Plugin";
+					default_data = "N"; // N = Normal RFS, D = Deep RFS, I = Init RFS (FirstBoot RFS)
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/RfsPlugin/src/Proxy.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* 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 class export ECom interface implementations.
+*
+*/
+
+
+#include <e32std.h>
+#include <implementationproxy.h>
+
+#include "RfsAppMgmtPlugin.h"
+
+// Map the interface UIDs to implementation factory functions
+const TImplementationProxy ImplementationTable[] =
+    {
+    	IMPLEMENTATION_PROXY_ENTRY(0x102073C0,	CRfsAppMgmtPlugin::NewL)
+    };
+
+// 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/applicationmanagement/RfsPlugin/src/RfsAppMgmtPlugin.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,95 @@
+/*
+* 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: Implementation of applicationmanagement components
+*     
+*
+*/
+
+
+// INCLUDE FILES
+#include "ApplicationManagementRfs.h"
+#include "RfsAppMgmtPlugin.h"
+#include "debug.h"
+
+_LIT(KScriptPath, "");
+
+// ================= MEMBER FUNCTIONS =======================
+
+// C++ default constructor can NOT contain any code, that
+// might leave.
+//
+CRfsAppMgmtPlugin::CRfsAppMgmtPlugin()
+    {
+    }
+
+CRfsAppMgmtPlugin::CRfsAppMgmtPlugin(TAny* /*aInitParams*/)
+    {
+    }
+
+// Destructor
+CRfsAppMgmtPlugin::~CRfsAppMgmtPlugin()
+    {
+    }
+
+// ---------------------------------------------------------
+// NewL
+// ---------------------------------------------------------
+//
+CRfsAppMgmtPlugin* CRfsAppMgmtPlugin::NewL(TAny* aInitParams)
+    {
+    RDEBUG("CRfsAppMgmtPlugin::NewL()");
+    CRfsAppMgmtPlugin* self = new (ELeave) CRfsAppMgmtPlugin(aInitParams);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+// ---------------------------------------------------------
+// ConstructL
+// ---------------------------------------------------------
+//
+void CRfsAppMgmtPlugin::ConstructL()
+    {
+    RDEBUG("CRfsAppMgmtPlugin::ConstructL()");
+    }
+
+void CRfsAppMgmtPlugin::RestoreFactorySettingsL( const TRfsReason /*aType*/ )
+    {
+    RDEBUG("CRfsAppMgmtPlugin::RestoreFactorySettingsL()");
+    RAppMgmtRfs appManagement;
+    if( appManagement.Connect() == KErrNone )
+        {
+        RDEBUG("CRfsAppMgmtPlugin::RestoreFactorySettingsL(): Connected to AppMgmt ");
+        appManagement.PerformRfsL();
+        appManagement.Close();
+        }
+    else
+        {
+        RDEBUG("CStartupAppUi::RTCStatus(): Unable to connect to AppMgmt ");
+        }
+    }
+
+void CRfsAppMgmtPlugin::GetScriptL( const TRfsReason /*aType*/, TDes& aPath )
+    {
+    aPath.Copy( KScriptPath);
+    }
+
+void CRfsAppMgmtPlugin::ExecuteCustomCommandL( const TRfsReason /*aType*/,
+                                        TDesC& /*aCommand*/ )
+    {
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/amadapter2/group/amadapter.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,80 @@
+/*
+* 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: Implementation of applicationmanagement components
+*
+*/
+  
+
+// To get the APP_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include "defaultcaps.hrh"
+
+TARGET          amadapter2.dll
+
+CAPABILITY 	    CAP_ECOM_PLUGIN
+
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x10207844
+VENDORID        VID_DEFAULT
+
+MACRO __AM_LASTERROR_NODE // uncomment to enable /SCM/Ext/LastError node
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+SYSTEMINCLUDE 	/epoc32/include/devman
+#else
+// nothing
+#endif
+
+SOURCEPATH      ../src
+SOURCE          amadapter.cpp
+SOURCE					nsmldmiapmatcher.cpp
+SOURCE					nsmldmuri.cpp
+
+USERINCLUDE     ../inc 
+USERINCLUDE			../../inc
+USERINCLUDE 		../../options/inc // install options
+
+
+START RESOURCE amadapter.rss
+TARGET amadapter2.rsc
+END
+
+
+LIBRARY		euser.lib 
+LIBRARY		ecom.lib 
+LIBRARY     estor.lib
+LIBRARY		efsrv.lib 
+LIBRARY		applicationmanagementclient.lib
+LIBRARY		centralrepository.lib 
+LIBRARY 	aminstalloptions.lib 
+LIBRARY		featmgr.lib 
+LIBRARY 	flogger.lib
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+LIBRARY		devmancmdmgr.lib
+LIBRARY		dmtreeclient.lib
+#else
+LIBRARY		nsmldmtreedbclient.lib
+LIBRARY		nsmldmclientserverutils.lib
+LIBRARY		nsmldmiapmatcher.lib 
+#endif
+
+	
+
+SMPSAFE
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/amadapter2/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  build info file for application management adapter
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+../rom/amadapter.iby						CORE_APP_LAYER_IBY_EXPORT_PATH(amadapter.iby)
+
+PRJ_TESTEXPORTS
+/* Commenting the internal folder exports
+../internal/AmadapterTestScript.cfg /epoc32/winscw/c/testframework/AmadapterTestScript.cfg
+../internal/verysilent_c_en.xml /epoc32/winscw/c/TestFramework/amadapter/verysilent_c_en.xml
+../internal/barew_locserv.sisx	/epoc32/winscw/c/TestFramework/amadapter/barew_locserv.sisx
+../internal/barew_locserv2.sisx	/epoc32/winscw/c/TestFramework/amadapter/barew_locserv2.sisx
+*/
+
+
+PRJ_MMPFILES
+./amadapter.mmp
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/amadapter2/inc/amadapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,797 @@
+/*
+* 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:  Application Management DM Adapter 
+*
+*/
+
+
+
+#ifndef __AMADAPTER_H__
+#define __AMADAPTER_H__
+
+// ------------------------------------------------------------------------------------------------
+// Includes
+// ------------------------------------------------------------------------------------------------
+#include <e32base.h>
+#include <smldmadapter.h>
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+#include <dmtree.h>
+#else
+#include "nsmldmtreedbclient.h"
+#endif
+
+#include "ApplicationManagementClient.h"
+
+namespace NApplicationManagement
+	{
+	
+const TUint KAMAdapterImplUid = 0x10207845;
+
+// the DDF version must be changed if any changes in DDF structure ( built in DDFStructureL() function )
+_LIT8( KAMDDFVersion, "1.0" ); 
+
+_LIT8( KAMTextPlain, "text/plain" );
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+_LIT8( KAMNodeName, "./SCM" );
+#else
+_LIT8( KAMNodeName, "SCM" );
+#endif
+_LIT8( KAMNodeDescription, "This node is the root node for all application management functionality" );
+
+_LIT8( KAMInventoryNodeName, "Inventory" );
+_LIT8( KAMInventoryNodeDescription, "This node is start node of application inventory" );
+
+_LIT8( KAMDeliveredNodeName, "Delivered" );
+_LIT8( KAMDeliveredNodeDescription, "This is node under which applications that are delivered but not installed are found." );
+
+_LIT8( KAMDeployedNodeName, "Deployed" );
+_LIT8( KAMDeployedNodeDescription, "This is a node under which deployed applications are found" );
+
+_LIT8( KAMDeliveredDynaNodeDescription, "This dynamic node is placeholder applications that are in Delivered state" );
+
+_LIT8( KAMIDNodeName, "ID" );
+_LIT8( KAMIDNodeDescription, "This leaf node holds an identifier for an application" );
+
+_LIT8( KAMNameNodeName, "Name" );
+_LIT8( KAMNameNodeDescription, "This leaf node holds name of an application" );
+
+_LIT8( KAMVersionNodeName, "Version" );
+_LIT8( KAMVersionNodeDescription, "This leaf node holds the version of an application" );
+
+_LIT8( KAMStateValueNodeName, "StateValue" );
+_LIT8( KAMStateValueNodeDescription, "This leaf node holds the state value of an application (active/inactive)" );
+
+_LIT8( KAMDataNodeName, "Data" );
+_LIT8( KAMDataNodeDescription, "This leaf node holds the data of an application" );
+
+_LIT8( KAMDescriptorNodeName, "Descriptor" );
+_LIT8( KAMDescriptorNodeDescription, "This leaf node holds the possible metadata of an application" );
+
+_LIT8( KAMOperationsNodeName, "Operations" );
+_LIT8( KAMOperationsNodeDescription, "This is a node under which operations are found" );
+
+_LIT8( KAMInstallOptsNodeName, "InstallOpts" );
+_LIT8( KAMInstallOptsNodeDescription, "This is a node that holds the installation options of an application" );
+
+_LIT8( KAMDeployedDynaNodeDescription, "This dynamic node is placeholder applications that are in Inactive state" );
+
+
+_LIT8( KAMDownloadOperationNodeName, "Download" );
+_LIT8( KAMDownloadOperationNodeDescription, "Starts the download" );
+
+_LIT8( KAMConRefNodeName, "ConRef" );
+_LIT8( KAMConRefNodeDescription, "Holds reference to IAP" );
+
+
+_LIT8( KAMLocalOperationsNodeDescription, "This is the root node for local operations" );
+
+_LIT8( KAMActivateNodeName, "Activate" );
+_LIT8( KAMActivateNodeDescription, "Exec command causes device to activate an inactive application" );
+
+_LIT8( KAMDeActivateNodeName, "Deactivate" );
+_LIT8( KAMDeActivateNodeDescription, "Exec command causes device to stop and deactivate an active application" );
+
+_LIT8( KAMInstallNodeName, "Install" );
+_LIT8( KAMInstallNodeDescription, "Exec command causes device to install a delivered application" );
+
+_LIT8( KAMInstallAndActivateNodeName, "InstallAndActivate" );
+_LIT8( KAMInstallAndActivateNodeDescription, "Exec command causes device to install a delivered application and activate it" );
+
+_LIT8( KAMUpdateNodeName, "Update" );
+_LIT8( KAMUpdateNodeDescription, "Exec command causes device to update an application" );
+
+_LIT8( KAMUpdateAndActivateNodeName, "UpdateAndActivate" );
+_LIT8( KAMUpdateAndActivateNodeDescription, "Exec command causes device to update an application and activate it" );
+
+_LIT8( KAMRemoveNodeName, "Remove" );
+_LIT8( KAMRemoveNodeDescription, "Exec command causes device to remove an application" );
+
+
+_LIT8( KAMDownloadNodeName, "Download" );
+_LIT8( KAMDownloadNodeDescription, "This node is a root node for application download functionality" );
+
+_LIT8( KAMDownloadAndInstallNodeName, "DownloadAndInstall" );
+_LIT8( KAMDownloadAndInstallOperationNodeDescription, "Starts the download and installs component when complete" );
+
+_LIT8( KAMDownloadAndInstallAndActivateNodeName, "DownloadAndInstallAndActivate" );
+_LIT8( KAMDownloadAndInstallAndActivateNodeDescription, "Starts the download and installs and activates component when complete" );
+
+_LIT8( KAMDownloadAndUpdateNodeName, "DownloadAndUpdate" );
+_LIT8( KAMDownloadAndUpdateNodeDescription, "Starts the download and installs component when complete" );
+
+_LIT8( KAMDownloadAndUpdateAndActivateNodeName, "DownloadAndUpdateAndActivate" );
+_LIT8( KAMDownloadAndUpdateAndActivateNodeDescription, "Starts the download and updates and activates component when complete" );
+
+_LIT8( KAMDownloadDynaNodeDescription, "This node is a placeholder for identifier of an application that is to be downloaded" );
+
+_LIT8( KAMURINodeName, "URI" );
+_LIT8( KAMURINodeDescription, "This leaf node holds the URL from which the application should be downloaded" );
+
+_LIT8( KAMStatusNodeName, "Status" );
+_LIT8( KAMStatusNodeDescription, "This leaf node holds the status of the download" );
+
+#ifdef __AM_LASTERROR_NODE
+_LIT8( KAMExtNodeName, "Ext" );
+_LIT8( KAMExtNodeDescription, "Non std extentions are found under this leaf" );
+_LIT8( KAMLastErrorNodeName, "LastError" );
+_LIT8( KAMLastErrorDescription, "This leaf node may hold the error" );
+#endif
+
+_LIT8( KAMDynamicNodeName, "" );
+_LIT( KAMSeparator16, "/" );
+
+_LIT8( KAMSeparator8, "/" );
+
+_LIT8( KAMRootChilds, "Inventory/Download" );
+_LIT8( KAMInventoryChilds, "Delivered/Deployed" );
+//_LIT8( KAMLocalOperationsChilds, "Activate/DeActivate/Install/Update/Remove" );
+
+_LIT8( KAMDownloadDynaChilds, "ID/Name/Version/URI/Status/Operations" );
+_LIT8( KAMInventoryDynaChilds, "ID/Name/Version/StateValue/Operations" );
+_LIT8( KAMDownloadOperationChilds, "Download/DownloadAndInstall/DownloadAndInstallAndActivate/DownloadAndUpdate/DownloadAndUpdateAndActivate" );
+_LIT8( KAMDeployedOperationChilds, "Activate/Deactivate/Remove" );
+_LIT8( KAMDeliveredOperationChilds, "Install/Update/InstallAndActivate/UpdateAndActivate/Remove" );
+_LIT8( KAMInventoryDeliveredDynaChilds, "ID/Name/Version/Descriptor/Data/InstallOpts/Operations" );
+
+
+struct TAMCommandBufferElement
+	{
+	TInt iStatusRef;
+	TBuf8<256> iURI;
+	TAMCommandBufferElement( TInt aRef, const TDesC8 &aURI )
+		: iStatusRef( aRef ), iURI( aURI )
+		{
+		}
+	};
+	
+typedef RArray<TAMCommandBufferElement> TAMCommandBuffer;	
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter 
+// ------------------------------------------------------------------------------------------------
+class CAmAdapter : public CSmlDmAdapter
+	{
+public:
+	static CAmAdapter* NewL( MSmlDmCallback* aDmCallback );
+	static CAmAdapter* NewLC( MSmlDmCallback* aDmCallback );
+
+	virtual ~CAmAdapter();
+
+
+/**
+	The function returns current version of the DDF.
+	By asking current DDF versions from adapters DM Module can control
+	possible changes in the data structure and send the changed DDF
+	description to a management server.
+	This function is always called after DDFStructureL.
+    @param aVersion DDF version of the adapter. (filled by the adapter)
+	@publishedPartner
+	@prototype
+	*/
+	virtual void DDFVersionL( CBufBase& aVersion );
+	
+	/**
+	The function for filling the DDF structure of the adapter
+	This function is only called once, immediately after the adapter is created.
+	@param aDDFObject	Reference to root object. A DM adapter starts filling
+						the data structure by calling AddChildObjectL to the root object and
+						so describes the DDF of the adapter. 
+	@publishedPartner
+	@prototype
+	*/
+	virtual void DDFStructureL( MSmlDmDDFObject& aDDF );
+	
+	/**
+	The function creates new leaf objects, or replaces data in existing leaf
+	objects. The information about the success of the command should be
+	returned by calling SetStatusL function of MSmlDmCallback callback
+	interface. This makes it possible to buffer the commands.  However, all
+	the status codes for buffered commands must be returned at the latest when
+	the adapter's CompleteOutstandingCmdsL() is called.
+	@param aURI			URI of the object
+	@param aLUID		LUID of the object (if the adapter has earlier returned a
+						LUID to the DM Module). For new objects, this is the LUID
+						inherited through the parent node.
+	@param aObject		Data of the object.
+	@param aType		MIME type of the object
+	@param aStatusRef	Reference to correct command, i.e. this reference
+						must be used when calling the SetStatusL of this command
+	@publishedPartner
+	@prototype
+	*/
+	virtual void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+									const TDesC8& aObject, const TDesC8& aType,
+									TInt aStatusRef );
+		
+	/**
+	The function creates new leaf objects, or replaces data in existing leaf
+	objects, in the case where data is large enough to be streamed. The
+	information about the success of the command should be returned by calling
+	SetStatusL function of MSmlDmCallback callback interface. This makes it
+	possible to buffer the commands.  However, all the status codes for buffered
+	commands must be returned at the latest when the CompleteOutstandingCmdsL()
+	of adapter is called.
+	@param aURI		URI of the object
+	@param aLUID		LUID of the object (if the adapter has earlier returned a
+						LUID to the DM Module). For new objects, this is the LUID
+						inherited through the parent node.
+	@param aStream	Data of the object. Adapter should create write stream
+						and return, when data is written to stream by DM agent,
+						StreamCommittedL() is called by DM engine
+	@param aType		MIME type of the object
+	@param aStatusRef	Reference to correct command, i.e. this reference
+						must be used when calling the SetStatusL of this
+						command.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+									RWriteStream*& aStream, const TDesC8& aType,
+		 							TInt aStatusRef );
+	
+	/**
+	The function deletes an object and its child objects. The SetStatusL
+	should be used as described in UpdateLeafObjectL()
+	@param aURI		URI of the object
+	@param aLUID		LUID of the object (if the adapter have earlier returned
+						LUID to the DM Module).
+	@param aStatusRef	Reference to correct command, i.e. this reference must
+						be used when calling the SetStatusL of this command.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+								TInt aStatusRef );
+	
+	/**
+	The function fetches data of a leaf object. The SetStatusL should be used
+	as described in UpdateLeafObjectL(). The data is returned by using the
+	SetResultsL function of MSmlCallback callback interface, and may be streamed.
+	@param aURI			URI of the object
+	@param aLUID			LUID of the object (if the adapter have earlier
+							returned LUID to the DM Module).   
+	@param aType 			MIME type of the object
+	@param aResultsRef	Reference to correct results, i.e. this reference
+							must be used when returning the result by calling
+							the SetResultsL.
+	@param aStatusRef		Reference to correct command, i.e. this reference
+							must be used when calling the SetStatusL of this
+							command.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+								   const TDesC8& aType, TInt aResultsRef,
+								   TInt aStatusRef );
+	
+	/**
+	The function fetches the size of the data of a leaf object. The size is
+	in bytes, and must reflect the number of bytes that will be transferred
+	when the framework calls FetchLeafObjectL. The SetStatusL should be used
+	as described in FetchLeafObjectL(). The size value is returned by using
+	the SetResultsL function of MSmlCallback callback interface, and must be
+	a decimal integer expressed as a string, eg. "1234".
+	Results from this call MUST NOT be streamed.
+	@param aURI			URI of the object
+	@param aLUID			LUID of the object (if the adapter have earlier
+							returned LUID to the DM Module).   
+	@param aType 			MIME type of the object
+	@param aResultsRef	Reference to correct results, i.e. this reference
+							must be used when returning the result by calling
+							the SetResultsL.
+	@param aStatusRef		Reference to correct command, i.e. this reference
+							must be used when calling the SetStatusL of this
+							command.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID,
+									   const TDesC8& aType, TInt aResultsRef,
+									   TInt aStatusRef );
+	/**
+	The function fetches URI list. An adapter returns the list of URI segments
+	under the given URI be separated by slash ("/"). The URI segment names for
+	new objects must be given by the adapter.
+	The list is returned by calling the SetResultsL function of MSmlCallback
+	callback interface.	Results from this call MUST NOT be streamed.
+	@param aParentURI					URI of the parent object
+	@param aParentLUID				LUID of the parent object (if the
+										adapter have earlier returned LUID to
+										the DM Module).   
+	@param aPreviousURISegmentList	URI list with mapping LUID information,
+										which is known by DM engine. An adapter
+										can use this information when verifying
+										if old objects still exists. An adapter
+										also knows what objects are new to DM
+										engine and can provide LUID mapping for
+										them. aPreviousURISegmentList parameter
+										(see above) helps to recognise new
+										objects.
+	@param aResultsRef				Reference to correct results, i.e. this
+										reference must be used when returning
+										the result by calling the SetResultsL.
+	@param aStatusRef					Reference to correct command, i.e. this
+										reference must be used when calling the
+										SetStatusL of this command.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void ChildURIListL( const TDesC8& aURI, const TDesC8& aLUID,
+					const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
+					TInt aResultsRef, TInt aStatusRef );
+	
+	/**
+	The function adds node object. In some cases an implementation of the
+	function may be empty function, if the node object does not need concrete
+	database update. Still this function may be helpful to an adapter, i.e. in
+	passing mapping LUID of the node to DM Module. The SetStatusL should be
+	used as described in UpdateLeafObjectL()
+	@param aURI			URI of the object
+	@param aParentLUID	LUID of the parent object (if the adapter have
+							earlier returned LUID to the DM Module).   
+	@param aStatusRef		Reference to correct command, i.e. this reference
+							must be used when calling the SetStatusL of this
+							command.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void AddNodeObjectL( const TDesC8& aURI, const TDesC8& aParentLUID,
+								 TInt aStatusRef );
+
+	/**
+	The function implements execute command. The information about the success
+	of the command should be returned by calling SetStatusL function of
+	MSmlDmCallback callback interface. This makes it possible to buffer the
+	commands.
+	However, all the status codes for buffered commands must be returned at
+	the latest when the CompleteOutstandingCmdsL() of adapter is called.
+	@param aURI			URI of the command
+	@param aLUID			LUID of the object (if the adapter have earlier
+							returned LUID to the DM Module).   
+	@param aArgument		Argument for the command
+	@param aType			MIME type of the object 
+	@param aStatusRef		Reference to correct command, i.e. this reference
+							must be used when calling the SetStatusL of this
+							command.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID,
+							      const TDesC8& aArgument, const TDesC8& aType,
+								  TInt aStatusRef );
+
+	/**
+	The function implements execute command. The information about the
+	success of the command should be returned by calling SetStatusL function
+	of MSmlDmCallback callback interface. This makes it possible to buffer the
+	commands.
+	However, all the status codes for buffered commands must be returned at
+	the latest when the CompleteOutstandingCmdsL() of adapter is called.
+	@param aURI			URI of the command
+	@param aLUID			LUID of the object (if the adapter have earlier
+							returned LUID to the DM Module).   
+	@param aStream		Argument for the command. Adapter should create
+							write stream and return, when data is written to
+							stream by DM agent, StreamCommittedL() is called by
+							DM engine
+	@param aType			MIME type of the object 
+	@param aStatusRef		Reference to correct command, i.e. this reference
+							must be used when calling the SetStatusL of this
+							command.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID,
+								  RWriteStream*& aStream, const TDesC8& aType,
+								  TInt aStatusRef );
+
+	/**
+	The function implements copy command. The information about the success of
+	the command should be returned by calling SetStatusL function of
+	MSmlDmCallback callback interface. This makes it possible to buffer the
+	commands.
+	However, all the status codes for buffered commands must be returned at
+	the latest when the CompleteOutstandingCmdsL() of adapter is called.
+	@param aTargetURI		Target URI for the command
+	@param aSourceLUID	LUID of the target object (if one exists, and if the adapter
+							has	earlier returned a LUID to the DM Module).   
+	@param aSourceURI		Source URI for the command
+	@param aSourceLUID	LUID of the source object (if the adapter has
+							earlier returned a LUID to the DM Module).   
+	@param aType			MIME type of the objects
+	@param aStatusRef		Reference to correct command, i.e. this reference
+							must be used when calling the SetStatusL of this
+							command.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void CopyCommandL( const TDesC8& aTargetURI, const TDesC8& aTargetLUID,
+							   const TDesC8& aSourceURI, const TDesC8& aSourceLUID,
+							   const TDesC8& aType, TInt aStatusRef );
+
+	/**
+	The function indicates start of Atomic command.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void StartAtomicL();
+	
+	/**
+	The function indicates successful end of Atomic command. The adapter
+	should commit all changes issued between StartAtomicL() and
+	CommitAtomicL()
+	@publishedPartner
+	@prototype
+	*/
+	virtual void CommitAtomicL();
+	
+	/**
+	The function indicates unsuccessful end of Atomic command. The adapter
+	should rollback all changes issued between StartAtomicL() and
+	RollbackAtomicL(). If rollback fails for a command, adapter should use
+	SetStatusL() to indicate it.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void RollbackAtomicL();
+	
+	/**
+    Returns ETrue if adapter supports streaming otherwise EFalse.
+	@param aItemSize size limit for stream usage
+    @return TBool ETrue for streaming support
+	@publishedPartner
+	@prototype
+    */
+	virtual TBool StreamingSupport( TInt& aItemSize ) ;
+	
+	/**
+    Called when stream returned from UpdateLeafObjectL or ExecuteCommandL has
+	been written to and committed. Not called when fetching item.
+	@publishedPartner
+	@prototype
+    */	
+#ifdef __TARM_SYMBIAN_CONVERGENCY	
+	virtual void StreamCommittedL( RWriteStream& aStream );
+#else
+	virtual void StreamCommittedL();
+#endif	
+	/**
+	The function tells the adapter that all the commands of the message that
+	can be passed to the adapter have now been passed.  This indciates that
+	the adapter must supply status codes and results to any buffered commands.
+	This must be done at latest by the time this function returns.
+	This function is used at the end of SyncML messages, and during processing
+	of Atomic.   In the case of Atomic processing, the function will be
+	followed by a call to CommitAtomicL or RollbackAtomicL.
+	@publishedPartner
+	@prototype
+	*/
+	virtual void CompleteOutstandingCmdsL();
+	
+private:
+	CAmAdapter( TAny* aDmCallback );
+	void ConstructL();
+	TInt DesToIntL( const TDesC8& aLuid );
+	HBufC8* IntToDes8LC( const TInt aLuid );
+	
+	TBool CheckStateL( const TDeploymentComponent &aComp, const TDesC8& aURI );
+	TBool CheckStateL( const TDesC8& aURI,const TDesC8& aLUID );
+	/**
+	 * UpdateFlagFromMapping Maps a node name to internal attribute flag that
+	 * 	is used by server to identify to data 
+	 * @param aMapping	The SyncML node name
+	 * @return  TDeplCompAttrType the attribute type
+	 */
+	TDeplCompAttrType UpdateFlagFromMapping( const TDesC8& aMapping );
+	
+	/**
+	 * IdListL Looks up the given state user ids of deployment components,
+	 * 	and places them to currentList in the format specified by SyncML spec 
+	 * @param aState	The deployment component state in which we are interested
+	 * @param aCurrentList The buffer where the results are placed
+	 * @param aAppend Does the list possibly contain some items already
+	 * @return  TError EOk if successful
+	 */
+	TError IdListL( TDeploymentComponentState aState, 
+			CBufBase &aCurrentList, TBool aAppend = EFalse );
+	
+	/**
+	 * DeliverOrDownloadL Depending on aURI, creates new delivery or download component
+	 *
+	 * @param aUserId	The name of dynamic node.
+	 * @param aURI		The full URI
+	 * @param aCnt		Count of URI segments
+	 * @param aParentMapping	The parent data
+	 * @param aStatus A reference to the error which will be set the status of the operation
+	 * @return  TError EOk if successful
+	 */
+	void DeliverOrDownloadL( const TDesC8 &aUserId, const TDesC8 &aURI, 
+		TInt aCnt, const TDesC8 &aParentMapping, 
+		MSmlDmAdapter::TError &aStatus );
+
+	
+	/**
+	 * Fills the node info in ddf structure
+	 */
+	void FillNodeInfoL( MSmlDmDDFObject& aNode, TSmlDmAccessTypes aAccTypes, 
+		MSmlDmDDFObject::TOccurence aOccurrence,
+		MSmlDmDDFObject::TScope aScope, MSmlDmDDFObject::TDFFormat aFormat,
+		const TDesC8& aDescription); 
+		
+	/**
+	 * Fills the node info in ddf structure, without default mime type
+	 */	
+	void FillNodeInfoNoDefaultMimeL( MSmlDmDDFObject& aNode, TSmlDmAccessTypes aAccTypes, 
+		MSmlDmDDFObject::TOccurence aOccurrence,
+		MSmlDmDDFObject::TScope aScope, MSmlDmDDFObject::TDFFormat aFormat,
+		const TDesC8& aDescription); 
+		
+	TBool IsImage(const TDesC8& aMime) ;
+	/**
+	Calls Callback().SetResultsL()
+	*/
+	void SetResultsL( TInt aResultsRef, CBufBase& aObject,
+							  const TDesC8& aType );
+/**
+	Calls Callback().SetStatusL()
+	*/
+	void SetStatusL( TInt aStatusRef,
+							 MSmlDmAdapter::TError aErrorCode );
+//	TInt FindBuffered( const TDesC8 &aURI ) ;
+	RApplicationManagement &SessionL();
+	TDeploymentComponentState StateL( const TDesC8& aURI );
+
+	void CheckStateChangesL();
+	void CheckStateChangesInternalL();
+	
+	
+	TPtrC8 URISegsUpTo(const TDesC8& aURI, TInt aUpTo, TBool aInclKeno=EFalse);
+	
+	/**
+	 * Helper method to move acl. Copies acl of node aFrom to acl of aTo,
+	 * and removes acl from aFrom.
+	 *
+	 * @param aFrom The source uri
+	 * @param aTo	The target uri
+	 */
+	void MoveAclL( const TDesC8 &aFrom, const TDesC8 &aTo );
+	
+	/**
+	 * Helper method to move nodes in SCM tree
+	 *
+	 * 1. Sets mapping of aOriginal to null.
+	 * 2. If aNewURI is null, constructs new uri depending on aTargetstate.
+	 * 3. Sets mapping of aNewURI to aLUID
+	 * 4. Moves acls of aOriginal to aNewURI (using MoveAclL)
+	 *
+	 * @param aOriginal The uri of original node to be moved
+	 * @param aTargetstate The target state the node is moving to
+	 * @param aLUID The luid of the original node
+	 * @param aNewUri The new uri of the node (will be constructed and left to stack if null)
+	 */
+	void SetMappingLC( const TDesC8 &aOriginal, 
+		const TDeploymentComponentState aTargetstate, const TDesC8 &aLUID, 
+		HBufC8 *&aNewUri );
+		
+	/**
+	 * Helper method to move nodes in SCM tree
+	 *
+	 * 1. Sets mapping of aOriginal to null.
+	 * 2. Sets mapping of a uri constructed using aTargetState to aLUID
+	 * 2. Moves acls of aOriginal to a uri constructed using aTargetState (using MoveAclL)
+	 *
+	 * @param aOriginal The uri of original node to be moved
+	 * @param aTargetstate The target state the node is moving to
+	 * @param aLUID The luid of the original node
+	 */
+	void SetMappingL( const TDesC8 &aOriginalURI, 
+		const TDeploymentComponentState aTargetState, const TDesC8 &aLUID ) ;
+	
+	/**
+	 * Helper method to set DM LUID mappings directly database.
+	 *
+	 * @param aURI The uri of node whose mapping is to be set
+	 * @param aLUID The new mapping value
+	 * @return Possible database error - KErrNone if successful
+	 */
+	TInt DirectSetMappingL( const TDesC8 &aURI, const TDesC8 &aLUID );
+	
+	TInt DirectRemoveMappingL(const TDesC8 &aURI);
+	/**
+	 * Helper method to get DM LUID mappings directly from database.
+	 *
+	 * @param aURI The uri of node whose mapping is to be found
+	 * @return The luid mapping - Empty string if not found.
+	 */
+	 HBufC8 *DirectGetLuidAllocLC( const TDesC8 &aURI );
+	
+	
+	/**
+	 * Helper method to perform install
+	 *
+	 * @param aLuidi The mapping value of component as integer
+	 * @param aURI The uri of node that is to be installed
+	 * @param aLUID The mapping value of component as text
+	 * @param aTargetstate The target state the node is moving to (EDCSActive or EDCSInactive)
+	 * @param aRet	The SyncML Error code - value will be updated according to success
+	 */
+	void InstallL( const TUint aLuidi, const TDesC8& aURI, const TDesC8& aLUID, 
+					const TDeploymentComponentState aTargetState, TError &aRet );
+	
+	/**
+	 * Helper method to perform update
+	 *
+	 * @param aLuidi The mapping value of component as integer
+	 * @param aURI The uri of node that is to be installed
+	 * @param aLUID The mapping value of component as text
+	 * @param aTargetstate The target state the node is moving to (EDCSActive or EDCSInactive)
+	 * @param aRet	The SyncML Error code - value will be updated according to success
+	 */
+	void UpdateL( const TUint aLuidi, const TDesC8& aURI, const TDesC8& aSourceLUID, 
+					const TDeploymentComponentState aTargetState, TError &aRet );
+	/**
+	 maps symbian error code to DM error code as follows:
+	  Kerrnone-> EOk
+	  Kerrnotfound ->Enotfound
+	  all oether -> EError
+	 */
+	void DefaultMapError( const TInt aErr, TError &aRet, const TDesC8& aDes = KNullDesC8 );
+	
+	/**
+	 * Deactivates given component if given state is inactive
+	 */
+	void DeactivateIfInactive( const TUint aLuidi, const TDeploymentComponentState aTargetState );
+	
+	/**
+	 * Finds luid from app mgmt server to given userid
+	 */
+	TUint32 GetLuidForUserIdL( const TDesC8 &aUserId, const TDeploymentComponentState aState );
+
+	TUint32 GetLuidL( const TDesC8 &aDMLuid, const TDesC8 &aUserId, 
+		const TDeploymentComponentState aState );
+	
+	/**
+	 * places result in current
+	 * @param aParent The deployment component identifying uri 
+	 * @param aMapping The user id part of the deployment component uri
+	 * @param aLuid Internal id of the deployment compoennt
+	 * @param aCurrentList The list that will get the data
+	 * @param aStatus The syncml status
+	 */
+	void GetComponentDataL( const TDesC8& aParent, const TDesC8& aMapping, const TUint32 aLuid, 
+		CBufBase &aCurrentList, CBufBase &currentMime, TError &aStatus );
+	/**
+	 * returns luid of leaf node, or 0
+	 */
+	TInt GetLeafLuidL( const TDesC8 &aURI, const TDesC8 & aParentMapping ) ;
+	/**
+	 * returns length of result
+	 */
+	TInt GetSizeL( const TDeplCompAttrType aDataType, const TInt aLuid, TError &aRet );
+
+	/**
+	 * places installoptions of given aLuid to aBuf
+	 */
+	void InstallOptionsDataL(const TUint32 aLuid, const TDeplCompAttrType& aDataType, 
+			CBufBase &aBuf, CBufBase *aRaw = NULL);
+	
+	/**
+	 * Gets the luid using GetLuidL, and updates aStatus to ENotFound if not found...
+	 */
+	TUint32 GetLuid2L( const TDesC8 &aDMLuid, const TDesC8 &aUserId, 
+			const TDeploymentComponentState aState, TError &aStatus );
+
+	/**
+	 * Finds out correct download target based on download operation 
+	 */
+	TDownloadTarget DownloadTargetL( const TDesC8& aOperation );
+	
+	TPtrC8 LastURISeg(const TDesC8& aURI);
+	TInt DesToInt(const TDesC8& aLuid);
+		
+#ifdef __AM_LASTERROR_NODE
+	void SetLastErrorL( const TDesC8& aLastError, const TInt aErr );
+	const TDesC8& LastError();
+	void SetErrorL( const TDesC8& aDes, const TInt aErr );
+#endif
+
+
+
+	/**
+	The function creates new leaf objects, or replaces data in existing leaf
+	objects. The information about the success of the command should be
+	returned by calling SetStatusL function of MSmlDmCallback callback
+	interface. This makes it possible to buffer the commands.  However, all
+	the status codes for buffered commands must be returned at the latest when
+	the adapter's CompleteOutstandingCmdsL() is called.
+	@param aURI			URI of the object
+	@param aLUID		LUID of the object (if the adapter has earlier returned a
+						LUID to the DM Module). For new objects, this is the LUID
+						inherited through the parent node.
+	@param aObject		Data of the object.
+	@param aType		MIME type of the object
+	@param aStatusRef	Reference to correct command, i.e. this reference
+						must be used when calling the SetStatusL of this command
+	@publishedPartner
+	@prototype
+	*/
+	void _UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+									const TDesC8& aObject, const TDesC8& aType,
+									TInt aStatusRef, MSmlDmAdapter::TError& aStatus );
+	/**
+	 * The function creates new leaf objects, or replaces data in existing leaf
+	 */	
+	void CloseStreaming();
+	TInt GetAdapterValue();
+	void SetAdapterValue(TInt aAdapterValue);
+	
+private:
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+	RDmTree iDbSession;
+#else
+	RNSmlDMCallbackSession iDbSession; // to change acl location
+#endif
+
+	RApplicationManagement iManagement ;
+	TBool iSessionOpened ;
+	TAMCommandBuffer iBuffer;
+	TBool iInAtomic ;
+	TBool iUpdated; // have we checked changed state DCs?
+	// Streaming API support
+	TBool iStreamOpen;
+	RFileWriteStream iStream;
+    TInt iStatusRef;
+	RFs iStreamRFs;
+	RFile iStreamFile;
+	TBool iIsStreamedContent;
+	HBufC8*	iStreamedURI;
+	HBufC8* iStreamedLuid;
+	HBufC8*	iStreamedType;
+	TBool iCertRequired;
+	TBool iTrustAdded;
+	
+#ifdef __AM_LASTERROR_NODE
+	HBufC8 *iLastError;
+#endif
+
+   HBufC8 *iUriDel;
+};
+
+	} // namespace
+#endif // __AMDMADAPTER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/amadapter2/inc/nsmldmiapmatcher.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,129 @@
+/*
+* 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:  DM Tree module
+*
+*/
+
+
+#ifndef __NSMLDMIAPMATCHER_H__
+#define __NSMLDMIAPMATCHER_H__
+
+// ------------------------------------------------------------------------------------------------
+// Includes
+// ------------------------------------------------------------------------------------------------
+#include <e32base.h>
+#include "nsmldmuri.h"
+
+//CLASS FORWARDS
+class MSmlDmCallback;
+
+_LIT8( KNSmlDMIAPUri, "AP" );
+_LIT8( KNSmlDMSeparator8, "/" );
+_LIT8( KNSmlDMIAPUriDotSlash, "./" );
+_LIT8( KNSmlDMConnMOIAPUri, "NAP" );
+
+const TUint8 KNSmlDMSlash = 0x2f; //forward slash
+/**
+* CNSmlDMIAPMatcher contains services for generating URI from IAPId and
+* vice versa in DM plug-in adapters. The class needs the working
+* MSmlDmCallback callback interface for operating, so ths can be used only
+* by DM plug-in adapters
+*
+*  @since
+*/
+class CNSmlDMIAPMatcher : public CBase
+	{
+    public:
+		/**
+		* Destructor
+		*/
+	    ~CNSmlDMIAPMatcher();
+
+		/**
+		* Two-phased constructor
+		* @param	aDmCallback			Pointer to callback interface
+		* @return						Pointer to newly created module instance
+		*/
+        static CNSmlDMIAPMatcher* NewL( MSmlDmCallback* aDmCallback);
+
+		/**
+		* Two-phased constructor, pushes pointer to cleanup stack.
+		* @param	aDmCallback			Pointer to callback interface
+		* @return						Pointer to newly created module instance
+		*/
+        static CNSmlDMIAPMatcher* NewLC( MSmlDmCallback* aDmCallback);
+
+		/**
+		* Gets the IAP id which corresponds to given URI
+		* @param	aURI				Accespoint URI
+		* @return						Accespoint id in AP database
+		*/
+        TInt IAPIdFromURIL( const TDesC8& aURI );
+
+		/**
+		* Generates the URI which corresponds to given IAP Id
+		* @param	aIAPId				Accespoint Id
+		* @return						Accesspoint URI in DM
+		*/
+        HBufC8* URIFromIAPIdL( TInt aIAPId );
+
+    private:
+		/**
+		* Second phase constructor
+		* @param	aDmCallback			Pointer to callback interface
+		*/
+        void ConstructL(MSmlDmCallback* aDmCallback);
+
+		/**
+		* Changes the given descriptor to Integer
+		* @param	aLuid				Luid in descriptor format
+		* @return						Luid in TInt type
+		*/
+        TInt DesToInt(const TDesC8& aLuid) const;
+
+		/**
+		* Return the URI without ./ at the beginning, if those exist
+		* @param	aURI		Uri
+		* @return 		 		Uri without ./
+		*/
+        TPtrC8 RemoveDotSlash(const TDesC8& aURI) const;
+
+		/**
+		* Return the last uri segment of the aURI
+		* @param	aURI		Uri
+		* @return 		 		The last uri segment
+		*/
+        TPtrC8 LastURISeg(const TDesC8& aURI) const;
+        
+    /**
+		* Return the last uri segment of the aURI
+		* @return 		 		The AccessPoint Reference
+		*/
+        const TDesC8& GetConRef() ;
+
+    private:
+    
+ 		/**
+		* Pointer to callback interface
+		*/
+		MSmlDmCallback* iCallback;
+		
+		/**
+		* Boolean to check FeatMgr Initialization
+		*/
+		TBool iFeatMgrInitialized;
+	
+	};
+
+#endif // __NSMLDMIAPMATCHER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/amadapter2/inc/nsmldmuri.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,95 @@
+/*
+* 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:  DM Utilities
+*
+*/
+
+
+#ifndef __NSMLDMURI_H
+#define __NSMLDMURI_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32def.h>
+
+
+const TUint8 KNSmlDMUriSeparator = 0x2f; //forward slash
+
+_LIT8(KNSmlDmRootUri, ".");
+_LIT8(KNSmlDmUriDotSlash, "./");
+_LIT8( KNSmlDmQuestionMark, "?" );
+
+// ===========================================================================
+// NSmlDmURI
+// ===========================================================================
+/**
+* NSmlDmURI contains just static methods for parsing URIs
+*
+*  @since
+*/
+class NSmlDmURI
+	{
+	public:
+	/**
+	* Return the parent URI of given URI
+	* @param	aURI		Uri
+	* @return 		 		Parent URI
+	*/
+	static TPtrC8 ParentURI(const TDesC8& aURI);
+
+	/**
+	* Return the last URI segment of given URI
+	* @param	aURI		Uri
+	* @return 		 		Last URI segment
+	*/
+	static TPtrC8 LastURISeg(const TDesC8& aURI);
+
+	/**
+	* Return the URI without ./ at the beginning, if those exist
+	* @param	aURI		Uri
+	* @return 		 		Uri without ./
+	*/
+	static TPtrC8 RemoveDotSlash(const TDesC8& aURI);
+
+	/**
+	* Return the URI without property info at the end (?prop=...)
+	* @param	aURI		Uri
+	* @return 		 		Uri without property info
+	*/
+	static TPtrC8 RemoveProp(const TDesC8& aURI);
+
+	/**
+	* Return the URI without last segment
+	* @param	aURI		Uri
+	* @return 		 		URI without last uri segment
+	*/
+	static TPtrC8 RemoveLastSeg(const TDesC8& aURI);
+
+	/**
+	* Return the aLocationth URI segment.
+	* @param	aURI		Uri
+	* @param	aLocation	The wanted segment number
+	* @return 		 		The aLocationth URI segment
+	*/
+	static TPtrC8 URISeg(const TDesC8& aURI,TInt aLocation);
+
+	/**
+	* Return the number of URI  segments of given URI
+	* @param	aURI		Uri
+	* @return 		 		Number of segments
+	*/
+	static TInt NumOfURISegs(const TDesC8& aURI);
+	};
+
+#endif // __NSMLDMURI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/amadapter2/rom/amadapter.iby	Tue Jul 13 04:01:20 2010 +0530
@@ -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: Implementation of applicationmanagement components
+*
+*/
+#ifndef __AMDMADAPTER_IBY__
+#define __AMDMADAPTER_IBY__
+
+//#if defined(__SYNCML_DM) && defined(__SAP_APPLICATION_MANAGEMENT)
+#if defined(__SYNCML_DM) 
+ECOM_PLUGIN(amadapter2.dll, amadapter2.rsc)
+#endif
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/amadapter2/src/amadapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,3897 @@
+/*
+* 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:  Application Management DM Adapter
+*
+*/
+
+
+/**
+
+1. Remember the applications managed by Corporate Admin Role certificate
+ 1.1 They must be removed during rfs
+ 1.2 Others must be left as is (applications at least must be left)
+
+*/
+
+/*
+
+./SCM -+-> Inventory -+--> Deployed ---> <X> * ---+--> ID
+      |            	 |              			 |
+      |            	 |              			 |--> Name ?
+      |            	 |              			 |
+      |            	 |      			 		 |--> Version ?
+      |            	 |      			 		 |
+      |            	 |            			     |--> StateValue ?
+      |            	 |      			 		 |
+      |            	 |            			     |--> EnvType ? X
+      |            	 |       					 |
+      |        	  	 |				             |--> Operations ---+-> Activate ?
+      |        	  	 |        					 |					|
+      |        	  	 |        					 |					|-> Deactivate ?
+      |        	  	 |        					 |					|
+      |        	  	 |        					 |					|-> Remove ?
+      |        	  	 |        					 |					|
+      |        	  	 |        					 |					|-> Ext ? X
+      |        	  	 |        					 |
+      |        	  	 |				             |--> Ext ? X
+      |        	  	 |            
+      |        	  	 +--> Delivered ---> <X> * --+--> ID
+      |            	                			 |
+      |            	                			 |--> Data
+      |            	                			 |
+      |            	        			 		 |--> Name ?
+      |				  							 |
+      |				  							 |--> Version ?
+      |				  							 |
+      |				  							 |--> InstallOpts ?
+      |            	        			 		 |
+      |            	              			     |--> Descriptor ?
+      |            	        			 		 |
+      |            	              			     |--> EnvType ? X
+      |            	        			 		 |
+      |            	              			     |--> ContentType ? X
+      |            	         					 |
+      |        	  	  				             |--> Operations ---+-> Install ?
+      |        	  	          					 |					|
+      |        	  	          					 |					|-> Update ?
+      |        	  	          					 |					|
+      |        	  	          					 |					|-> InstallAndActivate ? 
+      |        	  	          					 |					|
+      |        	  	          					 |					|-> UpdateAndActivate ? 
+      |        	  	          					 |					|
+      |        	  	          					 |					|-> Remove ?
+      |        	  	          					 |					|
+      |        	  	          					 |					|-> Ext ?
+      |        	  	          					 |
+      |        	  	  				             |--> Ext ?
+	  |
+      |
+      +-> Download --> <X> * ---+-> ID
+      |							|
+      |							|-> URI
+      |							|
+      |							|-> Name ?
+      |							|
+      |							|-> Version ?
+      |							|
+      |							|-> InstallOpts ? X      
+      |							|
+      |							|-> ConRef ? X      
+      |							|
+      |							|-> Status ?
+      |							|
+      |							|-> EnvType ? X
+      |							|
+      |							|-> ContentType ? X
+	  |							|
+      |			             	|--> Operations ----+-> Download ?
+      |						    |					|
+      |       	  	          	|				 	|-> DownloadAndInstall ? X
+      |        	  	          	|				 	|
+      |        	  	          	|				 	|-> DownloadAndInstallAndActivate ? X
+      |        	  	          	|				 	|
+      |        	  	          	|				 	|-> DownloadAndUpdate ? X
+      |        	  	          	|				 	|
+      |        	  	          	|				 	|-> DownloadAndUpdateAndActivate ? X
+      |        	  	          	|				 	|
+      |        	  	          	|				 	|-> Ext ?
+      |        	  	          	|				 
+      |        	  	  			|--> Ext ?
+	  |
+	  |--> Ext -> LastError (Debug Only) ?
+
+*/
+
+#define __AM_CHECKSTATE_CHANGES // uncomment to enable dynamic acl
+#include <badesca.h>
+#include <fbs.h>
+#include <s32file.h> 
+#include "amadapter.h"
+#include <implementationproxy.h> // For TImplementationProxy definition
+#include <f32file.h>
+#include "nsmldmuri.h"
+#include "nsmldmiapmatcher.h"
+#include "debug.h"
+
+#include <centralrepository.h>
+#include "aminstalloptions.h"
+#include <featmgr.h>
+#include "amprivateCRKeys.h"
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+#include <dmtreenode.h>
+#include <devman.h>
+#include "nsmldmuri.h"
+
+// Constants
+_LIT8( KDeployedURI, "./SCM/Inventory/Deployed/" );
+_LIT8( KDeliveredURI, "./SCM/Inventory/Delivered/" );
+_LIT8( KDownloadURI, "./SCM/Download/" );
+#else
+#include <nsmldmuri.h>
+
+// Constants
+_LIT8( KDeployedURI, "SCM/Inventory/Deployed/" );
+_LIT8( KDeliveredURI, "SCM/Inventory/Delivered/" );
+_LIT8( KDownloadURI, "SCM/Download/" );
+#endif
+
+#ifdef __NSML_DEBUG__
+#pragma message("NSml Debugging is ON!")
+#else
+#endif
+
+
+using namespace NApplicationManagement;
+
+
+
+_LIT8( KAMStateValueActive, "Active" );
+_LIT8( KAMStateValueInactive, "Inactive" );
+
+
+_LIT8( KSisxMimeType, "x-epoc/x-sisx-app" );
+_LIT8( KSisMimeType, "application/vnd.symbian.install" );
+_LIT8( KPipMimeType, "application/x-pip" );
+_LIT8( KJadMIMEType, "text/vnd.sun.j2me.app-descriptor" );
+_LIT8( KJarMIMEType, "application/java-archive" );
+_LIT8( KJavaMIMEType, "application/java" );
+
+_LIT8( KInstallOptsMimeType, "text/xml" );
+
+
+
+const TUint8 KNSmlDMAMSeparatorDef = 0x2f; //forward slash
+#ifdef __AM_LASTERROR_NODE
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+_LIT8( KAMLastErrorURI, "./SCM/Ext/LastError" );
+#else
+_LIT8( KAMLastErrorURI, "SCM/Ext/LastError" );
+#endif
+_LIT8( KStdError, "Error %d" );
+
+#define MAPERROR(x,y,z) DefaultMapError(x,y,z)
+#else
+
+#define MAPERROR(x,y,z) DefaultMapError(x,y)
+#endif
+
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter* CAmAdapter::NewL( )
+// ------------------------------------------------------------------------------------------------
+CAmAdapter* CAmAdapter::NewL( MSmlDmCallback* aDmCallback )
+	{
+	RDEBUG("CAmAdapter::NewL(): begin");
+
+	CAmAdapter* self = NewLC( aDmCallback );
+	CleanupStack::Pop();
+	return self;
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter* CAmAdapter::NewLC( )
+// ------------------------------------------------------------------------------------------------
+CAmAdapter* CAmAdapter::NewLC( MSmlDmCallback* aDmCallback )
+	{
+	CAmAdapter* self = new( ELeave ) CAmAdapter( aDmCallback );
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	return self;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::CAmAdapter()
+// ------------------------------------------------------------------------------------------------
+CAmAdapter::CAmAdapter( TAny* aEcomArguments ) 
+	: CSmlDmAdapter( aEcomArguments ), iSessionOpened ( EFalse ), iBuffer( 8 ), 
+	iInAtomic( EFalse ), iUpdated( EFalse ), iIsStreamedContent( EFalse )
+	{
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::~CAmAdapter()
+// ------------------------------------------------------------------------------------------------
+CAmAdapter::~CAmAdapter()
+	{
+	RDEBUG( "CAmAdapter::~CAmAdapter" );
+	iDbSession.Close();
+	iManagement.Close(); // make sure we're closed
+	iSessionOpened = EFalse ;
+	iBuffer.Close();
+
+	CloseStreaming();  // Ensures that no streams are left open and that the temporary file is removed
+	
+	delete	iStreamedURI;
+	delete  iStreamedLuid;
+	delete	iStreamedType;
+	
+#ifdef __AM_LASTERROR_NODE
+	delete iLastError;
+#endif
+
+
+    if(iUriDel)
+    delete iUriDel;
+	RDEBUG( "CAmAdapter::~CAmAdapter end" );
+	}
+
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::DDFVersionL()
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::DDFVersionL( CBufBase& aDDFVersion )
+	{
+	aDDFVersion.InsertL( 0, KAMDDFVersion );
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::DDFStructureL()
+//
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
+	{
+	RDEBUG( "CAmAdapter::DDFStructureL(): begin" );
+	
+	TSmlDmAccessTypes accessTypesGet;
+	accessTypesGet.SetGet();
+	
+	TSmlDmAccessTypes accessTypesExec;
+	accessTypesExec.SetExec();	
+
+	TSmlDmAccessTypes accessTypesExecReplace = accessTypesExec;
+	accessTypesExecReplace.SetReplace();
+	
+	TSmlDmAccessTypes accessTypesGetAdd = accessTypesGet;
+	accessTypesGetAdd.SetAdd();
+	
+	TSmlDmAccessTypes accessTypesGetReplace = accessTypesGet;
+	accessTypesGetReplace.SetGet();
+		
+	TSmlDmAccessTypes accessTypesGetAddReplace = accessTypesGetAdd;
+	accessTypesGetAddReplace.SetReplace();
+	
+	TSmlDmAccessTypes accessTypesGetAddReplaceDelete = accessTypesGetAddReplace;
+	accessTypesGetAddReplaceDelete.SetDelete();
+
+
+	
+	
+	/*
+	Node: ./SCM
+	AM node is the common parent to all application management functionality nodes. 
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Get
+	Values: N/A
+	*/
+	//MSmlDmDDFObject& root = aDDF.AddChildObjectGroupL();
+	MSmlDmDDFObject& am = aDDF.AddChildObjectL( KAMNodeName );
+	FillNodeInfoL( am, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMNodeDescription );
+	
+	/*
+	Node: ./SCM/Inventory
+	This node is start node to application inventory. 
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Get
+	Values: N/A
+	*/
+	MSmlDmDDFObject& inv = am.AddChildObjectL( KAMInventoryNodeName );
+	FillNodeInfoL( inv, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMInventoryNodeDescription );
+		
+	/*
+	Node: ./SCM/Inventory/Delivered
+	This is node under which applications that are delivered but not installed are found.
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Get, Add
+	Values: N/A
+	*/
+	MSmlDmDDFObject& del = inv.AddChildObjectL( KAMDeliveredNodeName );
+	FillNodeInfoL( del, accessTypesGetAdd, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMDeliveredNodeDescription );
+		
+		
+	/*
+	Node: ./SCM/Inventory/Deployed
+	This is a node under which active applications are found.
+	The child node descriptions are same as Delivered sibling node, except that <X> cannot be created, data node does not exist and there's no InstallOpts leaf.
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Get
+	Values: N/A
+	*/
+	
+	MSmlDmDDFObject& ac = inv.AddChildObjectL( KAMDeployedNodeName );
+	FillNodeInfoL( ac, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMDeployedNodeDescription );
+	
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>
+	This dynamic node is placeholder applications that are in Delivered state. 
+	Support: Mandatory
+	Occurs: ZeroOrMore
+	Format: Node
+	Access Types: Get, Add, Replace, Delete
+	Values: N/A
+	*/
+	MSmlDmDDFObject& deldyna = del.AddChildObjectGroupL();
+	FillNodeInfoL( deldyna, accessTypesGetAddReplaceDelete, MSmlDmDDFObject::EZeroOrMore, 
+		MSmlDmDDFObject::EDynamic,
+		MSmlDmDDFObject::ENode, KAMDeliveredDynaNodeDescription );
+
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/ID
+	This leaf node holds an identifier for an application.
+	Support: Mandatory
+	Occurs: One
+	Format: Chr
+	Access Types: Get 
+	Values: N/A
+	*/
+	MSmlDmDDFObject& delid = deldyna.AddChildObjectL( KAMIDNodeName );
+	FillNodeInfoL( delid, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMIDNodeDescription );
+
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/Name
+	This leaf node holds name of an application. 
+	Support: Mandatory
+	Occurs: One
+	Format: Chr
+	Access Types: Get ( + Add, Replace access within Delivered node only)
+	Values: N/A
+	*/
+	MSmlDmDDFObject& delname = deldyna.AddChildObjectL( KAMNameNodeName );
+	FillNodeInfoL( delname, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMNameNodeDescription );
+
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/Version
+	This leaf node holds the version of an application. 
+	Support: Mandatory
+	Occurs: One
+	Format: Chr
+	Access Types: Get ( + Add, Replace access within Delivered node only)
+	Values: N/A
+	*/
+	MSmlDmDDFObject& delver = deldyna.AddChildObjectL( KAMVersionNodeName );
+	FillNodeInfoL( delver, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMVersionNodeDescription );
+
+
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/Data
+	This leaf node holds the data of an application. 
+	Support: Mandatory
+	Occurs: One
+	Format: Bin
+	Access Types: Add, Get, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& delda = deldyna.AddChildObjectL( KAMDataNodeName );
+	FillNodeInfoNoDefaultMimeL( delda, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EBin, KAMDataNodeDescription );
+		
+	delda.AddDFTypeMimeTypeL( KSisxMimeType );
+	delda.AddDFTypeMimeTypeL( KSisMimeType );
+	delda.AddDFTypeMimeTypeL( KPipMimeType );
+	
+	FeatureManager::InitializeLibL();
+	if( FeatureManager::FeatureSupported(KFeatureIdJavaMIDP20) )
+		{
+		delda.AddDFTypeMimeTypeL( KJadMIMEType );
+		delda.AddDFTypeMimeTypeL( KJarMIMEType );
+		delda.AddDFTypeMimeTypeL( KJavaMIMEType);
+		}
+	
+	FeatureManager::UnInitializeLib();
+	
+	
+
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/Descriptor
+	This leaf node holds the possible metadata of an application. Descriptor can be for example such a data that is required by the actual data in the Data leaf, but for some reason they cannot be bundled into same package. An example is Java JAR and JAD file combination, in which JAD file could be placed in MetaData and JAR in Data leaf.
+	Support: Optional
+	Occurs: One
+	Format: Bin
+	Access Types: Add, Get, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& delmd = deldyna.AddChildObjectL( KAMDescriptorNodeName );
+	FillNodeInfoL( delmd, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EBin, KAMDescriptorNodeDescription );
+
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/InstallOpts
+	This is a node that holds the installation options of an application.  
+
+	Support: Optional
+	Occurs: ZeroOrOne
+	Format: Xml
+	Access Types: Get, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& delio = deldyna.AddChildObjectL( KAMInstallOptsNodeName );
+	FillNodeInfoNoDefaultMimeL( delio, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EXml, KAMInstallOptsNodeDescription );
+	delio.AddDFTypeMimeTypeL( KInstallOptsMimeType );
+	
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/Operations
+		This is a node that allows vendors to extend functionality.
+	Support: Optional
+	Occurs: One
+	Format: Node
+	Access Types: Get, Replace, Add, Delete
+	Values: N/A
+	*/
+	MSmlDmDDFObject& delop = deldyna.AddChildObjectL( KAMOperationsNodeName );
+	FillNodeInfoL( delop, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMOperationsNodeDescription );
+		
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/Operations/Install
+		Exec command causes device to install a delivered application. The data inside 
+		exec command refers to the application to be installed. 
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Exec, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& loinst = delop.AddChildObjectL( KAMInstallNodeName );
+	FillNodeInfoL( loinst, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMInstallNodeDescription );
+
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/Operations/InstallAndActivate
+		Exec command causes device to install a delivered application. The data inside 
+		exec command refers to the application to be installed. 
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Exec, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& loinstact = delop.AddChildObjectL( KAMInstallAndActivateNodeName );
+	FillNodeInfoL( loinstact, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMInstallAndActivateNodeDescription );
+	
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/Operations/Update
+		Exec command causes device to update an application. The data inside exec command 
+		refers to the application to be updated. 
+		In practice the flow is so that:
+		1.	Admin puts a new data with same ID in inventory/delivered or inventory/download.
+		2.	Admin deactivates existing component with same ID. 
+		3.	Server executes update with item data targeting to the ID.
+		So actually update needs at least three "high level" commands; add data for update, 
+			deactivate old, do the update.
+
+	Support: Optional
+	Occurs: One
+	Format: Node
+	Access Types: Exec, Replace
+	Values: N/A
+
+	*/
+	MSmlDmDDFObject& loupd = delop.AddChildObjectL( KAMUpdateNodeName );
+	FillNodeInfoL( loupd, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMUpdateNodeDescription );
+
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/Operations/UpdateAndActivate
+	Exec command causes device to update an application and activate it. The data inside exec command refers to the application to be updated. 
+	In practice the flow is so that:
+	1.	Admin puts a new data with same ID in inventory/delivered or inventory/download.
+	2.	Admin deactivates existing component with same ID. 
+	3.	Server executes update with item data targeting to the ID.
+	So actually update needs at least three "high level" commands; add data for update, deactivate old, do the update.
+
+	Support: Optional
+	Occurs: One
+	Format: Node
+	Access Types: Exec, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& loupda = delop.AddChildObjectL( KAMUpdateAndActivateNodeName );
+	FillNodeInfoL( loupda, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMUpdateAndActivateNodeDescription );
+
+	/*
+	Node: ./SCM/Inventory/Delivered/<X>/Operations/Remove
+	Exec command causes device to remove an application. The data inside exec command refers to the application to be removed. The application must be in Inactive state in order for remove to be successful.
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Exec, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& lorem = delop.AddChildObjectL( KAMRemoveNodeName );
+	FillNodeInfoL( lorem, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMRemoveNodeDescription );
+			
+				
+/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
+	DEPLOYED
+*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+
+	/*
+	Node: ./SCM/Inventory/Deployed/<X>
+		This dynamic node is placeholder applications that are in Inactive state. 
+	Support: Mandatory
+	Occurs: ZeroOrMore
+	Format: Node
+	Access Types: Get, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& depldyna = ac.AddChildObjectGroupL();
+	FillNodeInfoL( depldyna, accessTypesGetReplace, MSmlDmDDFObject::EZeroOrMore, MSmlDmDDFObject::EDynamic,
+		MSmlDmDDFObject::ENode, KAMDeployedDynaNodeDescription );
+
+	/*
+	Node: ./SCM/Inventory/Deployed/<X>/ID
+		This leaf node holds an identifier for an application. This cannot be changed.
+	Support: Mandatory
+	Occurs: One
+	Format: Chr
+	Access Types: Get
+	Values: N/A
+	*/
+	MSmlDmDDFObject& deplid = depldyna.AddChildObjectL( KAMIDNodeName );
+	FillNodeInfoL( deplid, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMIDNodeDescription );
+		
+	/*
+	Node: ./SCM/Inventory/Deployed/<X>/Name
+		This leaf node holds name of an application.
+	Support: Mandatory
+	Occurs: One
+	Format: Chr
+	Access Types: Get, Add, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& deplname = depldyna.AddChildObjectL( KAMNameNodeName );
+	FillNodeInfoL( deplname, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMNameNodeDescription );
+
+	/*
+	Node: ./SCM/Inventory/Deployed/<X>/Version
+		This leaf node holds the version of an application.
+	Support: Mandatory
+	Occurs: One
+	Format: Chr
+	Access Types: Get, Add, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& deplver = depldyna.AddChildObjectL( KAMVersionNodeName );
+	FillNodeInfoL( deplver, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMVersionNodeDescription );
+		
+	/*
+	Node: ./SCM/Inventory/Deployed/<X>/StateValue
+		This leaf node holds state value of an application. 
+	Support: ?
+	Occurs: One
+	Format: Chr
+	Access Types: Get 
+	Values: N/A
+	*/
+	MSmlDmDDFObject& deplstate = depldyna.AddChildObjectL( KAMStateValueNodeName );
+	FillNodeInfoL( deplstate, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMStateValueNodeDescription );
+
+
+
+	/*
+	Node: ./SCM/Inventory/Deployed/<X>/Operations
+		This is a node that allows vendors to extend functionality.
+	Support: Optional
+	Occurs: One
+	Format: Node
+	Access Types: Get, Replace, Add, Delete
+	Values: N/A
+
+	*/
+	MSmlDmDDFObject& deplop = depldyna.AddChildObjectL( KAMOperationsNodeName );
+	FillNodeInfoL( deplop, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMOperationsNodeDescription );
+		
+		
+
+	/*
+	Node: ./SCM/Inventory/Deployed/<X>/Operations/Remove
+		Exec command causes device to remove an application. The data inside exec command 
+		refers to the application to be removed. The application must be in Inactive state 
+		in order for remove to be successful.
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Exec, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& deplrem = deplop.AddChildObjectL( KAMRemoveNodeName );
+	FillNodeInfoL( deplrem, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMRemoveNodeDescription );
+		
+	/*
+	Node: ./SCM/Inventory/Deployed/<X>/Operations/Activate
+		Exec command causes device to activate an application. 
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Exec, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& deplac = deplop.AddChildObjectL( KAMActivateNodeName );
+	FillNodeInfoL( deplac, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMActivateNodeDescription );
+		
+	/*
+	Node: ./SCM/Inventory/Deployed/<X>/Operations/Deactivate
+		Exec command causes device to deactivate an application. 
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Exec, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& depldeac = deplop.AddChildObjectL( KAMDeActivateNodeName );
+	FillNodeInfoL( depldeac, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMDeActivateNodeDescription );
+			
+/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
+	DOWNLOAD
+*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+	/*
+	Node: ./SCM/Download
+		This node is a root node for application download functionality. In practice download 
+		works so that admin adds nodes under this node, and they are automatically moved to 
+		Inventory/Delivered when the download has been finished. Running get command targeting 
+		to this node returns a list of pending downloads. 
+	Support: Mandatory 
+	Occurs: One
+	Format: Node
+	Access Types: Get, Add, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dow = am.AddChildObjectL( KAMDownloadNodeName );
+	FillNodeInfoL( dow, accessTypesGetAddReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMDownloadNodeDescription );
+
+
+	/*
+	Node: ./SCM/Download/<X>
+	This node is a placeholder for identifier of an application that is to be downloaded. 
+	Support: Mandatory 
+	Occurs: One
+	Format: Node
+	Access Types: Get, Add, Replace, Delete
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowdyna = dow.AddChildObjectGroupL();
+	FillNodeInfoL( dowdyna, accessTypesGetAddReplaceDelete, MSmlDmDDFObject::EZeroOrMore, MSmlDmDDFObject::EDynamic,
+		MSmlDmDDFObject::ENode, KAMDownloadDynaNodeDescription );
+
+
+		/*
+	Node: ./SCM/Download/<X>/ID
+	This leaf node holds an identifier for an application. 
+	Support: Mandatory
+	Occurs: One
+	Format: Chr
+	Access Types: Get
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowid = dowdyna.AddChildObjectL( KAMIDNodeName );
+	FillNodeInfoL( dowid, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMIDNodeDescription );
+		
+	/*
+	Node: ./SCM/Download/<X>/Name
+	This leaf node holds name of an application. 
+	Support: Mandatory
+	Occurs: One
+	Format: Chr
+	Access Types: Add, Get, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& downame = dowdyna.AddChildObjectL( KAMNameNodeName );
+	FillNodeInfoL( downame, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMNameNodeDescription );
+
+	/*
+	Node: ./SCM/Download/<X>/Version
+	This leaf node holds the version of an application. 
+	Support: Mandatory
+	Occurs: One
+	Format: Chr
+	Access Types: Add, Get, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowver = dowdyna.AddChildObjectL( KAMVersionNodeName );
+	FillNodeInfoL( dowver, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMVersionNodeDescription );
+
+	/*
+	Node: ./SCM/Download/<X>/URI
+	This leaf node holds the URL from which the application should be downloaded.
+	Support: Mandatory 
+	Occurs: One
+	Format: Chr
+	Access Types: Add, Get, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowuri = dowdyna.AddChildObjectL( KAMURINodeName );
+	FillNodeInfoL( dowuri, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMURINodeDescription );
+	
+	/*
+	Node: ./SCM/Download/<X>/Status
+	This leaf node holds the status of the download. The client updates the node value. The values are typically error codes of download protocol. Initially after the URI leaf is filled, this will get value 100, and will be replaced by one.
+	Support: Optional 
+	Occurs: One
+	Format: Chr
+	Access Types: Get
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowstat = dowdyna.AddChildObjectL( KAMStatusNodeName );
+	FillNodeInfoL( dowstat, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMStatusNodeDescription );
+
+	/*
+	Node: ./SCM/Download/<X>/InstallOpts
+	This is a node that holds the installation options of an application.  
+
+	Support: Optional
+	Occurs: ZeroOrOne
+	Format: Xml
+	Access Types: Add, Get, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowio = dowdyna.AddChildObjectL( KAMInstallOptsNodeName );
+	FillNodeInfoNoDefaultMimeL( dowio, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EXml, KAMInstallOptsNodeDescription );
+	dowio.AddDFTypeMimeTypeL( KInstallOptsMimeType );
+	
+	/*
+	Node: ./SCM/Download/<X>/ConRef
+	This is a node that holds the installation options of an application.  
+
+	Support: Optional
+	Occurs: ZeroOrOne
+	Format: Xml
+	Access Types: Add, Get, Replace
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowcr = dowdyna.AddChildObjectL( KAMConRefNodeName );
+	FillNodeInfoL( dowcr, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMConRefNodeDescription );
+					
+	/*
+	Node: ./SCM/Download/<X>/Operations
+	This is a node that holds the operation nodes.
+	Support: Optional
+	Occurs: One
+	Format: Node
+	Access Types: Get, Replace, Add, Delete
+	Values: N/A
+
+	*/
+	MSmlDmDDFObject& dowop = dowdyna.AddChildObjectL( KAMOperationsNodeName );
+	FillNodeInfoL( dowop, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMOperationsNodeDescription );
+
+	/*
+	Node: ./SCM/Download/<X>/Operations/Download
+	Exec command causes device to download an application. The dynamic node specifies the application to be downloaded. 
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Exec
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowdown = dowop.AddChildObjectL( KAMDownloadOperationNodeName );
+	FillNodeInfoL( dowdown, accessTypesExecReplace, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMDownloadOperationNodeDescription );
+					
+	/*
+	Node: ./SCM/Download/<X>/Operations/DownloadAndInstall
+	Exec command causes device to download and install an application. The dynamic node specifies the application to be downloaded. 
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Exec
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowdowni = dowop.AddChildObjectL( KAMDownloadAndInstallNodeName );
+	FillNodeInfoL( dowdowni, accessTypesExec, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMDownloadAndInstallOperationNodeDescription );
+		
+	/*
+	Node: ./SCM/Download/<X>/Operations/DownloadAndInstallAndActivate
+	Exec command causes device to download and install and activate an application. The dynamic node specifies the application to be downloaded. 
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Exec
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowdownia = dowop.AddChildObjectL( KAMDownloadAndInstallAndActivateNodeName );
+	FillNodeInfoL( dowdownia, accessTypesExec, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMDownloadAndInstallAndActivateNodeDescription );
+		
+	/*
+	Node: ./SCM/Download/<X>/Operations/DownloadAndUpdate
+	Exec command causes device to download and update an application. The dynamic node specifies the application to be downloaded. 
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Exec
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowdownu = dowop.AddChildObjectL( KAMDownloadAndUpdateNodeName );
+	FillNodeInfoL( dowdownu, accessTypesExec, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMDownloadAndUpdateNodeDescription );
+		
+	/*
+	Node: ./SCM/Download/<X>/Operations/DownloadAndUpdateAndActivate
+	Exec command causes device to download and install and activate an application. The dynamic node specifies the application to be downloaded. 
+	Support: Mandatory
+	Occurs: One
+	Format: Node
+	Access Types: Exec
+	Values: N/A
+	*/
+	MSmlDmDDFObject& dowdownua = dowop.AddChildObjectL( KAMDownloadAndUpdateAndActivateNodeName );
+	FillNodeInfoL( dowdownua, accessTypesExec, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMDownloadAndUpdateAndActivateNodeName );
+		
+		
+#ifdef __AM_LASTERROR_NODE
+	MSmlDmDDFObject& amext = am.AddChildObjectL( KAMExtNodeName );
+	FillNodeInfoL( amext, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::ENode, KAMExtNodeDescription );
+		
+	MSmlDmDDFObject& amerr = amext.AddChildObjectL( KAMLastErrorNodeName );
+	FillNodeInfoL( amerr, accessTypesGet, MSmlDmDDFObject::EOne, MSmlDmDDFObject::EPermanent,
+		MSmlDmDDFObject::EChr, KAMLastErrorDescription );
+#endif
+	
+    if (GetAdapterValue() == KAMSCMAdapter)
+        {
+        CheckStateChangesL();
+        SetAdapterValue(KAMDefaultValue);
+        }
+	RDEBUG( "CAmAdapter::DDFStructureL(): end" );	
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::SessionL()
+// ------------------------------------------------------------------------------------------------
+RApplicationManagement &CAmAdapter::SessionL()
+	{
+	if ( !iSessionOpened )
+		{
+		TCertInfo info ;
+		
+		const TUid KCentralRepositoryUid = 
+			{
+			0x10207843
+			};
+		const TInt KCertKey = 0x01;
+		CRepository *re = NULL;
+		TRAPD( errx, re = CRepository::NewL ( KCentralRepositoryUid ) );
+		if (errx == KErrNone && re)
+			{
+			TPckg<TCertInfo> pcert( info );
+			errx = re->Get( KCertKey, pcert ) ;
+				
+			RDEBUG_2("aCertInfo.iFingerprint.Length() is  %u",info.iFingerprint.Length() );
+			if ( errx == KErrNone )
+				{
+				RDEBUG("CAmAdapter::SessionL() errx == KErrNone");
+				}
+			else
+				{
+				if ( errx != KErrNotFound )
+					{
+					RDEBUG("CAmAdapter::SessionL() errx != KErrNotFound");
+					}
+				else
+					{
+					RDEBUG("CAmAdapter::SessionL() errx == KErrNotFound");
+					}
+				
+				}	
+			delete re ;
+			}
+					
+		if ( errx == KErrNotFound || !iCertRequired)
+			{
+			RDEBUG("CAmAdapter::SessionL() calling iManagement.Connect()");
+			User::LeaveIfError( iManagement.Connect() );
+			iSessionOpened = ETrue;
+			iTrustAdded = EFalse;
+			}
+		else
+			{
+			RDEBUG("CAmAdapter::SessionL() calling iManagement.Connect( info )");
+			User::LeaveIfError( iManagement.Connect( info ) );
+			iSessionOpened = ETrue;
+			iTrustAdded = ETrue;
+			}
+		}
+	return iManagement;		
+	}
+
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::UpdateLeafObjectL()
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::UpdateLeafObjectL( 
+	const TDesC8& aURI, 
+	const TDesC8& aLUID, 
+	const TDesC8& aObject, 
+	const TDesC8& aType, 
+	TInt aStatusRef )
+	{
+	RDEBUG8_4("CAmAdapter::UpdateLeafObjectL(): begin, '%S', '%S' '%S'", &aURI, &aLUID, &aType );
+
+	MSmlDmAdapter::TError status = EOk;
+	SetAdapterValue(KAMSCMAdapter);
+	_UpdateLeafObjectL( aURI, aLUID, aObject, aType, aStatusRef, status);
+
+	SetStatusL( aStatusRef, status );
+	if ( status == EOk )
+		{
+		if ( iInAtomic )
+			{
+			iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) );
+			}
+		}
+	RDEBUG_2("CAmAdapter::UpdateLeafObjectL(): end (%d)", status);
+	}
+
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::UpdateLeafObjectL()
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::_UpdateLeafObjectL( 
+	const TDesC8& aURI, 
+	const TDesC8& aLUID, 
+	const TDesC8& aObject, 
+	const TDesC8& aType, 
+	TInt /*aStatusRef*/,
+	MSmlDmAdapter::TError& aStatus )
+	{
+	RDEBUG("CAmAdapter::_UpdateLeafObjectL(): begin");
+
+	CheckStateChangesL();
+
+	TError status( EError );
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+	TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash( aURI );
+	TInt numSeqs( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+	TPtrC8 mapping( NSmlDmURI::LastURISeg( uriPtrc ) );
+	TPtrC8 parent( NSmlDmURI::RemoveLastSeg( uriPtrc ) );
+#else
+	TInt numSeqs( NSmlDmURI::NumOfURISegs( aURI ) );
+	TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) );
+	TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) );
+#endif
+
+	if (mapping == KAMNameNodeName)
+	{
+		if (aObject.Size() > KDeploymentComponentNameMaxLength)
+		{
+			aStatus = ETooLargeObject;
+			return ;
+		}
+	}
+	else if (mapping == KAMVersionNodeName)
+	{
+		if (aObject.Size() > KDeploymentComponentVersionMaxLength)
+		{
+			aStatus = ETooLargeObject;
+			return ;
+		}
+	}
+	else if(mapping == KAMConRefNodeName)
+	{
+		if (aObject.Size() > KMaxConRef)
+		{
+			aStatus = ETooLargeObject;
+			return ;
+		}
+	}
+
+	TPtrC8 grandParent( NSmlDmURI::RemoveLastSeg( parent ) );
+	TPtrC8 grandParentMapping( NSmlDmURI::LastURISeg( grandParent ) );		
+	RApplicationManagement &session = SessionL();
+	TDeploymentComponentState state( EDCSNone ) ;	
+	if ( numSeqs == 4 || numSeqs == 5 )
+		{
+		if ( numSeqs == 4 )
+			{
+			state = EDCSDownload;
+			}
+		else 
+			{
+			if ( grandParentMapping == KAMDeliveredNodeName )
+				{
+				state = EDCSDelivered;
+				}
+			else if ( grandParentMapping == KAMDeployedNodeName )
+				{
+				state = EDCSActive;
+				}
+			else
+				{
+				RDEBUG8_3( "CAmAdapter::UpdateLeafObjectL(): ILLEGAL LEVEL %d NODE %S", numSeqs, &aURI );
+				User::Leave( KErrArgument );
+				}
+			}
+		}
+	else
+		{
+		RDEBUG8_3("CAmAdapter::UpdateLeafObjectL(): ILLEGAL LEVEL %d NODE %S", numSeqs, &aURI );
+		}
+	if ( state == EDCSDelivered || state == EDCSDownload ||state == EDCSActive ||state == EDCSInactive )
+		{
+		if ( aLUID != KNullDesC8 )
+			{
+			TInt iluid ( DesToIntL( aLUID ) );
+		    TDeploymentComponent comp ;
+		    TInt err( session.DeploymentComponent( iluid, comp ) );
+		    if ( err == KErrNone )
+		    	{
+	    		TDeplCompAttrType fl( UpdateFlagFromMapping( mapping ) );
+
+		    	if ( mapping == KAMDataNodeName || mapping == KAMDescriptorNodeName )
+		    		{
+		    		TInt erx(KErrNone);
+		    		
+					if ( iIsStreamedContent )
+						{
+						CloseStreaming();
+			    		TRAP( erx, session.UpdateDeploymentComponentStreamedDataL( iluid, fl, aType ) );
+						}
+					else
+						{
+						// 
+			    		TRAP( erx, session.UpdateDeploymentComponentDataL( iluid, fl, aObject, aType ) );
+						}
+		    		MAPERROR( erx, status, _L8("Update Delivered Data or metadata %d") );
+		    		}
+		    	else
+		    		{
+		    		if ( fl != EDCNone )
+		    			{
+		    			TPtrC8 obj;
+		    			TAMInstallOptions opts;
+		    			TAMInstallOptionsPckg optsb( opts );
+		    			TPckgBuf<TInt> iap;
+		    			if ( fl == EDCInstallOptions )
+		    				{
+		    				InstallOptionsParser::ParseOptionsL( aObject, opts );
+		    				if ( opts.iIAP == -1 && opts.iConRef != KNullDesC8() )
+		    					{
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+							
+			    				//CNSmlDMIAPMatcher* iapfinder = CNSmlDMIAPMatcher::NewLC( &Callback() );
+			    				//opts.iIAP = iapfinder->IAPIdFromURIL( opts.iConRef );
+			    				//CleanupStack::PopAndDestroy( iapfinder );
+					            CArrayFix<TSmlDmMappingInfo>* mapArray = new CArrayFixFlat<TSmlDmMappingInfo>(4);
+					            CleanupStack::PushL(mapArray);
+					        
+						        Callback().GetMappingInfoListL( KNSmlDMMMSSlashIAPUri,*mapArray );
+
+								TInt iap = KErrNotFound; 
+						        TSmlDmMappingInfo mapInfo;
+					        
+						        for(TInt i = 0;i<mapArray->Count();i++)
+							        {
+							        if(LastURISeg(opts.iConRef)==mapArray->At(i).iURISeg)
+								        {
+								        iap=DesToInt(mapArray->At(i).iURISegLUID);
+						                break;
+								        }
+							        }
+							    opts.iIAP = iap;   
+						        mapArray->Reset();
+						        CleanupStack::PopAndDestroy(); //mapArray
+					    				
+#else
+							CNSmlDMIAPMatcher* iapfinder = CNSmlDMIAPMatcher::NewLC( &Callback() );
+			    				opts.iIAP = iapfinder->IAPIdFromURIL( opts.iConRef );
+			    				CleanupStack::PopAndDestroy( iapfinder );
+#endif			    				
+			    				}
+		    				obj.Set( optsb );
+		    				}
+		    			else if ( fl == EDCConRef )
+		    				{
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+						
+		    				//CNSmlDMIAPMatcher* iapfinder = CNSmlDMIAPMatcher::NewLC( &Callback() );
+			    			//TInt i( iapfinder->IAPIdFromURIL( aObject ) );
+			    			//CleanupStack::PopAndDestroy( iapfinder );
+			    			//iap() = i;
+				            CArrayFix<TSmlDmMappingInfo>* mapArray = new CArrayFixFlat<TSmlDmMappingInfo>(4);
+				            CleanupStack::PushL(mapArray);
+				        
+					        Callback().GetMappingInfoListL( KNSmlDMMMSSlashIAPUri,*mapArray );
+
+							TInt iapValue = KErrNotFound; 
+					        TSmlDmMappingInfo mapInfo;
+				        
+					        for(TInt i = 0;i<mapArray->Count();i++)
+						        {
+						        if(LastURISeg(opts.iConRef)==mapArray->At(i).iURISeg)
+							        {
+							        iapValue=DesToInt(mapArray->At(i).iURISegLUID);
+					                break;
+							        }
+						        }
+						    iap() = iapValue;   
+					        mapArray->Reset();
+					        CleanupStack::PopAndDestroy(); //mapArray
+			    			
+#else
+						CNSmlDMIAPMatcher* iapfinder = CNSmlDMIAPMatcher::NewLC( &Callback() );
+			    			TInt i( iapfinder->IAPIdFromURIL( aObject ) );
+			    			CleanupStack::PopAndDestroy( iapfinder );
+			    			iap() = i;
+#endif
+			    			obj.Set( iap );
+		    				}
+		    			else
+		    				{
+		    				obj.Set( aObject );
+		    				}
+		    			TRAPD( erx, session.UpdateDeploymentComponentL( iluid, fl, obj ) );
+			    		MAPERROR( erx, status, _L8("Update some attribute %d") );
+		    			}
+		    		else
+		    			{
+		    			status = ENotFound;
+		    			RDEBUG( "CAmAdapter::UpdateLeafObjectL(): Unknown Target leaf" );
+		    			}
+		    		}
+		    	}
+			else
+				{
+				RDEBUG_3( "CAmAdapter::UpdateLeafObjectL(): FAILED TO GET COMPONENT OF ID %d: %d" , iluid, err );
+				status = ENotFound;
+				}
+			}
+		else
+			{
+			RDEBUG8_2( "CAmAdapter::UpdateLeafObjectL(): Faild to get luid allocation and find buffered for '%S'", &parent );	
+			status = ENotFound;
+			}
+		}
+	else
+		{
+		RDEBUG8_2( "CAmAdapter::UpdateLeafObjectL(): WARNING Tried to update illegal state leaf! '%S'", &grandParentMapping );
+		}
+
+	aStatus = status;
+
+	RDEBUG("CAmAdapter::_UpdateLeafObjectL(): end");
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::UpdateLeafObjectL
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+									RWriteStream*& aStream, const TDesC8& aType,
+		 							TInt aStatusRef )
+{
+	RDEBUG8_4("CAmAdapter::UpdateLeafObjectL() aStream: begin, '%S', '%S' '%S'", &aURI, &aLUID, &aType );
+
+	TError status( CSmlDmAdapter::EOk );
+
+	if(iStreamedURI)
+	{
+		delete iStreamedURI;
+		iStreamedURI = NULL;		
+	}
+	iStreamedURI = aURI.AllocL();
+
+	if(iStreamedLuid)
+	{
+		delete iStreamedLuid;
+		iStreamedLuid = NULL;
+	}
+	iStreamedLuid = aLUID.AllocL();
+
+	if(iStreamedType)
+	{
+		delete iStreamedType;
+		iStreamedType = NULL;		
+	}
+	iStreamedType = aType.AllocL();
+
+	if(!iStreamOpen)
+		{
+		RApplicationManagement &session = SessionL();
+		TDeplCompAttrType attrType;
+		TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) );
+		TDeplCompAttrType fl( UpdateFlagFromMapping( mapping ) );
+		if ( mapping == KAMDataNodeName )
+		{
+			attrType = EDCData;
+		}
+		else if( mapping == KAMDescriptorNodeName )
+		{
+			attrType = EDCMetaData;
+		}
+		else
+		{
+			RDEBUG8_2("CAmAdapter::UpdateLeafObjectL(): Unknown mapping: (%S)", &mapping);
+			status = CSmlDmAdapter::EError;
+		}
+		
+		if( status == CSmlDmAdapter::EOk )
+			{
+			TInt iluid ( DesToIntL( aLUID ) );
+			session.DeploymentComponentTempInstFileL( iluid, iStreamFile, attrType );
+			iStream.Attach( iStreamFile );
+			aStream = &iStream;
+			iStreamOpen = ETrue;
+			iIsStreamedContent = ETrue;
+			}
+		}
+	if ( !iInAtomic )
+		{
+        iStatusRef = aStatusRef;		
+		Callback().SetStatusL( aStatusRef, status );		
+		}
+	else
+		{
+		iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) );
+		}	
+
+	RDEBUG("CAmAdapter::UpdateLeafObjectL() aStream : end");
+}		 						
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::UpdateFlagFromMapping( const TDesC8& aMapping )
+// ------------------------------------------------------------------------------------------------
+TDeplCompAttrType CAmAdapter::UpdateFlagFromMapping( const TDesC8& aMapping )
+	{
+
+	TDeplCompAttrType res ;
+	if ( aMapping == KAMIDNodeName )
+		{
+		res = EDCId;
+		}
+	else if ( aMapping == KAMNameNodeName )
+		{
+		res = EDCName;
+		}
+	else if ( aMapping == KAMVersionNodeName )
+		{
+		res = EDCVersion;
+		}
+	else if ( aMapping == KAMStateValueNodeName )
+		{
+		res = EDCStateValue;
+		}
+	else if ( aMapping == KAMInstallOptsNodeName )
+		{
+		res = EDCInstallOptions;
+		}
+	else if ( aMapping == KAMDescriptorNodeName )
+		{
+		res = EDCMetaData;
+		}
+	else if ( aMapping == KAMDataNodeName )
+		{
+		res = EDCData;
+		}
+	else if( aMapping == KAMURINodeName )
+		{
+		res = EDCDownloadURI;
+		}
+	else if ( aMapping == KAMStatusNodeName )
+		{
+		res = EDCStatus;
+		}
+	else if ( aMapping == KAMConRefNodeName )
+		{
+		res = EDCConRef;
+		}
+	else
+		{
+		//User::Leave( KErrArgument );
+		res = EDCNone;
+		}
+	return res;
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::GetLuidForUserIdL( const TDesC8 &aUserId, 
+//		const TDeploymentComponentState aState )
+// ------------------------------------------------------------------------------------------------	
+TUint32 CAmAdapter::GetLuidForUserIdL( const TDesC8 &aUserId, const TDeploymentComponentState aState )
+	{
+	TUint32 ret( 0 );
+	if ( aState != EDCSNone )
+		{
+		RElementIdArray array;
+		TInt err( SessionL().DeploymentComponentIdsL( array, aState ) );
+		if ( err == KErrNone )
+			{
+			CleanupClosePushL( array );
+			TInt count( array.Count() );
+			for( TInt i( 0 ); i < count && ret == 0; i++ )
+				{
+				TUint32 el = array[i];
+				TDCUserId dc;
+				SessionL().DeploymentComponentUserIdL( el, dc );
+				if ( dc == aUserId )
+					{
+					ret = el;
+					}
+				}
+			CleanupStack::PopAndDestroy( &array );
+			}
+		else
+			{
+			}
+		}
+	return ret;	
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::GetLuid2L( const TDesC8 &aDMLuid, const TDesC8 &aUserId, 
+//		const TDeploymentComponentState aState, TError &aStatus )
+// ------------------------------------------------------------------------------------------------	
+TUint32 CAmAdapter::GetLuid2L( const TDesC8 &aDMLuid, const TDesC8 &aUserId, 
+	const TDeploymentComponentState aState, TError &aStatus )
+	{
+	TUint32 ret( GetLuidL(aDMLuid, aUserId, aState ) );
+	if ( (TInt32)ret <= 0 )
+		{
+		aStatus = ENotFound;
+		}
+	return ret;	
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::GetLuidL( const TDesC8 &aDMLuid, const TDesC8 &aUserId, 
+//		const TDeploymentComponentState aState )
+// ------------------------------------------------------------------------------------------------	
+TUint32 CAmAdapter::GetLuidL( const TDesC8 &aDMLuid, const TDesC8 &aUserId, 
+	const TDeploymentComponentState aState )
+	{
+	TUint32 ret( 0 );
+	if ( aDMLuid == KNullDesC8 )
+		{
+		ret = GetLuidForUserIdL( aUserId, aState );
+		}
+	else
+		{
+		ret = DesToIntL( aDMLuid ) ;
+		}
+	
+	return ret;	
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TInt aStatusRef )
+	{
+
+	RDEBUG8_4("CAmAdapter::DeleteObjectL(): begin (%S, %S, %d)" , &aURI, &aLUID, aStatusRef );
+	SetAdapterValue(KAMSCMAdapter);
+	CheckStateChangesL();
+	
+	TError ret( EError );
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	
+	TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);	
+	TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+	TPtrC8 mapping( NSmlDmURI::LastURISeg( uriPtrc ) );
+#else
+	TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) );
+	TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) );
+#endif
+	
+	switch ( cnt )
+		{
+		case 3:
+		case 4:
+			{
+			
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+			TPtrC8 which( NSmlDmURI::URISeg( uriPtrc, cnt == 4 ? 3 : 2 ) );
+#else
+			TPtrC8 which( NSmlDmURI::URISeg( aURI, cnt == 4 ? 3 : 2 ) );
+#endif
+			if ( which == KAMDeliveredNodeName || which == KAMDownloadNodeName )
+				{
+				TUint32 luid( GetLuidL( aLUID, mapping, (which == KAMDeliveredNodeName ? EDCSDelivered : EDCSDownload) ) );
+				if ( luid > 0 )
+					{
+					TRAPD( err, SessionL().RemoveL( luid ) );
+					if ( err == KErrNone || err == KErrNotFound )
+						{
+						ret = EOk;
+						Callback().SetMappingL( aURI, KNullDesC8 );
+						if ( err == KErrNone && iInAtomic )
+			    			{
+			    			iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) );
+			    			}
+						}
+					else
+						{
+						MAPERROR( err, ret, _L8("Delete %d") );	
+						}
+					}
+				else
+					{
+					RDEBUG( "CAmAdapter::DeleteObjectL(): WARNING Object not found" );	
+					ret = ENotFound;
+					}
+				}
+			else
+				{
+				RDEBUG8_2( "CAmAdapter::DeleteObjectL(): ERROR Removing node %S is not supported", &aURI );	
+				}
+			break;
+			}
+		default:
+			{
+			RDEBUG8_3( "CAmAdapter::DeleteObjectL(): ILLEGAL LEVEL %d NODE %S", cnt, &aURI );
+			break;
+			}
+		}
+	SetStatusL( aStatusRef, ret );
+	RDEBUG( "CAmAdapter::DeleteObjectL(): end" );
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::DeactivateIfInactive( const TUint aLuidi, const TDeploymentComponentState aTargetState )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::DeactivateIfInactive( const TUint aLuidi, const TDeploymentComponentState aTargetState )
+	{
+	if ( aTargetState == EDCSInactive )
+		{
+		RDEBUG( "CAmAdapter::DeactivateIfInactive():  deactivating!" );
+		TRAPD( derr, iManagement.DeactivateL( aLuidi ) );
+		if ( derr != KErrNone )
+			{
+			RDEBUG_2("CAmAdapter::DeactivateIfInactive(): ERROR deactivating failed %d", derr );
+			}
+		}
+	}
+
+void CAmAdapter::InstallL( 
+	TUint aLuidi, 
+	const TDesC8& aURI, 
+	const TDesC8& aLUID, 
+	const TDeploymentComponentState aTargetState,
+	TError &aRet
+	 ) 
+	{
+
+
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);	
+	#else
+		//nothing
+	#endif
+
+	TRAPD( err, SessionL().InstallL( aLuidi, aTargetState ) );
+	if ( err == KErrNone )
+		{
+		// Dont Update the mappings in client to reflect new
+		//		position in the management tree ( Inactive or Active..)
+		RDEBUG( "CAmAdapter::InstallL(): Install success!" );
+		
+		//TPtrC8 aclmapping( URISegsUpTo( aURI, 4) );
+		//SetMappingL( aclmapping, aTargetState, aLUID);
+		//iManagement.StateChangeComplete( aLuidi );			
+						
+		
+		
+		DeactivateIfInactive( aLuidi, aTargetState );
+		aRet = EOk;
+		}
+	else
+		{
+		RDEBUG_2( "CAmAdapter::InstallL(): INSTALL FAILED '%d'" , err);	
+		MAPERROR( err, aRet, _L8("Install %d") );
+		}
+	}
+	
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::DefaultMapError( const TInt aErr, TError &aRet )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::DefaultMapError( const TInt aErr, TError &aRet, const TDesC8& 
+	#ifdef __AM_LASTERROR_NODE
+	aDes 
+	#endif
+	)
+	{
+	if ( aErr == KErrNone )
+		{
+		aRet = EOk;
+		}
+	else if ( aErr == KErrNotFound )
+		{
+		aRet = ENotFound;
+		}
+	else if ( aErr == KErrArgument )
+		{
+		aRet = EInvalidObject ;
+		}
+	else if( aErr == KErrAlreadyExists )
+		{
+		aRet = EAlreadyExists;
+		}
+	else
+		{
+		aRet = EError;
+		}
+	#ifdef __AM_LASTERROR_NODE
+	TInt err = KErrNone;
+	TRAP( err, SetErrorL( aDes, aErr ) );
+	#endif
+	}
+
+#ifdef __AM_LASTERROR_NODE	
+void CAmAdapter::SetErrorL( const TDesC8& aDes, const TInt aErr )
+	{
+	if ( aDes != KNullDesC8 )
+		{
+		SetLastErrorL( aDes, aErr );
+		}
+	else
+		{
+		SetLastErrorL(KStdError, aErr);
+		}
+	}
+#endif	
+	
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aArgument, 
+//	const TDesC8& aType, 
+//	TInt aStatusRef )
+// ------------------------------------------------------------------------------------------------
+TDownloadTarget CAmAdapter::DownloadTargetL( const TDesC8& aCommand )
+	{
+	if ( aCommand == KAMDownloadOperationNodeName )
+		{
+		return EDeliver;
+		}
+	else if ( aCommand == KAMDownloadAndInstallNodeName )
+		{
+		return EInstall;
+		}
+	else if ( aCommand == KAMDownloadAndInstallAndActivateNodeName )
+		{
+		return EInstallAndActivate;
+		}
+	else if ( aCommand == KAMDownloadAndUpdateNodeName )
+		{
+		return EUpdate;
+		}
+	else if ( aCommand == KAMDownloadAndUpdateAndActivateNodeName )
+		{
+		return EUpdateAndActivate;
+		}
+
+	RDEBUG8_2( "CAmAdapter::DownloadTargetL(): ASKED OPERATION NOT SUPPORTED Download '%S'", &aCommand );
+	User::Leave( KErrArgument );
+	// NOTE! will not ever come here! Only to get rid of compiler warning !!
+	return EDeliver;
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aArgument, 
+//	const TDesC8& aType, 
+//	TInt aStatusRef )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::ExecuteCommandL( const TDesC8& aURI, 
+	const TDesC8& aLUID, 
+	const TDesC8& /*aArgument*/, 
+	const TDesC8& /*aType*/, 
+	TInt aStatusRef ) 
+	{
+
+
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);	
+	#else
+		//nothing
+	#endif
+
+	RDEBUG8_3("CAmAdapter::ExecuteCommandL(): begin, '%S', '%S'", &aURI, &aLUID );
+	SetAdapterValue(KAMSCMAdapter);
+	CheckStateChangesL();
+	TError ret( EError );
+	
+	if( aLUID == KNullDesC8 )
+		{
+		RDEBUG("CAmAdapter::ExecuteCommandL(): WARNING no valid luid provided" );
+		}
+	
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+	#else
+		TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) );
+	#endif	
+	
+	TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) );
+	
+	const TInt KDownloadMappingURILoc = 3;
+	switch ( cnt )
+		{
+		case 5:
+			{
+			TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KDownloadMappingURILoc), EDCSDownload  ) ) ;	
+			
+			// Track the Newly added delivered  node to make sure that this reference
+			// of delivered node is removed from Tree DB.
+			// This delivered node is removed only if Execute command is successful
+			// by either adding Install, Install& activate etc.
+			// This Fix would be applicable in case of DM 1.2. 
+				
+
+
+			TPtrC8 urival(URISegsUpTo(aURI, KDownloadMappingURILoc));
+			
+			if(iUriDel)
+			{
+				delete iUriDel;
+				iUriDel = NULL;
+			}
+	
+			
+			
+			iUriDel = urival.AllocL();
+			
+			RDEBUG_2("CAmAdapter::ExecuteCommandL(): luid is %d", iluid );
+			if ( iluid > 0 )
+				{
+				TDownloadTarget target = DownloadTargetL( mapping );
+		
+				TRAPD( errx, SessionL().StartDownloadL( iluid, target ) );
+			
+		
+				/*if(target == EInstall || target == EInstallAndActivate || target == EUpdate || target == EUpdateAndActivate)
+				{
+				TInt err( iDbSession.RemoveMappingInfoL( KAMAdapterImplUid, *iUriDel, ETrue ) );
+				}*/
+				if ( errx == KErrNone )
+					{
+					RDEBUG( "CAmAdapter::ExecuteCommandL(): StartDownloadL Successful " );	
+					ret = EOk;
+					}
+				else
+					{
+					RDEBUG_2( "CAmAdapter::ExecuteCommandL(): StartDownloadL FAILED '%d'", errx );	
+					if ( errx == KErrNotFound )
+						{
+						ret = ENotFound;
+						}
+					else if ( errx == KErrArgument )
+						{
+						ret = EInvalidObject ;
+						}
+					else
+						{
+						ret = EError;
+						}
+					}
+		
+				}
+			else
+				{
+				ret = ENotFound;
+				RDEBUG( "CAmAdapter::ExecuteCommandL(): case 5 Not found node" );
+				}
+			break;
+			}
+		case 6:
+			{
+			const TInt KInventoryMappingURILoc = 4 ;
+			
+	
+			// Track the Newly added delivered  node to make sure that this reference
+			// of delivered node is removed from Tree DB.
+			// This delivered node is removed only if Execute command is successful
+			// by either adding Install, Install& activate etc.
+			// This Fix would be applicable in case of DM 1.2. 
+
+
+			TPtrC8 urival(URISegsUpTo(aURI, KInventoryMappingURILoc));
+			
+			if(iUriDel)
+			{
+				delete iUriDel;
+				iUriDel = NULL;
+			}
+	
+			
+			
+			iUriDel = urival.AllocL();
+			
+			if ( mapping == KAMInstallNodeName || mapping == KAMInstallAndActivateNodeName )
+				{
+				TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSDelivered  ) ) ;
+				if( iluid > 0 )
+					{
+					TDeploymentComponentState targetstate = ((mapping == KAMInstallNodeName) ? EDCSInactive : EDCSActive);
+					InstallL( iluid, aURI, aLUID, targetstate, ret );	
+					
+					//TInt err( iDbSession.RemoveMappingInfoL( KAMAdapterImplUid, *iUriDel, iluid ) );
+					}
+				else
+					{
+					ret = ENotFound;
+					RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 install Not found node" );
+					}
+				}
+			else if ( mapping == KAMRemoveNodeName )	
+				{
+				TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSDelivered  ) ) ;
+				if ( (TInt32)iluid <= 0 )
+					{
+					iluid = GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSActive  )  ;
+					if ( (TInt32)iluid <= 0 )
+						{
+						iluid = GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSInactive  )  ;
+						}
+					}
+				if( iluid > 0 )
+					{
+					TRAPD( err, SessionL().RemoveL( iluid ) );
+					if ( err == KErrNone )
+						{
+						RDEBUG( "CAmAdapter::ExecuteCommandL(): Remove success!" );
+						TPtrC8 aclmapping( URISegsUpTo( aURI, 4) );
+						
+						// "Nullify" the mapping for argument
+						DirectSetMappingL( aclmapping, KNullDesC8 );
+						ret = EOk;
+						if ( iInAtomic )
+			    			{
+			    			iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) );
+			    			}
+						}
+					else
+						{
+						RDEBUG_2( "CAmAdapter::ExecuteCommandL(): Remove FAILED '%d'", err);	
+						
+						MAPERROR( err, ret, _L8("Execute Remove %d") );
+						}
+					}
+				else
+					{
+					ret = ENotFound;
+					RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 remove Not found node" );
+					}
+				}
+			else if ( mapping == KAMUpdateNodeName )
+				{
+				RDEBUG8_2( "CAmAdapter::ExecuteCommandL(): Update: '%S'", &mapping );
+				TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSDelivered  ) ) ;
+				if( iluid > 0 )
+					{
+					UpdateL( iluid, aURI, aLUID, EDCSInactive, ret );
+					//TInt err( iDbSession.RemoveMappingInfoL( KAMAdapterImplUid, *iUriDel, iluid ) );
+					}
+				else
+					{
+					ret = ENotFound;
+					RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 Update Not found node" );
+					}
+				}
+			else if ( mapping == KAMUpdateAndActivateNodeName )
+				{
+				RDEBUG8_2( "CAmAdapter::ExecuteCommandL(): UpdateAndActivate: '%S'", &mapping );
+				TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSDelivered  ) ) ;
+				if( iluid > 0 )
+					{
+					UpdateL( iluid, aURI, aLUID, EDCSActive, ret );	
+					//TInt err( iDbSession.RemoveMappingInfoL( KAMAdapterImplUid, *iUriDel, iluid ) );	
+					}
+				else
+					{
+					ret = ENotFound;
+					RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 UpdateAndActivate Not found node" );
+					}
+				}
+			else if ( mapping == KAMActivateNodeName )
+				{
+				//DBG_ARGS8( "CAmAdapter::ExecuteCommandL(): Activating " );
+				TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSActive ) );
+				if ( (TInt32)iluid <= 0 )
+					{
+					iluid = GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSInactive  )  ;
+					}
+				if( iluid > 0 )
+					{
+					TRAPD( erx, SessionL().ActivateL( iluid ) );
+					
+					MAPERROR( erx, ret, _L8("Activate %d") );
+					}
+				else
+					{
+					ret = ENotFound;
+					RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 Activate Not found node" );
+					}
+				}
+			else if ( mapping == KAMDeActivateNodeName )
+				{
+				//DBG_ARGS8( "CAmAdapter::ExecuteCommandL(): Inactivating " );
+				TUint32 iluid( GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSActive ) );
+				if ( (TInt32)iluid <= 0 )
+					{
+					iluid = GetLuidL( aLUID, NSmlDmURI::URISeg(aURI, KInventoryMappingURILoc), EDCSInactive  )  ;
+					}
+				if( iluid > 0 )
+					{
+					TRAPD( erx, SessionL().DeactivateL( iluid ) );
+					
+					MAPERROR( erx, ret,_L8("Dectivate %d") );
+					}
+				else
+					{
+					ret = ENotFound;
+					RDEBUG( "CAmAdapter::ExecuteCommandL(): case 6 DeActivate Not found node" );
+					}
+				}	
+			else
+				{
+				RDEBUG8_2( "CAmAdapter::ExecuteCommandL(): ASKED NOT SUPPORTED OPERATION '%S'", &mapping );
+				User::Leave( KErrArgument );
+				}
+			break;
+			}
+		
+		default:
+			{
+			RDEBUG8_3( "CAmAdapter::ExecuteCommandL(): ILLEGAL LEVEL %d NODE %S", cnt, &aURI );
+			User::Leave( KErrArgument );			
+			break;
+			}
+		}
+	SetStatusL( aStatusRef, ret ) ;
+	}
+
+
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::UpdateL( 
+// 	const TUint aLuidi, 
+// 	const TDesC8& aURI, 
+// 	const TDesC8& aSourceLUID,
+// 	const TDeploymentComponentState aTargetState,
+// 	TError &aRet
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::UpdateL( 
+	const TUint aLuidi, 
+	const TDesC8& aURI, 
+	const TDesC8& aSourceLUID,
+	const TDeploymentComponentState aTargetState,
+	TError &aRet
+	 ) 
+	{	
+
+
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);	
+	#else
+		//nothing
+	#endif
+
+	CBufBase *delivered = CBufFlat::NewL( 128 );
+	CleanupStack::PushL( delivered );
+	
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TPtrC8 aclmapping( NSmlDmURI::URISeg( uriPtrc, 4 ) );
+	#else
+		TPtrC8 aclmapping( NSmlDmURI::URISeg( aURI, 4 ) );
+	#endif
+
+	
+	HBufC8 *targetURI = HBufC8::NewLC( KDeployedURI().Length() + aclmapping.Length() );
+	
+	TPtr8 targetPtr( targetURI->Des() );
+	targetPtr.Copy( KDeployedURI );
+	targetPtr.Append( aclmapping );
+	
+	HBufC8 *deployed = Callback().GetLuidAllocL( targetPtr ) ;
+	CleanupStack::PushL( deployed );
+	
+	//DBG_ARGS8( "CAmAdapter::UpdateL(): Updating '%S' luid: '%S'" ), &targetPtr, &(*deployed));
+	if ( *deployed == KNullDesC8 )
+		{
+		//DBG_ARGS8( "CAmAdapter::UpdateL(): Failed to find to update target '%S'" ), &targetPtr );
+		aRet = EError;
+		}
+	else
+		{
+		// Found delivered & active or inactive components! Do update!
+		TInt depluid( DesToIntL( *deployed ) );
+		TRAPD( erx, SessionL().UpdateL( aLuidi, depluid ) );
+		MAPERROR( erx, aRet,_L8("Update %d") );
+		if ( erx == KErrNone )
+			{
+			//SetMappingLC( aclmapping, aTargetState, aSourceLUID, targetURI );
+			DeactivateIfInactive( aLuidi, aTargetState ); 
+			}
+		}
+	CleanupStack::PopAndDestroy( deployed ) ;
+	CleanupStack::PopAndDestroy( targetURI ) ;
+	CleanupStack::PopAndDestroy( delivered ) ;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::CheckStateL( const TDeploymentComponent &aComp, const TDesC8& aURI
+// ------------------------------------------------------------------------------------------------
+TBool CAmAdapter::CheckStateL( const TDeploymentComponent &aComp, const TDesC8& aURI )
+	{
+	// Scenarios like "./SCM/Download/Node1/Operations/Install" NumOfURISegs won't work.
+	
+	TBool ret;
+	if ((aComp.iState ==  EDCSDelivered) || (aComp.iState == EDCSActive) || ( aComp.iState == EDCSInactive) || (aComp.iState == EDCSDownload))
+	{
+        // Check for map & __TARM_SYMBIAN_CONVERGENCY also ?
+        ret = ETrue;
+    }
+	else
+	    ret = EFalse;
+	return ret;
+#if 0
+	#ifdef __TARM_SYMBIAN_CONVERGENCY
+		TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);	
+		TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) ) ;
+	#else
+		TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) ) ;
+	#endif
+
+	TBool ret( EFalse );
+	//TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) ) ;
+	if ( cnt == 4 )
+		{
+		#ifdef __TARM_SYMBIAN_CONVERGENCY	
+			TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);	
+			TPtrC8 map( NSmlDmURI::URISeg( uriPtrc, 3 ) );
+		#else
+			TPtrC8 map( NSmlDmURI::URISeg( aURI, 3 ) );
+		#endif		
+		switch ( aComp.iState )
+			{
+			case EDCSDelivered:
+				ret = (map == KAMDeliveredNodeName);
+				break;
+			case EDCSActive:
+			case EDCSInactive:
+				ret = (map == KAMDeployedNodeName);
+				break;
+			default:
+				ret = EFalse;
+				break;
+			}
+		}
+	else if ( cnt == 3 )
+		{
+		if ( NSmlDmURI::URISeg( aURI, 2 ) == KAMDownloadNodeName && aComp.iState == EDCSDownload) 
+			{
+			ret = ETrue; 
+			}
+		}
+	return ret;
+#endif
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::StateL( const TDeploymentComponent &aComp, const TDesC8& aURI
+// ------------------------------------------------------------------------------------------------
+TDeploymentComponentState CAmAdapter::StateL( const TDesC8& aURI )
+	{
+
+
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);	
+	#else
+		//nothing
+	#endif
+
+	TDeploymentComponentState ret( EDCSNone );
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) ) ;	
+	#else
+		TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) ) ;
+	#endif	
+	if ( cnt > 2)
+		{
+		#ifdef __TARM_SYMBIAN_CONVERGENCY	
+			TPtrC8 map( NSmlDmURI::URISeg( uriPtrc, 2 ) );	
+		#else
+			TPtrC8 map( NSmlDmURI::URISeg( aURI, 2 ) );
+		#endif	
+		if ( map == KAMInventoryNodeName )
+			{
+			#ifdef __TARM_SYMBIAN_CONVERGENCY
+				TPtrC8 map( NSmlDmURI::URISeg( uriPtrc, 2 ) );	
+			#else
+				TPtrC8 map( NSmlDmURI::URISeg( aURI, 2 ) );
+			#endif	
+			map.Set( NSmlDmURI::URISeg( aURI, 3 ) );
+			if ( map == KAMDeployedNodeName )
+				{
+					
+				}
+			else if ( map == KAMDeliveredNodeName )
+				{
+				ret = EDCSDelivered;
+				}
+			else
+				{
+				User::Leave( KErrArgument );
+				}
+			}
+		else if( map == KAMDownloadNodeName )
+			{
+			ret = EDCSDownload;
+			}
+		else
+			{
+			User::Leave( KErrArgument );
+			}
+		}
+	return ret;
+	}
+	
+
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::CheckStateL( const TDesC8& aURI, const TDesC8& aLUID )
+// ------------------------------------------------------------------------------------------------
+TBool CAmAdapter::CheckStateL( const TDesC8& aURI, const TDesC8& aLUID )
+	{
+
+
+	TUint32 iluid( DesToIntL( aLUID ) );
+    TDeploymentComponent comp ;
+    TInt err( SessionL().DeploymentComponent( iluid, comp ) );
+    TBool ret( EFalse );
+    if ( err == KErrNone )
+    	{
+		ret = CheckStateL( comp, aURI );
+    	}
+	return ret;
+	}
+
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::InstallOptionsDataL(const TUint32 iluid, const TDeplCompAttrType& aDataType, 
+//		CBufBase &aBuf, CBufBase *aRaw/*= NULL*/)
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::InstallOptionsDataL(const TUint32 iluid, const TDeplCompAttrType& aDataType, 
+		CBufBase &aBuf, CBufBase *aRaw/*= NULL*/)
+	{
+	TAMInstallOptionsPckgBuf iop;
+	TBool pushed( EFalse );
+	if ( !aRaw ) 
+		{
+		aRaw = CBufFlat::NewL(32);
+		CleanupStack::PushL( aRaw );
+		pushed = ETrue;
+		SessionL().DeploymentComponentDataL( iluid, aDataType, *aRaw );
+		}
+	
+	iop.Copy( aRaw->Ptr( 0 ) );
+	if ( pushed )
+		{
+		CleanupStack::PopAndDestroy( aRaw );
+		}
+	InstallOptionsParser::SerializeOptionsL( iop(), aBuf);
+	}
+
+	
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::GetComponentDataL( const TDesC8& parent, const TDesC8& mapping, 
+//		const TUint32 iluid, CBufBase *currentList, CBufBase *currentMime, TError &status )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::GetComponentDataL( const TDesC8& parent, const TDesC8& mapping, 
+		const TUint32 iluid, CBufBase &currentList, CBufBase &currentMime, TError &status )
+	{
+	TDeploymentComponent comp ;
+    TInt err( SessionL().DeploymentComponent( iluid, comp ) );
+    if ( err == KErrNone )
+    	{
+    	RDEBUG_3( "CAmAdapter::GetComponentDataL(): DeploymentComponent response: %d, state: %d", err, comp.iState );	
+    	if ( CheckStateL( comp, parent ) )
+    		{
+			if ( mapping == KAMIDNodeName )
+				{
+				currentList.InsertL( 0, comp.iId );
+				status = EOk;
+				}
+			else if ( mapping == KAMNameNodeName )
+				{
+				currentList.InsertL( 0, comp.iName );
+				status = EOk;
+				}
+			else if ( mapping == KAMVersionNodeName )
+				{
+				currentList.InsertL( 0, comp.iVersion );
+				status = EOk;
+				}
+			else
+				{
+				TDeplCompAttrType dataType( UpdateFlagFromMapping( mapping ) );
+				if ( comp.iState == EDCSDownload )
+					{
+					if ( dataType == EDCDownloadURI || dataType == EDCStatus)
+						{
+						SessionL().DeploymentComponentDataL( iluid, dataType, currentList );
+						status = EOk ;
+						}
+					else if (  dataType == EDCInstallOptions )
+						{
+						InstallOptionsDataL( iluid, dataType, currentList );
+						status = EOk;
+						}
+					else if ( dataType == EDCConRef )
+						{
+						CBufBase *b = CBufFlat::NewL(4);
+						CleanupStack::PushL( b );
+						SessionL().DeploymentComponentDataL( iluid, dataType, *b);
+						TPckgBuf<TInt> iap;
+						iap.Copy( b->Ptr( 0 ) );
+						CleanupStack::PopAndDestroy( b );
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+
+			            CArrayFix<TSmlDmMappingInfo>* mapArray = new CArrayFixFlat<TSmlDmMappingInfo>(4);
+			            CleanupStack::PushL(mapArray);
+			        
+				        Callback().GetMappingInfoListL( KNSmlDMMMSSlashIAPUri,*mapArray );
+
+						//TInt iap = KErrNotFound; 
+				        TSmlDmMappingInfo mapInfo;
+				        HBufC8 * uri = NULL;
+				        TPtr8 tempURI(uri->Des());
+			        
+				        for(TInt i = 0;i<mapArray->Count();i++)
+					        {
+						        if(iap()==DesToInt(mapArray->At(i).iURISegLUID))
+						        {
+									tempURI=mapArray->At(i).iURISeg;      	
+						        }
+						        
+					        }
+					    mapArray->Reset();
+				        CleanupStack::PopAndDestroy(); //mapArray
+		    			if ( uri != NULL )
+		    				{
+		    				CleanupStack::PushL( uri ) ;
+			    			currentList.InsertL( 0, *uri );
+			    			CleanupStack::PopAndDestroy( uri ) ;
+		    				}				        
+				        
+#else
+						
+						CNSmlDMIAPMatcher* iapfinder = CNSmlDMIAPMatcher::NewLC( &Callback() );
+		    			HBufC8 * uri = iapfinder->URIFromIAPIdL( iap() ) ;
+		    			CleanupStack::PopAndDestroy( iapfinder );
+		    			if ( uri != NULL )
+		    				{
+		    				CleanupStack::PushL( uri ) ;
+			    			currentList.InsertL( 0, *uri );
+			    			CleanupStack::PopAndDestroy( uri ) ;
+		    				}
+		    			
+#endif
+		    			status = EOk;
+						}
+					else
+						{
+						RDEBUG8_2( "CAmAdapter::GetComponentDataL(): ASKED NOT SUPPORTED LEAF '%S'", &mapping );
+						}
+					}
+				else if ( comp.iState == EDCSDelivered )
+					{
+					if ( dataType == EDCData || dataType == EDCMetaData || dataType == EDCInstallOptions)
+						{
+						CBufBase *raw = CBufFlat::NewL( 128 );
+						CleanupStack::PushL( raw );
+						SessionL().DeploymentComponentDataL( iluid, dataType, *raw );
+						TPtrC8 source( raw->Ptr(0) );
+						if ( source.Length() > 0 )
+							{
+		    				if ( dataType == EDCData )
+		    					{
+								currentList.InsertL( 0, source );
+								SessionL().DeploymentComponentDataL( iluid, EDCDataMime, currentMime );
+						
+		    					}
+		    				else if ( dataType == EDCInstallOptions )
+		    					{
+		    					InstallOptionsDataL( iluid, dataType, currentList, raw );
+		    					}
+		    				else
+		    					{
+		    					currentList.InsertL( 0, source );
+		    					SessionL().DeploymentComponentDataL( iluid, EDCMetaDataMime, currentMime );
+		    					}
+							}
+						else
+							{
+							// 0 data length...
+							}
+						status = EOk;
+						CleanupStack::PopAndDestroy( raw );
+						RDEBUG8_2( "CAmAdapter::GetComponentDataL(): DeploymentComponentDataL called '%S'", &mapping );
+						}
+					}
+				else if ( dataType == EDCStateValue )
+					{
+					if ( comp.iState == EDCSActive )
+						{
+						currentList.InsertL( 0, KAMStateValueActive() );
+						}
+					else 
+						{
+						currentList.InsertL( 0, KAMStateValueInactive() );
+						}
+					status = EOk;
+					}
+				else
+					{
+					RDEBUG8_2( "CAmAdapter::GetComponentDataL(): ERROR ASKED NOT SUPPORTED LEAF '%S'", &mapping );
+					}	    	
+				}
+			}
+    	else
+    		{
+    		RDEBUG8_3( "CAmAdapter::GetComponentDataL(): WARNING Asked illegal state leaf '%S', %d", &mapping, comp.iState );
+	    	status = ENotFound;
+    		}
+    	}
+	else
+		{
+		RDEBUG_3( "CAmAdapter::GetComponentDataL(): ERROR FAILED TO GET COMPOMENT OF ID %d: %d", iluid, err );
+		MAPERROR( err, status,_L8("Get Component %d") );
+		}
+	}
+	
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::GetLeafLuidL(const TDesC8 &aURI, const TDesC8 & aParentMapping ) 
+// ------------------------------------------------------------------------------------------------
+TInt CAmAdapter::GetLeafLuidL(const TDesC8 &aURI, const TDesC8 & aParentMapping ) 
+	{
+
+
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+		TInt numSeqs( NSmlDmURI::NumOfURISegs( uriPtrc ) );	
+	#else
+		TInt numSeqs( NSmlDmURI::NumOfURISegs( aURI ) );
+	#endif
+
+	TUint32 iluid( 0 );
+	//TInt numSeqs( NSmlDmURI::NumOfURISegs( aURI ) );
+		
+	switch ( numSeqs )
+		{
+		case 4: // must be a download leaf
+			{
+			iluid = GetLuidForUserIdL( aParentMapping, EDCSDownload ) ;
+			break;
+			}
+		case 5: // download operation or delivered or deployed leaf
+			{
+			if ( URISegsUpTo( aURI, 2, ETrue ) == KDownloadURI )
+				{
+				RDEBUG8_2( "CAmAdapter::GetLeafLuidL(): WARNING download operation leaf '%S'", &aURI );
+				//status = EOk; 
+				}
+			else 
+				{
+				TPtrC8 start( URISegsUpTo( aURI, 3, ETrue ) );
+				if ( start == KDeliveredURI )	
+					{
+					iluid = GetLuidForUserIdL( aParentMapping, EDCSDelivered ) ;
+					}
+				else if ( start == KDeployedURI )
+					{
+					iluid = GetLuidForUserIdL( aParentMapping, EDCSActive ) ;
+					if( (TInt32)iluid <= 0 )
+						{
+						iluid = GetLuidForUserIdL( aParentMapping, EDCSInactive ) ;
+						}
+					}
+				else
+					{
+					RDEBUG8_2( "CAmAdapter::GetLeafLuidL(): WARNING strange uri '%S'", &aURI );
+					}
+				}
+			break;
+			}
+		case 6: // delivered or deployed operation leaf
+			{
+			//iluid = GetLuidForUserIdL( parentMapping, EDCSDownload ) ;
+			//status = EOk;
+			RDEBUG8_2( "CAmAdapter::GetLeafLuidL(): WARNING delivered or deployed operation leaf '%S'", &aURI );
+			break;
+			}
+		default: // illegal uri
+			{
+			RDEBUG8_2( "CAmAdapter::GetLeafLuidL(): ERROR requested luid of illegal URI '%S'", &aURI );
+			break;
+			}
+		}
+	return iluid;
+	}
+	
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aType, 
+//			CBufBase& aObject )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aType, 
+		const TInt aResultsRef, TInt aStatusRef )
+	{
+
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+	#else
+		//Nothing
+	#endif
+
+
+	RDEBUG8_4("CAmAdapter::FetchLeafObjectL('%S', '%S', '%S'): begin", &aURI, &aLUID, &aType );
+	SetAdapterValue(KAMSCMAdapter);
+	CheckStateChangesL();
+	TError status( EError );
+	
+	CBufBase *currentList = CBufFlat::NewL( 128 );
+	CleanupStack::PushL( currentList );
+	
+	CBufBase *currentMime = CBufFlat::NewL( 128 );
+	CleanupStack::PushL( currentMime );
+	
+	TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) );
+	TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) );
+	TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) );
+
+	HBufC8 *luid = NULL;
+	if ( aLUID != KNullDesC8 )
+		{
+		luid = aLUID.AllocLC();
+		}
+	else 
+		{ // try if we find it from download path
+		TBuf8<256> down;
+		down = KDownloadURI;
+		down.Append ( parentMapping );
+		luid = Callback().GetLuidAllocL( down );
+		CleanupStack::PushL( luid );
+		if ( *luid != KNullDesC8 )
+			{ 
+			// make it to found next time
+			DirectSetMappingL( parent, *luid );
+			MoveAclL( down, parent );
+			
+			// remove old
+			DirectSetMappingL( down, KNullDesC8 );
+			}
+		}
+	if ( *luid != KNullDesC8 )
+		{
+		TUint32 iluid ( DesToIntL( *luid ) );
+		RDEBUG8_2( "CAmAdapter::FetchLeafObjectL(): Luid is : %d", iluid );
+	    GetComponentDataL( parent, mapping, iluid, *currentList, *currentMime, status );
+		}
+	else
+		{
+		TUint32 iluid( GetLeafLuidL( aURI, parentMapping ) );
+		if ( iluid > 0 )
+			{
+			HBufC8 *l = IntToDes8LC( iluid );
+			DirectSetMappingL( parent, *l );
+			CleanupStack::PopAndDestroy( l );
+			GetComponentDataL( parent, mapping, iluid, *currentList, *currentMime, status );
+			}
+		else
+			{
+			RDEBUG8_2( "CAmAdapter::FetchLeafObjectL(): WARNING Faild to get luid allocation for '%S'", &parent );
+			if ( aLUID == KNullDesC8 )
+				{
+#ifdef __AM_LASTERROR_NODE
+				if ( aURI == KAMLastErrorURI ) 
+					{
+					const TDesC8& error= LastError();
+					RDEBUG8_2( "CAmAdapter::FetchLeafObjectL(): Returning last error '%S'", &error );
+					currentList->InsertL(0, error );
+					status = EOk;
+					}
+				else 
+					{
+					status = ENotFound;
+					}
+#else
+				status = ENotFound ;
+#endif
+				}
+			}
+		}
+	
+	SetStatusL( aStatusRef, status );
+	if( status == EOk )
+		{
+		if ( iInAtomic )
+			{
+			iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) );
+			}
+		Callback().SetResultsL( aResultsRef, *currentList, 
+			( (currentMime->Size() > 0) ? currentMime->Ptr(0) : aType ) );
+		}
+	CleanupStack::PopAndDestroy( luid );
+	CleanupStack::PopAndDestroy( currentMime ); //currentMime
+	CleanupStack::PopAndDestroy( currentList ); //currentList
+	RDEBUG("CAmAdapter::FetchLeafObjectL: end" );
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::IdListL( TDeploymentComponentState aState, 
+//					CBufBase *aCurrentList, TBool aAppend /* = EFalse */)
+// ------------------------------------------------------------------------------------------------
+CAmAdapter::TError CAmAdapter::IdListL( 
+	TDeploymentComponentState aState, 
+	CBufBase &aCurrentList, TBool aAppend /* = EFalse */)
+	{
+	CAmAdapter::TError ret( CAmAdapter::EError );
+	RElementIdArray array;
+	TPtrC8 uriStart;
+	TBuf8<256> uri;
+	switch ( aState )
+		{
+		case EDCSDelivered:
+			uriStart.Set( KDeliveredURI );
+			break;
+		case EDCSActive:
+		case EDCSInactive:
+			uriStart.Set( KDeployedURI ) ;
+			break;
+		case EDCSDownload:
+			uriStart.Set( KDownloadURI ) ;
+			break;
+		default:
+			break;
+			
+		}
+	TInt err( SessionL().DeploymentComponentIdsL( array, aState ) );
+	if ( err == KErrNone )
+		{
+		TInt count( array.Count() );
+		if ( count && aAppend && aCurrentList.Size() )
+			{
+			aCurrentList.InsertL( aCurrentList.Size(), KAMSeparator8 );
+			}
+		for( TInt i( 0 ); i < count; i++ )
+			{
+			TUint32 el = array[i];
+			TDCUserId dc;
+			SessionL().DeploymentComponentUserIdL( el, dc );
+			
+			if ( uriStart == KNullDesC8() )
+				{
+				TDeploymentComponent comp ;
+			    err = SessionL().DeploymentComponent( el, comp ) ;
+			    if ( err == KErrNone )
+			    	{
+			    	switch ( comp.iState )
+			    		{
+			    		case EDCSDelivered:
+							uriStart.Set( KDeliveredURI );
+							break;
+						case EDCSActive:
+						case EDCSInactive:
+							uriStart.Set( KDeployedURI ) ;
+							break;
+						case EDCSDownload:
+							uriStart.Set( KDownloadURI ) ;
+							break;
+						default:
+							break;
+			    		}
+			    	}
+				}
+			if ( uriStart != KNullDesC8() )
+				{
+				uri.Copy( uriStart );
+				uri.Append( dc );
+				HBufC8 *luid = DirectGetLuidAllocLC( uri ); //Callback().GetLuidAllocL( uri );
+				if ( KNullDesC8() == *luid )				
+					{
+					RDEBUG8_3( "CAmAdapter::IdListL(): WARNING updating lost luid of '%S' %d", &uri, el );
+					HBufC8 *l = IntToDes8LC( el );
+					if ( *luid == *l )
+						{
+						RDEBUG( "CAmAdapter::IdListL(): WARNING CANCEL (not really updating, they're the same already" );
+						}
+					else
+						{
+						DirectSetMappingL( uri, *l );
+						}
+					CleanupStack::PopAndDestroy( l );
+					}
+				CleanupStack::PopAndDestroy( luid );
+			
+				}
+			else
+				{
+				RDEBUG_2( "CAmAdapter::IdListL(): WARNING failed to get component state of id %d, cannot check mappings ", el );
+				}
+			aCurrentList.InsertL( aCurrentList.Size(), dc);
+			if ( i + 1 < count )
+				{
+				aCurrentList.InsertL( aCurrentList.Size(), KAMSeparator8 );
+				}
+			}
+		ret = EOk;
+		}
+	else
+		{
+		RDEBUG_2( "CAmAdapter::IdListL(): Error %d", err );
+		}
+	array.Reset();
+	return ret; 	
+	}
+		
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::ChildURIListL( const TDesC8& aURI, const TDesC8& aParentLUID, 
+//			const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, const TInt aResultsRef, 
+//			TInt aStatusRef );
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::ChildURIListL( const TDesC8& aURI, const TDesC8& aParentLUID, 
+	const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, const TInt aResultsRef, 
+	TInt aStatusRef  )
+	{
+
+	
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+	#else
+		//Nothing
+	#endif
+
+	RDEBUG8_3 ( "CAmAdapter::ChildURIListL(): begin ('%S', '%S')" , &aURI, &aParentLUID );
+	CheckStateChangesL();
+	
+	TError ret( EError );
+		
+	CBufBase *currentList = CBufFlat::NewL( 128 );
+	CleanupStack::PushL( currentList );
+
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TInt numSeqs( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+	#else
+		TInt numSeqs( NSmlDmURI::NumOfURISegs( aURI ) );
+	#endif
+	
+	TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) );
+	if ( numSeqs == 1 ) 
+		{
+		currentList->InsertL( 0, KAMRootChilds );
+		ret = EOk;
+		}
+	else if ( numSeqs == 2 )
+		{
+		if ( mapping == KAMInventoryNodeName)
+			{
+			currentList->InsertL( 0, KAMInventoryChilds );
+			ret = EOk;
+			}
+		else if ( mapping == KAMDownloadNodeName )
+			{
+			RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level 2 NODE %S", &aURI );
+			TDeploymentComponentState state ( EDCSDownload );
+			ret = IdListL( state, *currentList );
+			}
+		else
+			{
+			RDEBUG8_2( "CAmAdapter::ChildURIListL(): ILLEGAL LEVEL 2 NODE %S", &aURI );
+			User::Leave( KErrArgument );
+			}	
+		}
+	else if ( numSeqs == 3 )
+		{
+		if ( mapping == KAMDeliveredNodeName )
+			{
+			RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level 3 NODE %S", &aURI );
+			TDeploymentComponentState state ( EDCSDelivered );			
+			ret = IdListL( state, *currentList );	
+			}
+		else if ( mapping == KAMDeployedNodeName )
+			{
+			TDeploymentComponentState state ( EDCSActive );
+			ret = IdListL( state, *currentList );
+			if ( ret == EOk )
+				{
+				state = EDCSInactive ;
+				ret = IdListL( state, *currentList, ETrue );
+				}
+			}
+		else
+			{
+			if ( aParentLUID != KNullDesC8 )
+				{
+				if ( CheckStateL( aURI, aParentLUID ) )
+					{
+					TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) );
+					TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) );
+					if ( parentMapping == KAMDownloadNodeName )
+						{
+						currentList->InsertL( 0, KAMDownloadDynaChilds );
+						ret = EOk;
+						}
+					else
+						{
+						RDEBUG8_2( "CAmAdapter::ChildURIListL(): ILLEGAL LEVEL 3 NODE %S", &aURI );
+						User::Leave( KErrArgument );
+						}
+					}
+				else
+					{
+					RDEBUG8_2( "CAmAdapter::ChildURIListL(): DC has changed state %S", &aURI );
+					ret = ENotFound;	
+					}
+				}
+			else
+				{
+				RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level3 Node not found %S", &aURI );
+				ret = ENotFound;
+				}
+			}
+		}
+	else if ( numSeqs == 4 )
+		{
+		TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) );
+		TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) );
+		if ( aParentLUID == KNullDesC8 )
+			{
+			RDEBUG8_2( "CAmAdapter::ChildURIListL(): WARNING possibly a illegal level 4 node %S", &aURI );
+			ret = ENotFound;
+			}
+				
+		if ( parentMapping == KAMDeliveredNodeName )
+			{
+			if ( GetLuid2L( aParentLUID, mapping, EDCSDelivered, ret ) > 0 )
+				{
+				currentList->InsertL( 0, KAMInventoryDeliveredDynaChilds );
+				ret = EOk;	
+				}
+			}
+		else if ( parentMapping == KAMDeployedNodeName )
+			{
+			if ( GetLuid2L( aParentLUID, mapping, EDCSActive, ret ) > 0 )
+				{
+				currentList->InsertL( 0, KAMInventoryDynaChilds );
+				ret = EOk;
+				}
+			else if ( GetLuid2L( aParentLUID, mapping, EDCSInactive, ret ) > 0 )
+				{
+				currentList->InsertL( 0, KAMInventoryDynaChilds );
+				ret = EOk;
+				}
+			}
+		else if ( mapping == KAMOperationsNodeName )
+			{
+		    if ( GetLuid2L( aParentLUID, parentMapping, EDCSDownload, ret ) > 0 )
+		    	{
+		    	if ( CheckStateL( aURI, aParentLUID ) )
+		    		{
+		    		currentList->InsertL( 0, KAMDownloadOperationChilds );
+					ret = EOk;	
+		    		}
+		    	else
+		    		{
+		    		RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level3 operations DC changed state '%S'", &aURI );
+					ret = ENotFound;
+		    		}
+		    	}
+			}
+		else
+			{
+			RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level4 Node not found '%S'", &aURI );
+			ret = ENotFound;
+			}
+		}
+	else if ( numSeqs == 5 )
+		{
+		if ( aParentLUID == KNullDesC8 )
+			{
+			RDEBUG8_2( "CAmAdapter::ChildURIListL(): WARNING possibly a illegal level 5 node %S", &aURI );
+			ret = ENotFound;
+			}
+		if ( mapping == KAMOperationsNodeName )
+			{
+			TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) );
+			TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) );
+			TPtrC8 gparent( NSmlDmURI::RemoveLastSeg( parent ) );
+			TPtrC8 gparentMapping( NSmlDmURI::LastURISeg( gparent ) );
+			if ( gparentMapping == KAMDeliveredNodeName )
+				{
+				if ( GetLuid2L( aParentLUID, parentMapping, EDCSDelivered, ret ) > 0 )
+					{
+					currentList->InsertL( 0, KAMDeliveredOperationChilds );
+					ret = EOk;	
+					}
+				}
+			else if ( gparentMapping == KAMDeployedNodeName )
+				{
+				if ( GetLuid2L( aParentLUID, parentMapping, EDCSActive, ret ) > 0 )
+					{
+					currentList->InsertL( 0, KAMDeployedOperationChilds );
+					ret = EOk;
+					}
+				else if ( GetLuid2L( aParentLUID, parentMapping, EDCSInactive, ret ) > 0 )
+					{
+					currentList->InsertL( 0, KAMDeployedOperationChilds );
+					ret = EOk;
+					}
+				}
+			else 
+				{
+				RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level5 Node not found wrong parent '%S'", &aURI );
+				ret = ENotFound;
+				}
+			}
+		else
+			{
+			RDEBUG8_2( "CAmAdapter::ChildURIListL(): Level5 Node not found '%S'", &aURI );
+			ret = ENotFound;
+			}
+		}
+	else 
+		{
+		RDEBUG8_3( "CAmAdapter::ChildURIListL(): ILLEGAL LEVEL %d NODE %S", numSeqs, &aURI );
+		ret = EError;
+		}
+	
+	SetStatusL( aStatusRef, ret );
+	
+	if( ret == EOk )
+		{
+		if ( iInAtomic )
+			{
+			iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) );
+			}
+		Callback().SetResultsL( aResultsRef, *currentList, KNullDesC8 );
+		}
+	CleanupStack::PopAndDestroy(); //currentList
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+//  CAmAdapter::DeliverOrDownloadL( const TDesC8 &aUserId, const TDesC8 &aURI, TInt aCnt, 
+//		const TDesC8 &aParentMapping, MSmlDmAdapter::TError &aStatus )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::DeliverOrDownloadL( const TDesC8 &aUserId, const TDesC8 &aURI, TInt aCnt, 
+	const TDesC8 &aParentMapping, MSmlDmAdapter::TError &aStatus )
+	{
+
+
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+	#else
+		//Nothing
+	#endif
+
+	switch ( aCnt )
+		{
+		case 3:
+			{
+			if ( aParentMapping == KAMDownloadNodeName )
+				{	
+				TUint32 luid( SessionL().DownloadL( aUserId ) );
+				Callback().SetMappingL( aURI, *IntToDes8LC( luid ) );
+				CleanupStack::PopAndDestroy();
+				aStatus = EOk;
+				}
+			else
+				{
+				RDEBUG( "CAmAdapter::DeliverOrDownloadL(): ERROR Illegal parent");
+				}
+			break;
+			} 	
+		case 4:
+			{
+			if ( aParentMapping == KAMDeliveredNodeName )
+				{	
+				TUint32 luid( SessionL().DeliverL( aUserId ) );
+				Callback().SetMappingL( aURI, *IntToDes8LC( luid ) );
+				CleanupStack::PopAndDestroy();
+				aStatus = EOk;
+				}
+			else
+				{
+				RDEBUG( "CAmAdapter::DeliverOrDownloadL(): ERROR Illegal parent");
+				}
+			break;
+			} 	
+		default:
+			{
+			RDEBUG( "CAmAdapter::DeliverOrDownloadL(): ERROR Illegal URI");
+			break;
+			}
+		}
+	}			
+
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::AddNodeObjectL( const TDesC8& aURI, const TDesC& aParentLUID )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::AddNodeObjectL( const TDesC8& aURI, const TDesC8& aParentLUID, TInt aStatusRef )
+	{
+
+
+	#ifdef __TARM_SYMBIAN_CONVERGENCY	
+		TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+		TPtrC8 mapping( NSmlDmURI::LastURISeg( uriPtrc ) );
+		TPtrC8 parent( NSmlDmURI::RemoveLastSeg( uriPtrc ) );
+		TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) );
+		TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+	#else
+		TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) );
+		TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) );
+		TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) );
+		TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) );
+	#endif
+
+	RDEBUG8_3( "CAmAdapter::AddNodeObjectL(): begin '%S', '%S'", &aURI, &aParentLUID );
+	SetAdapterValue(KAMSCMAdapter);
+	CheckStateChangesL();
+	TError status ( EError );
+//	TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) );
+//	TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) );
+//	TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) );
+//	TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) );
+	TUint32 iluid( GetLuidL( aParentLUID, mapping, (parentMapping == KAMDeliveredNodeName ? EDCSDelivered : ( parentMapping == KAMDownloadNodeName ? EDCSDownload : EDCSNone ) ) ) ) ;
+	if( !iluid && parentMapping == KAMDownloadNodeName )
+	    {
+            // This is added for avoiding duplicate node creation in Delivered/Download only.
+            iluid = GetLuidL( aParentLUID, mapping, EDCSDelivered );        
+	    }
+	if ( iluid == 0 )
+		{
+		// Not found, add it ... 
+		DeliverOrDownloadL( mapping, aURI, cnt, parentMapping, status );
+		}
+	else
+		{
+		RDEBUG_2( "CAmAdapter::AddNodeObjectL(): WARNING May Already exists '%d'", iluid );
+		TDeploymentComponent comp ;
+		TInt err( SessionL().DeploymentComponent( iluid, comp ) );
+		if ( err == KErrNone )
+			{
+			RDEBUG_2( "CAmAdapter::AddNodeObjectL(): ERROR Already exists '%d'", iluid );
+			if ( comp.iState == StateL( aURI ) )
+				{
+				RDEBUG( "CAmAdapter::AddNodeObjectL():    (state is ok) " );
+				}
+			else
+				{
+				RDEBUG( "CAmAdapter::AddNodeObjectL():    (state is NOK) " );
+				}
+			status = EAlreadyExists;
+			}
+		else
+			{
+			if ( err == KErrNotFound )
+				{
+				RDEBUG_2( "CAmAdapter::AddNodeObjectL(): WARNING Already exists but not found '%d'", iluid );
+				DeliverOrDownloadL( mapping, aURI, cnt, parentMapping, status );
+				}
+			else
+				{
+				
+				RDEBUG_2( "CAmAdapter::AddNodeObjectL(): ERROR May exists, but failed to fetch get one? '%d'", err );
+				}
+			}
+		}
+	if ( status == EOk )
+		{
+		if ( iInAtomic )
+    		{
+			iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) );
+			}
+		}
+	
+	
+	
+	SetStatusL( aStatusRef, status );
+	RDEBUG( "CAmAdapter::AddNodeObject(): end" );
+	}
+
+
+	
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::GetSizeL( const TDesC8& aURI, const TDesC& aParentLUID )
+// ------------------------------------------------------------------------------------------------
+TInt CAmAdapter::GetSizeL( const TDeplCompAttrType aDataType, const TInt aLuid, TError &aRet )
+	{
+	TInt size( 0 );
+	if ( aDataType == EDCStateValue )
+		{
+		TDeploymentComponent comp;
+		TInt err( SessionL().DeploymentComponent( aLuid, comp ) );
+		if ( err == KErrNone )
+			{
+			if ( comp.iState == EDCSActive )
+				{
+				size = KAMStateValueActive().Length();
+				}
+			else 
+				{
+				size = KAMStateValueInactive().Length() ;
+				}
+			aRet = EOk;
+			}
+		}
+	else 
+		{
+		size = SessionL().DeploymentComponentDataSizeL( aLuid, aDataType );
+		aRet = EOk;
+		}
+	return size;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC& aParentLUID )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID,
+									   const TDesC8& aType, TInt aResultsRef,
+									   TInt aStatusRef )
+	{
+
+
+
+	RDEBUG8_4("CAmAdapter::FetchLeafObjectSizeL('%S', '%S', '%S'): begin", &aURI, &aLUID, &aType );
+	CheckStateChangesL();
+	TError status( EError );
+	CBufBase *currentList = CBufFlat::NewL( 128 );
+	CleanupStack::PushL( currentList );
+	
+	TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) );
+	TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) );
+	TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) );
+	TInt size( 0 );
+	HBufC8 *luid = NULL;
+	if ( aLUID != KNullDesC8 )
+		{
+		luid = aLUID.AllocLC();
+		}
+	else 
+		{ // try if we find it from download path
+		TBuf8<256> down;
+		down = KDownloadURI;
+		down.Append ( parentMapping );
+		luid = Callback().GetLuidAllocL( down );
+		CleanupStack::PushL( luid );
+		if ( *luid != KNullDesC8 )
+			{ 
+			// make it to found next time
+			DirectSetMappingL( parent, *luid );
+			MoveAclL( down, parent );
+			
+			// remove old
+			DirectSetMappingL( down, KNullDesC8 );
+			}
+		}
+	TDeplCompAttrType dataType( UpdateFlagFromMapping( mapping ) );
+	if ( *luid != KNullDesC8 )
+		{
+		TUint32 iluid ( DesToIntL( *luid ) );
+		RDEBUG_2( "CAmAdapter::FetchLeafObjectSizeL(): Luid is : %d", iluid );
+	    size = GetSizeL( dataType, iluid, status );
+		}
+	else
+		{
+		TUint32 iluid( GetLeafLuidL( aURI, parentMapping ) );
+		if ( iluid > 0 )
+			{
+			HBufC8 *l = IntToDes8LC( iluid );
+			DirectSetMappingL( parent, *l );
+			CleanupStack::PopAndDestroy( l );
+			size = GetSizeL( dataType, iluid, status );
+			}
+		else
+			{
+			RDEBUG8_2( "CAmAdapter::FetchLeafObjectSizeL(): WARNING Faild to get luid allocation for '%S'", &parent );
+			if ( aLUID == KNullDesC8 )
+				{
+				status = ENotFound ;
+				}
+			}
+		}
+	SetStatusL( aStatusRef, status );
+	if( status == EOk && size > 0 )
+		{
+		HBufC8 *hsize = IntToDes8LC( size );
+		currentList->InsertL( 0, *hsize );
+		if ( iInAtomic )
+			{
+			iBuffer.Append( TAMCommandBufferElement( aStatusRef, aURI ) );
+			}
+		Callback().SetResultsL( aResultsRef, *currentList, aType );
+		CleanupStack::PopAndDestroy( hsize );
+		}
+	CleanupStack::PopAndDestroy( luid );
+	CleanupStack::PopAndDestroy( currentList ); //currentList	
+	}
+	
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC& aParentLUID )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::ExecuteCommandL( const TDesC8& /*aURI*/, const TDesC8& /*aLUID*/,
+								  RWriteStream*& /*aStream*/, const TDesC8& /*aType*/,
+								  TInt /*aStatusRef*/ )
+	{
+	RDEBUG("CAmAdapter::ExecuteCommandL(stream): begin (NOT SUPPORTED)");
+	User::Leave( KErrNotSupported );
+	}
+	
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::CopyCommandL( const TDesC8& aURI, const TDesC& aParentLUID )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/, const TDesC8& /*aTargetLUID*/,
+							   const TDesC8& /*aSourceURI*/, const TDesC8& /*aSourceLUID*/,
+							   const TDesC8& /*aType*/, TInt aStatusRef )
+	{
+	RDEBUG("CAmAdapter::CopyCommandL(): begin (NOT SUPPORTED)");
+	SetStatusL( aStatusRef, EError );
+	
+	}
+	
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::StartAtomicL(  )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::StartAtomicL()
+	{
+	RDEBUG("CAmAdapter::StartAtomicL(): begin (NOT properly SUPPORTED)");
+	iInAtomic = ETrue ;
+	}
+	
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::CommitAtomicL(  )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::CommitAtomicL()
+	{
+	RDEBUG("CAmAdapter::CommitAtomicL(): begin (NOT SUPPORTED)");
+	iInAtomic = EFalse ; // the initial statuses are already set
+	}
+	
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::RollbackAtomicL(  )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::RollbackAtomicL()
+	{
+	RDEBUG("CAmAdapter::RollbackAtomicL(): begin (NOT properly SUPPORTED)");
+	TInt count( iBuffer.Count() );
+	for ( TInt i( 0 ); i < count; i++ )
+		{
+		TAMCommandBufferElement &pm( iBuffer[i] );
+		SetStatusL( pm.iStatusRef, ERollbackFailed );
+		}
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::StreamingSupport( )
+// ------------------------------------------------------------------------------------------------
+TBool CAmAdapter::StreamingSupport( TInt& aItemSize ) 
+	{
+	RDEBUG("CAmAdapter::StreamingSupport(): begin");
+	aItemSize = 1024;
+	RDEBUG("CAmAdapter::StreamingSupport(): end");
+	return ETrue;
+	}
+	
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::StreamCommittedL( )
+// ------------------------------------------------------------------------------------------------
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+void CAmAdapter::StreamCommittedL( RWriteStream& /*aStream*/ )
+#else
+void CAmAdapter::StreamCommittedL()
+#endif
+	{
+	RDEBUG("CAmAdapter::StreamCommittedL(): begin");
+
+	if(iStreamOpen)
+		{
+		iStream.CommitL();
+		}
+
+	MSmlDmAdapter::TError status = EOk;
+
+	TRAPD( err,	_UpdateLeafObjectL( *iStreamedURI, *iStreamedLuid, KNullDesC8(), *iStreamedType, iStatusRef, status ) );
+
+	if(err != KErrNone)
+	{
+		RDEBUG_2("CAmAdapter::StreamCommittedL(): _UpdateLeafObjectL returned error (%d)", err);
+	}
+	
+	iIsStreamedContent = EFalse;
+	iStreamOpen = EFalse;
+
+	Callback().SetStatusL( iStatusRef, status );		
+
+	RDEBUG("CAmAdapter::StreamCommittedL(): end");
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::CloseStreaming( )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::CloseStreaming()
+{
+	if( iStreamOpen )
+	{
+		RDEBUG("CAmAdapter::CloseStreaming(): closing");
+		iStreamFile.Close();  // !!! Closing this will also close the iStreamRFs because it is adopted from server
+		iStreamOpen = EFalse;
+	}
+}
+
+	
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::CompleteOutstandingCmdsL()
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::CompleteOutstandingCmdsL()
+	{
+	RDEBUG("CAmAdapter::CompleteOutstandingCmdsL(): begin");
+/*	iManagement.Close();
+	iSessionOpened = EFalse ;*/
+	iBuffer.Reset();
+	RDEBUG("CAmAdapter::CompleteOutstandingCmdsL(): Management session closed");
+	}
+
+
+
+// ------------------
+//
+// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+const TImplementationProxy ImplementationTable[] = 
+	{
+	//
+	IMPLEMENTATION_PROXY_ENTRY( KAMAdapterImplUid, CAmAdapter::NewL )
+	};
+
+// ------------------------------------------------------------------------------------------------
+//
+// ------------------------------------------------------------------------------------------------
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+	{
+	aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+	return ImplementationTable;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+//
+// ------------------------------------------------------------------------------------------------
+TInt CAmAdapter::DesToIntL( const TDesC8& aLuid )
+	{
+	TLex8 lex( aLuid );
+	TInt value = 0;
+	User::LeaveIfError( lex.Val( value ) );
+	return value;
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+//
+// ------------------------------------------------------------------------------------------------
+HBufC8* CAmAdapter::IntToDes8LC( const TInt aLuid )
+	{
+	HBufC8* buf = HBufC8::NewLC( 10 ); //10 = max length of 32bit integer
+	TPtr8 ptrBuf = buf->Des();
+	ptrBuf.Num( aLuid );
+	return buf;
+	}
+
+
+
+// ------------------------------------------------------------------------------------------------
+//
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::ConstructL()
+	{
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+	iDbSession.ConnectL();
+#else
+	User::LeaveIfError( iDbSession.Connect());
+#endif
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::SetStatusL( TInt aStatusRef, MSmlDmAdapter::TError aErrorCode ) 
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::SetStatusL( TInt aStatusRef,
+						 MSmlDmAdapter::TError aErrorCode ) 
+	{
+	RDEBUG_3("CAmAdapter::SetStatusL( %d, %d )", aStatusRef, aErrorCode );
+	Callback().SetStatusL( aStatusRef, aErrorCode );
+	}
+							 
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::SetResultsL( TInt aResultsRef, CBufBase& aObject, const TDesC8& aType )
+// ------------------------------------------------------------------------------------------------
+void CAmAdapter::SetResultsL( TInt aResultsRef, CBufBase& aObject,
+						  const TDesC8& aType )
+	{
+	Callback().SetResultsL( aResultsRef, aObject, aType );
+	
+	}
+							  
+// -------------------------------------------------------------------------------------
+// CAmAdapter::FillNodeInfoL()
+// Fills the node info in ddf structure
+// -------------------------------------------------------------------------------------
+void CAmAdapter::FillNodeInfoL( MSmlDmDDFObject& aNode,TSmlDmAccessTypes aAccTypes,
+		MSmlDmDDFObject::TOccurence aOccurrence, MSmlDmDDFObject::TScope aScope, 
+		MSmlDmDDFObject::TDFFormat aFormat,const TDesC8& aDescription)
+	{
+	FillNodeInfoNoDefaultMimeL( aNode, aAccTypes, aOccurrence, aScope, aFormat, aDescription );
+	if(aFormat!=MSmlDmDDFObject::ENode)
+		{
+		aNode.AddDFTypeMimeTypeL(KAMTextPlain);
+		}
+	
+	}
+
+
+// -------------------------------------------------------------------------------------
+// CAmAdapter::FillNodeInfoNoDefaultMimeL()
+// Fills the node info in ddf structure, without default mime type
+// -------------------------------------------------------------------------------------
+void CAmAdapter::FillNodeInfoNoDefaultMimeL( MSmlDmDDFObject& aNode,TSmlDmAccessTypes aAccTypes,
+		MSmlDmDDFObject::TOccurence aOccurrence, MSmlDmDDFObject::TScope aScope, 
+		MSmlDmDDFObject::TDFFormat aFormat,const TDesC8& aDescription)
+	{
+	aNode.SetAccessTypesL(aAccTypes);
+	aNode.SetOccurenceL(aOccurrence);
+	aNode.SetScopeL(aScope);
+	aNode.SetDFFormatL(aFormat);
+	
+	aNode.SetDescriptionL(aDescription);
+	}
+	
+// -------------------------------------------------------------------------------------
+// CAmAdapter::CheckStateChangesInternalL()
+// Updates the changed DC states to DM client mappings and ACLs
+// -------------------------------------------------------------------------------------
+void CAmAdapter::CheckStateChangesInternalL()
+	{
+
+
+#ifdef __AM_CHECKSTATE_CHANGES
+	RDEBUG( "CAmAdapter::CheckStateChangesLInternal(): begin" );	
+	if ( !iUpdated )
+		{
+		RDEBUG( "CAmAdapter::CheckStateChangesLInternal(): !iUpdated" );
+		RElementIdArray arr;
+		CleanupClosePushL( arr );
+		TInt err( SessionL().StateChangingDCIdsL( arr ) );
+		if ( err == KErrNone )
+			{
+			TInt c( arr.Count() );
+			for( TInt i( 0 ); i < c; i++ )
+				{
+				TDeploymentComponent comp ;
+				err = iManagement.DeploymentComponent( arr[i], comp );
+				if ( err == KErrNone )
+					{
+					TDCUserId dc;
+					SessionL().DeploymentComponentUserIdL( arr[i], dc );
+					const TInt KNSmlDmMaxUriLength = 256;
+					HBufC8 *uri = HBufC8::NewLC( KNSmlDmMaxUriLength );
+					TPtr8 puri( uri->Des() );
+#ifdef __TARM_SYMBIAN_CONVERGENCY					
+					RDmTreeNode uriNode;
+					CleanupClosePushL(uriNode);
+
+					RBuf8 acl;
+					acl.CreateL(128);
+					CleanupClosePushL(acl);
+					
+					HBufC8 *newUri = HBufC8::NewLC( KNSmlDmMaxUriLength );
+					TPtr8 pnewUri( newUri->Des() );
+								
+					RDmTreeNode newUriNode;
+					CleanupClosePushL(newUriNode);
+#else
+					CBufBase* acl = CBufFlat::NewL( 128 );
+					CleanupStack::PushL( acl );
+				
+					HBufC8 *newUri = HBufC8::NewLC( KNSmlDmMaxUriLength );
+					TPtr8 pnewUri( newUri->Des() );
+
+#endif
+					
+					switch ( comp.iOldState ) 
+						{
+						case EDCSDelivered:
+							{
+							RDEBUG( "CAmAdapter::CheckStateChangesLInternal(): Old State = EDCSDelivered" );
+							puri.Copy( KDeliveredURI() );
+							puri.Append( dc );
+					
+							HBufC8 *luid = DirectGetLuidAllocLC( puri );
+							
+							if ( *luid == KNullDesC8 )
+								{ 
+                                        // try if we find it from download path
+                                        puri.Zero();
+                                        puri.Copy( KDownloadURI() );
+                                        puri.Append( dc );                                       
+                                        luid = DirectGetLuidAllocLC( puri );     
+								}
+							
+							// check if the luid is still null
+							
+							if ( *luid != KNullDesC8 )
+								{
+								// "Nullify" the old mapping 
+								//DirectSetMappingL( puri, KNullDesC8 );
+								DirectRemoveMappingL(puri);
+#ifdef __TARM_SYMBIAN_CONVERGENCY								
+								iDbSession.OpenNodeL(puri, uriNode, RDmTree::EReadOnly);
+								uriNode.DmPropertyL( DevMan::EACL, acl );
+#else
+								err = iDbSession.GetAclL(puri, *acl, EFalse ); // no need for inherited
+#endif										
+								// Determine new uri 
+								switch( comp.iState )
+									{
+									case EDCSActive:
+									case EDCSInactive: // both have same node
+										{
+										pnewUri.Copy( KDeployedURI() );
+										pnewUri.Append( dc );
+										DirectSetMappingL( pnewUri, *luid );	
+										if ( err == KErrNone )
+											{
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+											iDbSession.OpenNodeL(pnewUri, newUriNode, RDmTree::EReadOnly);
+											uriNode.RemoveDmPropertyL( DevMan::EACL );
+											newUriNode.SetDmPropertyL( DevMan::EACL, acl );
+#else
+											err = iDbSession.DeleteAclL( puri );
+											
+											err = iDbSession.UpdateAclL( pnewUri, acl->Ptr( 0 ) );
+#endif
+											}
+										else
+											{
+											RDEBUG_2("CAmAdapter::CheckStateChangesL: ERROR Failed to get acl from %d ", err );
+											}
+										iManagement.StateChangeComplete( arr[i] );							
+										break;
+										}
+									default:
+										{
+										
+										RDEBUG_2("CAmAdapter::CheckStateChangesL: WARNING Illegal state change from delivered to %d ", comp.iState );
+			
+										break;
+										}
+									}	
+								}
+							else
+                                {
+                                // probably moved already
+                                iManagement.StateChangeComplete( arr[i] );
+                                }
+							
+							CleanupStack::PopAndDestroy( luid );		
+							break;
+							}
+						case EDCSDownload:
+							{
+							RDEBUG( "CAmAdapter::CheckStateChangesLInternal(): Old State = EDCSDownload" );
+							puri.Copy( KDownloadURI() );
+							puri.Append( dc );
+							HBufC8 *luid = DirectGetLuidAllocLC( puri ); //Callback().GetLuidAllocL( puri );
+							//CleanupStack::PushL( luid );
+							if ( *luid == KNullDesC8 )
+								{ // probably moved already
+								CleanupStack::PopAndDestroy( luid );
+								puri.Copy( KDeliveredURI() );
+								puri.Append( dc );
+								luid = DirectGetLuidAllocLC( puri ); //Callback().GetLuidAllocL( puri );
+								if ( *luid == KNullDesC8 )
+								{ // probably moved already
+							
+									iManagement.StateChangeComplete( arr[i] );
+									
+								}
+								}
+							else
+								{
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+								iDbSession.OpenNodeL(puri, uriNode, RDmTree::EReadOnly);
+								uriNode.DmPropertyL( DevMan::EACL, acl );
+#else
+								err = iDbSession.GetAclL(puri, *acl, EFalse ); // no need for inherited
+#endif							
+								// "Nullify" the old mapping 
+								//DirectSetMappingL( puri, KNullDesC8 );
+								DirectRemoveMappingL(puri);
+								switch( comp.iState )
+									{
+									case EDCSActive:
+									case EDCSInactive: // both have same node
+										{
+										pnewUri.Copy( KDeployedURI() );
+										pnewUri.Append( dc );
+										DirectSetMappingL( pnewUri, *luid );	
+										if ( err == KErrNone )
+											{
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+											iDbSession.OpenNodeL(pnewUri, newUriNode, RDmTree::EReadOnly);
+											uriNode.RemoveDmPropertyL( DevMan::EACL );
+											newUriNode.SetDmPropertyL( DevMan::EACL, acl );
+#else											
+											err = iDbSession.DeleteAclL( puri );
+											err = iDbSession.UpdateAclL( pnewUri, acl->Ptr( 0 ) );
+#endif
+											}
+										else
+											{
+											RDEBUG_2("CAmAdapter::CheckStateChangesL: ERROR Failed to get acl from %d ", err );
+											}
+										iManagement.StateChangeComplete( arr[i] );							
+										break;
+										}
+									case EDCSDelivered:
+										{
+										RDEBUG( "CAmAdapter::CheckStateChangesLInternal(): Current State = EDCSDelivered" );
+										pnewUri.Copy( KDeliveredURI() );
+										pnewUri.Append( dc );
+										DirectSetMappingL( pnewUri, *luid );
+										if ( err == KErrNone )
+											{
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+											iDbSession.OpenNodeL(pnewUri, newUriNode, RDmTree::EReadOnly);
+											uriNode.RemoveDmPropertyL( DevMan::EACL );
+											newUriNode.SetDmPropertyL( DevMan::EACL, acl );
+#else
+											
+											err = iDbSession.DeleteAclL( puri );
+											err = iDbSession.UpdateAclL( pnewUri, acl->Ptr( 0 ) );
+#endif
+											}
+										else
+											{
+											RDEBUG_2("CAmAdapter::CheckStateChangesL: ERROR Failed to get acl from %d ", err );
+											}
+										iManagement.StateChangeComplete( arr[i] );								
+										break;
+										}
+									default:
+										{
+										
+										RDEBUG_2("CAmAdapter::CheckStateChangesL: WARNING Illegal state change from delivered to %d ", comp.iState );
+										break;
+										}
+									}
+							
+								}
+							CleanupStack::PopAndDestroy( luid );		
+							break;
+							}
+						case EDCSActive:
+						case EDCSInactive: // these both are in same node
+							{
+							if (comp.iState == EDCSDelete)
+							    {
+		                         puri.Copy( KDeployedURI());
+		                         puri.Append( dc ); 
+		                         HBufC8 *bufLuid = DirectGetLuidAllocLC( puri );
+		                         TUint32 luid = DesToIntL( *bufLuid ) ;
+		                         TRAPD(err,SessionL().RemoveL( luid ));
+		                         if ( err == KErrNone || err == KErrNotFound )
+		                             {}
+		                         DirectRemoveMappingL(puri);
+		                         iManagement.StateChangeComplete( arr[i] );
+		                         CleanupStack::PopAndDestroy(bufLuid);
+		                         RDEBUG("CAmAdapter::CheckStateChangesL:DirectRemoveMappingL for comp with istate EDCSDelete " );
+		                         break;
+							    }
+							RDEBUG_3("CAmAdapter::CheckStateChangesL: No need to move anything in change from %d to %d ", comp.iOldState, comp.iState );
+							iManagement.StateChangeComplete( arr[i] );								
+							break;
+							}
+						}
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+					CleanupStack::PopAndDestroy( &newUriNode );
+					CleanupStack::PopAndDestroy( newUri );
+					CleanupStack::PopAndDestroy( &uriNode );
+					CleanupStack::PopAndDestroy( &acl );
+					CleanupStack::PopAndDestroy( uri );
+#else
+					CleanupStack::PopAndDestroy( newUri );	
+					CleanupStack::PopAndDestroy( acl );
+					CleanupStack::PopAndDestroy( uri );			
+#endif
+					}
+				else
+					{
+					RDEBUG_2("CAmAdapter::CheckStateChangesL: ERROR Failed to get component: %d ", err );				
+					}
+				}
+			iUpdated = ETrue;
+			}
+		else
+			{
+			RDEBUG_2("CAmAdapter::CheckStateChangesL: ERROR Failed to get state change dcs: %d ", err );				
+			}
+		CleanupStack::PopAndDestroy( &arr );
+		}
+	else
+		{
+		RDEBUG("CAmAdapter::CheckStateChangesL: Already updated! ");				
+		}
+	RDEBUG( "CAmAdapter::CheckStateChangesL(): end" );	
+#else
+	DBG_ARGS8( "CAmAdapter::CheckStateChangesL(): disabled" );	
+#endif
+	}
+
+
+// -------------------------------------------------------------------------------------
+// CAmAdapter::CheckStateChangesL()
+// Updates acl and mapping trees to match state changes
+// -------------------------------------------------------------------------------------
+void CAmAdapter::CheckStateChangesL()	
+	{
+	iCertRequired = EFalse ;
+	RDEBUG( "CAmAdapter::CheckStateChangesL(): iCertRequired = EFalse" );
+	TRAPD( err, CheckStateChangesInternalL() );
+	if ( err != KErrNone )
+		{
+		RDEBUG_2("CAmAdapter::CheckStateChangesL(): warning failed to check state changes %d", err );
+		}
+	iCertRequired = ETrue ;
+	RDEBUG( "CAmAdapter::CheckStateChangesL(): iCertRequired = ETrue" );
+	if ( !iTrustAdded )
+		{
+			RDEBUG( "CAmAdapter::CheckStateChangesL(): Adding Trust Closing Session" );
+			iManagement.Close();
+			iSessionOpened = EFalse;
+			RApplicationManagement &session = SessionL();
+			RDEBUG( "CAmAdapter::CheckStateChangesL(): Adding Trust new session started" );
+		}
+	}
+
+		
+// -------------------------------------------------------------------------------------
+// CAmAdapter::URISegsUpTo(const TDesC8& aURI, TInt aUpTo)
+// -------------------------------------------------------------------------------------
+TPtrC8 CAmAdapter::URISegsUpTo( const TDesC8& aURI, TInt aUpTo, TBool aInclKeno/*=EFalse*/)
+	{
+
+
+
+	TPtrC8 ret;
+	TInt numOfURISegs( 0 );
+	for( TInt i( 0 ); i < aURI.Length() && ret.Ptr() == NULL; i++ )
+		{
+		if( aURI[i] == KNSmlDMUriSeparator )
+			{
+			numOfURISegs++;
+			if( aUpTo == numOfURISegs )
+				{
+				if( aInclKeno && aURI.Length() > i+1)
+					{
+					ret.Set( aURI.Left( i + 1 ) );
+					}
+				else
+					{
+					ret.Set( aURI.Left( i ) );
+					}
+				}
+			}
+		}
+	return ret;
+	}
+	
+		
+// -------------------------------------------------------------------------------------
+// CAmAdapter::DirectGetLuidAllocLC( const TDesC8 &aURI )
+// -------------------------------------------------------------------------------------	
+HBufC8 *CAmAdapter::DirectGetLuidAllocLC( const TDesC8 &aURI )
+	{
+
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+	HBufC8 *ret = Callback().GetLuidAllocL( aURI );
+#else
+	HBufC8* ret = iDbSession.GetLuidAllocL( KAMAdapterImplUid, aURI );
+#endif
+	
+	CleanupStack::PushL( ret );
+	return ret;
+	}
+	
+	
+// -------------------------------------------------------------------------------------
+// CAmAdapter::DirectSetMappingL( const TDesC8 &aURI, const TDesC8 &aLUID )
+// -------------------------------------------------------------------------------------		
+TInt CAmAdapter::DirectSetMappingL( const TDesC8 &aURI, const TDesC8 &aLUID )
+	{
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+	TRAPD( err, Callback().SetMappingL( aURI, aLUID ) );
+#else
+	TInt err( iDbSession.AddMappingInfoL( KAMAdapterImplUid, aURI, aLUID ) );
+#endif
+	return err;
+	}
+	
+// -------------------------------------------------------------------------------------
+// CAmAdapter::DirectRemoveMappingL( const TDesC8 &aURI )
+// -------------------------------------------------------------------------------------        
+TInt CAmAdapter::DirectRemoveMappingL( const TDesC8 &aURI )
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    TRAPD( err, Callback().SetMappingL( aURI, aLUID ) );
+#else
+    TInt err( iDbSession.RemoveMappingInfoL( KAMAdapterImplUid, aURI, ETrue ) );
+#endif
+    return err;
+    }
+	
+// -------------------------------------------------------------------------------------
+// CAmAdapter::MoveAclL( const TDesC8 &aFrom, const TDesC8 &aTo )
+// -------------------------------------------------------------------------------------		
+void CAmAdapter::MoveAclL( const TDesC8 &aFrom, const TDesC8 &aTo )
+	{	
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+	RDmTreeNode from;
+	CleanupClosePushL(from);
+
+	RDmTreeNode to;
+	CleanupClosePushL(to);
+
+	RBuf8 acl;
+	acl.CreateL(128);
+	CleanupClosePushL(acl);
+
+	iDbSession.OpenNodeL(aFrom, from, RDmTree::EReadOnly);
+	TRAPD( err, from.DmPropertyL( DevMan::EACL, acl ) );
+	if ( err == KErrNone )
+		{
+		iDbSession.OpenNodeL(aTo, to, RDmTree::EReadOnly);
+		from.RemoveDmPropertyL( DevMan::EACL );
+		to.SetDmPropertyL( DevMan::EACL, acl );
+		}
+	CleanupStack::PopAndDestroy( 3, &from );
+#else
+	CBufBase *acl = CBufFlat::NewL( 128 );
+	CleanupStack::PushL( acl );
+	TInt err  (iDbSession.GetAclL(aFrom, *acl, EFalse ) ); // no need for inherited
+	if ( err == KErrNone )
+		{
+		err = iDbSession.DeleteAclL( aFrom );
+		err = iDbSession.UpdateAclL( aTo, acl->Ptr( 0 ) );
+		}
+	CleanupStack::PopAndDestroy( acl );
+#endif
+	}
+
+
+// -------------------------------------------------------------------------------------
+// CAmAdapter::SetMappingL( const TDesC8 &aOriginalURI, 
+//	const TDeploymentComponentState aTargetState, const TDesC8 &aLUID )
+// -------------------------------------------------------------------------------------		
+void CAmAdapter::SetMappingL( const TDesC8 &aOriginalURI, 
+	const TDeploymentComponentState aTargetState, const TDesC8 &aLUID )
+	{
+
+
+	HBufC8 * targeturi = NULL;
+	SetMappingLC( aOriginalURI, aTargetState, aLUID, targeturi );
+	CleanupStack::PopAndDestroy( targeturi );
+	}
+
+
+// -------------------------------------------------------------------------------------
+// CAmAdapter::SetMappingLC( const TDesC8 &aOriginalURI, 
+//	const TDeploymentComponentState aTargetState, const TDesC8 &aLUID, 
+//	HBufC8 *&aNewUri )
+// -------------------------------------------------------------------------------------		
+void CAmAdapter::SetMappingLC( const TDesC8 &aOriginalURI, 
+	const TDeploymentComponentState aTargetState, const TDesC8 &aLUID, HBufC8 *&aNewUri )
+	{
+
+	
+	// "Nullify" the mapping for argument
+	DirectSetMappingL( aOriginalURI, KNullDesC8 );
+	
+	// Determine new uri for aArgument
+	TPtrC8 puri;
+	if ( aNewUri == NULL )	
+		{
+		TPtrC8 argMapping( NSmlDmURI::LastURISeg( aOriginalURI ) );
+		TPtrC8 target;
+		if ( aTargetState == EDCSInactive || aTargetState == EDCSActive )
+			{
+			target.Set( KDeployedURI() );
+			}
+		else if ( aTargetState == EDCSDelivered )
+			{
+			target.Set( KDeliveredURI() );
+			}
+		else
+			{
+			
+			User::Leave( KErrArgument );
+			}
+	
+		aNewUri = HBufC8::NewLC( target.Length() + argMapping.Length() );
+		TPtr8 p( aNewUri->Des() );
+		p.Copy( target );
+		p.Append( argMapping );
+		puri.Set( p );
+		}
+	else
+		{
+		puri.Set( *aNewUri );
+		}
+	DirectSetMappingL( puri, aLUID );
+	MoveAclL( aOriginalURI, puri );
+	}
+
+
+#ifdef __AM_LASTERROR_NODE
+// ------------------------------------------------------------------------------------------------
+// CAmAdapter::SetLastErrorL( const TDesC8& aLastError, const TInt aError )
+// ------------------------------------------------------------------------------------------------	
+void CAmAdapter::SetLastErrorL( const TDesC8& aLastError, const TInt aError )
+	{
+	if ( iLastError )
+		{
+		TPtrC8 p(*iLastError);
+		RDEBUG8_2( "CAmAdapter::SetLastErrorL: clearing last error %S", &p);
+		delete iLastError;
+		iLastError = NULL;
+		}
+	iLastError = HBufC8::NewL( aLastError.Length() + 10);
+	iLastError->Des().Format( aLastError, aError );
+	}
+	
+const TDesC8& CAmAdapter::LastError()
+	{
+	return iLastError == NULL ? KNullDesC8() : *iLastError;
+	}
+	
+#endif
+
+TPtrC8 CAmAdapter::LastURISeg(const TDesC8& aURI)
+    {
+    TInt i;
+    for(i=aURI.Length()-1;i>=0;i--)
+        {
+        if(aURI[i]==KNSmlDMAMSeparatorDef)
+            {
+            break;
+            }
+        }
+    if(i==0)
+        {
+        return aURI;
+        }
+    else
+        {
+        return aURI.Mid(i+1);
+        }
+    }
+
+TInt CAmAdapter::DesToInt(const TDesC8& aLuid)
+    {
+    TLex8 lex(aLuid);
+    TInt value = 0;
+    lex.Val(value);
+    return value;
+    }
+TInt CAmAdapter::GetAdapterValue()
+    {
+    TInt adapterValue;
+    CRepository *repository = NULL;
+    TRAPD( err, repository = CRepository::NewL ( KCRUidPrivateApplicationManagementKeys ) );
+    if (err == KErrNone)
+        {
+        err = repository->Get(KAMAdapterValue, adapterValue);
+        }
+    delete repository;
+    repository = NULL;
+    return adapterValue;
+    }
+
+void CAmAdapter::SetAdapterValue(TInt aAdapterValue)
+    {
+    
+    CRepository *repository = NULL;
+    TRAPD( err, repository = CRepository::NewL ( KCRUidPrivateApplicationManagementKeys ) );
+    if (err == KErrNone)
+        {
+        err = repository->Set(KAMAdapterValue, aAdapterValue);
+        }
+    delete repository;
+    repository = NULL;
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/amadapter2/src/amadapter.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,50 @@
+/*
+* 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: 
+*       Registery info for Application Management DM Adapter.
+*
+*/
+
+
+#include <registryinfo.rh>
+#define KSmlDMInterfaceUid 0x102018B4
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x10207844; //The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = KSmlDMInterfaceUid; // DM interface UID
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x10207845; // SCM DM Adapter implementation UID
+                version_no = 1; 
+                display_name = "Application Management DM Adapter";
+                default_data = "";
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+                opaque_data = "host=0x101F9A02";
+#else
+								opaque_data = "";
+#endif
+                }
+            };
+          }
+      };
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/amadapter2/src/nsmldmiapmatcher.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,235 @@
+/*
+* 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:  DM Tree module
+*
+*/
+
+
+// ------------------------------------------------------------------------------------------------
+// Includes
+// ------------------------------------------------------------------------------------------------
+
+#include <utf.h>
+#include "nsmldmiapmatcher.h"
+#include <smldmadapter.h>
+#include <featmgr.h>
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewL( MSmlDmCallback* aDmCallback )
+// ------------------------------------------------------------------------------------------------
+CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewL( 
+	MSmlDmCallback* aDmCallback )
+    {
+    CNSmlDMIAPMatcher* self = CNSmlDMIAPMatcher::NewLC( aDmCallback );	
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewLC( MSmlDmCallback* aDmCallback )
+// ------------------------------------------------------------------------------------------------
+CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewLC(
+	MSmlDmCallback* aDmCallback )
+    {
+    CNSmlDMIAPMatcher* self = new( ELeave ) CNSmlDMIAPMatcher;
+    CleanupStack::PushL( self );
+    self->ConstructL( aDmCallback );
+    return self;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// void CNSmlDMIAPMatcher::ConstructL( MSmlDmCallback* aDmCallback )
+// ------------------------------------------------------------------------------------------------
+void CNSmlDMIAPMatcher::ConstructL( MSmlDmCallback* aDmCallback )
+    {
+    iCallback = aDmCallback;
+    FeatureManager::InitializeLibL();
+    iFeatMgrInitialized = ETrue;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDMIAPMatcher::~CNSmlDMIAPMatcher()
+// ------------------------------------------------------------------------------------------------
+CNSmlDMIAPMatcher::~CNSmlDMIAPMatcher()
+    {
+    	if(iFeatMgrInitialized)
+    		{
+    			FeatureManager::UnInitializeLib();
+    		}
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlDMIAPMatcher::IAPIdFromURIL( const TDesC8& aURI )
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlDMIAPMatcher::IAPIdFromURIL( const TDesC8& aURI )
+    {
+    TInt iapId(KErrNotFound);
+
+	MSmlDmAdapter::TError status;
+	CBufBase* allIAPs = CBufFlat::NewL(16);
+	CleanupStack::PushL(allIAPs);
+	iCallback->FetchLinkL( GetConRef(), *allIAPs, status );
+	TPtrC8 uri = RemoveDotSlash(aURI);
+
+    if( status == MSmlDmAdapter::EOk &&
+        uri.Find(GetConRef()) == 0 &&
+        allIAPs->Ptr(0).Find(LastURISeg(uri))>=0)
+        {
+        HBufC8* luid = iCallback->GetLuidAllocL( uri ); 
+
+        if ( luid->Length() )
+            {
+            iapId = DesToInt(*luid);
+            } 
+        delete luid;
+        }
+
+    CleanupStack::PopAndDestroy(allIAPs);
+    
+    return iapId;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// HBufC8* CNSmlDMIAPMatcher::URIFromIAPIdL( TInt aIAPId )
+// ------------------------------------------------------------------------------------------------
+HBufC8* CNSmlDMIAPMatcher::URIFromIAPIdL( TInt aIAPId )
+    {
+    CBufBase *allIAPs = CBufFlat::NewL(16);
+	CleanupStack::PushL(allIAPs);
+    MSmlDmAdapter::TError status;
+
+    iCallback->FetchLinkL( GetConRef(), *allIAPs, status );
+
+    if ( status == MSmlDmAdapter::EOk )
+        {   
+        TInt index(0);
+        TInt segStart(0);
+
+        while ( index != KErrNotFound)
+            {                
+            TPtrC8 allIAPsptr = allIAPs->Ptr(segStart).Mid(0);
+            index = allIAPsptr.Locate('/');
+            HBufC8* uriSeg = 0;
+
+            if ( index == KErrNotFound )
+                {
+                TPtrC8 uriSeg8Ptr = allIAPs->Ptr(segStart);
+                uriSeg = uriSeg8Ptr.AllocLC();
+                }
+            else
+                {
+                TPtrC8 uriSeg8Ptr = allIAPs->Ptr(segStart).Mid( 0, index );
+                uriSeg = uriSeg8Ptr.AllocLC();
+                }
+
+            HBufC8* uri = HBufC8::NewLC( GetConRef().Length() + 1 +
+            	uriSeg->Length() );
+            	
+			TPtr8 uriPtr = uri->Des();
+			uriPtr.Format( GetConRef());
+			uriPtr.Append( KNSmlDMSeparator8 );
+			uriPtr.Append( *uriSeg );
+			HBufC8* luid = iCallback->GetLuidAllocL( uriPtr );
+			CleanupStack::PushL(luid);
+
+			if ( luid->Length() > 0 )
+				{				
+				TInt iapId = DesToInt(luid->Des());
+				if ( iapId == aIAPId )
+					{
+		            CleanupStack::PopAndDestroy();  //luid
+		            CleanupStack::Pop();  //uri
+		            CleanupStack::PopAndDestroy(2);  //uriSeg, allIAPs
+		            return uri;
+					}
+				}
+            CleanupStack::PopAndDestroy(3); // luid, uri, uriSeg
+
+            segStart += index + 1;
+            }        
+        }
+
+    CleanupStack::PopAndDestroy(); // allIAPs
+
+    return 0;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlDMIAPMatcher::DesToInt(const TDesC& aLuid)
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlDMIAPMatcher::DesToInt(const TDesC8& aLuid) const
+	{
+	TLex8 lex(aLuid);
+	TInt value = 0;
+	lex.Val(value);
+	return value;
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 CNSmlDMIAPMatcher::RemoveDotSlash(const TDesC8& aURI) const
+// ------------------------------------------------------------------------------------------------
+TPtrC8 CNSmlDMIAPMatcher::RemoveDotSlash(const TDesC8& aURI) const
+	{
+	if(aURI.Find(KNSmlDMIAPUriDotSlash)==0)
+		{
+		return aURI.Right( aURI.Length()-KNSmlDMIAPUriDotSlash().Length() );
+		}
+	else
+		{
+		return aURI;
+		}
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDMIAPMatcher::TPtrC8 LastURISeg(const TDesC8& aURI)
+// Returns only the last uri segemnt
+// ------------------------------------------------------------------------------------------------
+TPtrC8 CNSmlDMIAPMatcher::LastURISeg(const TDesC8& aURI) const
+	{
+	TInt i;
+	for(i=aURI.Length()-1;i>=0;i--)
+		{
+		if(aURI[i]==KNSmlDMSlash)
+			{
+			break;
+			}
+		}
+	if(i==0)
+		{
+		return aURI;
+		}
+	else
+		{
+		return aURI.Mid(i+1);
+		}
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CNSmlDMIAPMatcher::const TDesC8& GetConRef()
+// Returns the connection reference
+// ------------------------------------------------------------------------------------------------
+const TDesC8& CNSmlDMIAPMatcher::GetConRef()
+	{
+	if(FeatureManager::FeatureSupported(KFeatureIdFfDmConnmoAdapter))
+		{
+			return KNSmlDMConnMOIAPUri();
+		}
+	else
+		{
+			return KNSmlDMIAPUri();
+		}	
+  }
+  
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/amadapter2/src/nsmldmuri.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,208 @@
+/*
+* 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:  DM Utilities
+*
+*/
+
+
+#include "nsmldmuri.h"
+
+// ===========================================================================
+// NSmlDmURI
+// ===========================================================================
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::ParentURI(const TDesC8& aURI)
+// returns parent uri, i.e. removes last uri segment
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::ParentURI(const TDesC8& aURI)
+	{
+	TBool onlyOneSeg = ETrue;
+	TInt i;
+	for(i=aURI.Length()-1;i>=0;i--)
+		{
+		if(aURI[i]==KNSmlDMUriSeparator)
+			{
+			onlyOneSeg = EFalse;
+			break;
+			}
+		}
+	if(onlyOneSeg)
+		{
+		return KNSmlDmRootUri();
+		}
+	else
+		{
+		return aURI.Left(i);
+		}
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::LastURISeg(const TDesC8& aURI)
+// Returns only the last uri segemnt
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::LastURISeg(const TDesC8& aURI)
+	{
+	TInt i;
+	for(i=aURI.Length()-1;i>=0;i--)
+		{
+		if(aURI[i]==KNSmlDMUriSeparator)
+			{
+			break;
+			}
+		}
+	if(i==0)
+		{
+		return aURI;
+		}
+	else
+		{
+		return aURI.Mid(i+1);
+		}
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::RemoveDotSlash(const TDesC8& aURI)
+// return uri without dot and slash in start
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::RemoveDotSlash(const TDesC8& aURI)
+	{
+
+	TInt offset = 0;
+	TInt endSlash = 0;
+
+	if(aURI.Find(KNSmlDmUriDotSlash)==0)
+		{
+		offset = 2;
+		}
+	else
+		{
+		return aURI;
+		}
+
+	if(aURI.Length()>2&&aURI[aURI.Length()-1]==KNSmlDMUriSeparator)
+		{
+		endSlash = 1;
+		}
+
+	return aURI.Mid(offset,aURI.Length()-endSlash-offset);
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::RemoveProp(const TDesC8& aURI)
+// removes property from the uri
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::RemoveProp(const TDesC8& aURI)
+	{
+	TInt offset = aURI.Find(KNSmlDmQuestionMark);
+	if(offset!=KErrNotFound)
+		{
+		return aURI.Left(offset); 
+		}
+	return aURI;
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::RemoveLastSeg(const TDesC8& aURI)
+// Removes last uri segment
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::RemoveLastSeg(const TDesC8& aURI)
+	{
+	TInt i;
+	for(i=aURI.Length()-1;i>=0;i--)
+		{
+		if(aURI[i]==KNSmlDMUriSeparator)
+			{
+			break;
+			}
+		}
+
+	if(i>0)
+		{
+		return aURI.Left(i);
+		}
+	else
+		{
+		return KNullDesC8();
+		}
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::URISeg(const TDesC8& aURI,TInt aLocation)
+// Returns the aLocation:th URI segment
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::URISeg(const TDesC8& aURI,TInt aLocation)
+	{
+	TInt begin=0;
+	TInt end;
+	TInt num=0;
+
+	for(end=0;end<aURI.Length();end++)
+		{
+		if(aURI[end]==KNSmlDMUriSeparator||end==aURI.Length()-1)
+			{
+			num++;
+			if(num==aLocation)
+				{
+				break;
+				}
+			else
+				{
+				begin = end;
+				}
+			}
+		}
+	if(begin==0)
+		{
+		if(end==aURI.Length()-1)
+			{
+			return aURI;
+			}
+		else
+			{
+			return aURI.Left(end);
+			}
+		}
+	else
+		{
+		if(end==aURI.Length()-1)
+			{
+			return aURI.Mid(begin+1,end-begin);
+			}
+		else
+			{
+			return aURI.Mid(begin+1,end-begin-1);
+			}
+		}
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// TInt NSmlDmURI::NumOfURISegs(const TDesC8& aURI)
+// Returns the num of uri segs
+// ------------------------------------------------------------------------------------------------
+TInt NSmlDmURI::NumOfURISegs(const TDesC8& aURI)
+	{
+	TInt numOfURISegs = 1;
+	for(TInt i=0;i<aURI.Length();i++)
+		{
+		if(aURI[i]==KNSmlDMUriSeparator)
+			{
+			numOfURISegs++;
+			}
+		}
+	return numOfURISegs;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/applicationmanagement.pro	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,26 @@
+#
+# 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: Implementation of applicationmanagement components
+ #
+ #
+TEMPLATE = subdirs
+
+SUBDIRS  += server
+
+CONFIG += ordered
+
+symbian: {
+SYMBIAN_PLATFORMS = WINSCW \
+    ARMV5
+    }
\ No newline at end of file
Binary file applicationmanagement/cenrep/keys_application_management.xls has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/client/BWINS/applicationmanagementclientu.def	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,30 @@
+EXPORTS
+	?ActivateL@RApplicationManagement@NApplicationManagement@@QBEXK@Z @ 1 NONAME ; void NApplicationManagement::RApplicationManagement::ActivateL(unsigned long) const
+	?CheckStatusNodesL@RApplicationManagement@NApplicationManagement@@QBEXXZ @ 2 NONAME ; void NApplicationManagement::RApplicationManagement::CheckStatusNodesL(void) const
+	?Close@RAppMgmtRfs@@QAEXXZ @ 3 NONAME ; void RAppMgmtRfs::Close(void)
+	?Close@RApplicationManagement@NApplicationManagement@@QAEXXZ @ 4 NONAME ; void NApplicationManagement::RApplicationManagement::Close(void)
+	?Connect@RAppMgmtRfs@@QAEHXZ @ 5 NONAME ; int RAppMgmtRfs::Connect(void)
+	?Connect@RApplicationManagement@NApplicationManagement@@QAEHABVTCertInfo@@@Z @ 6 NONAME ; int NApplicationManagement::RApplicationManagement::Connect(class TCertInfo const &)
+	?Connect@RApplicationManagement@NApplicationManagement@@QAEHXZ @ 7 NONAME ; int NApplicationManagement::RApplicationManagement::Connect(void)
+	?DeactivateL@RApplicationManagement@NApplicationManagement@@QBEXK@Z @ 8 NONAME ; void NApplicationManagement::RApplicationManagement::DeactivateL(unsigned long) const
+	?DeliverL@RApplicationManagement@NApplicationManagement@@QBEKABV?$TBuf8@$0BAA@@@@Z @ 9 NONAME ; unsigned long NApplicationManagement::RApplicationManagement::DeliverL(class TBuf8<256> const &) const
+	?DeploymentComponent@RApplicationManagement@NApplicationManagement@@QBEHKAAUTDeploymentComponent@2@@Z @ 10 NONAME ; int NApplicationManagement::RApplicationManagement::DeploymentComponent(unsigned long, struct NApplicationManagement::TDeploymentComponent &) const
+	?DeploymentComponentDataL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@AAVCBufBase@@@Z @ 11 NONAME ; void NApplicationManagement::RApplicationManagement::DeploymentComponentDataL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class CBufBase &) const
+	?DeploymentComponentDataSizeL@RApplicationManagement@NApplicationManagement@@QBEHKABW4TDeplCompAttrType@2@@Z @ 12 NONAME ; int NApplicationManagement::RApplicationManagement::DeploymentComponentDataSizeL(unsigned long, enum NApplicationManagement::TDeplCompAttrType const &) const
+	?DeploymentComponentIdsL@RApplicationManagement@NApplicationManagement@@QBEHAAV?$RArray@K@@W4TDeploymentComponentState@2@@Z @ 13 NONAME ; int NApplicationManagement::RApplicationManagement::DeploymentComponentIdsL(class RArray<unsigned long> &, enum NApplicationManagement::TDeploymentComponentState) const
+	?DeploymentComponentTempInstFileL@RApplicationManagement@NApplicationManagement@@QBEXKAAVRFile@@ABW4TDeplCompAttrType@2@@Z @ 14 NONAME ; void NApplicationManagement::RApplicationManagement::DeploymentComponentTempInstFileL(unsigned long, class RFile &, enum NApplicationManagement::TDeplCompAttrType const &) const
+	?DeploymentComponentUserIdL@RApplicationManagement@NApplicationManagement@@QBEXKAAV?$TBuf8@$0BAA@@@@Z @ 15 NONAME ; void NApplicationManagement::RApplicationManagement::DeploymentComponentUserIdL(unsigned long, class TBuf8<256> &) const
+	?DownloadL@RApplicationManagement@NApplicationManagement@@QBEKABV?$TBuf8@$0BAA@@@@Z @ 16 NONAME ; unsigned long NApplicationManagement::RApplicationManagement::DownloadL(class TBuf8<256> const &) const
+	?GenericAlertSentL@RApplicationManagement@NApplicationManagement@@QBEXK@Z @ 17 NONAME ; void NApplicationManagement::RApplicationManagement::GenericAlertSentL(unsigned long) const
+	?GetFinalResultsForGAL@RApplicationManagement@NApplicationManagement@@QBEXKAAHAAVTDes8@@@Z @ 18 NONAME ; void NApplicationManagement::RApplicationManagement::GetFinalResultsForGAL(unsigned long, int &, class TDes8 &) const
+	?InstallL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeploymentComponentState@2@@Z @ 19 NONAME ; void NApplicationManagement::RApplicationManagement::InstallL(unsigned long, enum NApplicationManagement::TDeploymentComponentState) const
+	?PerformRfsL@RAppMgmtRfs@@QBEXXZ @ 20 NONAME ; void RAppMgmtRfs::PerformRfsL(void) const
+	?RemoveL@RApplicationManagement@NApplicationManagement@@QBEXK@Z @ 21 NONAME ; void NApplicationManagement::RApplicationManagement::RemoveL(unsigned long) const
+	?StartDownloadL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDownloadTarget@2@@Z @ 22 NONAME ; void NApplicationManagement::RApplicationManagement::StartDownloadL(unsigned long, enum NApplicationManagement::TDownloadTarget) const
+	?StateChangeComplete@RApplicationManagement@NApplicationManagement@@QBEHK@Z @ 23 NONAME ; int NApplicationManagement::RApplicationManagement::StateChangeComplete(unsigned long) const
+	?StateChangingDCIdsL@RApplicationManagement@NApplicationManagement@@QBEHAAV?$RArray@K@@@Z @ 24 NONAME ; int NApplicationManagement::RApplicationManagement::StateChangingDCIdsL(class RArray<unsigned long> &) const
+	?UpdateDeploymentComponentDataL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@ABVTDesC8@@1@Z @ 25 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateDeploymentComponentDataL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class TDesC8 const &, class TDesC8 const &) const
+	?UpdateDeploymentComponentL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@ABVTDesC8@@@Z @ 26 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateDeploymentComponentL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class TDesC8 const &) const
+	?UpdateDeploymentComponentStreamedDataL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@ABVTDesC8@@@Z @ 27 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateDeploymentComponentStreamedDataL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class TDesC8 const &) const
+	?UpdateL@RApplicationManagement@NApplicationManagement@@QBEXKK@Z @ 28 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateL(unsigned long, unsigned long) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/client/BWINS/applicationmanagementu.def	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,30 @@
+EXPORTS
+	?ActivateL@RApplicationManagement@NApplicationManagement@@QBEXK@Z @ 1 NONAME ; void NApplicationManagement::RApplicationManagement::ActivateL(unsigned long) const
+	?RemoveL@RApplicationManagement@NApplicationManagement@@QBEXK@Z @ 2 NONAME ; void NApplicationManagement::RApplicationManagement::RemoveL(unsigned long) const
+	?DeploymentComponent@RApplicationManagement@NApplicationManagement@@QBEHKAAUTDeploymentComponent@2@@Z @ 3 NONAME ; int NApplicationManagement::RApplicationManagement::DeploymentComponent(unsigned long, struct NApplicationManagement::TDeploymentComponent &) const
+	?DeploymentComponentTempInstFileL@RApplicationManagement@NApplicationManagement@@QBEXKAAVRFile@@ABW4TDeplCompAttrType@2@@Z @ 4 NONAME ; void NApplicationManagement::RApplicationManagement::DeploymentComponentTempInstFileL(unsigned long, class RFile &, enum NApplicationManagement::TDeplCompAttrType const &) const
+	?Close@RApplicationManagement@NApplicationManagement@@QAEXXZ @ 5 NONAME ; void NApplicationManagement::RApplicationManagement::Close(void)
+	?DeploymentComponentUserIdL@RApplicationManagement@NApplicationManagement@@QBEXKAAV?$TBuf8@$0BAA@@@@Z @ 6 NONAME ; void NApplicationManagement::RApplicationManagement::DeploymentComponentUserIdL(unsigned long, class TBuf8<256> &) const
+	?DeploymentComponentDataSizeL@RApplicationManagement@NApplicationManagement@@QBEHKABW4TDeplCompAttrType@2@@Z @ 7 NONAME ; int NApplicationManagement::RApplicationManagement::DeploymentComponentDataSizeL(unsigned long, enum NApplicationManagement::TDeplCompAttrType const &) const
+	?DeliverL@RApplicationManagement@NApplicationManagement@@QBEKABV?$TBuf8@$0BAA@@@@Z @ 8 NONAME ; unsigned long NApplicationManagement::RApplicationManagement::DeliverL(class TBuf8<256> const &) const
+	?InstallL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeploymentComponentState@2@@Z @ 9 NONAME ; void NApplicationManagement::RApplicationManagement::InstallL(unsigned long, enum NApplicationManagement::TDeploymentComponentState) const
+	?UpdateDeploymentComponentStreamedDataL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@ABVTDesC8@@@Z @ 10 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateDeploymentComponentStreamedDataL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class TDesC8 const &) const
+	?Close@RAppMgmtRfs@@QAEXXZ @ 11 NONAME ; void RAppMgmtRfs::Close(void)
+	?PerformRfsL@RAppMgmtRfs@@QBEXXZ @ 12 NONAME ; void RAppMgmtRfs::PerformRfsL(void) const
+	?DeactivateL@RApplicationManagement@NApplicationManagement@@QBEXK@Z @ 13 NONAME ; void NApplicationManagement::RApplicationManagement::DeactivateL(unsigned long) const
+	?DeploymentComponentIdsL@RApplicationManagement@NApplicationManagement@@QBEHAAV?$RArray@K@@W4TDeploymentComponentState@2@@Z @ 14 NONAME ; int NApplicationManagement::RApplicationManagement::DeploymentComponentIdsL(class RArray<unsigned long> &, enum NApplicationManagement::TDeploymentComponentState) const
+	?DownloadL@RApplicationManagement@NApplicationManagement@@QBEKABV?$TBuf8@$0BAA@@@@Z @ 15 NONAME ; unsigned long NApplicationManagement::RApplicationManagement::DownloadL(class TBuf8<256> const &) const
+	?Connect@RAppMgmtRfs@@QAEHXZ @ 16 NONAME ; int RAppMgmtRfs::Connect(void)
+	?Connect@RApplicationManagement@NApplicationManagement@@QAEHXZ @ 17 NONAME ; int NApplicationManagement::RApplicationManagement::Connect(void)
+	?DeploymentComponentDataL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@AAVCBufBase@@@Z @ 18 NONAME ; void NApplicationManagement::RApplicationManagement::DeploymentComponentDataL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class CBufBase &) const
+	?StartDownloadL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDownloadTarget@2@@Z @ 19 NONAME ; void NApplicationManagement::RApplicationManagement::StartDownloadL(unsigned long, enum NApplicationManagement::TDownloadTarget) const
+	?UpdateDeploymentComponentDataL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@ABVTDesC8@@1@Z @ 20 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateDeploymentComponentDataL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class TDesC8 const &, class TDesC8 const &) const
+	?StateChangeComplete@RApplicationManagement@NApplicationManagement@@QBEHK@Z @ 21 NONAME ; int NApplicationManagement::RApplicationManagement::StateChangeComplete(unsigned long) const
+	?Connect@RApplicationManagement@NApplicationManagement@@QAEHABVTCertInfo@@@Z @ 22 NONAME ; int NApplicationManagement::RApplicationManagement::Connect(class TCertInfo const &)
+	?GenericAlertSentL@RApplicationManagement@NApplicationManagement@@QBEXK@Z @ 23 NONAME ; void NApplicationManagement::RApplicationManagement::GenericAlertSentL(unsigned long) const
+	?CheckStatusNodesL@RApplicationManagement@NApplicationManagement@@QBEXXZ @ 24 NONAME ; void NApplicationManagement::RApplicationManagement::CheckStatusNodesL(void) const
+	?GetFinalResultsForGAL@RApplicationManagement@NApplicationManagement@@QBEXKAAHAAVTDes8@@@Z @ 25 NONAME ; void NApplicationManagement::RApplicationManagement::GetFinalResultsForGAL(unsigned long, int &, class TDes8 &) const
+	?UpdateDeploymentComponentL@RApplicationManagement@NApplicationManagement@@QBEXKW4TDeplCompAttrType@2@ABVTDesC8@@@Z @ 26 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateDeploymentComponentL(unsigned long, enum NApplicationManagement::TDeplCompAttrType, class TDesC8 const &) const
+	?StateChangingDCIdsL@RApplicationManagement@NApplicationManagement@@QBEHAAV?$RArray@K@@@Z @ 27 NONAME ; int NApplicationManagement::RApplicationManagement::StateChangingDCIdsL(class RArray<unsigned long> &) const
+	?UpdateL@RApplicationManagement@NApplicationManagement@@QBEXKK@Z @ 28 NONAME ; void NApplicationManagement::RApplicationManagement::UpdateL(unsigned long, unsigned long) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/client/eabi/applicationmanagementclientu.def	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,30 @@
+EXPORTS
+	_ZN11RAppMgmtRfs5CloseEv @ 1 NONAME
+	_ZN11RAppMgmtRfs7ConnectEv @ 2 NONAME
+	_ZN22NApplicationManagement22RApplicationManagement5CloseEv @ 3 NONAME
+	_ZN22NApplicationManagement22RApplicationManagement7ConnectERK9TCertInfo @ 4 NONAME
+	_ZN22NApplicationManagement22RApplicationManagement7ConnectEv @ 5 NONAME
+	_ZNK11RAppMgmtRfs11PerformRfsLEv @ 6 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement11DeactivateLEm @ 7 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement14StartDownloadLEmNS_15TDownloadTargetE @ 8 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement17CheckStatusNodesLEv @ 9 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement17GenericAlertSentLEm @ 10 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement19DeploymentComponentEmRNS_20TDeploymentComponentE @ 11 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement19StateChangeCompleteEm @ 12 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement19StateChangingDCIdsLER6RArrayImE @ 13 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement21GetFinalResultsForGALEmRiR5TDes8 @ 14 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement23DeploymentComponentIdsLER6RArrayImENS_25TDeploymentComponentStateE @ 15 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement24DeploymentComponentDataLEmNS_17TDeplCompAttrTypeER8CBufBase @ 16 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement26DeploymentComponentUserIdLEmR5TBuf8ILi256EE @ 17 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement26UpdateDeploymentComponentLEmNS_17TDeplCompAttrTypeERK6TDesC8 @ 18 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement28DeploymentComponentDataSizeLEmRKNS_17TDeplCompAttrTypeE @ 19 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement30UpdateDeploymentComponentDataLEmNS_17TDeplCompAttrTypeERK6TDesC8S4_ @ 20 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement32DeploymentComponentTempInstFileLEmR5RFileRKNS_17TDeplCompAttrTypeE @ 21 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement38UpdateDeploymentComponentStreamedDataLEmNS_17TDeplCompAttrTypeERK6TDesC8 @ 22 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement7RemoveLEm @ 23 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement7UpdateLEmm @ 24 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement8DeliverLERK5TBuf8ILi256EE @ 25 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement8InstallLEmNS_25TDeploymentComponentStateE @ 26 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement9ActivateLEm @ 27 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement9DownloadLERK5TBuf8ILi256EE @ 28 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/client/eabi/applicationmanagementu.def	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,30 @@
+EXPORTS
+	_ZN11RAppMgmtRfs5CloseEv @ 1 NONAME
+	_ZN11RAppMgmtRfs7ConnectEv @ 2 NONAME
+	_ZN22NApplicationManagement22RApplicationManagement5CloseEv @ 3 NONAME
+	_ZN22NApplicationManagement22RApplicationManagement7ConnectERK9TCertInfo @ 4 NONAME
+	_ZN22NApplicationManagement22RApplicationManagement7ConnectEv @ 5 NONAME
+	_ZNK11RAppMgmtRfs11PerformRfsLEv @ 6 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement11DeactivateLEm @ 7 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement14StartDownloadLEmNS_15TDownloadTargetE @ 8 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement17CheckStatusNodesLEv @ 9 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement17GenericAlertSentLEm @ 10 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement19DeploymentComponentEmRNS_20TDeploymentComponentE @ 11 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement19StateChangeCompleteEm @ 12 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement19StateChangingDCIdsLER6RArrayImE @ 13 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement21GetFinalResultsForGALEmRiR5TDes8 @ 14 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement23DeploymentComponentIdsLER6RArrayImENS_25TDeploymentComponentStateE @ 15 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement24DeploymentComponentDataLEmNS_17TDeplCompAttrTypeER8CBufBase @ 16 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement26DeploymentComponentUserIdLEmR5TBuf8ILi256EE @ 17 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement26UpdateDeploymentComponentLEmNS_17TDeplCompAttrTypeERK6TDesC8 @ 18 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement28DeploymentComponentDataSizeLEmRKNS_17TDeplCompAttrTypeE @ 19 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement30UpdateDeploymentComponentDataLEmNS_17TDeplCompAttrTypeERK6TDesC8S4_ @ 20 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement32DeploymentComponentTempInstFileLEmR5RFileRKNS_17TDeplCompAttrTypeE @ 21 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement38UpdateDeploymentComponentStreamedDataLEmNS_17TDeplCompAttrTypeERK6TDesC8 @ 22 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement7RemoveLEm @ 23 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement7UpdateLEmm @ 24 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement8DeliverLERK5TBuf8ILi256EE @ 25 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement8InstallLEmNS_25TDeploymentComponentStateE @ 26 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement9ActivateLEm @ 27 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement9DownloadLERK5TBuf8ILi256EE @ 28 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/client/group/ApplicationManagementClient.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,50 @@
+/*
+* 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: Implementation of applicationmanagement components
+*
+*/
+  
+
+// To get the APP_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include "defaultcaps.hrh"
+
+TARGET        applicationmanagementclient.dll
+TARGETTYPE    dll
+UID           0x1000008d 0x2001247C
+#if 0
+CAPABILITY    CAP_CLIENT_DLL -TCB -DRM WriteDeviceData
+#endif
+CAPABILITY    CAP_CLIENT_DLL
+
+SOURCEPATH    ../src
+SOURCE        ApplicationManagementClient.cpp
+
+USERINCLUDE   . ../../inc 
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY       euser.lib
+LIBRARY				bafl.lib
+LIBRARY 			flogger.lib
+LIBRARY				efsrv.lib
+LIBRARY         apparc.lib         
+LIBRARY         apgrfx.lib
+LIBRARY         avkon.lib
+LIBRARY         estor.lib
+LIBRARY         cone.lib
+LIBRARY         eikcore.lib
+LIBRARY			centralrepository.lib
+
+
+//SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/client/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,21 @@
+/*
+* 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:  build info file for application management client & server
+*
+*/
+
+
+PRJ_MMPFILES
+
+ApplicationManagementClient.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/client/src/ApplicationManagementClient.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,809 @@
+/*
+* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 Application Management Components
+*
+*/
+
+
+
+
+#include <e32svr.h>
+#include "ApplicationManagementClientServer.h"
+#include "ApplicationManagementClient.h"
+#include "ApplicationManagementRfs.h"
+#include "debug.h"
+#include <apacmdln.h>
+#include <apgtask.h>
+#include <e32property.h>
+
+#include <apgcli.h>
+
+#include <badesca.h>
+
+using namespace NApplicationManagement;
+
+// ----------------------------------------------------------------------------------------
+// Server startup code
+// ----------------------------------------------------------------------------------------
+
+static TInt StartServer()
+	{
+    RDEBUG("RApplicationManagement: Starting server...");
+
+    const TUidType serverUid(KNullUid, KNullUid,
+            KApplicationManagementServerUid);
+
+    // EPOC and EKA 2 is easy, we just create a new server process. Simultaneous
+    // launching of two such processes should be detected when the second one
+    // attempts to create the server object, failing with KErrAlreadyExists.
+    RProcess server;
+    //TInt r=server.Create(KHelloWorldServerImg,KNullDesC,serverUid);
+    TInt r = server.Create(KApplicationManagementServerImg, KNullDesC);
+    if (r != KErrNone)
+        {
+        RDEBUG_2("ApplicationManagementClient: server start failed %d",r);
+        return r;
+        }
+    TRequestStatus stat;
+    server.Rendezvous(stat);
+    if (stat != KRequestPending)
+        server.Kill(0); // abort startup
+    else
+        server.Resume(); // logon OK - start the server
+    RDEBUG("ApplicationManagementClient: Started");
+    User::WaitForRequest(stat);
+    TInt err = RProperty::Define(KProperty, KInteger, RProperty::EInt);
+    RProperty ServerLaunch;
+    ServerLaunch.Attach(KProperty, KInteger, EOwnerThread);
+    TRequestStatus status;
+
+    ServerLaunch.Subscribe(status);
+    //server.Resume();
+    User::WaitForRequest(status);
+
+    ServerLaunch.Close();
+    RProperty::Delete(KProperty, KInteger);
+
+    //User::WaitForRequest(stat);		// wait for start or death
+    // we can't use the 'exit reason' if the server panicked as this
+    // is the panic 'reason' and may be '0' which cannot be distinguished
+    // from KErrNone
+    r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
+    // _LIT_SECURITY_POLICY_S0(KWritePolicy,KApplicationManagementServerUid.iUid);
+    //  _LIT_SECURITY_POLICY_C1( KReadPolicy, ECapabilityReadDeviceData );
+
+    server.Close();
+    return r;
+    }
+
+
+EXPORT_C TInt RAppMgmtRfs::Connect()
+	{
+	TInt retry=2;
+	TVersion ver( KAMVerMajor, KAMVerMinor, KAMVerBuild );
+	for (;;)
+		{
+		
+		TInt r=CreateSession(KApplicationManagementServerName,ver,1);
+		if (r!=KErrNotFound && r!=KErrServerTerminated)
+			return r;
+		if (--retry==0)
+			return r;
+		r=StartServer();
+		if (r!=KErrNone && r!=KErrAlreadyExists)
+			{
+			return r;
+			}
+		}
+	}
+	
+	
+EXPORT_C void RAppMgmtRfs::Close()
+	{
+	RSessionBase::Close();  //basecall
+	}
+
+// New methods
+EXPORT_C void RAppMgmtRfs::PerformRfsL() const
+	{
+	User::LeaveIfError( SendReceive( EPerformRfs, TIpcArgs() ) );	
+	}
+	
+
+
+// This is the standard retry pattern for server connection
+EXPORT_C TInt RApplicationManagement::Connect( )
+	{
+	TInt retry=2;
+	TVersion ver( KAMVerMajor, KAMVerMinor, KAMVerBuild );
+	for (;;)
+		{
+		
+		TInt r=CreateSession(KApplicationManagementServerName,ver,1);
+		if (r!=KErrNotFound && r!=KErrServerTerminated)
+			return r;
+		if (--retry==0)
+			return r;
+		r=StartServer();
+		if (r!=KErrNone && r!=KErrAlreadyExists)
+			{
+			return r;
+			}
+		}
+	}
+
+EXPORT_C TInt RApplicationManagement::Connect( const TCertInfo &aCertInfo )
+	{
+	TInt r( Connect() );
+	if ( r == KErrNone || r == KErrAlreadyExists )
+		{
+		TPckg<TCertInfo> pkg( aCertInfo );
+		r = SendReceive( EAddTrust, TIpcArgs( &pkg ) );
+		}
+	return r;
+	}
+
+	
+EXPORT_C void RApplicationManagement::Close()
+	{
+	RSessionBase::Close();  //basecall
+	}
+
+
+	
+EXPORT_C TUint32 RApplicationManagement::DeliverL( const TDCUserId &aUserId ) const
+	{
+	TDeploymentComponent aInfo( KNullDesC8(), KNullDesC8(), KNullDesC8(), EDCSNone );
+	TDeploymentComponentIPC pkg( aInfo, KNullDesC8(), aUserId );
+		
+	TPckg<TDeploymentComponentIPC> pinfo(pkg);
+	TUint32 id = 0;
+	TPckg< TUint32 > pid( id );
+	const TDesC8& empty = KNullDesC8();
+	
+	TInt err( SendReceive( EDeplCompDeliverStartOperation2, TIpcArgs( &pinfo, &empty, &pid) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG_2( "ApplicationManagementServer: DeliverL start SUCCESS id: %d", id );
+		//TPckg<TDeploymentComponent> pinfo2(aInfo);
+
+		err = SendReceive( EDeplCompDeliverCompleteOperation, TIpcArgs( &pid, &empty, &empty ));
+		
+		if ( err == KErrNone )
+			{	
+			RDEBUG_2( "ApplicationManagementServer: DeliverL complete SUCCESS id: %d", id );
+			err = id;
+			}
+		else
+			{
+			RDEBUG_2( "ApplicationManagementServer: DeliverL failed2... %d", err);
+			}
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: DeliverL failed1... %d", err);
+		}
+	User::LeaveIfError( err );
+	return err;
+	}
+	
+	
+	
+EXPORT_C TInt RApplicationManagement::DeploymentComponent( 
+	TUint32 aInternalId, TDeploymentComponent &aReturnValue ) const
+	{
+	TPckg<TDeploymentComponent> pinfo(aReturnValue);
+	TPckg< TUint32 > pid( aInternalId );
+	TInt err( SendReceive( EDeplCompGetOperation, TIpcArgs( &pid, &pinfo) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG_2( "RApplicationManagement: DeploymentComponent start SUCCESS id: %d", aInternalId );
+		}
+	else
+		{
+		RDEBUG_2("RApplicationManagement: DeploymentComponent failed... %d", err);
+		}
+		
+	return err;
+	}
+	
+	
+EXPORT_C void RApplicationManagement::DeploymentComponentUserIdL( 
+	TUint32 aInternalId, TDCUserId &aResponse ) const
+	{
+	
+	TPckgC< TUint32 > pid( aInternalId );
+	TInt err( SendReceive( EDeplCompGetUserIdOperation, TIpcArgs( &pid, &aResponse) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG_2( "RApplicationManagement: DeploymentComponentUserIdL SUCCESS id: %d", aInternalId );
+		}
+	else
+		{
+		RDEBUG_2( "RApplicationManagement: DeploymentComponentUserIdL failed... %d", err);
+		}
+		
+	User::LeaveIfError( err );
+	}
+	
+	
+/**
+* @param aInternalId Id of the component to be found
+* @param aBuffer a buffer to store results
+* @return KErrNone Symbian error code
+*/
+EXPORT_C void RApplicationManagement::DeploymentComponentDataL( 
+	TUint32 aInternalId, TDeplCompAttrType aDataType, CBufBase &aBuffer ) const
+	{
+	//aBuffer.ResizeL(
+	TPckg< TUint32 > pid( aInternalId );
+	TPckg< TDeplCompAttrType > pdt( aDataType );
+	TInt length( 0 );
+	TPckg< TInt > plen( length );
+	aBuffer.Reset();
+	TInt err( KErrNone) ;
+	if ( aDataType == EDCInstallOptions 
+		|| aDataType == EDCMetaData 
+		|| aDataType ==	EDCData
+		|| aDataType ==	EDCDataMime
+		|| aDataType ==	EDCMetaDataMime
+	 	|| aDataType == EDCDownloadURI )
+		{
+		err = SendReceive( EDeplCompGetDataLengthOperation, TIpcArgs( &pid, &pdt, &plen) ) ;
+		if ( err == KErrNone )
+			{
+		
+			}
+		else
+			{
+			RDEBUG_2( "RApplicationManagement: DeploymentComponentDataL EDeplCompGetDataLengthOperation ERROR failed to get length... %d", err );
+			}
+		}
+	else if ( aDataType == EDCStatus)
+		{
+		length = 0; // to make sure we don't fetch it twice
+		TPckgBuf<TInt> ptr;
+		err = SendReceive( EDeplCompGetDataOperation, TIpcArgs( &pid, &pdt, &ptr ) );
+		if ( err == KErrNone )
+			{	
+			TBuf8<10> b;
+			b.AppendNum( ptr() );
+			aBuffer.InsertL( 0, b );
+			RDEBUG( "RApplicationManagement: DeploymentComponentDataL EDCDownloadStatus SUCCESS!" );
+			}
+		else
+			{
+			RDEBUG_2( "RApplicationManagement: DeploymentComponentDataL EDCDownloadStatus ERROR failed... %d", err );
+			}
+		}
+	else if ( aDataType == EDCConRef )
+		{
+		length = 0; // to make sure we don't fetch it twice
+		TPckgBuf<TInt> ptr;
+		err = SendReceive( EDeplCompGetDataOperation, TIpcArgs( &pid, &pdt, &ptr ) );
+		if ( err == KErrNone )
+			{	
+			aBuffer.InsertL( 0, ptr );
+			RDEBUG( "RApplicationManagement: DeploymentComponentDataL EDCConRef SUCCESS!" );
+			}
+		else
+			{
+			RDEBUG_2( "RApplicationManagement: DeploymentComponentDataL EDCConRefERROR failed... %d" , err );
+			}
+		}
+	else
+		{
+		User::Leave( KErrArgument );
+		}
+	if ( length > 0 )
+		{
+		HBufC8 *buf = HBufC8::NewLC( length );
+		TPtr8 ptr( buf->Des() );
+		err = SendReceive( EDeplCompGetDataOperation, TIpcArgs( &pid, &pdt, &ptr ) );
+		if ( err == KErrNone )
+			{	
+			aBuffer.InsertL( 0, ptr );
+			RDEBUG( "RApplicationManagement: DeploymentComponentDataL EDeplCompGetDataOperation SUCCESS!" );
+			}
+		else
+			{
+			RDEBUG_2( "RApplicationManagement: DeploymentComponentDataL EDeplCompGetDataOperationERROR failed... %d", err );
+			}
+		CleanupStack::PopAndDestroy( buf );
+		}
+	else
+		{
+		RDEBUG( "RApplicationManagement: DeploymentComponentDataL:  Length is zero" );
+		}
+	User::LeaveIfError( err );
+	}
+	
+	
+EXPORT_C TInt RApplicationManagement::DeploymentComponentIdsL(
+			RElementIdArray &aArray, const TDeploymentComponentState aState	) const
+	{
+	RDEBUG_2( "RApplicationManagement: DeploymentComponentIds aState=%d!", aState );
+	TInt count = 0;
+	TPckg<TInt> cnt(count);
+	TPckg<TDeploymentComponentState> pk(aState);
+	TInt err( SendReceive( EDeplCompCountOperation, TIpcArgs( &cnt, &pk ) ) );
+	RDEBUG_2( "RApplicationManagement: DeploymentComponentIds : Count is %d", count );
+	if ( err == KErrNone )
+		{
+		if ( count > 0 )
+			{
+			aArray.Reset();
+			for ( TInt i( 0 ); i != count; ++i )
+				{
+				aArray.AppendL( 0 );
+				}
+			TPtr8 p( reinterpret_cast< TUint8* >( &aArray[0] ), 0, count * sizeof( TUint32 ) );
+			err = SendReceive( EDeplCompIdsOperation, TIpcArgs( &p, &pk ) ) ;	
+			if ( err == KErrNone )
+				{	
+				RDEBUG( "RApplicationManagement: DeploymentComponentIds SUCCESS!" );
+				}
+			else
+				{
+				RDEBUG_2( "RApplicationManagement: DeploymentComponentIds failed... %d", err );
+				}
+			}
+		}
+	else
+		{
+		RDEBUG_2( "RApplicationManagement: DeploymentComponentIds failed to get count... %d", err);
+		}
+	return err;
+	}
+	
+/**
+* InstallL Installs given deployment component.
+* @param aDeploymentComponent The deployment component to be installed
+* @param aTargetState Will the installed component be actibve or inactive (default active)
+* @return KErrNone Symbian error code
+*/
+EXPORT_C void RApplicationManagement::InstallL( TUint32 aInternalId, 
+	TDeploymentComponentState aTargetState  ) const
+	{
+	TPckg<TUint32> id(aInternalId);
+	if ( aTargetState != EDCSActive && aTargetState != EDCSInactive )
+		{
+		// install only to either of above states
+		User::Leave( KErrArgument );
+		}
+	TPckg<TDeploymentComponentState> pk( aTargetState );
+
+	TInt err( SendReceive( EInstallOperation, TIpcArgs( &id, &pk ) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG( "RApplicationManagement: InstallL SUCCESS!" );
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: InstallL failed... %d", err);
+		if( err == KErrNotFound )
+			{
+			err = KErrArgument ; // indicates that data was not filled...
+			}
+		}
+	User::LeaveIfError( err ) ;
+	}
+	
+EXPORT_C void RApplicationManagement::UpdateDeploymentComponentDataL( 
+		TUint32 aInternalId, TDeplCompAttrType aItem, const TDesC8 &aItemData, const TDesC8 &aDataMime  ) const
+	{
+	TDeplCompDataIPC ipc ;
+	ipc.iDataMime = aDataMime;
+	ipc.iInternalId = aInternalId ;
+	ipc.iAttrType = aItem ;
+	TPckg<TDeplCompDataIPC> pipc( ipc );
+	
+	TInt err( SendReceive( EDeplCompUpdateDataOperation, TIpcArgs( &pipc, &aItemData ) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG( "RApplicationManagement: UpdateDeploymentComponentDataL SUCCESS!" );
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: UpdateDeploymentComponentDataL failed... %d", err);
+		}
+	User::LeaveIfError( err );
+	}
+
+EXPORT_C void RApplicationManagement::UpdateDeploymentComponentStreamedDataL( 
+		TUint32 aInternalId, TDeplCompAttrType aItem, const TDesC8 &aDataMime  ) const
+	{
+	TDeplCompDataIPC ipc ;
+	ipc.iDataMime = aDataMime;
+	ipc.iInternalId = aInternalId ;
+	ipc.iAttrType = aItem ;
+	TPckg<TDeplCompDataIPC> pipc( ipc );
+	
+	TInt err( SendReceive( EDeplCompUpdateStreamedDataOperation, TIpcArgs( &pipc ) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG( "RApplicationManagement: UpdateDeploymentComponentStreamedDataL SUCCESS!" );
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: UpdateDeploymentComponentStreamedDataL failed... %d", err);
+		}
+	User::LeaveIfError( err );
+	}
+		
+	
+EXPORT_C void RApplicationManagement::UpdateDeploymentComponentL( 
+			TUint32 aInternalId, TDeplCompAttrType aItem, const TDesC8 &aItemData ) const
+	{
+	TPckg<TUint32> id(aInternalId);
+	TPckg<TDeplCompAttrType> itemid(aItem);
+	
+	TInt err( SendReceive( EDeplCompAttrUpdateOperation, TIpcArgs( &id, &itemid, &aItemData ) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG( "RApplicationManagement: UpdateDeploymentComponentL SUCCESS!" );
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: UpdateDeploymentComponentL failed... %d", err);
+		}
+	User::LeaveIfError( err );
+	}
+	
+
+/**
+* RemoveL Removes given deployment component.
+* @param aInternalId Id of the component to be removed
+* @return KErrNone Symbian error code
+*/
+EXPORT_C void RApplicationManagement::RemoveL( TUint32 aInternalId ) const
+	{
+	TPckg< TUint32 > id( aInternalId );
+	RDEBUG_2( "RApplicationManagement: RemoveL %d!" , aInternalId );
+		
+	TInt err( SendReceive( EDeplCompRemoveOperation, TIpcArgs( &id ) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG( "RApplicationManagement: RemoveL SUCCESS!" );
+		}
+	else if ( err == KErrNotFound )
+		{
+		RDEBUG( "RApplicationManagement: RemoveL WARNING Component already missing!" );
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: RemoveL failed... %d", err);
+		User::LeaveIfError( err );
+		}
+	}
+	
+
+/**
+		* StartDownloadL Starts download of deployment component.
+		* @param aInternalId The id of the component to be downloaded
+	    * @return 
+		*/
+EXPORT_C void RApplicationManagement::StartDownloadL( TUint32 aInternalId, 
+		const TDownloadTarget aTarget ) const
+	{
+	TPckg< TUint32 > id( aInternalId );
+	RDEBUG_2( "RApplicationManagement: StartDownloadL %d!", aInternalId );
+	TPckg< TDownloadTarget > trg( aTarget );
+	TInt err( SendReceive( EDeplCompStartDownloadOperation, TIpcArgs( &id, &trg ) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG( "RApplicationManagement: StartDownloadL SUCCESS!" );
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: StartDownloadL failed... %d", err);
+		}
+	User::LeaveIfError( err );
+	}
+		
+
+EXPORT_C TUint32 RApplicationManagement::DownloadL( const TDCUserId &aUserId ) const
+	{
+	TUint32 id( 0 ) ;
+	TPckg< TUint32 > pid( id );
+	
+	TInt err( SendReceive( EDeplCompDownloadOperation, TIpcArgs( &pid, &aUserId ) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG( "RApplicationManagement: DownloadL SUCCESS!" );
+		err = pid() ;
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: DownloadL failed... %d", err);
+		}
+	return err ;
+	}
+	
+EXPORT_C void RApplicationManagement::UpdateL( TUint32 aSourceInternalId, TUint32 aTargetInternalId ) const
+	{
+	TPckg< TUint32 > sid( aSourceInternalId );
+	TPckg< TUint32 > tid( aTargetInternalId );
+	
+	TInt err( SendReceive( EDeplCompUpdateOperation, TIpcArgs( &sid, &tid ) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG( "RApplicationManagement: UpdateL SUCCESS!" );
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: UpdateL failed... %d", err);
+		}
+	User::LeaveIfError( err );
+	}
+	
+
+
+EXPORT_C TInt RApplicationManagement::StateChangingDCIdsL( RElementIdArray &aArray ) const
+	{
+	RDEBUG( "RApplicationManagement: StateChangingDCIds " );
+	TInt count( 0 ) ;
+	TPckg<TInt> cnt(count);
+	TInt err( SendReceive( EGetStateChangingIdsCountOperation, TIpcArgs( &cnt ) ) );	
+	if ( err == KErrNone )
+		{
+		aArray.Reset();
+		if ( count > 0 )
+			{
+			for ( TInt i( 0 ); i != count; ++i )
+				{
+				aArray.AppendL( 0 );
+				}
+			TPtr8 p( reinterpret_cast< TUint8* >( &aArray[0] ), 0, count * sizeof( TUint32 ) );
+			err = SendReceive( EGetStateChangingIdsOperation, TIpcArgs( &p ) ) ;	
+			if ( err == KErrNone )
+				{	
+				RDEBUG( "RApplicationManagement: StateChangingDCIds SUCCESS!" );
+				}
+			else
+				{
+				RDEBUG_2( "RApplicationManagement: StateChangingDCIds failed... %d" , err );
+				}
+			}
+		else
+			{
+			RDEBUG_2("RApplicationManagement: StateChangingDCIds SUCCESS zero dcs... %d", count);	
+			}
+		}
+	else
+		{
+		RDEBUG_2("RApplicationManagement: StateChangingDCIds failed... %d", err);
+		}
+	return err;
+	}
+	
+
+EXPORT_C TInt RApplicationManagement::StateChangeComplete( TUint32 aInternalId ) const
+	{
+	TPckg<TUint32> id(aInternalId);
+	
+	TInt err( SendReceive( ECompleteStateChangeOperation, TIpcArgs( &id ) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG( "RApplicationManagement: StateChangeComplete SUCCESS!" );		
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: StateChangeComplete failed... %d", err);
+		if( err == KErrNotFound )
+			{
+			err = KErrArgument ; // indicates that data was not filled...
+			}
+		}
+	return ( err ) ;
+	}
+
+
+/**
+* ActivateL Tries to activate given deployment component
+*	
+* @param aInternalId The id of the component to be activated
+*/
+EXPORT_C void RApplicationManagement::ActivateL( TUint32 aInternalId ) const
+	{
+	TPckg< TUint32 > id( aInternalId );
+	RDEBUG_2( "RApplicationManagement: ActivateL %d!" , aInternalId );
+	
+	TInt err( SendReceive( EDeplCompActivateOperation, TIpcArgs( &id ) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG( "RApplicationManagement: ActivateL SUCCESS!" );
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: ActivateL failed... %d", err);
+		}
+	User::LeaveIfError( err );	
+	}
+	
+/**
+* DeactivateL Tries to deactivate given deployment component
+*	
+* @param aInternalId The id of the component to be deactivated
+*/
+EXPORT_C void RApplicationManagement::DeactivateL( TUint32 aInternalId ) const
+	{
+	TPckg< TUint32 > id( aInternalId );
+	RDEBUG_2( "RApplicationManagement: DeactivateL %d!", aInternalId );
+	
+	TInt err( SendReceive( EDeplCompDeactivateOperation, TIpcArgs( &id ) ) );	
+	if ( err == KErrNone )
+		{
+		RDEBUG( "RApplicationManagement: DeactivateL SUCCESS!" );
+		}
+	else
+		{
+		RDEBUG_2("ApplicationManagementServer: DeactivateL failed... %d", err);
+		}
+	User::LeaveIfError( err );	
+	}
+		
+
+/**
+* DeploymentComponentDataSizeL Get deployment component attribute size
+*	
+* @param aInternalId The id of the component 
+* @param aItem The type of attribute whose size is to be got
+* @return The size
+*/
+EXPORT_C TInt RApplicationManagement::DeploymentComponentDataSizeL( TUint32 aInternalId, const TDeplCompAttrType &aDataType ) const
+	{
+	TPckg< TUint32 > pid( aInternalId );
+	TPckg< TDeplCompAttrType > pdt( aDataType );
+	TInt length( 0 );
+	TPckg< TInt > plen( length );
+	TInt err( KErrNone) ;
+	if ( aDataType == EDCInstallOptions 
+		|| aDataType == EDCMetaData 
+		|| aDataType ==	EDCData
+	 	|| aDataType == EDCDownloadURI )
+		{
+		err = SendReceive( EDeplCompGetDataLengthOperation, TIpcArgs( &pid, &pdt, &plen) ) ;
+		if ( err == KErrNone )
+			{
+			
+			}
+		}
+	else if ( aDataType == EDCStatus )
+		{
+		length = 0;
+		TPckgBuf<TInt> ptr;
+		err = SendReceive( EDeplCompGetDataOperation, TIpcArgs( &pid, &pdt, &ptr ) );
+		if ( err == KErrNone )
+			{	
+			TBuf8<10> b;
+			b.AppendNum( ptr() );
+			length = b.Length();
+			RDEBUG( "RApplicationManagement: DeploymentComponentDataSizeL elseif SUCCESS!" );
+			}
+		else
+			{
+			RDEBUG_2( "RApplicationManagement: DeploymentComponentDataSizeL ERROR failed... %d", err );
+			}
+		}
+	else
+		{
+		TPckgBuf<TDeploymentComponent> pinfo;
+		TPckg< TUint32 > pid( aInternalId );
+		err = SendReceive( EDeplCompGetOperation, TIpcArgs( &pid, &pinfo) );
+		if ( err == KErrNone )
+			{
+			RDEBUG_2( "RApplicationManagement: DeploymentComponentDataSizeL else SUCCESS id: %d", aInternalId );
+			switch ( aDataType )
+				{
+				case EDCId:
+					{
+					length = pinfo().iId.Length();
+					break;
+					}
+				case EDCName:
+					{
+					length = pinfo().iName.Length();
+					break;
+					}
+				case EDCVersion:
+					{
+					length = pinfo().iVersion.Length();
+					break;
+					}
+				default:
+					{
+					break;
+					}
+				}
+			}
+		else
+			{
+			RDEBUG_2("RApplicationManagement: DeploymentComponentDataSizeL failed... %d", err);
+			}
+		}
+			
+	RDEBUG_2("RApplicationManagement: DeploymentComponentDataSizeL returning... %d", length);
+			
+	return length;
+	}
+
+/**
+* DeploymentComponentTempInstFileL ask file handle from server to be used
+*	
+* @param aInternalId The id of the component 
+* @param aTempFile temporary file handle 
+* @param aItem The type of attribute whose type of temporary file to get
+* @return KErrNone Symbian error code
+*/
+EXPORT_C void RApplicationManagement::DeploymentComponentTempInstFileL( TUint32 aInternalId, RFile& aTempFile, const TDeplCompAttrType &aItem ) const
+	{
+	RDEBUG_3( "RApplicationManagement: DeploymentComponentTempInstFileL: Id (%d) AttrType (%d)", aInternalId, aItem );
+	TPckg<TUint32> id(aInternalId);
+	TPckg<TDeplCompAttrType> itemid(aItem);
+	TPckgBuf<TInt> filehandle;
+
+	TInt fshandle = SendReceive(EDeplCompGetTemporaryInstFile, TIpcArgs( &id, &itemid, &filehandle ) );
+	TInt err = aTempFile.AdoptFromServer( fshandle, filehandle() ) ;
+	User::LeaveIfError( err );
+	RDEBUG_2( "RApplicationManagement: DeploymentComponentTempInstFileL fshandle (%d)", fshandle );
+	}
+
+/**
+* GetFinalResultsForGAL ask results from AM Server. In response AM 
+* server returns final result and target URI of node
+*	
+* @param aInternalId The id of the component 
+* @param aFinalResult Final result of deployment component
+* @param aTargetURI Target URI of deployment component
+* @return void
+*/
+
+EXPORT_C void RApplicationManagement::GetFinalResultsForGAL(TUint32 aInternalId, TInt& aFinalResult,  TDes8& aTargetURI) const
+{
+	TPckg<TUint32>  internalid(aInternalId);
+	TPckg<TInt>  finalresult(aFinalResult);
+	TPckg<TDesC8> targeturi(aTargetURI);
+	
+	TInt err = SendReceive(EDeplCompGetFinalResultForGA, TIpcArgs( &internalid, &finalresult, &aTargetURI) );
+}
+
+EXPORT_C void RApplicationManagement::GenericAlertSentL(TUint32 aInternalId) const
+{
+	
+	TPckg<TUint32>  internalid(aInternalId);
+	
+	
+	TInt err = SendReceive(EDeplCompGenericAlertSent, TIpcArgs( &internalid) );
+}
+
+/**
+* Implementation of Service UID() from base class. Returns AM service UID 
+* to framework
+*	
+* @return uid of AM service UID
+*/
+EXPORT_C void RApplicationManagement::CheckStatusNodesL( ) const
+    {
+    User::LeaveIfError( SendReceive( ECheckStatusNodes, TIpcArgs() ) );
+    }
+
+TUid RApplicationManagement::ServiceUid() const
+	{
+    	
+
+	return TUid::Uid( KAMServiceUid);
+	}
+
+//  End of File
Binary file applicationmanagement/conf/application_management.confml has changed
Binary file applicationmanagement/conf/application_management_200267FB.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/eabi/ApplicationManagementu.def	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,27 @@
+EXPORTS
+	_ZN11RAppMgmtRfs5CloseEv @ 1 NONAME
+	_ZN11RAppMgmtRfs7ConnectEv @ 2 NONAME
+	_ZN22NApplicationManagement22RApplicationManagement5CloseEv @ 3 NONAME
+	_ZN22NApplicationManagement22RApplicationManagement7ConnectERK9TCertInfo @ 4 NONAME
+	_ZN22NApplicationManagement22RApplicationManagement7ConnectEv @ 5 NONAME
+	_ZNK11RAppMgmtRfs11PerformRfsLEv @ 6 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement11DeactivateLEm @ 7 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement14StartDownloadLEmNS_15TDownloadTargetE @ 8 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement19DeploymentComponentEmRNS_20TDeploymentComponentE @ 9 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement19StateChangeCompleteEm @ 10 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement19StateChangingDCIdsLER6RArrayImE @ 11 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement23DeploymentComponentIdsLER6RArrayImENS_25TDeploymentComponentStateE @ 12 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement24DeploymentComponentDataLEmNS_17TDeplCompAttrTypeER8CBufBase @ 13 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement26DeploymentComponentUserIdLEmR5TBuf8ILi256EE @ 14 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement26UpdateDeploymentComponentLEmNS_17TDeplCompAttrTypeERK6TDesC8 @ 15 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement28DeploymentComponentDataSizeLEmRKNS_17TDeplCompAttrTypeE @ 16 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement30UpdateDeploymentComponentDataLEmNS_17TDeplCompAttrTypeERK6TDesC8S4_ @ 17 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement7RemoveLEm @ 18 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement7UpdateLEmm @ 19 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement8DeliverLERK5TBuf8ILi256EE @ 20 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement8InstallLEmNS_25TDeploymentComponentStateE @ 21 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement9ActivateLEm @ 22 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement9DownloadLERK5TBuf8ILi256EE @ 23 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement31DeploymentComponentTempInstFileEmR5RFileRKNS_17TDeplCompAttrTypeE @ 24 NONAME
+	_ZNK22NApplicationManagement22RApplicationManagement38UpdateDeploymentComponentStreamedDataLEmNS_17TDeplCompAttrTypeERK6TDesC8 @ 25 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  build info file for application management client & server
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+//../rom/1020781c.txt /epoc32/data/Z/private/10202be9/1020781c.txt
+//../rom/1020781c.txt /epoc32/RELEASE/winscw/UDEB/z/private/10202be9/1020781c.txt
+//../rom/1020781c.txt /epoc32/RELEASE/winscw/UREL/z/private/10202be9/1020781c.txt
+
+../rom/appmgmt.iby	CORE_APP_LAYER_IBY_EXPORT_PATH(appmgmt.iby)
+// Generic configuration interface for component cenrep settings  
+../conf/application_management.confml                        APP_LAYER_CONFML(application_management.confml)
+../conf/application_management_200267FB.crml 	        APP_LAYER_CRML(application_management_200267FB.crml)
+
+PRJ_MMPFILES
+
+#include "../options/group/bld.inf"
+#include "../client/group/bld.inf"
+//#include "../server/bld.inf"
+//#include "../RfsPlugin/group/bld.inf"
+#include "../amadapter2/group/bld.inf"
+#include "../omascomoadapter/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/inc/ApplicationManagementClient.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,304 @@
+/*
+* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 applicationmanagement components
+*
+*/
+
+
+#ifndef __APPLICATIONMANAGEMENTCLIENT_H__
+#define __APPLICATIONMANAGEMENTCLIENT_H__
+
+// INCLUDES
+
+#include <e32std.h>
+#include "ApplicationManagementCommon.h"
+#include "ApplicationManagementClientServer.h"
+#include "ApplicationManagementConst.h"
+#include <ssl.h>
+#include <f32file.h>
+//#include <AknServerApp.h>
+typedef RArray<TUint32> RElementIdArray;
+
+namespace NApplicationManagement
+	{
+
+// CLASS DECLARATION
+
+/**
+*  RApplicationManagement class to establish ApplicationManagement server connection
+*/
+class RAMTC : public RSessionBase
+	{
+		public:
+    /**
+	* Connect Connects client side to application management server
+    * @return KErrNone Symbian error code
+    */
+	IMPORT_C TInt Connect();
+	
+	
+    /**
+	* Close Close server connection
+    */
+	IMPORT_C void Close();
+
+	/**
+	* GetApplicationUidL finds uid for given deployment component.
+	* @param aInternalId Id of the deployment component, whose uid is wished
+	* @param aUid	After successful call, will hold the uid
+	*/	
+	IMPORT_C void GetApplicationUidL( TInt aInternalId, TUid &aUid );
+	};
+	
+
+
+class RApplicationManagement : public RSessionBase
+	{
+	public:
+	    /**
+		* Connect Connects client side to application management server
+	    * @return KErrNone Symbian error code
+        */
+		IMPORT_C TInt Connect( const TCertInfo &aCertInfo );
+		IMPORT_C TInt Connect( );
+		
+	    /**
+		* Close Close server connection
+        */
+		IMPORT_C void Close();
+		
+	
+//Session management		
+	    /**
+		* DeliverL Add deployment component to the system. At least some parameter
+		* (in the aInfo or aData) must not be empty.
+		*
+		* @param aInfo  TDeploymentComponentInfo containing the essentials of component
+		* @param aData The Delivery deployment component Data
+		* @param aInstallOpts Optional install options
+		* @param aMetaData Optional meta data for install operation
+	    * @return Created Internal Id for the deployment component
+        */
+	
+		/**
+		* DownloadL Adds deployment component with EDCSDownload to the system. 
+		* @param aUserId The user id of the component
+	    * @return Created Internal Id for the deployment component
+        */
+		IMPORT_C TUint32 DownloadL( const TDCUserId &aUserId ) const;
+			
+		IMPORT_C TUint32 DeliverL( const TDCUserId &aUserId ) const;
+		/**
+		* DeploymentComponent Returns the deployment component having the given Id.
+		* If there's no such deployment component, method returns
+		* KErrNotFound. 
+		
+		* @param aId Id of the component to be found
+	    * @return KErrNone  Symbian error code (KErrNotFound if not found)
+		*/
+		IMPORT_C TInt DeploymentComponent( 
+			TUint32 aInternalId, TDeploymentComponent &aReturnValue ) const;
+			
+		/**
+		* DeploymentComponentUserId Returns the user id of deployment component 
+		* having the given internal Id.
+		* @param aId Id of the component to be found
+		* @param aResponse The buffer in which the user id will be placed
+	    * @return KErrNone  Symbian error code (KErrNotFound if not found)
+		*/
+		IMPORT_C void DeploymentComponentUserIdL( 
+			TUint32 aInternalId, TDCUserId &aResponse ) const;
+	
+		/**
+		* DeploymentComponentDataL Fetches data for component that's in EDCSDelivered state.
+		* @param aInternalId Id of the component to be found
+		* @param aDataType Type of the data to be found. Must be one of EDCInstallOptions
+		*		EDCMetaData, EDCData, 
+		* @param aBuffer The buffer that will be filled with the data
+	    * @return 
+		*/
+		IMPORT_C void DeploymentComponentDataL( 
+			TUint32 aInternalId, TDeplCompAttrType aDataType, CBufBase &aBuffer ) const;
+			
+		
+		/**
+		* UpdateDeploymentComponentL Updates deployment component.
+		* @param aInternalId Id of the component to be updated
+		* @param aItem Type of the data to be updated.
+		* @param aItemData The data
+	    * @leave The deployment component, or NULL if there's not one
+		*/
+		IMPORT_C void UpdateDeploymentComponentL( TUint32 aInternalId,
+			TDeplCompAttrType aItem, const TDesC8 &aItemData ) const;
+		
+		/**
+		* UpdateDeploymentComponentL Updates deployment component with mime type too.
+		* @param aInternalId Id of the component to be updated
+		* @param aItem Type of the data to be updated. This must be 
+		*	EDCMetaData or EDCData for call to be successful
+		* @param aItemData The data
+		* @param aDataMime The data mime type
+	    * @leave The deployment component, or NULL if there's not one
+		*/	
+		IMPORT_C void UpdateDeploymentComponentDataL( 
+			TUint32 aInternalId, TDeplCompAttrType aItem, 
+			const TDesC8 &aItemData, const TDesC8 &aDataMime ) const; 
+
+		/**
+		* UpdateDeploymentComponentStreamedDataL Updates deployment component with mime type too.
+		* @param aInternalId Id of the component to be updated
+		* @param aItem Type of the data to be updated. This must be 
+		*	EDCMetaData or EDCData for call to be successful
+		* @param aDataMime The data mime type
+	    * @leave The deployment component, or NULL if there's not one
+		*/	
+		IMPORT_C void UpdateDeploymentComponentStreamedDataL( 
+			TUint32 aInternalId, TDeplCompAttrType aItem, const TDesC8 &aDataMime ) const; 
+		
+		/**
+		* DeploymentComponentIds Returns array of the deployment component Ids, that exist in the
+		* system. Optionally one can give a TDeploymentComponentState flag to restrict
+		* resulted ids to those components that has the given state.
+		* @param aArray Will hold the response
+		* @param aState Optional state of the wished deployment components
+	    * @return KErrNone Symbian error code
+		*/
+		IMPORT_C TInt DeploymentComponentIdsL(
+			RElementIdArray &aArray, 
+			const TDeploymentComponentState aState = EDCSNone  ) const;
+			
+		/**
+		* InstallL Installs given deployment component.
+		* @param aInternalId The id of deployment component to be installed
+	    * @param aTargetState Will the installed component be actibve or inactive (default active)
+		* @return KErrNone Symbian error code
+		*/
+		IMPORT_C void InstallL( TUint32 aInternalId , 
+			TDeploymentComponentState aTargetState = EDCSActive) const;
+
+		/**
+		* RemoveL Removes given deployment component.
+		* @param aInternalId The id of the component to be removed
+	    * @return 
+		*/
+		IMPORT_C void RemoveL( TUint32 aInternalId ) const;
+		
+		/**
+		* UpdateL Updates the given deployment
+		* @param aSourceInternalId The id of the component that is source of update
+		* @param aTargetInternalId The id of the component that is target of update
+	    * @leave 
+		*/
+		IMPORT_C void UpdateL( TUint32 aSourceInternalId, TUint32 aTargetInternalId ) const;
+		
+		/**
+		* StartDownloadL Starts download of deployment component.
+		* @param aInternalId The id of the component to be downloaded
+		* @param aTargetState The target state of download (
+	    * @return 
+		*/
+		IMPORT_C void StartDownloadL( TUint32 aInternalId, 
+			const TDownloadTarget aTarget= EDeliver  ) const;
+		
+		
+	 	/**
+		* StateChangingDCIds Returns array of the deployment component Ids, that are
+		* in the state changing list. Currently they are those that are being downloaded.
+		* @param aArray Will hold the response
+		
+	    * @return KErrNone Symbian error code
+		*/
+		IMPORT_C TInt StateChangingDCIdsL( RElementIdArray &aArray ) const;
+		
+		/**
+		* StateChangeComplete Informs server that the state of component is updated in the
+		*	adapter, and that it thus can be removed from the list of state changing objects.
+		* @param aInternalId The id of the component to be removed from list
+		*
+	    * @return KErrNone Symbian error code
+		*/
+		IMPORT_C TInt StateChangeComplete( TUint32 aInternalId ) const;
+		
+		/**
+		* ActivateL Tries to activate given deployment component
+		*	
+		* @param aInternalId The id of the component to be activated
+		*/
+		IMPORT_C void ActivateL( TUint32 aInternalId ) const;
+		
+		/**
+		* DeactivateL Tries to deactivate given deployment component
+		*	
+		* @param aInternalId The id of the component to be deactivated
+		*/
+		IMPORT_C void DeactivateL( TUint32 aInternalId ) const;
+		
+		/**
+		* DeploymentComponentDataSizeL Get deployment component attribute size
+		*	
+		* @param aInternalId The id of the component 
+		* @param aItem The type of attribute whose size is to be got
+		* @return The size
+		*/
+		IMPORT_C TInt DeploymentComponentDataSizeL( TUint32 aInternalId, 
+			const TDeplCompAttrType &aItem ) const;
+
+		/**
+		* DeploymentComponentTempInstFile ask file handle from server to be used
+		*	
+		* @param aTempFile temporary file handle 
+		* @param aItem The type of attribute whose type of temporary file to get
+	    * @return KErrNone Symbian error code
+		*/
+		IMPORT_C void DeploymentComponentTempInstFileL( TUint32 aInternalId, RFile& aTempFile, const TDeplCompAttrType &aItem ) const;
+
+		/**
+		 * GetFinalResultsForGAL ask results from AM Server. In response AM 
+         * server returns final result and target URI of node
+         *	
+         * @param aInternalId The id of the component 
+         * @param aFinalResult Final result of deployment component
+         * @param aTargetURI Target URI of deployment component
+         * @return void
+         */
+		IMPORT_C void GetFinalResultsForGAL(TUint32 aInternalId, TInt& aFinalResult,  TDes8& aTargetURI) const;
+		
+		IMPORT_C void GenericAlertSentL(TUint32 aInternalId) const;
+		
+		/**
+		* Implementation of Service UID() from base class. Returns AM service UID 
+		* to framework
+		*	
+		* @return uid of AM service UID
+		*/	
+		TUid ServiceUid() const;  
+        /**
+         * CheckStatusNodes Checks all deployed,delivered and download component's status node values
+         * and set the state accordingly. For ex, on first SCOMO session if status node = Download progress
+         * which means that download operation is failed in previous sessiona and hence we need to set the
+         * value of status node to Download failed.
+         *   
+         */
+        IMPORT_C void CheckStatusNodesL( ) const;
+		  
+	private:	
+	};
+
+
+	}
+
+#endif //__APPLICATIONMANAGEMENTCLIENT_H__
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/inc/ApplicationManagementClientServer.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 applicationmanagement components
+*
+*/
+ 
+
+#ifndef __APPLICATIONMANAGEMENTCLIENTSERVER_H__
+#define __APPLICATIONMANAGEMENTCLIENTSERVER_H__
+
+#include <e32std.h>
+
+_LIT(KApplicationManagementServerName,"applicationmanagementserver");
+_LIT(KApplicationManagementServerImg,"\\applicationmanagementserver.exe");		// DLL/EXE name
+
+const TUid KApplicationManagementServerUid={0x200267FB};
+
+namespace NApplicationManagement
+	{
+	
+//const TInt KMaxReturnMessageLength = 100;
+//const TInt KElementIdMaxLength = 100;
+
+const TUint KMessageDelimiterChar = '|' ;
+
+
+const TInt KAMVerMajor = 1;
+const TInt KAMVerMinor = 0;
+const TInt KAMVerBuild = 0;
+
+
+enum TApplicationManagementMessages
+	{
+	EAddTrust,
+	EDeplCompCountOperation,
+	EDeplCompIdsOperation,
+//	EDeplCompDeliverStartOperation,
+	EDeplCompDeliverCompleteOperation,
+	EDeplCompGetOperation,
+	EDeplCompGetDataOperation,
+	EDeplCompGetDataLengthOperation,
+	EDeplCompAttrUpdateOperation, // updates "simple" common attribute
+	EDeplCompUpdateDataOperation, // updates "larger" attrbute, such as data
+	EDeplCompUpdateStreamedDataOperation,// 10
+	EInstallOperation, 
+	EUpdateOperation,
+	EDeplCompRemoveOperation,
+	EDeplCompDownloadOperation,
+	EDeplCompActivateOperation,
+	EDeplCompDeactivateOperation,
+	EDeplCompDeliverStartOperation2,
+	EDeplCompUpdateOperation, // updates whole component
+	EDeplCompGetUserIdOperation, // returns the user id
+	EDeplCompStartDownloadOperation,  // 20
+	EGetStateChangingIdsCountOperation,
+	EGetStateChangingIdsOperation, // gets list of ids that are potentially changing state
+	ECompleteStateChangeOperation, // completes change of state
+	EDeplCompGetTemporaryInstFile,
+	EDeplCompGetTargetURI,
+	EDeplCompGetFinalResultForGA,
+	EDeplCompGenericAlertSent,
+	ECheckStatusNodes,
+    EPerformRfs,
+	ELast
+	
+	};
+
+	
+	}
+#endif// __ApplicationManagementCLIENTSERVER_H__
+	
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/inc/ApplicationManagementCommon.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,219 @@
+/*
+* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 applicationmanagement components
+*
+*/
+
+
+#ifndef __APPLICATIONMANAGEMENTCOMMON_H__
+#define __APPLICATIONMANAGEMENTCOMMON_H__
+
+#include <e32base.h>
+#include <uikon.hrh>
+#include "ApplicationManagementConst.h"
+
+namespace NApplicationManagement
+	{
+
+const TUint32  KAppMgmtServerUid         = {0x200267FB};
+
+const TUint32 KAMServiceUid = {0x1020781B};
+
+const TUid KProperty = {0x101F9A02};
+
+const TUint32 KInteger = 0x00000001;
+
+//const TUint32 KOmaDMAppUid = {0x200267FB};
+const TInt KVersionLength= 7; // 3 for Major, 1 for '.' and 3 for Minor
+_LIT( KLiteralPeriod, ".");
+
+const TInt KAMDefaultValue = 0;
+const TInt KAMSCMAdapter = 1;
+const TInt KAMSCOMOAdapter = 2;
+
+const int KDCIdMaxLength = 128 ;
+typedef TBuf8<KDCIdMaxLength> TDeploymentComponentId;
+
+const int KDeploymentComponentNameMaxLength = 128 ;
+typedef TBuf8<KDeploymentComponentNameMaxLength> TDeploymentComponentName;
+
+const int KDeploymentComponentVersionMaxLength = 32;
+typedef TBuf8<KDeploymentComponentVersionMaxLength> TDeploymentComponentVersion;
+
+const int KDeploymentComponentDescriptionMaxLength = 512;
+typedef TBuf8<KDeploymentComponentVersionMaxLength> TDeploymentComponentDescription;
+
+const int KDeploymentComponentPkgIdMaxLength = 256;
+typedef TBuf8<KDeploymentComponentPkgIdMaxLength> TDeploymentComponentPkgId;
+
+const int KDeploymentComponentPkgIdRefMaxLength = 256;
+typedef TBuf8<KDeploymentComponentPkgIdRefMaxLength> TDeploymentComponentPkgIdRef;
+
+const int KDeploymentComponentPkgTypeRefMaxLength = 256;
+typedef TBuf8<KDeploymentComponentPkgTypeRefMaxLength> TDeploymentComponentPkgType;
+
+typedef TBuf8<KDeploymentComponentNameMaxLength> TMidletnameName;
+
+typedef TBuf8<KDeploymentComponentNameMaxLength> TMidletVendorName;
+typedef TBuf8<KDeploymentComponentVersionMaxLength> TMidletVersion;
+
+typedef TBuf8<KDeploymentComponentNameMaxLength> TPreInstalledAppName;
+typedef TBuf8<KDeploymentComponentNameMaxLength> TPreInstalledAppVendorName;
+typedef TBuf8<KDeploymentComponentVersionMaxLength> TPreInstalledVersion;
+
+const int KDeploymentComponentURLMaxLength = 32;
+
+const int KMaxMimeLength = 256 ;
+typedef TBuf8<KMaxMimeLength> TMimeType;
+
+const int KMaxDCUserIdLength = 256;
+typedef TBuf8<KMaxDCUserIdLength> TDCUserId;
+
+enum TDeploymentComponentState
+	{
+	EDCSError = -1,
+	EDCSNone = 0,
+	EDCSDelivered = 1,
+	EDCSInactive = 2,
+	EDCSActive = 3,
+	EDCSDownload = 4,
+	EDCSDeployed =5,
+	EDCSDelete = 6
+	};
+	
+enum TDeplCompAttrType 
+	{
+	EDCNone = 0,
+	EDCId = 1,
+	EDCName = 2,
+	EDCVersion = 4,
+	EDCInstallOptions = 8,
+	EDCMetaData = 16,
+	EDCMetaDataMime = 24,
+	EDCData = 32,
+	EDCDataMime = 48,
+	EDCStatus = 64,
+	EDCDownloadURI = 128,
+	EDCStateValue = 256,
+	EDCConRef = 512,
+	EDCDescriptionRef = 1024,
+	EDCPkgID = 2048,
+	EDCPkgType = 4096
+	};
+
+enum TDownloadTarget
+	{
+	EDeliver,
+	EInstall,
+	EInstallAndActivate,
+	EUpdate,
+	EUpdateAndActivate
+	};
+enum TSCOMOStatusNodeStates
+    {
+    //Download Status Values
+    EIdle = 10,
+    EDownload_DownloadFailed = 20,
+    EDownload_DownloadProgress = 30,
+    EDownload_DownloadComplete = 40,
+    EDownload_InstallProgress = 50,
+    EDownload_InstalledFailedWithData = 60,
+    EDownload_InstalledFailedWithOutData = 70,
+    //Delivered Status Values
+    EDelivered_RemoveFailed = 20,
+    EDelivered_RemoveProgress = 30,
+    EDelivered_InstallProgress = 40,
+    EDelivered_InstalledFailedWithData = 50,
+    EDelivered_InstallFailedwithOutData = 60,
+    //Deployed Status Values
+    EDeployed_RemoveFailed = 20,
+    EDeployed_RemoveProgress = 30,
+    EDeployed_ActivateFailed = 40,
+    EDeployed_ActivateProgress = 50,
+    EDeployed_DeactivateFailed = 60,
+    EDeployed_DeactivateProgress = 70
+    };
+/**
+*  CAMDeliveryDeploymentComponent class to represent delivery items
+*/	
+
+struct TDeploymentComponent 
+	{
+	// Data
+	TDeploymentComponentId iId ;
+	TDeploymentComponentName iName;
+	TDeploymentComponentVersion iVersion ;
+	TDeploymentComponentDescription iDescription;
+	TDeploymentComponentPkgId iPkgID;
+	TDeploymentComponentPkgIdRef iPkgIDRef;
+	TDeploymentComponentPkgType iPkgType;
+	TDeploymentComponentState iState ;
+	TDeploymentComponentState iOldState ;
+	TDeploymentComponent() : iId( KNullDesC8() ),
+							 iName( KNullDesC8() ),
+							 iVersion( KNullDesC8() ),
+							 iDescription (KNullDesC8),
+							 iState( EDCSNone ),
+							 iOldState ( EDCSNone ) 
+							 
+	{
+	
+	}
+	TDeploymentComponent( const TDesC8 &aId, 
+						  const TDesC8 &aName, 
+						  const TDesC8 &aVersion, 
+						  TDeploymentComponentState aState )
+		: iId( aId ), 
+		iName( aName ), 
+		iVersion ( aVersion ), 
+		iState ( aState ), 
+		iOldState( EDCSNone )
+		{
+		} 
+	};
+
+struct TDeploymentComponentIPC
+	{
+	TDeploymentComponent iComponent;
+	TBuf8<256> iMimeType;
+	TDCUserId iUserId;
+	TDeploymentComponentIPC() : iComponent(),
+								iMimeType( KNullDesC8() ),
+								iUserId( KNullDesC8())
+								
+		{
+		
+		}
+	TDeploymentComponentIPC( const TDeploymentComponent &aComponent,
+		const TDesC8 &aMimeType,
+		const TDCUserId &aUserId) 
+			: iComponent( aComponent ), 
+				iMimeType( aMimeType ),
+				iUserId( aUserId )
+		{
+		
+		}
+	};
+	
+struct TDeplCompDataIPC
+	{
+	TUint32 iInternalId;
+	TDeplCompAttrType iAttrType;
+	TBuf8<256> iDataMime;
+	};	
+	
+	}
+#endif 
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/inc/ApplicationManagementConst.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+ *
+ * Description:  Implementation of applicationmanagement components
+ *
+*/
+
+
+#ifndef __AMC_H__
+#define __AMC_H__
+
+
+// Successful - The Request has Succeeded
+
+const TInt KStatusSuccess = 1200;
+
+//User chose not to accept the operation when prompted
+
+const TInt KStatusUserCancelled = 1401;
+
+//The Software Component download failed 
+
+const TInt KStatusDownloadFailed = 1402;
+
+//The download failed due to insufficient memory in the Device 
+//to save the Delivery Package.
+
+const TInt KStatusDowloadFailedOOM = 1404;
+
+//Software Component  installation failed in the Device
+
+const TInt KStatusInstallFailed = 1405;
+
+//The install failed because there wasn't sufficient memory to install 
+//the Software Component in the Device.
+
+const TInt KStatusInstallFailedOOM = 1406;
+
+//Failure to positively validate digital signature of the Delivery Package
+
+const TInt KStatusPkgValidationFailed = 1407;
+
+//The Software Component Remove operation failed
+
+const TInt KStatusRemoveFailed = 1408;
+
+//The Software Component Activate operation failed
+
+const TInt KStatusActivationFailed = 1409;
+
+//The Software Component Deactivate operation failed
+
+const TInt KStatusDeactivationFailed = 1410;
+
+//The Operation has been rejected because the device does not support the target environment type
+
+const TInt KStatusUnSupportedEnvironment = 1413;
+
+//Alternate Download Server Error Encountered
+
+const TInt KStatusAltDowldError = 1500;
+
+//The Alternate Download Server is unavailable or does not respond
+
+const TInt KStatusAltDowldUnavailable = 1501;
+
+//Authentication was Required but Authentication Failure was encountered when downloading Software Component
+
+const TInt KStatusAlternateDownldAuthFail = 1403;
+
+
+
+
+    
+
+#endif
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/inc/ApplicationManagementRfs.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 applicationmanagement components
+*
+*/
+
+
+#ifndef __AMRFS_H__
+#define __AMRFS_H__
+
+#include <e32std.h>
+
+class RAppMgmtRfs : public RSessionBase
+	{
+	public:
+	
+	/**
+	 * Connect Connects to ApplicationManagmeent server (starts it if it's not 
+	 *	running
+	 * @return KErrNone or Symbian error code
+	 */
+	IMPORT_C TInt Connect();
+	
+	
+	/**
+	 * Close Closes connection to ApplicationManagement server
+	 * @return KErrNone or Symbian error code
+	 */
+	IMPORT_C void Close();
+
+	// New methods
+	
+	/**
+	 * PerformRfsL Causes ApplicationManagement to prepare for RFS. That means
+	 * 	uninstall of serveral applications, etc.
+	 * @return KErrNone or Symbian error code
+	 */
+	IMPORT_C void PerformRfsL() const;
+	
+	  /**
+		* Implementation of Service UID() from base class. Returns AM service UID 
+		* to framework
+		*	
+		* @return uid of AM service UID
+		*/	
+		TUid ServiceUid() const;  
+	};
+	
+#endif
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/inc/amprivateCRKeys.h	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  Implementation of applicationmanagement components
+ *
+*/
+
+#ifndef __AMPRIVATECRKEYS_H__
+#define __AMPRIVATECRKEYS_H__
+
+/**
+* Application Management Internal Keys UID
+*/
+const TUid KCRUidPrivateApplicationManagementKeys = {	0x200267FB };
+
+/**
+* CenRep key that holds smallest supported Internal Component Id 
+*
+* Possible integer values:
+* positive integer values 
+*
+* Default value: -1 (not defined)
+*
+* Note: Only for Application Management private use
+*
+*/
+ 
+const TInt KMinIdValue = 0x20;
+
+/**
+* CenRep key for Next free ID:
+* Holds the next free if for deployment component
+*
+* Possible integer values:
+* positive integer values 
+*
+* Default value: -1 (not defined)
+*
+* Note: Only for Application Management private use
+*
+*/
+const TInt KNextIdKey = 0x01;
+
+/**
+* Holds the lenght of deployment component id list
+*
+* Possible integer values:
+* positive integer values 
+*
+* Default value: 0 
+*
+* Note: Only for Application Management private use
+*
+*/
+const TInt KIdListLengthKey = 0x02;
+
+/**
+* Holds the deployment component id list
+*
+* Possible string values: Application Management defined
+*
+* Default value: (empty)
+*
+* Note: Only for Application Management private use
+*
+*/
+const TInt KIdListKey = 0x03 ;
+
+/**
+* Holds the value which determines whether SYnc or Async operation
+* is enabled
+*
+* Possible string values: Application Management defined
+*
+* Default value: 1 ( ASync is enabled)
+*
+* Note: Only for Application Management private use
+*
+*/
+const TInt KAsyncEnabled = 0x04;
+
+/**
+* This value is static node name and cenrep configurable
+*
+* Possible string values: Application Management defined
+*
+* Note: Only for Application Management private use
+*
+*/
+
+const TInt KAMDownloadPredefinedNode= 0x05 ;
+
+/**
+* This value is retry count and determines the maximum
+* allowable retry count
+*
+* Possible string values: Application Management defined
+*
+* Note: Only for Application Management private use
+*
+*/
+const TInt KMaxRetryCount = 0x06;
+
+/**
+* This value stores the status of Sync reporting 
+*
+* Possible string values: Application Management defined
+*
+* Note: Only for Application Management private use
+*
+*/
+const TInt KAMSyncStatus = 0x07;
+
+/**
+* This value tells which adapter(SCM/SCOMO) did DM operations (ADD/DELETE/GET/UPDATE/EXEC) in previous DM session.
+* Based on this we will call CheckStateChangesL() in DDFStructurel() API 
+*
+* Possible string values: default      - 0
+*                         SCM adapter  - 1
+*                         SCOMO adapter -2
+*
+* Note: Only for Application Management private use
+*
+*/
+const TInt KAMAdapterValue = 0x08;
+
+/**
+* This value checks if Static node feature is enabled  
+* if value is 1 then CMCCSCM static node is visible under 
+* download node otherwise it is not visible
+* 
+* default value from platform side this feature is disabled.
+* 
+* Note: Only for Application Management private use
+*/
+const TInt KAMStaticNodeEnabled = 0x09;
+
+/**
+* This value indicate SCOMO MetaType used in generic alert and this 
+* is configurable
+* 
+* Note: Only for Application Management private use
+* 
+* 
+*/
+const TInt KSCOMOMetaTypeKey = 0x0A;
+
+/**
+* This value indicate SCOMO MetaFormat used in generic alert and this 
+* is configurable
+* 
+* Note: Only for Application Management private use
+* 
+* 
+*/
+const TInt KSCOMOMetaFormatKey = 0x0B;
+
+/**
+* This value indicate SCOMO Mark used in generic alert and this 
+* is configurable
+* 
+* Note: Only for Application Management private use
+* 
+* 
+*/
+const TInt KSCOMOMark = 0x0C;
+
+/**
+* This default value is used to get drive from cenrep and this is
+* applicable in case of silent mode of SCOMO operation
+* 
+* Note: Only for Application Management private use
+* 
+* 
+*/
+const TInt KDefaultDriveForInstall = 0x0D;
+
+#endif // __AMPRIVATECRKEYS_H__
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/inc/ampskeys.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+ *
+ * Description:  Implementation of applicationmanagement components
+ *
+*/
+
+ 
+#ifndef __AMPSKEYS_H__
+#define __AMPSKEYS_H__
+
+// Application Management Server UID for Publish and Subscribe key
+
+const TUid KUidPSApplicationManagementKeys = { 0x200267FB };
+
+// P&S key to check whether AM UI Server is enabled or disabled
+
+const TUint KAMServerUIEnabled = 0x00001;
+
+// P&S key to check whether device management session is silent
+// or interactive(can be information or nonspecified as well)
+
+const TUint KAMOperationNonSilent = 0x00002;
+
+// P&S key to Notify OMA SCOMO adapter as soon as download is
+// complete. This will be applicable in case of Sync operation
+
+const TUint KSyncNotifier = 0x000004;
+
+// Set this P&S key so that DM UI will not be closed in case of server initiated session
+// applicable only for Interactive, Informative or Non specified
+
+const TUint KDMUINotClosed = 0x00005;
+
+
+// DM UI application ID
+
+const TUid KPSUidNSmlDMSyncApp = {0x101f6de5};
+
+// Key defined in DM UI Fw to know application management server
+// whether session started in silent mode or non-silent
+
+const TUint32 KSilentSession = 0x0000000D;
+
+
+
+
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/inc/debug.h	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  Application Management Debug macro definitions
+*
+*/
+
+
+#ifndef DEBUG_HEADER_
+#define DEBUG_HEADER_
+
+// INCLUDES
+
+#include <f32file.h>
+#include <flogger.h>
+
+// CONSTANTS
+_LIT( KTarmLogFolderName, "tarm" );
+_LIT( KTarmLogFileName, "tarm.log" );
+// MACROS
+//#define _TARM_FILE_DEBUG
+#ifdef _TARM_FILE_DEBUG
+		#define RDEBUG(X)					RFileLogger::Write( KTarmLogFolderName, KTarmLogFileName, EFileLoggingModeAppend, _L(X) )
+		#define RDEBUG_2(X,Y)			RFileLogger::WriteFormat( KTarmLogFolderName, KTarmLogFileName, EFileLoggingModeAppend, _L(X),Y )	
+		#define RDEBUG_3(X,Y,Z)	  RFileLogger::WriteFormat( KTarmLogFolderName, KTarmLogFileName, EFileLoggingModeAppend, _L(X),Y,Z )	
+		#define RDEBUG_4(X,Y,Z,A)	  RFileLogger::WriteFormat( KTarmLogFolderName, KTarmLogFileName, EFileLoggingModeAppend, _L(X),Y,Z,A )	
+		#define RDEBUG_5(X,Y,Z,A,B)	  RFileLogger::WriteFormat( KTarmLogFolderName, KTarmLogFileName, EFileLoggingModeAppend, _L(X),Y,Z,A,B )
+		
+		#define RDEBUG8_2(X,Y)			RFileLogger::WriteFormat( KTarmLogFolderName, KTarmLogFileName, EFileLoggingModeAppend, _L8(X),Y )	
+		#define RDEBUG8_3(X,Y,Z)	  RFileLogger::WriteFormat( KTarmLogFolderName, KTarmLogFileName, EFileLoggingModeAppend, _L8(X),Y,Z )	
+		#define RDEBUG8_4(X,Y,Z,A)	  RFileLogger::WriteFormat( KTarmLogFolderName, KTarmLogFileName, EFileLoggingModeAppend, _L8(X),Y,Z,A )	
+		#define RDEBUG8_5(X,Y,Z,A,B)	  RFileLogger::WriteFormat( KTarmLogFolderName, KTarmLogFileName, EFileLoggingModeAppend, _L8(X),Y,Z,A,B )
+		#define RDEBUG_HEX8(X,Y)	RFileLogger::HexDump( KTarmLogFolderName, KTarmLogFileName, EFileLoggingModeAppend, NULL, NULL, X,Y )	
+		
+#else
+
+	#ifdef _DEBUG
+		#define RDEBUG(X)								RDebug::Print(_L(X))
+		#define RDEBUG_2(X,Y)						RDebug::Print(_L(X),Y)
+		#define RDEBUG_3(X,Y,Z)					RDebug::Print(_L(X),Y,Z)
+		#define RDEBUG_4(X,Y,Z,A)					RDebug::Print(_L(X),Y,Z,A)
+		#define RDEBUG_5(X,Y,Z,A,B)					RDebug::Print(_L(X),Y,Z,A,B)
+		
+		#define RDEBUG8_2(X,Y)						RDebug::Printf(X,Y)
+		#define RDEBUG8_3(X,Y,Z)					RDebug::Printf(X,Y,Z)
+		#define RDEBUG8_4(X,Y,Z,A)					RDebug::Printf(X,Y,Z,A)
+		#define RDEBUG8_5(X,Y,Z,A,B)					RDebug::Printf(X,Y,Z,A,B)
+		
+		#define RDEBUG_HEX8(X,Y)
+		
+	#else
+		#define RDEBUG(X)								
+		#define RDEBUG_2(X,Y)						
+		#define RDEBUG_3(X,Y,Z)	
+		#define RDEBUG_4(X,Y,Z,A)	
+		#define RDEBUG_5(X,Y,Z,A,B)	
+		
+		#define RDEBUG8_2(X,Y)
+		#define RDEBUG8_3(X,Y,Z)	
+		#define RDEBUG8_4(X,Y,Z,A)			
+		#define RDEBUG8_5(X,Y,Z,A,B)		
+		
+		#define RDEBUG_HEX8(X,Y)		
+		
+	#endif // _DEBUG
+	
+#endif // _TARM_FILE_DEBUG
+
+
+
+
+#endif // DEBUG_HEADER_
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  build info file for application management adapter
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+
+
+// ARMv5 udeb
+../src/20021335.SPD        /epoc32/release/armv5/udeb/z/private/100012a5/policy/20021335.spd
+
+// ARMv5 urel
+../src/20021335.SPD        /epoc32/release/armv5/urel/z/private/100012a5/policy/20021335.spd
+
+// WINSCW udeb
+../src/20021335.SPD        /epoc32/release/winscw/udeb/z/private/100012a5/policy/20021335.spd
+
+// WINSCW urel
+../src/20021335.SPD        /epoc32/release/winscw/urel/z/private/100012a5/policy/20021335.spd
+
+../src/20021335.SPD        /epoc32/data/z/private/100012a5/policy/20021335.spd
+
+PRJ_MMPFILES
+./omascomoadapter.mmp
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/group/omascomoadapter.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,82 @@
+/*
+* 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:  Implementation of oma scomo adapter
+*
+*/
+  
+
+// To get the APP_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include "defaultcaps.hrh"
+
+
+TARGET          omascomoadapter.dll
+
+CAPABILITY 	    CAP_GENERAL_DLL -TCB -DRM
+
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x20021335
+VENDORID        VID_DEFAULT
+
+MACRO __AM_LASTERROR_NODE // uncomment to enable /SCOMO/Ext/LastError node
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+SYSTEMINCLUDE 	/epoc32/include/devman
+#else
+// nothing
+#endif
+
+SOURCEPATH      ../src
+SOURCE          omascomoadapter.cpp
+SOURCE					nsmldmiapmatcher.cpp
+SOURCE					nsmldmuri.cpp
+SOURCE		omascomoadapterdb.cpp
+
+USERINCLUDE     ../inc 
+USERINCLUDE			../../inc
+USERINCLUDE 		../../options/inc // install options
+USERINCLUDE 		../../server/inc  //for amprivateCRKeys.h
+ 
+
+START RESOURCE omascomoadapter.rss
+TARGET omascomoadapter.rsc
+END
+
+
+LIBRARY		euser.lib edbms.lib sysutil.lib 
+LIBRARY		ecom.lib 
+LIBRARY     estor.lib
+LIBRARY		efsrv.lib 
+LIBRARY		applicationmanagementclient.lib
+LIBRARY		centralrepository.lib 
+LIBRARY 	aminstalloptions.lib 
+LIBRARY		featmgr.lib 
+LIBRARY 	flogger.lib
+LIBRARY			syncmlclientapi.lib
+LIBRARY			nsmlprivateapi.lib
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+LIBRARY		devmancmdmgr.lib
+LIBRARY		dmtreeclient.lib
+#else
+LIBRARY		nsmldmtreedbclient.lib
+LIBRARY		nsmldmclientserverutils.lib
+LIBRARY		nsmldmiapmatcher.lib apgrfx.lib ws32.lib 
+#endif
+
+	
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/inc/nsmldmiapmatcher.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+ *
+ * Description:  Implementation of applicationmanagement components
+ *
+*/
+
+
+#ifndef __NSMLDMIAPMATCHER_H__
+#define __NSMLDMIAPMATCHER_H__
+
+// ------------------------------------------------------------------------------------------------
+// Includes
+// ------------------------------------------------------------------------------------------------
+#include <e32base.h>
+#include "nsmldmuri.h"
+
+//CLASS FORWARDS
+class MSmlDmCallback;
+
+_LIT8( KNSmlDMIAPUri, "AP" );
+_LIT8( KNSmlDMSeparator8, "/" );
+_LIT8( KNSmlDMIAPUriDotSlash, "./" );
+_LIT8( KNSmlDMConnMOIAPUri, "NAP" );
+
+const TUint8 KNSmlDMSlash = 0x2f; //forward slash
+/**
+* CNSmlDMIAPMatcher contains services for generating URI from IAPId and
+* vice versa in DM plug-in adapters. The class needs the working
+* MSmlDmCallback callback interface for operating, so ths can be used only
+* by DM plug-in adapters
+*
+*  @since
+*/
+class CNSmlDMIAPMatcher : public CBase
+	{
+    public:
+		/**
+		* Destructor
+		*/
+	    ~CNSmlDMIAPMatcher();
+
+		/**
+		* Two-phased constructor
+		* @param	aDmCallback			Pointer to callback interface
+		* @return						Pointer to newly created module instance
+		*/
+        static CNSmlDMIAPMatcher* NewL( MSmlDmCallback* aDmCallback);
+
+		/**
+		* Two-phased constructor, pushes pointer to cleanup stack.
+		* @param	aDmCallback			Pointer to callback interface
+		* @return						Pointer to newly created module instance
+		*/
+        static CNSmlDMIAPMatcher* NewLC( MSmlDmCallback* aDmCallback);
+
+		/**
+		* Gets the IAP id which corresponds to given URI
+		* @param	aURI				Accespoint URI
+		* @return						Accespoint id in AP database
+		*/
+        TInt IAPIdFromURIL( const TDesC8& aURI );
+
+		/**
+		* Generates the URI which corresponds to given IAP Id
+		* @param	aIAPId				Accespoint Id
+		* @return						Accesspoint URI in DM
+		*/
+        HBufC8* URIFromIAPIdL( TInt aIAPId );
+
+    private:
+		/**
+		* Second phase constructor
+		* @param	aDmCallback			Pointer to callback interface
+		*/
+        void ConstructL(MSmlDmCallback* aDmCallback);
+
+		/**
+		* Changes the given descriptor to Integer
+		* @param	aLuid				Luid in descriptor format
+		* @return						Luid in TInt type
+		*/
+        TInt DesToInt(const TDesC8& aLuid) const;
+
+		/**
+		* Return the URI without ./ at the beginning, if those exist
+		* @param	aURI		Uri
+		* @return 		 		Uri without ./
+		*/
+        TPtrC8 RemoveDotSlash(const TDesC8& aURI) const;
+
+		/**
+		* Return the last uri segment of the aURI
+		* @param	aURI		Uri
+		* @return 		 		The last uri segment
+		*/
+        TPtrC8 LastURISeg(const TDesC8& aURI) const;
+        
+    /**
+		* Return the last uri segment of the aURI
+		* @return 		 		The AccessPoint Reference
+		*/
+        const TDesC8& GetConRef() ;
+
+    private:
+    
+ 		/**
+		* Pointer to callback interface
+		*/
+		MSmlDmCallback* iCallback;
+		
+		/**
+		* Boolean to check FeatMgr Initialization
+		*/
+		TBool iFeatMgrInitialized;
+	
+	};
+
+#endif // __NSMLDMIAPMATCHER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/inc/nsmldmuri.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+ *
+ * Description:  Implementation of applicationmanagement components
+ *
+*/
+
+#ifndef __NSMLDMURI_H
+#define __NSMLDMURI_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <e32def.h>
+
+
+const TUint8 KNSmlDMUriSeparator = 0x2f; //forward slash
+
+_LIT8(KNSmlDmRootUri, ".");
+_LIT8(KNSmlDmUriDotSlash, "./");
+_LIT8( KNSmlDmQuestionMark, "?" );
+
+// ===========================================================================
+// NSmlDmURI
+// ===========================================================================
+/**
+* NSmlDmURI contains just static methods for parsing URIs
+*
+*  @since
+*/
+class NSmlDmURI
+	{
+	public:
+	/**
+	* Return the parent URI of given URI
+	* @param	aURI		Uri
+	* @return 		 		Parent URI
+	*/
+	static TPtrC8 ParentURI(const TDesC8& aURI);
+
+	/**
+	* Return the last URI segment of given URI
+	* @param	aURI		Uri
+	* @return 		 		Last URI segment
+	*/
+	static TPtrC8 LastURISeg(const TDesC8& aURI);
+
+	/**
+	* Return the URI without ./ at the beginning, if those exist
+	* @param	aURI		Uri
+	* @return 		 		Uri without ./
+	*/
+	static TPtrC8 RemoveDotSlash(const TDesC8& aURI);
+
+	/**
+	* Return the URI without property info at the end (?prop=...)
+	* @param	aURI		Uri
+	* @return 		 		Uri without property info
+	*/
+	static TPtrC8 RemoveProp(const TDesC8& aURI);
+
+	/**
+	* Return the URI without last segment
+	* @param	aURI		Uri
+	* @return 		 		URI without last uri segment
+	*/
+	static TPtrC8 RemoveLastSeg(const TDesC8& aURI);
+
+	/**
+	* Return the aLocationth URI segment.
+	* @param	aURI		Uri
+	* @param	aLocation	The wanted segment number
+	* @return 		 		The aLocationth URI segment
+	*/
+	static TPtrC8 URISeg(const TDesC8& aURI,TInt aLocation);
+
+	/**
+	* Return the number of URI  segments of given URI
+	* @param	aURI		Uri
+	* @return 		 		Number of segments
+	*/
+	static TInt NumOfURISegs(const TDesC8& aURI);
+	};
+
+#endif // __NSMLDMURI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/inc/omascomoadapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,853 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 applicationmanagement components
+ *
+*/
+
+
+#ifndef __OMASCOMOADAPTER_H__
+#define __OMASCOMOADAPTER_H__
+
+// ------------------------------------------------------------------------------------------------
+// Includes
+// ------------------------------------------------------------------------------------------------
+#include <e32base.h>
+#include <smldmadapter.h>
+#include "omascomoadapterdb.h"
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+#include <dmtree.h>
+#else
+#include "nsmldmtreedbclient.h"
+#endif
+
+#include "ApplicationManagementClient.h"
+
+const TInt KMaxUrlLength = 2048;
+
+namespace NApplicationManagement
+    {
+
+    const TUint KAMAdapterImplUid = 0x20021336;
+    
+    const TInt KMaxSizeString = 256;
+
+    // the DDF version must be changed if any changes in DDF structure ( built in DDFStructureL() function )
+    _LIT8( KAMDDFVersion, "1.0" );
+
+    _LIT8( KAMTextPlain, "text/plain" );
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    _LIT8( KAMNodeName, "./SCOMO" );
+#else
+    _LIT8( KAMNodeName, "SCOMO" );
+#endif
+    _LIT8( KAMNodeDescription, "This node is the root node for all application management functionality" );
+
+    _LIT8( KAMInventoryNodeName, "Inventory" );
+    _LIT8( KAMInventoryNodeDescription, "This node is start node of application inventory" );
+
+    _LIT8( KAMDeliveredNodeName, "Delivered" );
+    _LIT8( KAMDeliveredNodeDescription, "This is node under which applications that are delivered but not installed are found." );
+
+    _LIT8( KAMDeployedNodeName, "Deployed" );
+    _LIT8( KAMDeployedNodeDescription, "This is a node under which deployed applications are found" );
+
+    _LIT8( KAMDeliveredDynaNodeDescription, "This dynamic node is placeholder applications that are in Delivered state" );
+
+    _LIT8( KAMPkgIDNodeName, "PkgID" );
+    _LIT8( KAMPkgIDNodeDescription, "This leaf node holds an package identifier for an application" );
+
+
+    _LIT8( KAMIDNodeName, "ID" );
+    _LIT8( KAMIDNodeDescription, "This leaf node holds an identifier for an deployment component" );
+    
+    _LIT8( KAMPkgIDRefNodeName, "PkgIDRef" );
+    _LIT8( KAMPkgIDRefNodeDescription, "This leaf node holds an identifier for an deployment component" );
+
+    _LIT8( KAMNameNodeName, "Name" );
+    _LIT8( KAMNameNodeDescription, "This leaf node holds name of an application" );
+
+    _LIT8( KAMVersionNodeName, "Version" );
+    _LIT8( KAMVersionNodeDescription, "This leaf node holds the version of an application" );
+
+    _LIT8( KAMStateValueNodeName, "State" );
+    _LIT8( KAMStateValueNodeDescription, "This leaf node holds the state value of an application (active/inactive)" );
+
+    _LIT8( KAMDataNodeName, "Data" );
+    _LIT8( KAMDataNodeDescription, "This leaf node holds the data of an application" );
+
+    _LIT8( KAMDescriptorNodeName, "Descriptor" );
+    _LIT8( KAMDescriptorNodeDescription, "This leaf node holds the possible metadata of an application" );
+
+    _LIT8( KAMOperationsNodeName, "Operations" );
+    _LIT8( KAMOperationsNodeDescription, "This is a node under which operations are found" );
+
+    _LIT8( KAMInstallOptsNodeName, "InstallOpts" );
+    _LIT8( KAMInstallOptsNodeDescription, "This is a node that holds the installation options of an application" );
+
+    _LIT8( KAMDeployedDynaNodeDescription, "This dynamic node is placeholder applications that are in Inactive state" );
+
+    _LIT8( KAMDownloadOperationNodeName, "Download" );
+    _LIT8( KAMDownloadOperationNodeDescription, "Starts the download" );
+
+    _LIT8( KAMConRefNodeName, "ConRef" );
+    _LIT8( KAMConRefNodeDescription, "Holds reference to IAP" );
+
+    _LIT8( KAMLocalOperationsNodeDescription, "This is the root node for local operations" );
+
+    _LIT8( KAMActivateNodeName, "Activate" );
+    _LIT8( KAMActivateNodeDescription, "Exec command causes device to activate an inactive application" );
+
+    _LIT8( KAMDeActivateNodeName, "Deactivate" );
+    _LIT8( KAMDeActivateNodeDescription, "Exec command causes device to stop and deactivate an active application" );
+
+    _LIT8( KAMInstallNodeName, "Install" );
+    _LIT8( KAMInstallNodeDescription, "Exec command causes device to install a delivered application" );
+
+    _LIT8( KAMInstallInactiveNodeName, "InstallInactive" );
+    _LIT8( KAMInstallInactivateNodeDescription, "Exec command causes device to install a delivered application and activate it" );
+
+    _LIT8( KAMUpdateNodeName, "Update" );
+    _LIT8( KAMUpdateNodeDescription, "Exec command causes device to update an application" );
+
+    _LIT8( KAMUpdateAndActivateNodeName, "UpdateAndActivate" );
+    _LIT8( KAMUpdateAndActivateNodeDescription, "Exec command causes device to update an application and activate it" );
+
+    _LIT8( KAMRemoveNodeName, "Remove" );
+    _LIT8( KAMRemoveNodeDescription, "Exec command causes device to remove an application" );
+
+    _LIT8( KAMDownloadNodeName, "Download" );
+    _LIT8( KAMDownloadNodeDescription, "This node is a root node for application download functionality" );
+
+    _LIT8( KAMDownloadAndInstallNodeName, "DownloadInstall" );
+    _LIT8( KAMDownloadAndInstallOperationNodeDescription, "Starts the download and installs component when complete" );
+
+    _LIT8( KAMDownloadAndInstallAndInActivateNodeName, "DownloadInstallInactive" );
+    _LIT8( KAMDownloadAndInstallAndInActivateNodeDescription, "Starts the download and installs and activates component when complete" );
+
+    _LIT8( KAMDownloadAndUpdateNodeName, "DownloadAndUpdate" );
+    _LIT8( KAMDownloadAndUpdateNodeDescription, "Starts the download and installs component when complete" );
+
+    _LIT8( KAMDownloadAndUpdateAndActivateNodeName, "DownloadAndUpdateAndActivate" );
+    _LIT8( KAMDownloadAndUpdateAndActivateNodeDescription, "Starts the download and updates and activates component when complete" );
+
+    _LIT8( KAMDownloadDynaNodeDescription, "This node is a placeholder for identifier of an application that is to be downloaded" );
+
+    _LIT8( KAMURINodeName, "PkgURL" );
+    _LIT8( KAMURINodeDescription, "This leaf node holds the URL from which the application should be downloaded" );
+
+    _LIT8( KAMStatusNodeName, "Status" );
+    _LIT8( KAMStatusNodeDescription, "This leaf node holds the status of the download" );
+
+    _LIT8( KAMDescriptionNodeName, "Description" );
+    _LIT8( KAMDescriptionNodeDescription, "This leaf node holds the description of the download" );
+    
+    _LIT8( KAMPkgTypeNodeName, "PkgType" );
+    _LIT8( KAMPkgTypeNodeDescription, "This leaf node holds the PkgType of the download or delivered" );
+
+#ifdef __AM_LASTERROR_NODE
+    _LIT8( KAMExtNodeName, "Ext" );
+    _LIT8( KAMExtNodeDescription, "Non std extentions are found under this leaf" );
+    _LIT8( KAMLastErrorNodeName, "LastError" );
+    _LIT8( KAMLastErrorDescription, "This leaf node may hold the error" );
+#endif
+
+    _LIT8( KAMDynamicNodeName, "" );
+    _LIT( KAMSeparator16, "/" );
+
+    _LIT8( KAMSeparator8, "/" );
+
+    _LIT8( KAMRootChilds, "Inventory/Download" );
+    _LIT8( KAMInventoryChilds, "Delivered/Deployed" );
+    //_LIT8( KAMLocalOperationsChilds, "Activate/DeActivate/Install/Update/Remove" );
+
+    _LIT8( KAMDownloadDynaChilds, "PkgID/Name/PkgURL/Description/Status/PkgType/Operations" );
+_LIT8( KAMInventoryDynaChilds, "ID/PkgIDRef/Name/Description/Version/State/Operations" );
+_LIT8( KAMDownloadOperationChilds, "Download/DownloadInstall/DownloadInstallInactivate" );
+_LIT8( KAMDeployedOperationChilds, "Activate/Deactivate/Remove" );
+_LIT8( KAMDeliveredOperationChilds, "Install/InstallInactive/Remove" );
+_LIT8( KAMInventoryDeliveredDynaChilds, "PkgID/Data/Name/Description/Status/State/PkgType/Operations" );
+
+    _LIT8( KNSmlDMSCOMOMetaType,"org.openmobilealliance.dm.softwarecomponent.OperationComplete" );
+    _LIT8( KNSmlDMSCOMOMetaFormat, "text/plain" );
+    
+    _LIT8(KDataStart, "<![CDATA[");
+            _LIT8(KDataEnd, "]]>");
+            _LIT8(KResultCodeStart, "<ResultCode>");
+            _LIT8(KResultCodeEnd, "</ResultCode>");
+            _LIT8(KIdentifierStart, "<Identifier>");
+            _LIT8(KIdentifierEnd, "</Identifier>");
+                    
+            
+            _LIT8(KMark, "warning");
+
+    struct TAMCommandBufferElement
+        {
+        TInt iStatusRef;
+        TBuf8<256> iURI;
+        TAMCommandBufferElement(TInt aRef, const TDesC8 &aURI) :
+            iStatusRef(aRef), iURI(aURI)
+            {
+            }
+        };
+
+    typedef RArray<TAMCommandBufferElement> TAMCommandBuffer;
+
+    // ------------------------------------------------------------------------------------------------
+    // CSCOMOAdapter 
+    // ------------------------------------------------------------------------------------------------
+    class CSCOMOAdapter : public CSmlDmAdapter
+        {
+public:
+        static CSCOMOAdapter* NewL(MSmlDmCallback* aDmCallback);
+        static CSCOMOAdapter* NewLC(MSmlDmCallback* aDmCallback);
+
+        virtual ~CSCOMOAdapter();
+
+        /**
+         The function returns current version of the DDF.
+         By asking current DDF versions from adapters DM Module can control
+         possible changes in the data structure and send the changed DDF
+         description to a management server.
+         This function is always called after DDFStructureL.
+         @param aVersion DDF version of the adapter. (filled by the adapter)
+         @publishedPartner
+         @prototype
+         */
+        virtual void DDFVersionL(CBufBase& aVersion);
+
+        /**
+         The function for filling the DDF structure of the adapter
+         This function is only called once, immediately after the adapter is created.
+         @param aDDFObject	Reference to root object. A DM adapter starts filling
+         the data structure by calling AddChildObjectL to the root object and
+         so describes the DDF of the adapter. 
+         @publishedPartner
+         @prototype
+         */
+        virtual void DDFStructureL(MSmlDmDDFObject& aDDF);
+
+        /**
+         The function creates new leaf objects, or replaces data in existing leaf
+         objects. The information about the success of the command should be
+         returned by calling SetStatusL function of MSmlDmCallback callback
+         interface. This makes it possible to buffer the commands.  However, all
+         the status codes for buffered commands must be returned at the latest when
+         the adapter's CompleteOutstandingCmdsL() is called.
+         @param aURI			URI of the object
+         @param aLUID		LUID of the object (if the adapter has earlier returned a
+         LUID to the DM Module). For new objects, this is the LUID
+         inherited through the parent node.
+         @param aObject		Data of the object.
+         @param aType		MIME type of the object
+         @param aStatusRef	Reference to correct command, i.e. this reference
+         must be used when calling the SetStatusL of this command
+         @publishedPartner
+         @prototype
+         */
+        virtual void UpdateLeafObjectL(const TDesC8& aURI,
+                const TDesC8& aLUID, const TDesC8& aObject,
+                const TDesC8& aType, TInt aStatusRef);
+
+        /**
+         The function creates new leaf objects, or replaces data in existing leaf
+         objects, in the case where data is large enough to be streamed. The
+         information about the success of the command should be returned by calling
+         SetStatusL function of MSmlDmCallback callback interface. This makes it
+         possible to buffer the commands.  However, all the status codes for buffered
+         commands must be returned at the latest when the CompleteOutstandingCmdsL()
+         of adapter is called.
+         @param aURI		URI of the object
+         @param aLUID		LUID of the object (if the adapter has earlier returned a
+         LUID to the DM Module). For new objects, this is the LUID
+         inherited through the parent node.
+         @param aStream	Data of the object. Adapter should create write stream
+         and return, when data is written to stream by DM agent,
+         StreamCommittedL() is called by DM engine
+         @param aType		MIME type of the object
+         @param aStatusRef	Reference to correct command, i.e. this reference
+         must be used when calling the SetStatusL of this
+         command.
+         @publishedPartner
+         @prototype
+         */
+        virtual void UpdateLeafObjectL(const TDesC8& aURI,
+                const TDesC8& aLUID, RWriteStream*& aStream,
+                const TDesC8& aType, TInt aStatusRef);
+
+        /**
+         The function deletes an object and its child objects. The SetStatusL
+         should be used as described in UpdateLeafObjectL()
+         @param aURI		URI of the object
+         @param aLUID		LUID of the object (if the adapter have earlier returned
+         LUID to the DM Module).
+         @param aStatusRef	Reference to correct command, i.e. this reference must
+         be used when calling the SetStatusL of this command.
+         @publishedPartner
+         @prototype
+         */
+        virtual void DeleteObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+                TInt aStatusRef);
+
+        /**
+         The function fetches data of a leaf object. The SetStatusL should be used
+         as described in UpdateLeafObjectL(). The data is returned by using the
+         SetResultsL function of MSmlCallback callback interface, and may be streamed.
+         @param aURI			URI of the object
+         @param aLUID			LUID of the object (if the adapter have earlier
+         returned LUID to the DM Module).   
+         @param aType 			MIME type of the object
+         @param aResultsRef	Reference to correct results, i.e. this reference
+         must be used when returning the result by calling
+         the SetResultsL.
+         @param aStatusRef		Reference to correct command, i.e. this reference
+         must be used when calling the SetStatusL of this
+         command.
+         @publishedPartner
+         @prototype
+         */
+        virtual void FetchLeafObjectL(const TDesC8& aURI,
+                const TDesC8& aLUID, const TDesC8& aType, TInt aResultsRef,
+                TInt aStatusRef);
+
+        /**
+         The function fetches the size of the data of a leaf object. The size is
+         in bytes, and must reflect the number of bytes that will be transferred
+         when the framework calls FetchLeafObjectL. The SetStatusL should be used
+         as described in FetchLeafObjectL(). The size value is returned by using
+         the SetResultsL function of MSmlCallback callback interface, and must be
+         a decimal integer expressed as a string, eg. "1234".
+         Results from this call MUST NOT be streamed.
+         @param aURI			URI of the object
+         @param aLUID			LUID of the object (if the adapter have earlier
+         returned LUID to the DM Module).   
+         @param aType 			MIME type of the object
+         @param aResultsRef	Reference to correct results, i.e. this reference
+         must be used when returning the result by calling
+         the SetResultsL.
+         @param aStatusRef		Reference to correct command, i.e. this reference
+         must be used when calling the SetStatusL of this
+         command.
+         @publishedPartner
+         @prototype
+         */
+        virtual void FetchLeafObjectSizeL(const TDesC8& aURI,
+                const TDesC8& aLUID, const TDesC8& aType, TInt aResultsRef,
+                TInt aStatusRef);
+        /**
+         The function fetches URI list. An adapter returns the list of URI segments
+         under the given URI be separated by slash ("/"). The URI segment names for
+         new objects must be given by the adapter.
+         The list is returned by calling the SetResultsL function of MSmlCallback
+         callback interface.	Results from this call MUST NOT be streamed.
+         @param aParentURI					URI of the parent object
+         @param aParentLUID				LUID of the parent object (if the
+         adapter have earlier returned LUID to
+         the DM Module).   
+         @param aPreviousURISegmentList	URI list with mapping LUID information,
+         which is known by DM engine. An adapter
+         can use this information when verifying
+         if old objects still exists. An adapter
+         also knows what objects are new to DM
+         engine and can provide LUID mapping for
+         them. aPreviousURISegmentList parameter
+         (see above) helps to recognise new
+         objects.
+         @param aResultsRef				Reference to correct results, i.e. this
+         reference must be used when returning
+         the result by calling the SetResultsL.
+         @param aStatusRef					Reference to correct command, i.e. this
+         reference must be used when calling the
+         SetStatusL of this command.
+         @publishedPartner
+         @prototype
+         */
+        virtual void ChildURIListL(const TDesC8& aURI, const TDesC8& aLUID,
+                const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
+                TInt aResultsRef, TInt aStatusRef);
+
+        /**
+         The function adds node object. In some cases an implementation of the
+         function may be empty function, if the node object does not need concrete
+         database update. Still this function may be helpful to an adapter, i.e. in
+         passing mapping LUID of the node to DM Module. The SetStatusL should be
+         used as described in UpdateLeafObjectL()
+         @param aURI			URI of the object
+         @param aParentLUID	LUID of the parent object (if the adapter have
+         earlier returned LUID to the DM Module).   
+         @param aStatusRef		Reference to correct command, i.e. this reference
+         must be used when calling the SetStatusL of this
+         command.
+         @publishedPartner
+         @prototype
+         */
+        virtual void AddNodeObjectL(const TDesC8& aURI,
+                const TDesC8& aParentLUID, TInt aStatusRef);
+
+        /**
+         The function implements execute command. The information about the success
+         of the command should be returned by calling SetStatusL function of
+         MSmlDmCallback callback interface. This makes it possible to buffer the
+         commands.
+         However, all the status codes for buffered commands must be returned at
+         the latest when the CompleteOutstandingCmdsL() of adapter is called.
+         @param aURI			URI of the command
+         @param aLUID			LUID of the object (if the adapter have earlier
+         returned LUID to the DM Module).   
+         @param aArgument		Argument for the command
+         @param aType			MIME type of the object 
+         @param aStatusRef		Reference to correct command, i.e. this reference
+         must be used when calling the SetStatusL of this
+         command.
+         @publishedPartner
+         @prototype
+         */
+        virtual void
+                ExecuteCommandL(const TDesC8& aURI, const TDesC8& aLUID,
+                        const TDesC8& aArgument, const TDesC8& aType,
+                        TInt aStatusRef);
+
+        /**
+         The function implements execute command. The information about the
+         success of the command should be returned by calling SetStatusL function
+         of MSmlDmCallback callback interface. This makes it possible to buffer the
+         commands.
+         However, all the status codes for buffered commands must be returned at
+         the latest when the CompleteOutstandingCmdsL() of adapter is called.
+         @param aURI			URI of the command
+         @param aLUID			LUID of the object (if the adapter have earlier
+         returned LUID to the DM Module).   
+         @param aStream		Argument for the command. Adapter should create
+         write stream and return, when data is written to
+         stream by DM agent, StreamCommittedL() is called by
+         DM engine
+         @param aType			MIME type of the object 
+         @param aStatusRef		Reference to correct command, i.e. this reference
+         must be used when calling the SetStatusL of this
+         command.
+         @publishedPartner
+         @prototype
+         */
+        virtual void ExecuteCommandL(const TDesC8& aURI, const TDesC8& aLUID,
+                RWriteStream*& aStream, const TDesC8& aType, TInt aStatusRef);
+
+        /**
+         The function implements copy command. The information about the success of
+         the command should be returned by calling SetStatusL function of
+         MSmlDmCallback callback interface. This makes it possible to buffer the
+         commands.
+         However, all the status codes for buffered commands must be returned at
+         the latest when the CompleteOutstandingCmdsL() of adapter is called.
+         @param aTargetURI		Target URI for the command
+         @param aSourceLUID	LUID of the target object (if one exists, and if the adapter
+         has	earlier returned a LUID to the DM Module).   
+         @param aSourceURI		Source URI for the command
+         @param aSourceLUID	LUID of the source object (if the adapter has
+         earlier returned a LUID to the DM Module).   
+         @param aType			MIME type of the objects
+         @param aStatusRef		Reference to correct command, i.e. this reference
+         must be used when calling the SetStatusL of this
+         command.
+         @publishedPartner
+         @prototype
+         */
+        virtual void CopyCommandL(const TDesC8& aTargetURI,
+                const TDesC8& aTargetLUID, const TDesC8& aSourceURI,
+                const TDesC8& aSourceLUID, const TDesC8& aType,
+                TInt aStatusRef);
+
+        /**
+         The function indicates start of Atomic command.
+         @publishedPartner
+         @prototype
+         */
+        virtual void StartAtomicL();
+
+        /**
+         The function indicates successful end of Atomic command. The adapter
+         should commit all changes issued between StartAtomicL() and
+         CommitAtomicL()
+         @publishedPartner
+         @prototype
+         */
+        virtual void CommitAtomicL();
+
+        /**
+         The function indicates unsuccessful end of Atomic command. The adapter
+         should rollback all changes issued between StartAtomicL() and
+         RollbackAtomicL(). If rollback fails for a command, adapter should use
+         SetStatusL() to indicate it.
+         @publishedPartner
+         @prototype
+         */
+        virtual void RollbackAtomicL();
+
+        /**
+         Returns ETrue if adapter supports streaming otherwise EFalse.
+         @param aItemSize size limit for stream usage
+         @return TBool ETrue for streaming support
+         @publishedPartner
+         @prototype
+         */
+        virtual TBool StreamingSupport(TInt& aItemSize);
+
+        /**
+         Called when stream returned from UpdateLeafObjectL or ExecuteCommandL has
+         been written to and committed. Not called when fetching item.
+         @publishedPartner
+         @prototype
+         */
+#ifdef __TARM_SYMBIAN_CONVERGENCY	
+        virtual void StreamCommittedL( RWriteStream& aStream );
+#else
+        virtual void StreamCommittedL();
+#endif	
+        /**
+         The function tells the adapter that all the commands of the message that
+         can be passed to the adapter have now been passed.  This indciates that
+         the adapter must supply status codes and results to any buffered commands.
+         This must be done at latest by the time this function returns.
+         This function is used at the end of SyncML messages, and during processing
+         of Atomic.   In the case of Atomic processing, the function will be
+         followed by a call to CommitAtomicL or RollbackAtomicL.
+         @publishedPartner
+         @prototype
+         */
+        virtual void CompleteOutstandingCmdsL();
+
+private:
+        CSCOMOAdapter(TAny* aDmCallback);
+        void ConstructL();
+        TInt DesToIntL(const TDesC8& aLuid);
+        HBufC8* IntToDes8LC(const TInt aLuid);
+
+        TBool CheckStateL(const TDeploymentComponent &aComp,
+                const TDesC8& aURI);
+        TBool CheckStateL(const TDesC8& aURI, const TDesC8& aLUID);
+        /**
+         * UpdateFlagFromMapping Maps a node name to internal attribute flag that
+         * 	is used by server to identify to data 
+         * @param aMapping	The SyncML node name
+         * @return  TDeplCompAttrType the attribute type
+         */
+        TDeplCompAttrType UpdateFlagFromMapping(const TDesC8& aMapping);
+
+        /**
+         * IdListL Looks up the given state user ids of deployment components,
+         * 	and places them to currentList in the format specified by SyncML spec 
+         * @param aState	The deployment component state in which we are interested
+         * @param aCurrentList The buffer where the results are placed
+         * @param aAppend Does the list possibly contain some items already
+         * @return  TError EOk if successful
+         */
+        TError IdListL(TDeploymentComponentState aState,
+                CBufBase &aCurrentList, TBool aAppend = EFalse);
+
+        /**
+         * DeliverOrDownloadL Depending on aURI, creates new delivery or download component
+         *
+         * @param aUserId	The name of dynamic node.
+         * @param aURI		The full URI
+         * @param aCnt		Count of URI segments
+         * @param aParentMapping	The parent data
+         * @param aStatus A reference to the error which will be set the status of the operation
+         * @return  TError EOk if successful
+         */
+        void DeliverOrDownloadL(const TDesC8 &aUserId, const TDesC8 &aURI,
+                TInt aCnt, const TDesC8 &aParentMapping,
+                MSmlDmAdapter::TError &aStatus);
+
+        /**
+         * Fills the node info in ddf structure
+         */
+        void
+                FillNodeInfoL(MSmlDmDDFObject& aNode,
+                        TSmlDmAccessTypes aAccTypes,
+                        MSmlDmDDFObject::TOccurence aOccurrence,
+                        MSmlDmDDFObject::TScope aScope,
+                        MSmlDmDDFObject::TDFFormat aFormat,
+                        const TDesC8& aDescription);
+
+        /**
+         * Fills the node info in ddf structure, without default mime type
+         */
+        void
+                FillNodeInfoNoDefaultMimeL(MSmlDmDDFObject& aNode,
+                        TSmlDmAccessTypes aAccTypes,
+                        MSmlDmDDFObject::TOccurence aOccurrence,
+                        MSmlDmDDFObject::TScope aScope,
+                        MSmlDmDDFObject::TDFFormat aFormat,
+                        const TDesC8& aDescription);
+
+        TBool IsImage(const TDesC8& aMime);
+        /**
+         Calls Callback().SetResultsL()
+         */
+        void SetResultsL(TInt aResultsRef, CBufBase& aObject,
+                const TDesC8& aType);
+        /**
+         Calls Callback().SetStatusL()
+         */
+        void SetStatusL(TInt aStatusRef, MSmlDmAdapter::TError aErrorCode);
+        //	TInt FindBuffered( const TDesC8 &aURI ) ;
+        RApplicationManagement &SessionL();
+        TDeploymentComponentState StateL(const TDesC8& aURI);
+
+        void CheckStateChangesL();
+        void CheckStateChangesInternalL();
+
+        TPtrC8 URISegsUpTo(const TDesC8& aURI, TInt aUpTo,
+                TBool aInclKeno=EFalse);
+
+        /**
+         * Helper method to move acl. Copies acl of node aFrom to acl of aTo,
+         * and removes acl from aFrom.
+         *
+         * @param aFrom The source uri
+         * @param aTo	The target uri
+         */
+        void MoveAclL(const TDesC8 &aFrom, const TDesC8 &aTo);
+
+        /**
+         * Helper method to move nodes in SCOMO tree
+         *
+         * 1. Sets mapping of aOriginal to null.
+         * 2. If aNewURI is null, constructs new uri depending on aTargetstate.
+         * 3. Sets mapping of aNewURI to aLUID
+         * 4. Moves acls of aOriginal to aNewURI (using MoveAclL)
+         *
+         * @param aOriginal The uri of original node to be moved
+         * @param aTargetstate The target state the node is moving to
+         * @param aLUID The luid of the original node
+         * @param aNewUri The new uri of the node (will be constructed and left to stack if null)
+         */
+        void SetMappingLC(const TDesC8 &aOriginal,
+                const TDeploymentComponentState aTargetstate,
+                const TDesC8 &aLUID, HBufC8 *&aNewUri);
+
+        /**
+         * Helper method to move nodes in SCOMO tree
+         *
+         * 1. Sets mapping of aOriginal to null.
+         * 2. Sets mapping of a uri constructed using aTargetState to aLUID
+         * 2. Moves acls of aOriginal to a uri constructed using aTargetState (using MoveAclL)
+         *
+         * @param aTargetstate The target state the node is moving to
+         * @param aLUID The luid of the original node
+         */
+        void SetMappingL(const TDesC8 &aOriginalURI,
+                const TDeploymentComponentState aTargetState,
+                const TDesC8 &aLUID);
+
+        /**
+         * Helper method to set DM LUID mappings directly database.
+         *
+         * @param aURI The uri of node whose mapping is to be set
+         * @param aLUID The new mapping value
+         * @return Possible database error - KErrNone if successful
+         */
+        TInt DirectSetMappingL(const TDesC8 &aURI, const TDesC8 &aLUID);
+
+	TInt DirectRemoveMappingL(const TDesC8 &aURI);
+
+        /**
+         * Helper method to get DM LUID mappings directly from database.
+         *
+         * @param aURI The uri of node whose mapping is to be found
+         * @return The luid mapping - Empty string if not found.
+         */
+        HBufC8 *DirectGetLuidAllocLC(const TDesC8 &aURI);
+
+        /**
+         * Helper method to perform install
+         *
+         * @param aLuidi The mapping value of component as integer
+         * @param aURI The uri of node that is to be installed
+         * @param aLUID The mapping value of component as text
+         * @param aTargetstate The target state the node is moving to (EDCSActive or EDCSInactive)
+         * @param aRet	The SyncML Error code - value will be updated according to success
+         */
+        void InstallL(const TUint aLuidi, const TDesC8& aURI,
+                const TDesC8& aLUID,
+                const TDeploymentComponentState aTargetState, TError &aRet);
+
+        /**
+         * Helper method to perform update
+         *
+         * @param aLuidi The mapping value of component as integer
+         * @param aURI The uri of node that is to be installed
+         * @param aLUID The mapping value of component as text
+         * @param aTargetstate The target state the node is moving to (EDCSActive or EDCSInactive)
+         * @param aRet	The SyncML Error code - value will be updated according to success
+         */
+        void UpdateL(const TUint aLuidi, const TDesC8& aURI,
+                const TDesC8& aSourceLUID,
+                const TDeploymentComponentState aTargetState, TError &aRet);
+        /**
+         maps symbian error code to DM error code as follows:
+         Kerrnone-> EOk
+         Kerrnotfound ->Enotfound
+         all oether -> EError
+         */
+        void DefaultMapError(const TInt aErr, TError &aRet,
+                const TDesC8& aDes = KNullDesC8);
+
+        /**
+         * Deactivates given component if given state is inactive
+         */
+        void DeactivateIfInactive(const TUint aLuidi,
+                const TDeploymentComponentState aTargetState);
+
+        /**
+         * Finds luid from app mgmt server to given userid
+         */
+        TUint32 GetLuidForUserIdL(const TDesC8 &aUserId,
+                const TDeploymentComponentState aState);
+
+        TUint32 GetLuidL(const TDesC8 &aDMLuid, const TDesC8 &aUserId,
+                const TDeploymentComponentState aState);
+
+        /**
+         * places result in current
+         * @param aParent The deployment component identifying uri 
+         * @param aMapping The user id part of the deployment component uri
+         * @param aLuid Internal id of the deployment compoennt
+         * @param aCurrentList The list that will get the data
+         * @param aStatus The syncml status
+         */
+        void GetComponentDataL(const TDesC8& aParent, const TDesC8& aMapping,
+                const TUint32 aLuid, CBufBase &aCurrentList,
+                CBufBase &currentMime, TError &aStatus);
+        /**
+         * returns luid of leaf node, or 0
+         */
+        TInt GetLeafLuidL(const TDesC8 &aURI, const TDesC8 & aParentMapping);
+        /**
+         * returns length of result
+         */
+        TInt GetSizeL(const TDeplCompAttrType aDataType, const TInt aLuid,
+                TError &aRet);
+
+        /**
+         * places installoptions of given aLuid to aBuf
+         */
+        void InstallOptionsDataL(const TUint32 aLuid,
+                const TDeplCompAttrType& aDataType, CBufBase &aBuf,
+                CBufBase *aRaw = NULL);
+
+        /**
+         * Gets the luid using GetLuidL, and updates aStatus to ENotFound if not found...
+         */
+        TUint32 GetLuid2L(const TDesC8 &aDMLuid, const TDesC8 &aUserId,
+                const TDeploymentComponentState aState, TError &aStatus);
+
+        /**
+         * Finds out correct download target based on download operation 
+         */
+        TDownloadTarget DownloadTargetL(const TDesC8& aOperation);
+
+        TPtrC8 LastURISeg(const TDesC8& aURI);
+        TInt DesToInt(const TDesC8& aLuid);
+
+#ifdef __AM_LASTERROR_NODE
+        void SetLastErrorL(const TDesC8& aLastError, const TInt aErr);
+        const TDesC8& LastError();
+        void SetErrorL(const TDesC8& aDes, const TInt aErr);
+#endif
+
+        /**
+         The function creates new leaf objects, or replaces data in existing leaf
+         objects. The information about the success of the command should be
+         returned by calling SetStatusL function of MSmlDmCallback callback
+         interface. This makes it possible to buffer the commands.  However, all
+         the status codes for buffered commands must be returned at the latest when
+         the adapter's CompleteOutstandingCmdsL() is called.
+         @param aURI			URI of the object
+         @param aLUID		LUID of the object (if the adapter has earlier returned a
+         LUID to the DM Module). For new objects, this is the LUID
+         inherited through the parent node.
+         @param aObject		Data of the object.
+         @param aType		MIME type of the object
+         @param aStatusRef	Reference to correct command, i.e. this reference
+         must be used when calling the SetStatusL of this command
+         @publishedPartner
+         @prototype
+         */
+        void _UpdateLeafObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+                const TDesC8& aObject, const TDesC8& aType, TInt aStatusRef,
+                MSmlDmAdapter::TError& aStatus);
+        /**
+         * The function creates new leaf objects, or replaces data in existing leaf
+         */
+        void CloseStreaming();
+
+        void GetServerInfoL(TSmlProfileId& aProfId, HBufC8*& aServerId) const;
+
+        void SendPendingGenericAlertL();
+
+        void ASyncReportL(TUint32 aLuid, const TDesC8& aArgument,
+                const TDownloadTarget aTarget, const TDesC8& aURI);
+
+        void SyncReportL(TUint32 aLuid, const TDesC8& aArgument,
+                const TDownloadTarget aTarget, const TDesC8& aURI, TError &aRet);
+	/**
+	 Checks if predefined node for Download object is in tree if not add to the tree 
+	*/
+	void CheckAndAddPredefinedNodeL();
+	/**
+	 Gets  predefined node for Download object from cenrep 
+	 */
+	void GetPredefinedNodeL(TDes8& aNode);
+	TInt GetAdapterValue();
+	void SetAdapterValue(TInt aAdapterValue);
+	TBool RecognizeMimeType(const TDesC8& aMimeType);
+
+private:
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+        RDmTree iDbSession;
+#else
+        RNSmlDMCallbackSession iDbSession; // to change acl location
+#endif
+
+        RApplicationManagement iManagement;
+        TBool iSessionOpened;
+        TAMCommandBuffer iBuffer;
+        TBool iInAtomic;
+        TBool iUpdated; // have we checked changed state DCs?
+        // Streaming API support
+        TBool iStreamOpen;
+        RFileWriteStream iStream;
+        TInt iStatusRef;
+        RFs iStreamRFs;
+        RFile iStreamFile;
+        TBool iIsStreamedContent;
+        HBufC8* iStreamedURI;
+        HBufC8* iStreamedLuid;
+        HBufC8* iStreamedType;
+        TBool iCertRequired;
+        TBool iTrustAdded;
+        CSCOMOAdapterDb* iAMdb;
+        TUint iInternalId;
+#ifdef __AM_LASTERROR_NODE
+        HBufC8 *iLastError;
+#endif
+
+        HBufC8 *iUriDel;
+        };
+
+    } // namespace
+#endif // __AMDMADAPTER_H__
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/inc/omascomoadapterdb.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,193 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+ *
+ * Description:  Implementation of applicationmanagement components
+ *
+*/
+
+#ifndef __SCOMOADAPTERDB_H
+#define __SCOMOADAPTERDB_H
+
+// INCLUDE FILES
+
+#include <e32std.h>
+#include <e32base.h>
+#include <d32dbms.h>
+#include <f32file.h>
+#include <SyncMLDef.h>
+
+// CONSTANTS
+
+// null final result value
+const TInt KAMNullResult = 0;
+
+// Database name & location
+const TInt KAMAdapterDbDrive = EDriveC;
+const TUid KAMPolicyUID =
+    {
+    0x20021335
+    };
+const TInt KAMMaxPkgURLLength( 2048);
+const TInt KAMMaxPkgNameLength( 80);
+const TInt KAMMaxPkgVersionLength( 80);
+
+_LIT( KDBMSSecureID, "secure[20021335]" );
+
+_LIT( KAMAdapterDbName, "c:TARMAppMgmtAdapterDB.db" );
+
+// Table and column names
+_LIT( KTableAMMgmtObject, "AMMgmtObject" );
+_LIT( KAMMgmtObjectId, "Id" );
+_LIT( KAMMgmtObjectProfileId, "ProfileId" );
+_LIT( KAMMgmtObjectServerId, "ServerId" );
+_LIT( KAMMgmtObjectRetryCount, "RetryCount");
+
+// SQL statements
+_LIT( KCreateAMMgmtObjectTable, "CREATE TABLE AMMgmtObject ( Id \
+COUNTER NOT NULL,  ProfileId INTEGER, ServerId CHAR(%d), RetryCount INTEGER" );
+
+_LIT( KGetAMMgmtObject, "SELECT * FROM AMMgmtObject WHERE Id = %d" );
+
+_LIT( KGetUnfinishedAMMgmtObjectByServerId, "SELECT * FROM AMMgmtObject \
+WHERE Id = %d AND ServerId = '%S'" );
+
+_LIT( KDeleteAMMgmtObject,"DELETE FROM AMMgmtObject WHERE Id = %d");
+
+// Max. lengths of string fields in AMMgmtObject
+const TInt KMaxMgmtUriLength = 60;
+const TInt KMaxServerIdLength = 150;
+const TInt KMaxCorrelatorLength = 150;
+
+// Estimate of url size used in max row size (OOD checks)
+const TInt KPkgURLLengthEstimate = 350;
+
+// space needed for above integers in buffer
+const TInt KAMMgmtObjectIntLength = 4;
+
+// space needed for an integer in buffer
+const TInt KAMMgmtObjectIntegerLength = 10;
+
+// Size of empty AM database in bytes (+ additional treshold)
+const TInt KAMAdapterEmptyDbSize = 350;
+
+// Estimated maximum size of AMMgmtObject table row (+ additional treshold)
+const TInt KMaxAMMgmtObjectRowSize = KAMMaxPkgNameLength
+        + KAMMaxPkgVersionLength + KPkgURLLengthEstimate + KMaxMgmtUriLength
+        + KMaxServerIdLength + KMaxCorrelatorLength + 115;
+
+// TYPEDEFS
+typedef TInt TDmAMObjectId;
+typedef RArray<TDmAMObjectId> RDmAMObjectArray;
+
+_LIT(NCol1, "Id");
+_LIT(NCol2, "LUID");
+_LIT(NCol3, "ProfileId");
+_LIT(NCol4, "ServerId");
+_LIT(NCol5, "Correlator");
+_LIT(NCol6, "SourceURI");
+_LIT(NCol7, "RetryCount");
+
+class CAMDbItem : public CBase
+    {
+public:
+    static CAMDbItem* NewL();
+    ~CAMDbItem();
+
+    TInt id;
+    TUint32 iLUID;
+    TInt iProfileId;
+
+    HBufC8* iServerID;
+    HBufC8* iCorrelator;
+    HBufC8* iSourceURI;
+    TInt iRetryCount;
+
+    };
+
+// CLASS DECLARATION
+
+/**
+ *  CSCOMOAdapterDb provides an interface for accessing AM database.
+ *  
+ *  @lib SCOMOAdapter.lib
+ *  
+ */
+class CSCOMOAdapterDb : public CBase
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @return A pointer to the newly created instance.
+     */
+    static CSCOMOAdapterDb* NewL();
+
+    /**
+     * Two-phased constructor. Pushes the pointer onto the CleanupStack.
+     * @return A pointer to the newly created instance.
+     */
+    static CSCOMOAdapterDb* NewLC();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CSCOMOAdapterDb();
+
+    void CreateTableL(RDbDatabase& aDatabase);
+
+    void CreateandOpenL(TParse& name);
+
+    TBool DeleteFromDatabaseL(TUint32 aLuid);
+
+    void SaveToDatabaseL(TInt& aIndex, TUint32 aLuid, TInt aProfileid,
+            TInt aRetryCount, const TDesC8& aSourceURI,
+            const TDesC8& aServerid, const TDesC8& aCorrelator);
+
+    void ReadItemsL(RPointerArray<CAMDbItem>& aItemArray, TDesC& aSqlQuery);
+
+    void ReadDbItemsL(RPointerArray<CAMDbItem>& aItemArray);
+
+    void GetEntryForServerIDL(RPointerArray<CAMDbItem>& aItemArray, TDesC8& aValue);
+    
+    void UpdateRetryCountForLuidL(TInt aLuid, TInt aRetryCount);
+    
+    TInt GetRetryCountForLuidL(TInt aLuid);
+    
+    void BeginDatabaseTransaction();
+
+    void CommitDatabaseTransaction();
+    
+    void PrepareLuidQuery(TInt aLuid, TDes& aSqlQuery);
+
+
+private:
+
+    void ConstructL();
+
+    CSCOMOAdapterDb();
+
+private:
+
+    RDbNamedDatabase iDatabase;
+    RFs iFsSession;
+    RDbs iRdbSession;
+
+    RDbTable iAMObjectTable;
+    CDbColSet* iColSet;
+    RDbView iView;
+
+    };
+
+#endif // __AMADAPTERDB_H   
+// End of File
Binary file applicationmanagement/omascomoadapter/src/20021335.SPD has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/src/20021335.txt	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,10 @@
+[database]
+read
+capability = ReadDeviceData
+write
+capability = WriteDeviceData
+schema
+capability = WriteDeviceData
+
+[backup]
+SID = 101F8597
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/src/nsmldmiapmatcher.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,235 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 applicationmanagement components
+ *
+*/
+
+
+// ------------------------------------------------------------------------------------------------
+// Includes
+// ------------------------------------------------------------------------------------------------
+
+#include <utf.h>
+#include "nsmldmiapmatcher.h"
+#include <smldmadapter.h>
+#include <featmgr.h>
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewL( MSmlDmCallback* aDmCallback )
+// ------------------------------------------------------------------------------------------------
+CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewL( 
+	MSmlDmCallback* aDmCallback )
+    {
+    CNSmlDMIAPMatcher* self = CNSmlDMIAPMatcher::NewLC( aDmCallback );	
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewLC( MSmlDmCallback* aDmCallback )
+// ------------------------------------------------------------------------------------------------
+CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewLC(
+	MSmlDmCallback* aDmCallback )
+    {
+    CNSmlDMIAPMatcher* self = new( ELeave ) CNSmlDMIAPMatcher;
+    CleanupStack::PushL( self );
+    self->ConstructL( aDmCallback );
+    return self;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// void CNSmlDMIAPMatcher::ConstructL( MSmlDmCallback* aDmCallback )
+// ------------------------------------------------------------------------------------------------
+void CNSmlDMIAPMatcher::ConstructL( MSmlDmCallback* aDmCallback )
+    {
+    iCallback = aDmCallback;
+    FeatureManager::InitializeLibL();
+    iFeatMgrInitialized = ETrue;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDMIAPMatcher::~CNSmlDMIAPMatcher()
+// ------------------------------------------------------------------------------------------------
+CNSmlDMIAPMatcher::~CNSmlDMIAPMatcher()
+    {
+    	if(iFeatMgrInitialized)
+    		{
+    			FeatureManager::UnInitializeLib();
+    		}
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlDMIAPMatcher::IAPIdFromURIL( const TDesC8& aURI )
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlDMIAPMatcher::IAPIdFromURIL( const TDesC8& aURI )
+    {
+    TInt iapId(KErrNotFound);
+
+	MSmlDmAdapter::TError status;
+	CBufBase* allIAPs = CBufFlat::NewL(16);
+	CleanupStack::PushL(allIAPs);
+	iCallback->FetchLinkL( GetConRef(), *allIAPs, status );
+	TPtrC8 uri = RemoveDotSlash(aURI);
+
+    if( status == MSmlDmAdapter::EOk &&
+        uri.Find(GetConRef()) == 0 &&
+        allIAPs->Ptr(0).Find(LastURISeg(uri))>=0)
+        {
+        HBufC8* luid = iCallback->GetLuidAllocL( uri ); 
+
+        if ( luid->Length() )
+            {
+            iapId = DesToInt(*luid);
+            } 
+        delete luid;
+        }
+
+    CleanupStack::PopAndDestroy(allIAPs);
+    
+    return iapId;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// HBufC8* CNSmlDMIAPMatcher::URIFromIAPIdL( TInt aIAPId )
+// ------------------------------------------------------------------------------------------------
+HBufC8* CNSmlDMIAPMatcher::URIFromIAPIdL( TInt aIAPId )
+    {
+    CBufBase *allIAPs = CBufFlat::NewL(16);
+	CleanupStack::PushL(allIAPs);
+    MSmlDmAdapter::TError status;
+
+    iCallback->FetchLinkL( GetConRef(), *allIAPs, status );
+
+    if ( status == MSmlDmAdapter::EOk )
+        {   
+        TInt index(0);
+        TInt segStart(0);
+
+        while ( index != KErrNotFound)
+            {                
+            TPtrC8 allIAPsptr = allIAPs->Ptr(segStart).Mid(0);
+            index = allIAPsptr.Locate('/');
+            HBufC8* uriSeg = 0;
+
+            if ( index == KErrNotFound )
+                {
+                TPtrC8 uriSeg8Ptr = allIAPs->Ptr(segStart);
+                uriSeg = uriSeg8Ptr.AllocLC();
+                }
+            else
+                {
+                TPtrC8 uriSeg8Ptr = allIAPs->Ptr(segStart).Mid( 0, index );
+                uriSeg = uriSeg8Ptr.AllocLC();
+                }
+
+            HBufC8* uri = HBufC8::NewLC( GetConRef().Length() + 1 +
+            	uriSeg->Length() );
+            	
+			TPtr8 uriPtr = uri->Des();
+			uriPtr.Format( GetConRef());
+			uriPtr.Append( KNSmlDMSeparator8 );
+			uriPtr.Append( *uriSeg );
+			HBufC8* luid = iCallback->GetLuidAllocL( uriPtr );
+			CleanupStack::PushL(luid);
+
+			if ( luid->Length() > 0 )
+				{				
+				TInt iapId = DesToInt(luid->Des());
+				if ( iapId == aIAPId )
+					{
+		            CleanupStack::PopAndDestroy();  //luid
+		            CleanupStack::Pop();  //uri
+		            CleanupStack::PopAndDestroy(2);  //uriSeg, allIAPs
+		            return uri;
+					}
+				}
+            CleanupStack::PopAndDestroy(3); // luid, uri, uriSeg
+
+            segStart += index + 1;
+            }        
+        }
+
+    CleanupStack::PopAndDestroy(); // allIAPs
+
+    return 0;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlDMIAPMatcher::DesToInt(const TDesC& aLuid)
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlDMIAPMatcher::DesToInt(const TDesC8& aLuid) const
+	{
+	TLex8 lex(aLuid);
+	TInt value = 0;
+	lex.Val(value);
+	return value;
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 CNSmlDMIAPMatcher::RemoveDotSlash(const TDesC8& aURI) const
+// ------------------------------------------------------------------------------------------------
+TPtrC8 CNSmlDMIAPMatcher::RemoveDotSlash(const TDesC8& aURI) const
+	{
+	if(aURI.Find(KNSmlDMIAPUriDotSlash)==0)
+		{
+		return aURI.Right( aURI.Length()-KNSmlDMIAPUriDotSlash().Length() );
+		}
+	else
+		{
+		return aURI;
+		}
+	}
+
+// ------------------------------------------------------------------------------------------------
+// CNSmlDMIAPMatcher::TPtrC8 LastURISeg(const TDesC8& aURI)
+// Returns only the last uri segemnt
+// ------------------------------------------------------------------------------------------------
+TPtrC8 CNSmlDMIAPMatcher::LastURISeg(const TDesC8& aURI) const
+	{
+	TInt i;
+	for(i=aURI.Length()-1;i>=0;i--)
+		{
+		if(aURI[i]==KNSmlDMSlash)
+			{
+			break;
+			}
+		}
+	if(i==0)
+		{
+		return aURI;
+		}
+	else
+		{
+		return aURI.Mid(i+1);
+		}
+	}
+	
+// ------------------------------------------------------------------------------------------------
+// CNSmlDMIAPMatcher::const TDesC8& GetConRef()
+// Returns the connection reference
+// ------------------------------------------------------------------------------------------------
+const TDesC8& CNSmlDMIAPMatcher::GetConRef()
+	{
+	if(FeatureManager::FeatureSupported(KFeatureIdFfDmConnmoAdapter))
+		{
+			return KNSmlDMConnMOIAPUri();
+		}
+	else
+		{
+			return KNSmlDMIAPUri();
+		}	
+  }
+  
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/src/nsmldmuri.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,208 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+ *
+ * Description:  Implementation of applicationmanagement components
+ *
+*/
+
+
+#include "nsmldmuri.h"
+
+// ===========================================================================
+// NSmlDmURI
+// ===========================================================================
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::ParentURI(const TDesC8& aURI)
+// returns parent uri, i.e. removes last uri segment
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::ParentURI(const TDesC8& aURI)
+	{
+	TBool onlyOneSeg = ETrue;
+	TInt i;
+	for(i=aURI.Length()-1;i>=0;i--)
+		{
+		if(aURI[i]==KNSmlDMUriSeparator)
+			{
+			onlyOneSeg = EFalse;
+			break;
+			}
+		}
+	if(onlyOneSeg)
+		{
+		return KNSmlDmRootUri();
+		}
+	else
+		{
+		return aURI.Left(i);
+		}
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::LastURISeg(const TDesC8& aURI)
+// Returns only the last uri segemnt
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::LastURISeg(const TDesC8& aURI)
+	{
+	TInt i;
+	for(i=aURI.Length()-1;i>=0;i--)
+		{
+		if(aURI[i]==KNSmlDMUriSeparator)
+			{
+			break;
+			}
+		}
+	if(i==0)
+		{
+		return aURI;
+		}
+	else
+		{
+		return aURI.Mid(i+1);
+		}
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::RemoveDotSlash(const TDesC8& aURI)
+// return uri without dot and slash in start
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::RemoveDotSlash(const TDesC8& aURI)
+	{
+
+	TInt offset = 0;
+	TInt endSlash = 0;
+
+	if(aURI.Find(KNSmlDmUriDotSlash)==0)
+		{
+		offset = 2;
+		}
+	else
+		{
+		return aURI;
+		}
+
+	if(aURI.Length()>2&&aURI[aURI.Length()-1]==KNSmlDMUriSeparator)
+		{
+		endSlash = 1;
+		}
+
+	return aURI.Mid(offset,aURI.Length()-endSlash-offset);
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::RemoveProp(const TDesC8& aURI)
+// removes property from the uri
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::RemoveProp(const TDesC8& aURI)
+	{
+	TInt offset = aURI.Find(KNSmlDmQuestionMark);
+	if(offset!=KErrNotFound)
+		{
+		return aURI.Left(offset); 
+		}
+	return aURI;
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::RemoveLastSeg(const TDesC8& aURI)
+// Removes last uri segment
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::RemoveLastSeg(const TDesC8& aURI)
+	{
+	TInt i;
+	for(i=aURI.Length()-1;i>=0;i--)
+		{
+		if(aURI[i]==KNSmlDMUriSeparator)
+			{
+			break;
+			}
+		}
+
+	if(i>0)
+		{
+		return aURI.Left(i);
+		}
+	else
+		{
+		return KNullDesC8();
+		}
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::URISeg(const TDesC8& aURI,TInt aLocation)
+// Returns the aLocation:th URI segment
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::URISeg(const TDesC8& aURI,TInt aLocation)
+	{
+	TInt begin=0;
+	TInt end;
+	TInt num=0;
+
+	for(end=0;end<aURI.Length();end++)
+		{
+		if(aURI[end]==KNSmlDMUriSeparator||end==aURI.Length()-1)
+			{
+			num++;
+			if(num==aLocation)
+				{
+				break;
+				}
+			else
+				{
+				begin = end;
+				}
+			}
+		}
+	if(begin==0)
+		{
+		if(end==aURI.Length()-1)
+			{
+			return aURI;
+			}
+		else
+			{
+			return aURI.Left(end);
+			}
+		}
+	else
+		{
+		if(end==aURI.Length()-1)
+			{
+			return aURI.Mid(begin+1,end-begin);
+			}
+		else
+			{
+			return aURI.Mid(begin+1,end-begin-1);
+			}
+		}
+	}
+
+
+// ------------------------------------------------------------------------------------------------
+// TInt NSmlDmURI::NumOfURISegs(const TDesC8& aURI)
+// Returns the num of uri segs
+// ------------------------------------------------------------------------------------------------
+TInt NSmlDmURI::NumOfURISegs(const TDesC8& aURI)
+	{
+	TInt numOfURISegs = 1;
+	for(TInt i=0;i<aURI.Length();i++)
+		{
+		if(aURI[i]==KNSmlDMUriSeparator)
+			{
+			numOfURISegs++;
+			}
+		}
+	return numOfURISegs;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/src/omascomoadapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,4502 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 applicationmanagement components
+ *
+*/
+
+
+
+/**
+
+ 1. Remember the applications managed by Corporate Admin Role certificate
+ 1.1 They must be removed during rfs
+ 1.2 Others must be left as is (applications at least must be left)
+
+ */
+
+
+#define __AM_CHECKSTATE_CHANGES // uncomment to enable dynamic acl
+#include <badesca.h>
+#include <fbs.h>
+#include <s32file.h> 
+#include "omascomoadapter.h"
+#include <implementationproxy.h> // For TImplementationProxy definition
+#include <f32file.h>
+#include "nsmldmuri.h"
+#include "nsmldmiapmatcher.h"
+#include "debug.h"
+#include "amprivateCRKeys.h"
+#include <centralrepository.h>
+#include "aminstalloptions.h"
+#include <featmgr.h>
+#include <apgtask.h>
+#include <w32std.h>
+
+#include <SyncMLClient.h>
+#include <SyncMLClientDM.h>
+#include <e32property.h>
+#include <centralrepository.h>
+#include <DevManInternalCRKeys.h>
+
+#include "NSmlPrivateAPI.h"
+
+#include "nsmldmconst.h"
+#include "ampskeys.h"
+
+#include "nsmldmtreedbclient.h"
+//#include "SyncService.h"
+#include "amprivateCRKeys.h"
+#include <e32cmn.h>
+#include <SWInstDefs.h>
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+#include <dmtreenode.h>
+#include <devman.h>
+#include "nsmldmuri.h"
+
+// Constants
+_LIT8( KDeployedURI, "./SCOMO/Inventory/Deployed/" );
+_LIT8( KDeliveredURI, "./SCOMO/Inventory/Delivered/" );
+_LIT8( KDownloadURI, "./SCOMO/Download/" );
+#else
+#include <nsmldmuri.h>
+
+// Constants
+_LIT8( KDeployedURI, "SCOMO/Inventory/Deployed/" );
+_LIT8( KDeliveredURI, "SCOMO/Inventory/Delivered/" );
+_LIT8( KDownloadURI, "SCOMO/Download/" );
+#endif
+
+#ifdef __NSML_DEBUG__
+#pragma message("NSml Debugging is ON!")
+#else
+#endif
+
+using namespace NApplicationManagement;
+
+_LIT8( KAMStateValueActive, "20" );
+_LIT8( KAMStateValueInactive, "10" );
+_LIT8( KAMStateValueDelivered, "10" );
+
+_LIT8( KSisxMimeType, "x-epoc/x-sisx-app" );
+_LIT8( KSisMimeType, "application/vnd.symbian.install" );
+_LIT8( KPipMimeType, "application/x-pip" );
+_LIT8( KJadMIMEType, "text/vnd.sun.j2me.app-descriptor" );
+_LIT8( KJarMIMEType, "application/java-archive" );
+_LIT8( KJavaMIMEType, "application/java" );
+
+
+
+const TUint8 KNSmlDMAMSeparatorDef = 0x2f; //forward slash
+#ifdef __AM_LASTERROR_NODE
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+_LIT8( KAMLastErrorURI, "./SCOMO/Ext/LastError" );
+#else
+_LIT8( KAMLastErrorURI, "SCOMO/Ext/LastError" );
+#endif
+_LIT8( KStdError, "Error %d" );
+
+#define MAPERROR(x,y,z) DefaultMapError(x,y,z)
+#else
+
+#define MAPERROR(x,y,z) DefaultMapError(x,y)
+#endif
+
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter* CSCOMOAdapter::NewL( )
+// ------------------------------------------------------------------------------------------------
+CSCOMOAdapter* CSCOMOAdapter::NewL(MSmlDmCallback* aDmCallback)
+    {
+    RDEBUG("CSCOMOAdapter::NewL(): begin");
+
+    CSCOMOAdapter* self = NewLC(aDmCallback);
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter* CSCOMOAdapter::NewLC( )
+// ------------------------------------------------------------------------------------------------
+CSCOMOAdapter* CSCOMOAdapter::NewLC(MSmlDmCallback* aDmCallback)
+    {
+    CSCOMOAdapter* self = new( ELeave ) CSCOMOAdapter( aDmCallback );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::CSCOMOAdapter()
+// ------------------------------------------------------------------------------------------------
+CSCOMOAdapter::CSCOMOAdapter(TAny* aEcomArguments) :
+    CSmlDmAdapter(aEcomArguments), iSessionOpened(EFalse), iBuffer( 8),
+            iInAtomic(EFalse), iUpdated(EFalse), iIsStreamedContent(EFalse)
+    {
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::~CSCOMOAdapter()
+// ------------------------------------------------------------------------------------------------
+CSCOMOAdapter::~CSCOMOAdapter()
+    {
+    RDEBUG( "CSCOMOAdapter::~CSCOMOAdapter" );
+    iDbSession.Close();
+    iManagement.Close(); // make sure we're closed
+    iSessionOpened = EFalse;
+    iBuffer.Close();
+
+    CloseStreaming(); // Ensures that no streams are left open and that the temporary file is removed
+
+    delete iStreamedURI;
+    delete iStreamedLuid;
+    delete iStreamedType;
+
+#ifdef __AM_LASTERROR_NODE
+    delete iLastError;
+#endif
+
+    if (iAMdb)
+        delete iAMdb;
+
+    if (iUriDel)
+        delete iUriDel;
+    RDEBUG( "CSCOMOAdapter::~CSCOMOAdapter end" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::DDFVersionL()
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::DDFVersionL(CBufBase& aDDFVersion)
+    {
+    aDDFVersion.InsertL( 0, KAMDDFVersion);
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::DDFStructureL()
+//
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::DDFStructureL(MSmlDmDDFObject& aDDF)
+    {
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): begin" );
+
+    TSmlDmAccessTypes accessTypesGet;
+    accessTypesGet.SetGet();
+
+    TSmlDmAccessTypes accessTypesExec;
+    accessTypesExec.SetExec();
+
+    TSmlDmAccessTypes accessTypesAdd;
+    accessTypesAdd.SetAdd();
+
+    TSmlDmAccessTypes accessTypesExecReplace = accessTypesExec;
+    accessTypesExecReplace.SetReplace();
+
+    TSmlDmAccessTypes accessTypesGetAdd = accessTypesGet;
+    accessTypesGetAdd.SetAdd();
+
+    TSmlDmAccessTypes accessTypesGetReplace = accessTypesGet;
+    accessTypesGetReplace.SetGet();
+
+    TSmlDmAccessTypes accessTypesGetAddReplace = accessTypesGetAdd;
+    accessTypesGetAddReplace.SetReplace();
+
+    TSmlDmAccessTypes accessTypesGetAddReplaceDelete =
+            accessTypesGetAddReplace;
+    accessTypesGetAddReplaceDelete.SetDelete();
+
+    TSmlDmAccessTypes accessTypesAddReplace = 
+	    accessTypesAdd;
+    accessTypesAddReplace.SetReplace();
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step1" );
+
+    /*
+     Node: ./SCOMO
+     AM node is the common parent to all application management functionality nodes. 
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Get
+     Values: N/A
+     */
+    //MSmlDmDDFObject& root = aDDF.AddChildObjectGroupL();
+    MSmlDmDDFObject& am = aDDF.AddChildObjectL(KAMNodeName);
+    FillNodeInfoL(am, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMNodeDescription);
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 2" );
+
+    /*
+     Node: ./SCOMO/Inventory
+     This node is start node to application inventory. 
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Get
+     Values: N/A
+     */
+    MSmlDmDDFObject& inv = am.AddChildObjectL(KAMInventoryNodeName);
+    FillNodeInfoL(inv, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMInventoryNodeDescription);
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 3" );
+
+    /*
+     Node: ./SCOMO/Inventory/Delivered
+     This is node under which applications that are delivered but not installed are found.
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Get, Add
+     Values: N/A
+     */
+    MSmlDmDDFObject& del = inv.AddChildObjectL(KAMDeliveredNodeName);
+    FillNodeInfoL(del, accessTypesGetAdd, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMDeliveredNodeDescription);
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 4" );
+
+    /*
+     Node: ./SCOMO/Inventory/Deployed
+     This is a node under which active applications are found.
+     The child node descriptions are same as Delivered sibling node, except that <X> cannot be created, data node does not exist and there's no InstallOpts leaf.
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Get
+     Values: N/A
+     */
+
+    MSmlDmDDFObject& ac = inv.AddChildObjectL(KAMDeployedNodeName);
+    FillNodeInfoL(ac, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMDeployedNodeDescription);
+
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 5" );
+    /*
+     Node: ./SCOMO/Inventory/Delivered/<X>
+     This dynamic node is placeholder applications that are in Delivered state. 
+     Support: Mandatory
+     Occurs: ZeroOrMore
+     Format: Node
+     Access Types: Get, Add, Replace, Delete
+     Values: N/A
+     */
+    MSmlDmDDFObject& deldyna = del.AddChildObjectGroupL();
+    FillNodeInfoL(deldyna, accessTypesGetAddReplaceDelete,
+            MSmlDmDDFObject::EZeroOrMore, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KAMDeliveredDynaNodeDescription);
+
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 6" );
+    /*
+     Node: ./SCOMO/Inventory/Delivered/<X>/PkgID
+     This leaf node holds an identifier for an application.
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Get, Add, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& delid = deldyna.AddChildObjectL(KAMPkgIDNodeName);
+    FillNodeInfoL(delid, accessTypesGetAddReplace, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EChr,
+            KAMPkgIDNodeDescription);
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 7" );
+    /*
+     Node: ./SCOMO/Inventory/Delivered/<X>/Name
+     This leaf node holds name of an application. 
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Get ( + Add, Replace access within Delivered node only)
+     Values: N/A
+     */
+    MSmlDmDDFObject& delname = deldyna.AddChildObjectL(KAMNameNodeName);
+    FillNodeInfoL(delname, accessTypesGetAddReplace,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+            MSmlDmDDFObject::EChr, KAMNameNodeDescription);
+
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 8" );
+    /*
+     Node: ./SCM/Inventory/Delivered/<X>/Status
+     This leaf node holds the status of the Delivered. The client updates the node value. 
+     The values are typically error codes of Operations done on delivered node
+     Support: Mandatory 
+     Occurs: One
+     Format: Int
+     Access Types: Get
+     Values: N/A
+     */
+    MSmlDmDDFObject& delstatus = deldyna.AddChildObjectL(KAMStatusNodeName);
+    FillNodeInfoL(delstatus, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EInt,
+            KAMStatusNodeDescription);
+
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 9" );
+    /*
+     Node: ./SCOMO/Inventory/Delivered/<X>/PkgType
+     This leaf node holds an identifier for an application.
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Get 
+     Values: N/A
+     */
+    MSmlDmDDFObject& delpkgtype = deldyna.AddChildObjectL(KAMPkgTypeNodeName);
+    FillNodeInfoL(delpkgtype, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EChr,
+            KAMPkgTypeNodeDescription);
+    
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 10" );
+    /*
+     Node: ./SCOMO/Inventory/Delivered/<X>/Data
+     This leaf node holds the data of an application. 
+     Support: Mandatory
+     Occurs: One
+     Format: Bin
+     Access Types: Add, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& delda = deldyna.AddChildObjectL(KAMDataNodeName);
+    FillNodeInfoNoDefaultMimeL(delda, accessTypesAddReplace,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+            MSmlDmDDFObject::EBin, KAMDataNodeDescription);
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 11" );
+
+    delda.AddDFTypeMimeTypeL(KSisxMimeType);
+    delda.AddDFTypeMimeTypeL(KSisMimeType);
+    delda.AddDFTypeMimeTypeL(KPipMimeType);
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 12" );
+
+    FeatureManager::InitializeLibL();
+    if (FeatureManager::FeatureSupported(KFeatureIdJavaMIDP20) )
+        {
+	    RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 13" );
+        delda.AddDFTypeMimeTypeL(KJadMIMEType);
+        delda.AddDFTypeMimeTypeL(KJarMIMEType);
+        delda.AddDFTypeMimeTypeL(KJavaMIMEType);
+        }
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 14" );
+    FeatureManager::UnInitializeLib();
+
+    /*
+     Node: ./SCOMO/Inventory/Delivered/<X>/Description
+     This leaf node holds the possible metadata of an application. Descriptor can be for example such a data that is required by the actual data in the Data leaf, but for some reason they cannot be bundled into same package. An example is Java JAR and JAD file combination, in which JAD file could be placed in MetaData and JAR in Data leaf.
+     Support: Optional
+     Occurs: One
+     Format: Bin
+     Access Types: Add, Get, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& delmd = deldyna.AddChildObjectL(KAMDescriptionNodeName);
+    FillNodeInfoL(delmd, accessTypesGetAddReplace,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+            MSmlDmDDFObject::EBin, KAMDescriptorNodeDescription);
+
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 15" );
+     /*
+     Node: ./SCOMO/Inventory/Delivered/<X>/State
+     This leaf node holds state value of an application. 
+     Support: ?
+     Occurs: One
+     Format: Chr
+     Access Types: Get 
+     Values: N/A
+     */
+    MSmlDmDDFObject& delstate =
+            deldyna.AddChildObjectL(KAMStateValueNodeName);
+    FillNodeInfoL(delstate, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EChr,
+            KAMStateValueNodeDescription);
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 16" );
+    /*
+     Node: ./SCOMO/Inventory/Delivered/<X>/Operations
+     This is a node that allows vendors to extend functionality.
+     Support: Optional
+     Occurs: One
+     Format: Node
+     Access Types: Get, Replace, Add, Delete
+     Values: N/A
+     */
+    MSmlDmDDFObject& delop = deldyna.AddChildObjectL(KAMOperationsNodeName);
+    FillNodeInfoL(delop, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMOperationsNodeDescription);
+
+    /*
+     Node: ./SCOMO/Inventory/Delivered/<X>/Operations/Install
+     Exec command causes device to install a delivered application. The data inside 
+     exec command refers to the application to be installed. 
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Exec, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& loinst = delop.AddChildObjectL(KAMInstallNodeName);
+    FillNodeInfoL(loinst, accessTypesExecReplace, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMInstallNodeDescription);
+
+    /*
+     Node: ./SCOMO/Inventory/Delivered/<X>/Operations/InstallInactive
+     Exec command causes device to install a delivered application. The data inside 
+     exec command refers to the application to be installed. 
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Exec, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& loinstact =
+            delop.AddChildObjectL(KAMInstallInactiveNodeName);
+    FillNodeInfoL(loinstact, accessTypesExecReplace, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMInstallInactivateNodeDescription);
+
+    
+    /*
+     Node: ./SCOMO/Inventory/Delivered/<X>/Operations/Remove
+     Exec command causes device to remove an application. The data inside exec command refers to the application to be removed. The application must be in Inactive state in order for remove to be successful.
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Exec, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& lorem = delop.AddChildObjectL(KAMRemoveNodeName);
+    FillNodeInfoL(lorem, accessTypesExecReplace, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMRemoveNodeDescription);
+
+    /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
+     DEPLOYED
+     *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 17" );
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>
+     This dynamic node is placeholder applications that are in Inactive state. 
+     Support: Mandatory
+     Occurs: ZeroOrMore
+     Format: Node
+     Access Types: Get, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& depldyna = ac.AddChildObjectGroupL();
+    FillNodeInfoL(depldyna, accessTypesGetReplace,
+            MSmlDmDDFObject::EZeroOrMore, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KAMDeployedDynaNodeDescription);
+
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>/ID
+     This leaf node holds an identifier for an application. This cannot be changed.
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Get
+     Values: N/A
+     */
+    MSmlDmDDFObject& deplid = depldyna.AddChildObjectL(KAMIDNodeName);
+    FillNodeInfoL(deplid, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EChr,
+            KAMIDNodeDescription);
+
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>/Name
+     This leaf node holds name of an application.
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Get, Add, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& deplname = depldyna.AddChildObjectL(KAMNameNodeName);
+    FillNodeInfoL(deplname, accessTypesGetAddReplace,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+            MSmlDmDDFObject::EChr, KAMNameNodeDescription);
+
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>/Version
+     This leaf node holds the version of an application.
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Get, Add, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& deplver = depldyna.AddChildObjectL(KAMVersionNodeName);
+    FillNodeInfoL(deplver, accessTypesGetAddReplace,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+            MSmlDmDDFObject::EChr, KAMVersionNodeDescription);
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 18" );
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>/Description
+     This leaf node holds the version of an application.
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Get, Add, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& depldesc = depldyna.AddChildObjectL(KAMDescriptionNodeName);
+    FillNodeInfoL(depldesc, accessTypesGetAddReplace,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+            MSmlDmDDFObject::EChr, KAMDescriptionNodeDescription);        
+            
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>/PkgIDRef
+     This leaf node holds an identifier for an application. This cannot be changed.
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Get
+     Values: N/A
+     */
+    MSmlDmDDFObject& deplidref = depldyna.AddChildObjectL(KAMPkgIDRefNodeName);
+    FillNodeInfoL(deplidref, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EChr,
+            KAMPkgIDRefNodeDescription);
+
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>/Status
+     This leaf node holds the status of the Deployed. The client updates the node value. 
+     The values are typically error codes of Operations done on deployed node
+     Support: Mandatory 
+     Occurs: One
+     Format: Int
+     Access Types: Get
+     Values: N/A
+     */
+    MSmlDmDDFObject& deplstatus = depldyna.AddChildObjectL(KAMStatusNodeName);
+    FillNodeInfoL(deplstatus, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EInt,
+            KAMStatusNodeDescription);
+
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>/State
+     This leaf node holds state value of an application. 
+     Support: ?
+     Occurs: One
+     Format: Chr
+     Access Types: Get 
+     Values: N/A
+     */
+    MSmlDmDDFObject& deplstate =
+            depldyna.AddChildObjectL(KAMStateValueNodeName);
+    FillNodeInfoL(deplstate, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EChr,
+            KAMStateValueNodeDescription);
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 19" );
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>/Operations
+     This is a node that allows vendors to extend functionality.
+     Support: Optional
+     Occurs: One
+     Format: Node
+     Access Types: Get, Replace, Add, Delete
+     Values: N/A
+
+     */
+    MSmlDmDDFObject& deplop = depldyna.AddChildObjectL(KAMOperationsNodeName);
+    FillNodeInfoL(deplop, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMOperationsNodeDescription);
+
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>/Operations/Remove
+     Exec command causes device to remove an application. The data inside exec command 
+     refers to the application to be removed. The application must be in Inactive state 
+     in order for remove to be successful.
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Exec, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& deplrem = deplop.AddChildObjectL(KAMRemoveNodeName);
+    FillNodeInfoL(deplrem, accessTypesExecReplace, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMRemoveNodeDescription);
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 20" );
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>/Operations/Activate
+     Exec command causes device to activate an application. 
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Exec, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& deplac = deplop.AddChildObjectL(KAMActivateNodeName);
+    FillNodeInfoL(deplac, accessTypesExecReplace, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMActivateNodeDescription);
+
+    /*
+     Node: ./SCOMO/Inventory/Deployed/<X>/Operations/Deactivate
+     Exec command causes device to deactivate an application. 
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Exec, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& depldeac = deplop.AddChildObjectL(KAMDeActivateNodeName);
+    FillNodeInfoL(depldeac, accessTypesExecReplace, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMDeActivateNodeDescription);
+
+    /*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
+     DOWNLOAD
+     *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
+
+    /*
+     Node: ./SCOMO/Download
+     This node is a root node for application download functionality. In practice download 
+     works so that admin adds nodes under this node, and they are automatically moved to 
+     Inventory/Delivered when the download has been finished. Running get command targeting 
+     to this node returns a list of pending downloads. 
+     Support: Mandatory 
+     Occurs: One
+     Format: Node
+     Access Types: Get, Add, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& dow = am.AddChildObjectL(KAMDownloadNodeName);
+    FillNodeInfoL(dow, accessTypesGetAddReplace, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMDownloadNodeDescription);
+
+    /*
+     Node: ./SCOMO/Download/<X>
+     This node is a placeholder for identifier of an application that is to be downloaded. 
+     Support: Mandatory 
+     Occurs: One
+     Format: Node
+     Access Types: Get, Add, Replace, Delete
+     Values: N/A
+     */
+    MSmlDmDDFObject& dowdyna = dow.AddChildObjectGroupL();
+    FillNodeInfoL(dowdyna, accessTypesGetAddReplaceDelete,
+            MSmlDmDDFObject::EZeroOrMore, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KAMDownloadDynaNodeDescription);
+
+    /*
+     Node: ./SCOMO/Download/<X>/PkgID
+     This leaf node holds an identifier for an application. 
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Get
+     Values: N/A
+     */
+    MSmlDmDDFObject& dowid = dowdyna.AddChildObjectL(KAMPkgIDNodeName);
+    FillNodeInfoL(dowid, accessTypesGetAddReplace, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EChr,
+            KAMPkgIDNodeDescription);
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 21" );
+    /*
+     Node: ./SCOMO/Download/<X>/Name
+     This leaf node holds name of an application. 
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Add, Get, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& downame = dowdyna.AddChildObjectL(KAMNameNodeName);
+    FillNodeInfoL(downame, accessTypesGetAddReplace,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+            MSmlDmDDFObject::EChr, KAMNameNodeDescription);
+
+    
+    /*
+     Node: ./SCOMO/Download/<X>/PkgURL
+     This leaf node holds the URL from which the application should be downloaded.
+     Support: Mandatory 
+     Occurs: One
+     Format: Chr
+     Access Types: Add, Get, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& dowuri = dowdyna.AddChildObjectL(KAMURINodeName);
+    FillNodeInfoL(dowuri, accessTypesGetAddReplace,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+            MSmlDmDDFObject::EChr, KAMURINodeDescription);
+            
+    /*
+     Node: /SCOMO/Download/<X>/PkgType
+     This leaf node holds an identifier for an application.
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Add, Get, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& dowpkgtype = dowdyna.AddChildObjectL(KAMPkgTypeNodeName);
+    FillNodeInfoL(dowpkgtype, accessTypesGetAddReplace, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EChr,
+            KAMPkgTypeNodeDescription);
+
+    /*
+     Node: ./SCOMO/Download/<X>/Status
+     This leaf node holds the status of the download. The client updates the node value. The values are typically error codes of download protocol. Initially after the URI leaf is filled, this will get value 100, and will be replaced by one.
+     Support: Optional 
+     Occurs: One
+     Format: Chr
+     Access Types: Get
+     Values: N/A
+     */
+    MSmlDmDDFObject& dowstat = dowdyna.AddChildObjectL(KAMStatusNodeName);
+    FillNodeInfoL(dowstat, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EChr,
+            KAMStatusNodeDescription);
+
+    /*
+     Node: ./SCOMO/Download/<X>/Description
+     This leaf node holds the version of an application. 
+     Support: Mandatory
+     Occurs: One
+     Format: Chr
+     Access Types: Add, Get, Replace
+     Values: N/A
+     */
+    MSmlDmDDFObject& dowver = dowdyna.AddChildObjectL(KAMDescriptionNodeName);
+    FillNodeInfoL(dowver, accessTypesGetAddReplace,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EPermanent,
+            MSmlDmDDFObject::EChr, KAMDescriptionNodeDescription);
+    
+    
+    /*
+     Node: ./SCOMO/Download/<X>/Operations
+     This is a node that holds the operation nodes.
+     Support: Optional
+     Occurs: One
+     Format: Node
+     Access Types: Get, Replace, Add, Delete
+     Values: N/A
+
+     */
+    MSmlDmDDFObject& dowop = dowdyna.AddChildObjectL(KAMOperationsNodeName);
+    FillNodeInfoL(dowop, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMOperationsNodeDescription);
+
+    /*
+     Node: ./SCOMO/Download/<X>/Operations/Download
+     Exec command causes device to download an application. The dynamic node specifies the application to be downloaded. 
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Exec
+     Values: N/A
+     */
+    MSmlDmDDFObject& dowdown =
+            dowop.AddChildObjectL(KAMDownloadOperationNodeName);
+    FillNodeInfoL(dowdown, accessTypesExecReplace, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMDownloadOperationNodeDescription);
+
+    /*
+     Node: ./SCOMO/Download/<X>/Operations/DownloadInstall
+     Exec command causes device to download and install an application. The dynamic node specifies the application to be downloaded. 
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Exec
+     Values: N/A
+     */
+    MSmlDmDDFObject& dowdowni =
+            dowop.AddChildObjectL(KAMDownloadAndInstallNodeName);
+    FillNodeInfoL(dowdowni, accessTypesExec, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMDownloadAndInstallOperationNodeDescription);
+
+    /*
+     Node: ./SCOMO/Download/<X>/Operations/DownloadInstallInactive
+     Exec command causes device to download and install and activate an application. The dynamic node specifies the application to be downloaded. 
+     Support: Mandatory
+     Occurs: One
+     Format: Node
+     Access Types: Exec
+     Values: N/A
+     */
+    MSmlDmDDFObject& dowdownia =
+            dowop.AddChildObjectL(KAMDownloadAndInstallAndInActivateNodeName);
+    FillNodeInfoL(dowdownia, accessTypesExec, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMDownloadAndInstallAndInActivateNodeName);
+
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 22" );
+#ifdef __AM_LASTERROR_NODE
+    MSmlDmDDFObject& amext = am.AddChildObjectL(KAMExtNodeName);
+    FillNodeInfoL(amext, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode,
+            KAMExtNodeDescription);
+
+    MSmlDmDDFObject& amerr = amext.AddChildObjectL(KAMLastErrorNodeName);
+    FillNodeInfoL(amerr, accessTypesGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EChr,
+            KAMLastErrorDescription);
+#endif
+
+    // Ignore generic alert error status if any otherwise adapter fails to load 
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 23" );
+    TRAP_IGNORE(SendPendingGenericAlertL());
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 24" );
+    //if (GetAdapterValue() == KAMSCOMOAdapter)
+        {
+		RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 25" );
+        CheckStateChangesL();
+        SetAdapterValue(KAMDefaultValue);
+        }
+	RDEBUG( "CSCOMOAdapter::DDFStructureL(): Step 26" );
+    CheckAndAddPredefinedNodeL();
+    RDEBUG( "CSCOMOAdapter::DDFStructureL(): end" );
+    }
+
+void CSCOMOAdapter::SendPendingGenericAlertL()
+    {
+
+    // get information of the remote DM server
+    TSmlProfileId profId = 0;
+    HBufC8* serverId= NULL;
+    TBuf8<KMaxSizeString> scomometatype;
+    TBuf8<KMaxSizeString> scomometaformat;
+    TBuf8<KMaxSizeString> scomomark;
+
+    TBuf8<512> targetURIGet;
+
+    TUint32 internalid = KErrNone;
+    TInt finalresult = KErrNone;
+    TInt i =0;
+
+    // Get all the generic alert parameters from cenrep
+    // to construct generic alert message
+    CRepository *repository=CRepository::NewLC ( KCRUidPrivateApplicationManagementKeys );
+    repository->Get(KSCOMOMetaTypeKey,scomometatype);
+    repository->Get(KSCOMOMetaFormatKey,scomometaformat);
+    repository->Get(KSCOMOMark,scomomark);
+    CleanupStack::PopAndDestroy();
+    
+    // Retrive server info of current DM Session
+
+    GetServerInfoL(profId, serverId);
+    CleanupStack::PushL(serverId);
+
+    RPointerArray<CAMDbItem> genericalerts;
+    
+
+    // Get generic alert entry from Database for particular server ID.
+    TRAPD(err, iAMdb->GetEntryForServerIDL(genericalerts, *serverId));
+    
+    
+    // Send Pending generic alerts for server
+    
+    for(i=0; i<genericalerts.Count(); i++)
+    {
+    	
+    if (genericalerts.Count()!= 0 && err == KErrNone)
+        {  
+
+	
+       
+            internalid = genericalerts[i]->iLUID;
+           
+            // Get Target URI and Final Generic Alert result from App. Mgmt. Server 
+            // database.
+
+            TRAPD(err, SessionL().GetFinalResultsForGAL(internalid, finalresult,
+                    targetURIGet));
+                    
+            // If data in SCOMO DB is inconsistent with AM Server DB or
+            // if it exceeds retry count then delete that entry from adapter
+            // and server database
+            
+            if(finalresult <= KErrNone || err!=KErrNone)
+            {
+            	iAMdb->DeleteFromDatabaseL(internalid);
+            	User::Leave(KErrGeneral);
+            }
+	         
+            
+            TBuf8<6> dataresult;
+            dataresult.Num(finalresult);
+            
+            TPtrC8 mapping(NSmlDmURI::LastURISeg(targetURIGet) );
+            
+            
+            TInt retryupdate = iAMdb->GetRetryCountForLuidL(internalid);
+            
+            // If retryupdate in Zero then delete its entry from 
+            // database.
+            
+            if(retryupdate == KErrNone)
+            {
+            iAMdb->DeleteFromDatabaseL(internalid);
+            SessionL().GenericAlertSentL(internalid);
+            User::Leave(KErrCompletion);	
+            }
+            
+            // Decrement the retry count and update in database for
+            // that internalid.
+            iAMdb->UpdateRetryCountForLuidL(internalid, --retryupdate);    
+            
+            
+
+            // open handle to private api
+
+            RNSmlPrivateAPI privateAPI;
+            privateAPI.OpenL();
+            CleanupClosePushL(privateAPI);
+            
+            RArray<CNSmlDMAlertItem> iItemArray;
+            
+
+    		CNSmlDMAlertItem* item = new (ELeave) CNSmlDMAlertItem ;
+    		
+    		HBufC8 *data = HBufC8::NewL(1024);
+            
+            TPtr8 ptr = data->Des();
+            //ptr.Append(KDataStart);
+            ptr.Append(KResultCodeStart);
+            ptr.Append(dataresult);
+            ptr.Append(KResultCodeEnd);
+            ptr.Append(KIdentifierStart);
+            ptr.Append(mapping);
+            ptr.Append(KIdentifierEnd);
+            //ptr.Append(KDataEnd);
+
+            HBufC8 *sourceuri = genericalerts[i]->iSourceURI;
+    		
+    		item->iSource = sourceuri;
+
+			HBufC8 *targeturi = targetURIGet.AllocL();
+    		
+    		item->iTarget = targeturi;
+    		
+    		HBufC8 *metatype = scomometatype.AllocL();
+    		            
+    		item->iMetaType = metatype;
+    		            
+    		HBufC8 *metaformat = scomometaformat.AllocL();         
+
+    		item->iMetaFormat = metaformat;
+
+    		HBufC8 *metamark = scomomark.AllocL();
+    		            
+    		item->iMetaMark = metamark;
+    
+    		item->iData = data;
+    
+    		iItemArray.AppendL(*item);
+            
+            TRAP_IGNORE(privateAPI.AddDMGenericAlertRequestL(              
+                    *genericalerts[i]->iCorrelator,iItemArray ));
+                    
+                    
+            delete data;
+            
+            delete metamark;
+            
+            delete metaformat;
+            
+            delete metatype;
+            
+            delete targeturi;
+            delete item;
+                    
+            iItemArray.Reset();			
+			iItemArray.Close();
+            CleanupStack::PopAndDestroy( &privateAPI);
+            }
+        }
+    genericalerts.ResetAndDestroy();
+    CleanupStack::PopAndDestroy(); //serverid
+
+
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::SessionL()
+// ------------------------------------------------------------------------------------------------
+RApplicationManagement &CSCOMOAdapter::SessionL()
+    {
+    if ( !iSessionOpened)
+        {
+        TCertInfo info;
+
+        const TUid KCentralRepositoryUid =
+            {
+            0x10207843
+            };
+        const TInt KCertKey = 0x01;
+        CRepository *re= NULL;
+        TRAPD( errx, re = CRepository::NewL ( KCentralRepositoryUid ) );
+        if (errx == KErrNone && re)
+            {
+            TPckg<TCertInfo> pcert(info);
+            errx = re->Get(KCertKey, pcert) ;
+
+            RDEBUG_2("aCertInfo.iFingerprint.Length() is  %u",info.iFingerprint.Length() );
+            if (errx == KErrNone)
+                {
+                RDEBUG("CSCOMOAdapter::SessionL() errx == KErrNone");
+                }
+            else
+                {
+                if (errx != KErrNotFound)
+                    {
+                    RDEBUG("CSCOMOAdapter::SessionL() errx != KErrNotFound");
+                    }
+                else
+                    {
+                    RDEBUG("CSCOMOAdapter::SessionL() errx == KErrNotFound");
+                    }
+
+                }
+            delete re;
+            }
+
+        if (errx == KErrNotFound || !iCertRequired)
+            {
+            RDEBUG("CSCOMOAdapter::SessionL() calling iManagement.Connect()");
+            User::LeaveIfError(iManagement.Connect() );
+            iSessionOpened = ETrue;
+            iTrustAdded = EFalse;
+            }
+        else
+            {
+            RDEBUG("CSCOMOAdapter::SessionL() calling iManagement.Connect( info )");
+            User::LeaveIfError(iManagement.Connect(info) );
+            iSessionOpened = ETrue;
+            iTrustAdded = ETrue;
+            }
+        }
+    return iManagement;
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::UpdateLeafObjectL()
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::UpdateLeafObjectL(const TDesC8& aURI,
+        const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& aType,
+        TInt aStatusRef)
+    {
+    RDEBUG8_4("CSCOMOAdapter::UpdateLeafObjectL(): begin, '%S', '%S' '%S'", &aURI, &aLUID, &aType );
+
+    MSmlDmAdapter::TError status = EOk;
+    SetAdapterValue(KAMSCOMOAdapter);
+    _UpdateLeafObjectL(aURI, aLUID, aObject, aType, aStatusRef, status);
+
+    SetStatusL(aStatusRef, status);
+    if (status == EOk)
+        {
+        if (iInAtomic)
+            {
+            iBuffer.Append(TAMCommandBufferElement(aStatusRef, aURI) );
+            }
+        }
+    RDEBUG_2("CSCOMOAdapter::UpdateLeafObjectL(): end (%d)", status);
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::UpdateLeafObjectL()
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::_UpdateLeafObjectL(const TDesC8& aURI,
+        const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& aType,
+        TInt /*aStatusRef*/, MSmlDmAdapter::TError& aStatus)
+    {
+    RDEBUG("CSCOMOAdapter::_UpdateLeafObjectL(): begin");
+
+    CheckStateChangesL();
+
+    TError status(EError);
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash( aURI );
+    TInt numSeqs( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+    TPtrC8 mapping( NSmlDmURI::LastURISeg( uriPtrc ) );
+    TPtrC8 parent( NSmlDmURI::RemoveLastSeg( uriPtrc ) );
+#else
+    TInt numSeqs(NSmlDmURI::NumOfURISegs(aURI) );
+    TPtrC8 mapping(NSmlDmURI::LastURISeg(aURI) );
+    TPtrC8 parent(NSmlDmURI::RemoveLastSeg(aURI) );
+#endif
+
+    if (mapping == KAMNameNodeName)
+        {
+        if (aObject.Size() > KDeploymentComponentNameMaxLength)
+            {
+            aStatus = ETooLargeObject;
+            return;
+            }
+        }
+    else
+        if (mapping == KAMVersionNodeName)
+            {
+            if (aObject.Size() > KDeploymentComponentVersionMaxLength)
+                {
+                aStatus = ETooLargeObject;
+                return;
+                }
+            }
+        else
+	if (mapping == KAMURINodeName)
+	  {
+	   if (aObject.Size() > KMaxUrlLength)
+                {
+                aStatus = ETooLargeObject;
+                return;
+                }
+
+	  }
+        else
+            if (mapping == KAMConRefNodeName)
+                {
+                if (aObject.Size() > KMaxConRef)
+                    {
+                    aStatus = ETooLargeObject;
+                    return;
+                    }
+                }
+            else
+                if (mapping == KAMDescriptionNodeName)
+                    {
+                    if (aObject.Size() > 512)
+                        {
+                        aStatus = ETooLargeObject;
+                        return;
+                        }
+                    }
+            else
+               if(mapping == KAMPkgIDNodeName)
+               {
+               if(aObject.Size() > 256)
+               {
+               	aStatus = ETooLargeObject;
+                        return;
+               }
+               }
+            else
+              if(mapping == KAMPkgTypeNodeName)
+              {
+                // ADD check for PkgType MIME Type if not supported 
+                // error status should be sent and operation should stop
+                
+              	if(aObject.Size() >100)
+              	{
+              		aStatus = ETooLargeObject;
+                        return;
+              	}
+              }
+             
+
+    TPtrC8 grandParent(NSmlDmURI::RemoveLastSeg(parent) );
+    TPtrC8 grandParentMapping(NSmlDmURI::LastURISeg(grandParent) );
+    RApplicationManagement &session = SessionL();
+    TDeploymentComponentState state(EDCSNone);
+    if (numSeqs == 4 || numSeqs == 5)
+        {
+        if (numSeqs == 4)
+            {
+            state = EDCSDownload;
+            }
+        else
+            {
+            if (grandParentMapping == KAMDeliveredNodeName)
+                {
+                state = EDCSDelivered;
+                }
+            else
+                if (grandParentMapping == KAMDeployedNodeName)
+                    {
+                    state = EDCSActive;
+                    }
+                else
+                    {
+                    RDEBUG8_3( "CSCOMOAdapter::UpdateLeafObjectL(): ILLEGAL LEVEL %d NODE %S", numSeqs, &aURI );
+                    User::Leave(KErrArgument);
+                    }
+            }
+        }
+    else
+        {
+        RDEBUG8_3("CSCOMOAdapter::UpdateLeafObjectL(): ILLEGAL LEVEL %d NODE %S", numSeqs, &aURI );
+        }
+    if (state == EDCSDelivered || state == EDCSDownload ||state == EDCSActive
+            ||state == EDCSInactive)
+        {
+        if (aLUID != KNullDesC8)
+            {
+            TInt iluid(DesToIntL(aLUID) );
+            TDeploymentComponent comp;
+            TInt err(session.DeploymentComponent(iluid, comp) );
+            if (err == KErrNone)
+                {
+                
+                // Set default component install options for particular iluid.
+                TPtrC8 obj;
+                TAMInstallOptions opts; 
+                TAMInstallOptionsPckg optsb(opts);
+                
+                TBuf<KMaxSizeString> drive;
+                
+                CRepository *rep = CRepository::NewLC(KCRUidPrivateApplicationManagementKeys );
+                rep->Get(KDefaultDriveForInstall,drive);
+                CleanupStack::PopAndDestroy();
+                
+                //TChar KDefaultDrive = 'c';
+                TChar KDefaultDrive = drive[0]; 
+                
+	 			opts.iOptions.iUpgrade = SwiUI::EPolicyAllowed;
+     			opts.iOptions.iOptionalItems = SwiUI::EPolicyAllowed;
+     			opts.iOptions.iOCSP = SwiUI::EPolicyAllowed;
+     			opts.iOptions.iIgnoreOCSPWarnings = SwiUI::EPolicyAllowed;
+					
+     			opts.iOptions.iUntrusted = SwiUI::EPolicyAllowed;
+     			opts.iOptions.iPackageInfo = SwiUI::EPolicyAllowed;
+     			opts.iOptions.iCapabilities = SwiUI::EPolicyAllowed;
+     			opts.iOptions.iKillApp = SwiUI::EPolicyAllowed;
+     			opts.iOptions.iOverwrite = SwiUI::EPolicyAllowed;
+     			opts.iOptions.iDownload = SwiUI::EPolicyAllowed;
+     			opts.iOptions.iDrive = KDefaultDrive;
+     			opts.iOptions.iLang = ELangNone;
+     			opts.iOptions.iUsePhoneLang = EFalse ;
+     			
+     			obj.Set(optsb);
+                
+                TRAP_IGNORE( session.UpdateDeploymentComponentL( iluid, EDCInstallOptions, obj ) );
+                
+                
+                TDeplCompAttrType fl(UpdateFlagFromMapping(mapping) );
+
+                if (mapping == KAMDataNodeName || mapping
+                        == KAMDescriptorNodeName)
+                    {
+                    TInt erx(KErrNone);
+                    if ((mapping == KAMDataNodeName) &&(RecognizeMimeType(aType)== EFalse))
+                        {
+                        User::Leave(EInvalidObject);
+                        }
+                    if (iIsStreamedContent)
+                        {
+                        CloseStreaming();
+                        TRAP( erx, session.UpdateDeploymentComponentStreamedDataL( iluid, fl, aType ) );
+                        }
+                    else
+                        {
+                        // 
+                        TRAP( erx, session.UpdateDeploymentComponentDataL( iluid, fl, aObject, aType ) );
+                        }
+                    MAPERROR( erx, status, _L8("Update Delivered Data or metadata %d") );
+                    }
+                else
+                    {
+                    if (fl != EDCNone)
+                        {
+                        TPtrC8 obj;
+                        TAMInstallOptions opts;
+                        TAMInstallOptionsPckg optsb(opts);
+                        TPckgBuf<TInt> iap;
+                        if (fl == EDCInstallOptions)
+                            {
+                            }
+                        else
+                            if (fl == EDCConRef)
+                                {
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+
+                                //CNSmlDMIAPMatcher* iapfinder = CNSmlDMIAPMatcher::NewLC( &Callback() );
+                                //TInt i( iapfinder->IAPIdFromURIL( aObject ) );
+                                //CleanupStack::PopAndDestroy( iapfinder );
+                                //iap() = i;
+                                CArrayFix<TSmlDmMappingInfo>* mapArray = new CArrayFixFlat<TSmlDmMappingInfo>(4);
+                                CleanupStack::PushL(mapArray);
+
+                                Callback().GetMappingInfoListL( KNSmlDMMMSSlashIAPUri,*mapArray );
+
+                                TInt iapValue = KErrNotFound;
+                                TSmlDmMappingInfo mapInfo;
+
+                                for(TInt i = 0;i<mapArray->Count();i++)
+                                    {
+                                    if(LastURISeg(opts.iConRef)==mapArray->At(i).iURISeg)
+                                        {
+                                        iapValue=DesToInt(mapArray->At(i).iURISegLUID);
+                                        break;
+                                        }
+                                    }
+                                iap() = iapValue;
+                                mapArray->Reset();
+                                CleanupStack::PopAndDestroy(); //mapArray
+
+#else
+                                CNSmlDMIAPMatcher
+                                        * iapfinder =
+                                                CNSmlDMIAPMatcher::NewLC( &Callback() );
+                                TInt i(iapfinder->IAPIdFromURIL(aObject) );
+                                CleanupStack::PopAndDestroy(iapfinder);
+                                iap() = i;
+#endif
+                                obj.Set(iap);
+                                }
+                            else
+                                {
+                                obj.Set(aObject);
+                                }
+                        TRAPD( erx, session.UpdateDeploymentComponentL( iluid, fl, obj ) )
+                        ;
+                        MAPERROR( erx, status, _L8("Update some attribute %d") );
+                        }
+                    else
+                        {
+                        status = ENotFound;
+                        RDEBUG( "CSCOMOAdapter::UpdateLeafObjectL(): Unknown Target leaf" );
+                        }
+                    }
+                }
+            else
+                {
+                RDEBUG_3( "CSCOMOAdapter::UpdateLeafObjectL(): FAILED TO GET COMPONENT OF ID %d: %d" , iluid, err );
+                status = ENotFound;
+                }
+            }
+        else
+            {
+            RDEBUG8_2( "CSCOMOAdapter::UpdateLeafObjectL(): Faild to get luid allocation and find buffered for '%S'", &parent );
+            status = ENotFound;
+            }
+        }
+    else
+        {
+        RDEBUG8_2( "CSCOMOAdapter::UpdateLeafObjectL(): WARNING Tried to update illegal state leaf! '%S'", &grandParentMapping );
+        }
+
+    aStatus = status;
+
+    RDEBUG("CSCOMOAdapter::_UpdateLeafObjectL(): end");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::UpdateLeafObjectL
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::UpdateLeafObjectL(const TDesC8& aURI,
+        const TDesC8& aLUID, RWriteStream*& aStream, const TDesC8& aType,
+        TInt aStatusRef)
+    {
+    RDEBUG8_4("CSCOMOAdapter::UpdateLeafObjectL() aStream: begin, '%S', '%S' '%S'", &aURI, &aLUID, &aType );
+
+    TError status(CSmlDmAdapter::EOk);
+
+    if (iStreamedURI)
+        {
+        delete iStreamedURI;
+        iStreamedURI = NULL;
+        }
+    iStreamedURI = aURI.AllocL();
+
+    if (iStreamedLuid)
+        {
+        delete iStreamedLuid;
+        iStreamedLuid = NULL;
+        }
+    iStreamedLuid = aLUID.AllocL();
+
+    if (iStreamedType)
+        {
+        delete iStreamedType;
+        iStreamedType = NULL;
+        }
+    iStreamedType = aType.AllocL();
+
+    if (!iStreamOpen)
+        {
+        RApplicationManagement &session = SessionL();
+        TDeplCompAttrType attrType;
+        TPtrC8 mapping(NSmlDmURI::LastURISeg(aURI) );
+        TDeplCompAttrType fl(UpdateFlagFromMapping(mapping) );
+        if (mapping == KAMDataNodeName)
+            {
+            attrType = EDCData;
+            }
+        else
+            if (mapping == KAMDescriptorNodeName)
+                {
+                attrType = EDCMetaData;
+                }
+            else
+                {
+                RDEBUG8_2("CSCOMOAdapter::UpdateLeafObjectL(): Unknown mapping: (%S)", &mapping);
+                status = CSmlDmAdapter::EError;
+                }
+
+        if (status == CSmlDmAdapter::EOk)
+            {
+            TInt iluid(DesToIntL(aLUID) );
+            session.DeploymentComponentTempInstFileL(iluid, iStreamFile,
+                    attrType);
+            iStream.Attach(iStreamFile);
+            aStream = &iStream;
+            iStreamOpen = ETrue;
+            iIsStreamedContent = ETrue;
+            }
+        }
+    if ( !iInAtomic)
+        {
+        iStatusRef = aStatusRef;
+        Callback().SetStatusL(aStatusRef, status);
+        }
+    else
+        {
+        iBuffer.Append(TAMCommandBufferElement(aStatusRef, aURI) );
+        }
+
+    RDEBUG("CSCOMOAdapter::UpdateLeafObjectL() aStream : end");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::UpdateFlagFromMapping( const TDesC8& aMapping )
+// ------------------------------------------------------------------------------------------------
+TDeplCompAttrType CSCOMOAdapter::UpdateFlagFromMapping(const TDesC8& aMapping)
+    {
+
+    TDeplCompAttrType res;
+    if (aMapping == KAMIDNodeName)
+        {
+        res = EDCId;
+        }
+    else
+        if (aMapping == KAMNameNodeName)
+            {
+            res = EDCName;
+            }
+        else
+            if (aMapping == KAMVersionNodeName)
+                {
+                res = EDCVersion;
+                }
+            else
+                if (aMapping == KAMStateValueNodeName)
+                    {
+                    res = EDCStateValue;
+                    }
+                else
+                    if (aMapping == KAMInstallOptsNodeName)
+                        {
+                        res = EDCInstallOptions;
+                        }
+                    else
+                        if (aMapping == KAMDescriptorNodeName)
+                            {
+                            res = EDCMetaData;
+                            }
+                        else
+                            if (aMapping == KAMDataNodeName)
+                                {
+                                res = EDCData;
+                                }
+                            else
+                                if (aMapping == KAMURINodeName)
+                                    {
+                                    res = EDCDownloadURI;
+                                    }
+                                else
+                                    if (aMapping == KAMStatusNodeName)
+                                        {
+                                         res = EDCStatus;
+                                        }
+                                    else
+                                        if (aMapping == KAMConRefNodeName)
+                                            {
+                                            res = EDCConRef;
+                                            }
+                                        else
+                                            if (aMapping
+                                                    == KAMDescriptionNodeName)
+                                                {
+                                                res = EDCDescriptionRef;
+                                                }
+                                              else
+                                                if(aMapping == KAMPkgIDNodeName)
+                                                {
+                                                	res = EDCPkgID;
+                                                }
+                                                else
+                                                if(aMapping == KAMPkgTypeNodeName)
+                                                {
+                                                	res = EDCPkgType;
+                                                }
+                                                
+
+                                            else
+                                                {
+                                                //User::Leave( KErrArgument );
+                                                res = EDCNone;
+                                                }
+    return res;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::GetLuidForUserIdL( const TDesC8 &aUserId, 
+//		const TDeploymentComponentState aState )
+// ------------------------------------------------------------------------------------------------	
+TUint32 CSCOMOAdapter::GetLuidForUserIdL(const TDesC8 &aUserId,
+        const TDeploymentComponentState aState)
+    {
+    TUint32 ret( 0);
+    if (aState != EDCSNone)
+        {
+        RElementIdArray array;
+        TInt err(SessionL().DeploymentComponentIdsL(array, aState) );
+        if (err == KErrNone)
+            {
+            CleanupClosePushL(array);
+            TInt count(array.Count() );
+            for (TInt i( 0); i < count && ret == 0; i++)
+                {
+                TUint32 el = array[i];
+                TDCUserId dc;
+                SessionL().DeploymentComponentUserIdL(el, dc);
+                if (dc == aUserId)
+                    {
+                    ret = el;
+                    }
+                }
+            CleanupStack::PopAndDestroy( &array);
+            }
+        else
+            {
+            }
+        }
+    return ret;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::GetLuid2L( const TDesC8 &aDMLuid, const TDesC8 &aUserId, 
+//		const TDeploymentComponentState aState, TError &aStatus )
+// ------------------------------------------------------------------------------------------------	
+TUint32 CSCOMOAdapter::GetLuid2L(const TDesC8 &aDMLuid,
+        const TDesC8 &aUserId, const TDeploymentComponentState aState,
+        TError &aStatus)
+    {
+    TUint32 ret(GetLuidL(aDMLuid, aUserId, aState) );
+    if ( (TInt32)ret <= 0)
+        {
+        aStatus = ENotFound;
+        }
+    return ret;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::GetLuidL( const TDesC8 &aDMLuid, const TDesC8 &aUserId, 
+//		const TDeploymentComponentState aState )
+// ------------------------------------------------------------------------------------------------	
+TUint32 CSCOMOAdapter::GetLuidL(const TDesC8 &aDMLuid, const TDesC8 &aUserId,
+        const TDeploymentComponentState aState)
+    {
+    TUint32 ret( 0);
+    if (aDMLuid == KNullDesC8)
+        {
+        ret = GetLuidForUserIdL(aUserId, aState);
+        }
+    else
+        {
+        ret = DesToIntL(aDMLuid) ;
+        }
+
+    return ret;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::DeleteObjectL( const TDesC8& aURI, const TDesC8& aLUID )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::DeleteObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+        const TInt aStatusRef)
+    {
+
+    RDEBUG8_4("CSCOMOAdapter::DeleteObjectL(): begin (%S, %S, %d)" , &aURI, &aLUID, aStatusRef );
+    SetAdapterValue(KAMSCOMOAdapter);
+    CheckStateChangesL();
+
+    TError ret(EError);
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	
+    TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+    TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+    TPtrC8 mapping( NSmlDmURI::LastURISeg( uriPtrc ) );
+#else
+    TInt cnt(NSmlDmURI::NumOfURISegs(aURI) );
+    TPtrC8 mapping(NSmlDmURI::LastURISeg(aURI) );
+#endif
+	
+	TBuf8<KMaxFullName> temp;
+	GetPredefinedNodeL(temp);
+	TInt comp = mapping.Compare( temp );
+		if (temp.Length() && mapping.Compare( temp ) == 0)
+            {
+            MSmlDmAdapter::TError status = MSmlDmAdapter::ENotAllowed;
+            Callback().SetStatusL( aStatusRef, status );
+            return;
+            }
+    switch (cnt)
+        {
+        case 3:
+        case 4:
+            {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+            TPtrC8 which( NSmlDmURI::URISeg( uriPtrc, cnt == 4 ? 3 : 2 ) );
+#else
+            TPtrC8 which(NSmlDmURI::URISeg(aURI, cnt == 4 ? 3 : 2) );
+#endif
+            if (which == KAMDeliveredNodeName || which == KAMDownloadNodeName)
+                {
+                TUint32 luid(GetLuidL(aLUID, mapping, (which
+                        == KAMDeliveredNodeName
+                                                ? EDCSDelivered
+                                                   : EDCSDownload)) );
+                if (luid > 0)
+                    {
+                    TRAPD( err, SessionL().RemoveL( luid ) )
+                    ;
+                    if (err == KErrNone || err == KErrNotFound)
+                        {
+                        ret = EOk;
+                        Callback().SetMappingL(aURI, KNullDesC8);
+                        if (err == KErrNone && iInAtomic)
+                            {
+                            iBuffer.Append(TAMCommandBufferElement(
+                                    aStatusRef, aURI) );
+                            }
+                        }
+                    else
+                        {
+                        MAPERROR( err, ret, _L8("Delete %d") );
+                        }
+                    }
+                else
+                    {
+                    RDEBUG( "CSCOMOAdapter::DeleteObjectL(): WARNING Object not found" );
+                    ret = ENotFound;
+                    }
+                }
+            else
+                {
+                RDEBUG8_2( "CSCOMOAdapter::DeleteObjectL(): ERROR Removing node %S is not supported", &aURI );
+                }
+            break;
+            }
+        default:
+            {
+            RDEBUG8_3( "CSCOMOAdapter::DeleteObjectL(): ILLEGAL LEVEL %d NODE %S", cnt, &aURI );
+            break;
+            }
+        }
+    SetStatusL(aStatusRef, ret);
+    RDEBUG( "CSCOMOAdapter::DeleteObjectL(): end" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::DeactivateIfInactive( const TUint aLuidi, const TDeploymentComponentState aTargetState )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::DeactivateIfInactive(const TUint aLuidi,
+        const TDeploymentComponentState aTargetState)
+    {
+    if (aTargetState == EDCSInactive)
+        {
+        RDEBUG( "CSCOMOAdapter::DeactivateIfInactive():  deactivating!" );
+        TRAPD( derr, iManagement.DeactivateL( aLuidi ) )
+        ;
+        if (derr != KErrNone)
+            {
+            RDEBUG_2("CSCOMOAdapter::DeactivateIfInactive(): ERROR deactivating failed %d", derr );
+            }
+        }
+    }
+
+void CSCOMOAdapter::InstallL(TUint aLuidi, const TDesC8& aURI,
+        const TDesC8& aLUID, const TDeploymentComponentState aTargetState,
+        TError &aRet)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	
+    TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+#else
+    //nothing
+#endif
+
+    TRAPD( err, SessionL().InstallL( aLuidi, aTargetState ) )
+    ;
+    if (err == KErrNone)
+        {
+        // Update the mappings in client to reflect new
+        //		position in the management tree ( Inactive or Active..)
+        RDEBUG( "CSCOMOAdapter::InstallL(): Install success!" );
+
+        TPtrC8 aclmapping(URISegsUpTo(aURI, 4) );
+        SetMappingL(aclmapping, aTargetState, aLUID);
+        iManagement.StateChangeComplete(aLuidi);
+
+        DeactivateIfInactive(aLuidi, aTargetState);
+        aRet = EOk;
+        }
+    else
+        {
+        RDEBUG_2( "CSCOMOAdapter::InstallL(): INSTALL FAILED '%d'" , err);
+        MAPERROR( err, aRet, _L8("Install %d") );
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::DefaultMapError( const TInt aErr, TError &aRet )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::DefaultMapError(const TInt aErr, TError &aRet,
+        const TDesC8&
+#ifdef __AM_LASTERROR_NODE
+        aDes
+#endif
+)
+    {
+    if (aErr == KErrNone)
+        {
+        aRet = EOk;
+        }
+    else
+        if (aErr == KErrNotFound)
+            {
+            aRet = ENotFound;
+            }
+        else
+            if (aErr == KErrArgument)
+                {
+                aRet = EInvalidObject;
+                }
+            else
+                if (aErr == KErrAlreadyExists)
+                    {
+                    aRet = EAlreadyExists;
+                    }
+                else
+                    {
+                    aRet = EError;
+                    }
+#ifdef __AM_LASTERROR_NODE
+    TInt err = KErrNone;
+    TRAP( err, SetErrorL( aDes, aErr ) );
+#endif
+    }
+
+#ifdef __AM_LASTERROR_NODE	
+void CSCOMOAdapter::SetErrorL(const TDesC8& aDes, const TInt aErr)
+    {
+    if (aDes != KNullDesC8)
+        {
+        SetLastErrorL(aDes, aErr);
+        }
+    else
+        {
+        SetLastErrorL(KStdError, aErr);
+        }
+    }
+#endif	
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aArgument, 
+//	const TDesC8& aType, 
+//	TInt aStatusRef )
+// ------------------------------------------------------------------------------------------------
+TDownloadTarget CSCOMOAdapter::DownloadTargetL(const TDesC8& aCommand)
+    {
+    if (aCommand == KAMDownloadOperationNodeName)
+        {
+        return EDeliver;
+        }
+    else
+        if (aCommand == KAMDownloadAndInstallNodeName)
+            {
+            return EInstallAndActivate;
+            }
+        else
+            if (aCommand == KAMDownloadAndInstallAndInActivateNodeName)
+                {
+                return EInstall;
+                }
+
+    RDEBUG8_2( "CSCOMOAdapter::DownloadTargetL(): ASKED OPERATION NOT SUPPORTED Download '%S'", &aCommand );
+    User::Leave(KErrArgument);
+    // NOTE! will not ever come here! Only to get rid of compiler warning !!
+    return EDeliver;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aArgument, 
+//	const TDesC8& aType, 
+//	TInt aStatusRef )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::ExecuteCommandL(const TDesC8& aURI, const TDesC8& aLUID,
+        const TDesC8& aArgument, const TDesC8& /*aType*/, TInt aStatusRef)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+    TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+#else
+    //nothing
+#endif
+
+    RDEBUG8_3("CSCOMOAdapter::ExecuteCommandL(): begin, '%S', '%S'", &aURI, &aLUID );
+    SetAdapterValue(KAMSCOMOAdapter);
+    CheckStateChangesL();
+    TError ret(EError);
+
+    if (aLUID == KNullDesC8)
+        {
+        RDEBUG("CSCOMOAdapter::ExecuteCommandL(): WARNING no valid luid provided" );
+        }
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+    TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+#else
+    TInt cnt(NSmlDmURI::NumOfURISegs(aURI) );
+#endif	
+
+    TPtrC8 mapping(NSmlDmURI::LastURISeg(aURI) );
+
+    const TInt KDownloadMappingURILoc = 3;
+    switch (cnt)
+        {
+        case 5:
+            {
+            TUint32 iluid(GetLuidL(aLUID, NSmlDmURI::URISeg(aURI,
+                    KDownloadMappingURILoc), EDCSDownload) );
+
+            // Track the Newly added delivered  node to make sure that this reference
+            // of delivered node is removed from Tree DB.
+            // This delivered node is removed only if Execute command is successful
+            // by either adding Install, Install& activate etc.
+            // This Fix would be applicable in case of DM 1.2. 
+
+
+            TPtrC8 urival(URISegsUpTo(aURI, KDownloadMappingURILoc));
+
+            if (iUriDel)
+                {
+                delete iUriDel;
+                iUriDel = NULL;
+                }
+
+            iUriDel = urival.AllocL();
+
+            RDEBUG_2("CSCOMOAdapter::ExecuteCommandL(): luid is %d", iluid );
+            if (iluid > 0)
+                {
+                TDownloadTarget target = DownloadTargetL(mapping);
+
+                TRAPD( errx, SessionL().StartDownloadL( iluid, target ) );
+                
+
+                //Check If Sync is supported. Default is ASyncReporting.
+                //If ASyncSupported is 0 mean Sync reporting is supported.  
+                TInt ASyncSupported = -1;
+
+                CRepository *repository=CRepository::NewLC ( KCRUidPrivateApplicationManagementKeys );
+                repository->Get(KAsyncEnabled,ASyncSupported);
+                CleanupStack::PopAndDestroy();
+                    
+				if(errx == KErrNone)
+				{
+                if (ASyncSupported)
+                    ASyncReportL(iluid, aArgument, target, aURI);
+                else
+                    SyncReportL(iluid, aArgument, target, aURI, ret);
+				}
+
+                if (target == EInstall || target == EInstallAndActivate)
+                    {
+                    TInt err(iDbSession.RemoveMappingInfoL(KAMAdapterImplUid,
+                            *iUriDel, iluid) );
+                    }
+                if (errx == KErrNone)
+                    {
+                    RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): StartDownloadL Successful " );
+                    if (ASyncSupported)
+                    {
+                       
+                       ret = EAcceptedForProcessing;
+                    }
+                        
+                    
+                    }
+                else
+                    {
+                    RDEBUG_2( "CSCOMOAdapter::ExecuteCommandL(): StartDownloadL FAILED '%d'", errx );
+                    if (errx == KErrNotFound)
+                        {
+                        ret = ENotFound;
+                        }
+                    else
+                        if (errx == KErrArgument)
+                            {
+                            ret = EInvalidObject ;
+                            }
+                        else
+                            {
+                            ret = EError;
+                            }
+                    }
+
+                }
+            else
+                {
+                ret = ENotFound;
+                RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): case 5 Not found node" );
+                }
+            break;
+            }
+        case 6:
+            {
+            const TInt KInventoryMappingURILoc = 4;
+
+            // Track the Newly added delivered  node to make sure that this reference
+            // of delivered node is removed from Tree DB.
+            // This delivered node is removed only if Execute command is successful
+            // by either adding Install, Install& activate etc.
+            // This Fix would be applicable in case of DM 1.2. 
+
+
+            TPtrC8 urival(URISegsUpTo(aURI, KInventoryMappingURILoc));
+
+            if (iUriDel)
+                {
+                delete iUriDel;
+                iUriDel = NULL;
+                }
+
+            iUriDel = urival.AllocL();
+
+            if (mapping == KAMInstallNodeName || mapping
+                    == KAMInstallInactiveNodeName)
+                {
+                TUint32 iluid(GetLuidL(aLUID, NSmlDmURI::URISeg(aURI,
+                        KInventoryMappingURILoc), EDCSDelivered) );
+                if (iluid > 0)
+                    {
+                    TDeploymentComponentState targetstate = ((mapping
+                            == KAMInstallNodeName)
+                                                   ? EDCSActive
+                                                      : EDCSInactive);
+                    InstallL(iluid, aURI, aLUID, targetstate, ret);
+
+                    TInt err(iDbSession.RemoveMappingInfoL(KAMAdapterImplUid,
+                            *iUriDel, iluid) );
+                    }
+                else
+                    {
+                    ret = ENotFound;
+                    RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): case 6 install Not found node" );
+                    }
+                }
+            else
+                if (mapping == KAMRemoveNodeName)
+                    {
+                    TPtrC8 parent( NSmlDmURI::RemoveLastSeg( urival ) );
+                    TPtrC8 ParentMapping( NSmlDmURI::LastURISeg( parent ) );
+                    TUint32 iluid(0);
+                    if ( ParentMapping == KAMDeliveredNodeName )
+                        {
+                        iluid = GetLuidL(aLUID, NSmlDmURI::URISeg(aURI,
+                                                    KInventoryMappingURILoc), EDCSDelivered) ;
+                        }
+                    
+                    else if ( ParentMapping == KAMDeployedNodeName)
+                        {
+                        iluid = GetLuidL(aLUID, NSmlDmURI::URISeg(aURI,
+                                KInventoryMappingURILoc), EDCSActive) ;
+                        if ( (TInt32)iluid <= 0)
+                            {
+                            iluid = GetLuidL(aLUID, NSmlDmURI::URISeg(aURI,
+                                    KInventoryMappingURILoc), EDCSInactive) ;
+                            }
+                        }
+                    if (iluid > 0)
+                        {
+                        TRAPD( err, SessionL().RemoveL( iluid ) )
+                        ;
+                        if (err == KErrNone)
+                            {
+                            RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): Remove success!" );
+                            TPtrC8 aclmapping(URISegsUpTo(aURI, 4) );
+
+                            // "Nullify" the mapping for argument
+                           err = iDbSession.RemoveMappingInfoL(KAMAdapterImplUid, aclmapping);
+                            if (err == KErrNone)
+                                {
+                                ret = EOk;
+                                }
+                            if (iInAtomic)
+                                {
+                                iBuffer.Append(TAMCommandBufferElement(
+                                        aStatusRef, aURI) );
+                                }
+                            }
+                        else
+                            {
+                            RDEBUG_2( "CSCOMOAdapter::ExecuteCommandL(): Remove FAILED '%d'", err);
+
+                            if (err == SwiUI::KSWInstErrUserCancel)
+                                ret = EError;
+                            else
+                                MAPERROR( err, ret, _L8("Execute Remove %d") );
+                            }
+                        }
+                    else
+                        {
+                        ret = ENotFound;
+                        RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): case 6 remove Not found node" );
+                        }
+                    }
+                        else
+                            if (mapping == KAMActivateNodeName)
+                                {
+                                //DBG_ARGS8( "CSCOMOAdapter::ExecuteCommandL(): Activating " );
+                                TUint32 iluid(GetLuidL(aLUID,
+                                        NSmlDmURI::URISeg(aURI,
+                                                KInventoryMappingURILoc),
+                                        EDCSActive) );
+                                if ( (TInt32)iluid <= 0)
+                                    {
+                                    iluid = GetLuidL(aLUID,
+                                            NSmlDmURI::URISeg(aURI,
+                                                    KInventoryMappingURILoc),
+                                            EDCSInactive) ;
+                                    }
+                                if (iluid > 0)
+                                    {
+                                    TRAP_IGNORE( SessionL().ActivateL( iluid ) );
+                                    ret = EOk;
+								
+                                    //MAPERROR( erx, ret, _L8("Activate %d") );
+                                    }
+                                else
+                                    {
+                                    ret = ENotFound;
+                                    RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): case 6 Activate Not found node" );
+                                    }
+                                }
+                            else
+                                if (mapping == KAMDeActivateNodeName)
+                                    {
+                                    //DBG_ARGS8( "CSCOMOAdapter::ExecuteCommandL(): Inactivating " );
+                                    TUint32 iluid(GetLuidL(aLUID,
+                                            NSmlDmURI::URISeg(aURI,
+                                                    KInventoryMappingURILoc),
+                                            EDCSActive) );
+                                    if ( (TInt32)iluid <= 0)
+                                        {
+                                        iluid
+                                                = GetLuidL(
+                                                        aLUID,
+                                                        NSmlDmURI::URISeg(
+                                                                aURI,
+                                                                KInventoryMappingURILoc),
+                                                        EDCSInactive) ;
+                                        }
+                                    if (iluid > 0)
+                                        {
+                                        TRAP_IGNORE(SessionL().DeactivateL( iluid ) )
+                                        ;
+										ret = EOk;
+                                        //MAPERROR( erx, ret,_L8("Dectivate %d") );
+                                        }
+                                    else
+                                        {
+                                        ret = ENotFound;
+                                        RDEBUG( "CSCOMOAdapter::ExecuteCommandL(): case 6 DeActivate Not found node" );
+                                        }
+                                    }
+                                else
+                                    {
+                                    RDEBUG8_2( "CSCOMOAdapter::ExecuteCommandL(): ASKED NOT SUPPORTED OPERATION '%S'", &mapping );
+                                    
+                                    ret = EError;
+                                    }
+            break;
+            }
+
+        default:
+            {
+            RDEBUG8_3( "CSCOMOAdapter::ExecuteCommandL(): ILLEGAL LEVEL %d NODE %S", cnt, &aURI );
+            
+            ret = EInvalidObject;
+            break;
+            }
+        }
+    SetStatusL(aStatusRef, ret) ;
+    }
+
+void CSCOMOAdapter::ASyncReportL(TUint32 aLuid, const TDesC8& aArgument,
+        const TDownloadTarget aTarget,const TDesC8& aURI)
+    {
+    // while sending generic alert
+    // adapter uses entry stored in database and constructs generic alert
+    // using SyncML framework API.
+    TInt index = 0;
+	// Default max retry count is 5. It is also cenep configurable
+	// Cenrep configuration responsible can change the max retry 
+	// count
+    TInt retrycount = 5;
+    
+    CRepository *repository = CRepository::NewLC ( KCRUidPrivateApplicationManagementKeys );
+    repository->Get(KMaxRetryCount,retrycount);
+    CleanupStack::PopAndDestroy(); //repository
+      
+    TSmlProfileId profId = KErrNotFound;
+    HBufC8* serverId= NULL;
+
+    //Retrive Server Information
+
+    GetServerInfoL(profId, serverId);
+
+    CleanupStack::PushL(serverId);
+
+    //Add Download entry to database
+
+    iAMdb->SaveToDatabaseL(index, aLuid, profId, retrycount, aURI,
+           *serverId, aArgument);
+
+    CleanupStack::PopAndDestroy(serverId);
+
+    }
+
+void CSCOMOAdapter::SyncReportL(TUint32 aLuid, const TDesC8& aArgument,
+        const TDownloadTarget aTarget,const TDesC8& aURI, TError &aRet )
+    {
+    TInt status = KStatusSuccess;
+
+    RProperty counter;
+    TInt r=counter.Attach(KUidPSApplicationManagementKeys, KSyncNotifier,
+            EOwnerThread);
+    User::LeaveIfError(r);
+
+    /*CSyncService *syncService = CSyncService::NewL(NULL, KDevManServiceStart);
+    if (syncService)
+        {
+        syncService->EnableProgressNoteL(EFalse);
+        }
+
+    delete syncService;*/
+
+    // wait for the previously attached ‘counter’ property to be updated
+    TRequestStatus s;
+    counter.Subscribe(s);
+    User::WaitForRequest(s);
+    
+    CRepository *repository = CRepository::NewLC ( KCRUidPrivateApplicationManagementKeys );
+    repository->Get(KAMSyncStatus,status);
+    CleanupStack::PopAndDestroy();
+                		   
+		switch(status)
+		{
+			case KStatusUserCancelled:
+			{
+				aRet = MSmlDmAdapter::EError;
+				break;
+			}
+			               
+			case KStatusDowloadFailedOOM:
+			{
+				aRet = MSmlDmAdapter::EError;
+				break;
+			}
+
+			case KStatusAlternateDownldAuthFail:
+			{
+			    aRet = MSmlDmAdapter::EError;
+			    break;	
+			}
+
+			case KStatusDownloadFailed:
+			{
+				aRet = MSmlDmAdapter::EError;
+				break;
+			}
+
+			case KStatusPkgValidationFailed:
+			{
+				aRet = MSmlDmAdapter::EError;
+				break;
+			}
+
+			case KStatusInstallFailedOOM:
+			{
+				aRet = MSmlDmAdapter::EError;
+				break;
+			}
+
+			case KStatusInstallFailed:
+			{
+				aRet = MSmlDmAdapter::EError;
+				break;
+			}
+		
+		  case KStatusUnSupportedEnvironment:
+			{
+				aRet = MSmlDmAdapter::EError;
+				break;
+			}
+			
+			case KStatusAltDowldUnavailable:
+			{
+				aRet = MSmlDmAdapter::EError;
+				break;
+			}
+		
+			default:
+			{
+			    aRet = MSmlDmAdapter::EOk;
+				break;
+			}
+		}                
+    
+
+    }
+
+void CSCOMOAdapter::GetServerInfoL(TSmlProfileId& aProfId, HBufC8*& aServerId) const
+    {
+    // Open session
+    RSyncMLSession session;
+    session.OpenL();
+    CleanupClosePushL(session);
+
+    // get current job's id (and usage type)
+    TSmlJobId jobId = KErrNotFound;
+    TSmlUsageType type = ESmlDevMan;
+    session.CurrentJobL(jobId, type);
+
+    // open currently running job
+    RSyncMLDevManJob dmJob;
+    dmJob.OpenL(session, jobId);
+    CleanupClosePushL(dmJob);
+
+    // get job's profile id
+    aProfId = dmJob.Profile();
+
+    // open profile using id in read-only mode
+    RSyncMLDevManProfile dmProf;
+    dmProf.OpenL(session, aProfId, ESmlOpenRead);
+    CleanupClosePushL(dmProf);
+
+    // get profile's server id
+    aServerId = dmProf.ServerId().AllocL();
+
+    // close handles
+    CleanupStack::PopAndDestroy( &dmProf);
+    CleanupStack::PopAndDestroy( &dmJob);
+    CleanupStack::PopAndDestroy( &session);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::UpdateL( 
+// 	const TUint aLuidi, 
+// 	const TDesC8& aURI, 
+// 	const TDesC8& aSourceLUID,
+// 	const TDeploymentComponentState aTargetState,
+// 	TError &aRet
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::UpdateL(const TUint aLuidi, const TDesC8& aURI,
+        const TDesC8& aSourceLUID,
+        const TDeploymentComponentState aTargetState, TError &aRet)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+    TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+#else
+    //nothing
+#endif
+
+    CBufBase *delivered = CBufFlat::NewL( 128);
+    CleanupStack::PushL(delivered);
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+    TPtrC8 aclmapping( NSmlDmURI::URISeg( uriPtrc, 4 ) );
+#else
+    TPtrC8 aclmapping(NSmlDmURI::URISeg(aURI, 4) );
+#endif
+
+    HBufC8 *targetURI = HBufC8::NewLC(KDeployedURI().Length() + aclmapping.Length() );
+
+    TPtr8 targetPtr(targetURI->Des() );
+    targetPtr.Copy(KDeployedURI);
+    targetPtr.Append(aclmapping);
+
+    HBufC8 *deployed = Callback().GetLuidAllocL(targetPtr) ;
+    CleanupStack::PushL(deployed);
+
+    //DBG_ARGS8( "CSCOMOAdapter::UpdateL(): Updating '%S' luid: '%S'" ), &targetPtr, &(*deployed));
+    if ( *deployed == KNullDesC8)
+        {
+        //DBG_ARGS8( "CSCOMOAdapter::UpdateL(): Failed to find to update target '%S'" ), &targetPtr );
+        aRet = EError;
+        }
+    else
+        {
+        // Found delivered & active or inactive components! Do update!
+        TInt depluid(DesToIntL( *deployed ));
+        TRAPD( erx, SessionL().UpdateL( aLuidi, depluid ) )
+        ;
+        MAPERROR( erx, aRet,_L8("Update %d") );
+        if (erx == KErrNone)
+            {
+            SetMappingLC(aclmapping, aTargetState, aSourceLUID, targetURI);
+            DeactivateIfInactive(aLuidi, aTargetState);
+            }
+        }
+    CleanupStack::PopAndDestroy(deployed) ;
+    CleanupStack::PopAndDestroy(targetURI) ;
+    CleanupStack::PopAndDestroy(delivered) ;
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::CheckStateL( const TDeploymentComponent &aComp, const TDesC8& aURI
+// ------------------------------------------------------------------------------------------------
+TBool CSCOMOAdapter::CheckStateL(const TDeploymentComponent &aComp,
+        const TDesC8& aURI)
+    {
+	TBool ret;
+	if ((aComp.iState ==  EDCSDelivered) || (aComp.iState == EDCSActive) || ( aComp.iState == EDCSInactive) || (aComp.iState == EDCSDownload))
+	{
+        // Check for map & __TARM_SYMBIAN_CONVERGENCY also ?
+        ret = ETrue;
+    }
+	else
+	    ret = EFalse;
+	return ret;
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::StateL( const TDeploymentComponent &aComp, const TDesC8& aURI
+// ------------------------------------------------------------------------------------------------
+TDeploymentComponentState CSCOMOAdapter::StateL(const TDesC8& aURI)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+    TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+#else
+    //nothing
+#endif
+
+    TDeploymentComponentState ret(EDCSNone);
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+    TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+#else
+    TInt cnt(NSmlDmURI::NumOfURISegs(aURI) );
+#endif	
+    if (cnt > 2)
+        {
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+        TPtrC8 map( NSmlDmURI::URISeg( uriPtrc, 2 ) );
+#else
+        TPtrC8 map(NSmlDmURI::URISeg(aURI, 2) );
+#endif	
+        if (map == KAMInventoryNodeName)
+            {
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+            TPtrC8 map( NSmlDmURI::URISeg( uriPtrc, 2 ) );
+#else
+            TPtrC8 map(NSmlDmURI::URISeg(aURI, 2) );
+#endif	
+            map.Set(NSmlDmURI::URISeg(aURI, 3) );
+            if (map == KAMDeployedNodeName)
+                {
+
+                }
+            else
+                if (map == KAMDeliveredNodeName)
+                    {
+                    ret = EDCSDelivered;
+                    }
+                else
+                    {
+                    User::Leave(KErrArgument);
+                    }
+            }
+        else
+            if (map == KAMDownloadNodeName)
+                {
+                ret = EDCSDownload;
+                }
+            else
+                {
+                User::Leave(KErrArgument);
+                }
+        }
+    return ret;
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::CheckStateL( const TDesC8& aURI, const TDesC8& aLUID )
+// ------------------------------------------------------------------------------------------------
+TBool CSCOMOAdapter::CheckStateL(const TDesC8& aURI, const TDesC8& aLUID)
+    {
+
+    TUint32 iluid(DesToIntL(aLUID) );
+    TDeploymentComponent comp;
+    TInt err(SessionL().DeploymentComponent(iluid, comp) );
+    TBool ret(EFalse);
+    if (err == KErrNone)
+        {
+        ret = CheckStateL(comp, aURI);
+        }
+    return ret;
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::InstallOptionsDataL(const TUint32 iluid, const TDeplCompAttrType& aDataType, 
+//		CBufBase &aBuf, CBufBase *aRaw/*= NULL*/)
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::InstallOptionsDataL(const TUint32 iluid,
+        const TDeplCompAttrType& aDataType, CBufBase &aBuf, CBufBase *aRaw/*= NULL*/)
+    {
+    TAMInstallOptionsPckgBuf iop;
+    TBool pushed(EFalse);
+    if ( !aRaw)
+        {
+        aRaw = CBufFlat::NewL(32);
+        CleanupStack::PushL(aRaw);
+        pushed = ETrue;
+        SessionL().DeploymentComponentDataL(iluid, aDataType, *aRaw);
+        }
+
+    iop.Copy(aRaw->Ptr( 0) );
+    if (pushed)
+        {
+        CleanupStack::PopAndDestroy(aRaw);
+        }
+    InstallOptionsParser::SerializeOptionsL(iop(), aBuf);
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::GetComponentDataL( const TDesC8& parent, const TDesC8& mapping, 
+//		const TUint32 iluid, CBufBase *currentList, CBufBase *currentMime, TError &status )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::GetComponentDataL(const TDesC8& parent,
+        const TDesC8& mapping, const TUint32 iluid, CBufBase &currentList,
+        CBufBase &currentMime, TError &status)
+    {
+    TDeploymentComponent comp;
+    TInt err(SessionL().DeploymentComponent(iluid, comp) );
+    if (err == KErrNone)
+        {
+        RDEBUG_3( "CSCOMOAdapter::GetComponentDataL(): DeploymentComponent response: %d, state: %d", err, comp.iState );
+        if (CheckStateL(comp, parent) )
+            {
+            if (mapping == KAMPkgIDNodeName)
+                {
+                currentList.InsertL( 0, comp.iPkgID);
+                status = EOk;
+                }
+            else
+                if (mapping == KAMNameNodeName)
+                    {
+                    currentList.InsertL( 0, comp.iName);
+                    status = EOk;
+                    }
+                else
+                    if (mapping == KAMVersionNodeName)
+                        {
+                        currentList.InsertL( 0, comp.iVersion);
+                        status = EOk;
+                        }
+                else
+                   if(mapping == KAMIDNodeName)
+                   {
+                   	
+                        currentList.InsertL( 0, comp.iId);
+                        status = EOk;
+                        
+                   }
+                else
+                   if(mapping == KAMPkgIDRefNodeName)
+                   {
+                   	
+                        currentList.InsertL( 0, comp.iPkgIDRef);
+                        status = EOk;
+                        
+                   }
+				else
+                   if(mapping == KAMPkgIDNodeName)
+                   {
+                   	
+                        currentList.InsertL( 0, comp.iPkgID);
+                        status = EOk;
+                        
+                   }               
+				else
+                   if(mapping == KAMPkgTypeNodeName)
+                   {
+                   	
+                        currentList.InsertL( 0, comp.iPkgType);
+                        status = EOk;
+                        
+                   }             
+                else 
+                   if ( mapping == KAMStatusNodeName )
+                {
+                TDeplCompAttrType dataType( UpdateFlagFromMapping( mapping ) );
+                SessionL().DeploymentComponentDataL( iluid, dataType, currentList );
+                status = EOk;
+                }			
+
+                    else
+                        if (mapping == KAMDescriptionNodeName)
+                            {
+                            currentList.InsertL(0, comp.iDescription);
+                            status = EOk;
+                            }
+                        else
+                            {
+                            TDeplCompAttrType
+                                    dataType(UpdateFlagFromMapping(mapping) );
+                            if (comp.iState == EDCSDownload)
+                                {
+					if ( dataType == EDCDownloadURI )//|| dataType == EDCDownloadStatus )
+                                    {
+                                    SessionL().DeploymentComponentDataL(iluid,
+                                            dataType, currentList);
+                                    status = EOk;
+                                    }
+                                else
+                                    if (dataType == EDCInstallOptions)
+                                        {
+                                        InstallOptionsDataL(iluid, dataType,
+                                                currentList);
+                                        status = EOk;
+                                        }
+                                    else
+                                        if (dataType == EDCConRef)
+                                            {
+                                            CBufBase *b = CBufFlat::NewL(4);
+                                            CleanupStack::PushL(b);
+                                            SessionL().DeploymentComponentDataL(
+                                                    iluid, dataType, *b);
+                                            TPckgBuf<TInt> iap;
+                                            iap.Copy(b->Ptr( 0) );
+                                            CleanupStack::PopAndDestroy(b);
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+
+                                            CArrayFix<TSmlDmMappingInfo>* mapArray = new CArrayFixFlat<TSmlDmMappingInfo>(4);
+                                            CleanupStack::PushL(mapArray);
+
+                                            Callback().GetMappingInfoListL( KNSmlDMMMSSlashIAPUri,*mapArray );
+
+                                            //TInt iap = KErrNotFound; 
+                                            TSmlDmMappingInfo mapInfo;
+                                            HBufC8 * uri = NULL;
+                                            TPtr8 tempURI(uri->Des());
+
+                                            for(TInt i = 0;i<mapArray->Count();i++)
+                                                {
+                                                if(iap()==DesToInt(mapArray->At(i).iURISegLUID))
+                                                    {
+                                                    tempURI=mapArray->At(i).iURISeg;
+                                                    }
+
+                                                }
+                                            mapArray->Reset();
+                                            CleanupStack::PopAndDestroy(); //mapArray
+                                            if ( uri != NULL )
+                                                {
+                                                CleanupStack::PushL( uri );
+                                                currentList.InsertL( 0, *uri );
+                                                CleanupStack::PopAndDestroy( uri );
+                                                }
+
+#else
+
+                                            CNSmlDMIAPMatcher
+                                                    * iapfinder =
+                                                            CNSmlDMIAPMatcher::NewLC( &Callback() );
+                                            HBufC8
+                                                    * uri =
+                                                            iapfinder->URIFromIAPIdL(iap() ) ;
+                                            CleanupStack::PopAndDestroy(iapfinder);
+                                            if (uri != NULL)
+                                                {
+                                                CleanupStack::PushL(uri) ;
+                                                currentList.InsertL( 0, *uri);
+                                                CleanupStack::PopAndDestroy(uri) ;
+                                                }
+
+#endif
+                                            status = EOk;
+                                            }
+                                        else
+                                            {
+                                            RDEBUG8_2( "CSCOMOAdapter::GetComponentDataL(): ASKED NOT SUPPORTED LEAF '%S'", &mapping );
+                                            }
+                                }
+                            else
+                                if (comp.iState == EDCSDelivered)
+                                    {
+                                    if(mapping == KAMStateValueNodeName)
+                                        {
+                                      currentList.InsertL( 0,KAMStateValueDelivered() );
+                                      status = EOk;
+                                        }
+                                    if (dataType == EDCData || dataType
+                                            == EDCMetaData || dataType
+                                            == EDCInstallOptions)
+                                        {
+                                        CBufBase *raw = CBufFlat::NewL( 128);
+                                        CleanupStack::PushL(raw);
+                                        SessionL().DeploymentComponentDataL(
+                                                iluid, dataType, *raw);
+                                        TPtrC8 source(raw->Ptr(0) );
+                                        if (source.Length() > 0)
+                                            {
+                                            if (dataType == EDCData)
+                                                {
+                                                currentList.InsertL( 0,
+                                                        source);
+                                                SessionL().DeploymentComponentDataL(
+                                                        iluid, EDCDataMime,
+                                                        currentMime);
+
+                                                }
+                                            else
+                                                if (dataType
+                                                        == EDCInstallOptions)
+                                                    {
+                                                    InstallOptionsDataL(
+                                                            iluid, dataType,
+                                                            currentList, raw);
+                                                    }
+                                                else
+                                                    {
+                                                    currentList.InsertL( 0,
+                                                            source);
+                                                    SessionL().DeploymentComponentDataL(
+                                                            iluid,
+                                                            EDCMetaDataMime,
+                                                            currentMime);
+                                                    }
+                                            }
+                                        else
+                                            {
+                                            // 0 data length...
+                                            }
+                                        status = EOk;
+                                        CleanupStack::PopAndDestroy(raw);
+                                        RDEBUG8_2( "CSCOMOAdapter::GetComponentDataL(): DeploymentComponentDataL called '%S'", &mapping );
+                                        }
+                                    }
+                                else
+                                    if (dataType == EDCStateValue)
+                                        {
+                                        if (comp.iState == EDCSActive)
+                                            {
+                                            currentList.InsertL( 0,
+                                                    KAMStateValueActive() );
+                                            }
+                                        else
+                                            {
+                                            currentList.InsertL( 0,
+                                                    KAMStateValueInactive() );
+                                            }
+                                        status = EOk;
+                                        }
+                                    else
+                                        {
+                                        RDEBUG8_2( "CSCOMOAdapter::GetComponentDataL(): ERROR ASKED NOT SUPPORTED LEAF '%S'", &mapping );
+                                        }
+                            }
+            }
+        else
+            {
+            RDEBUG8_3( "CSCOMOAdapter::GetComponentDataL(): WARNING Asked illegal state leaf '%S', %d", &mapping, comp.iState );
+            status = ENotFound;
+            }
+        }
+    else
+        {
+        RDEBUG_3( "CSCOMOAdapter::GetComponentDataL(): ERROR FAILED TO GET COMPOMENT OF ID %d: %d", iluid, err );
+        MAPERROR( err, status,_L8("Get Component %d") );
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::GetLeafLuidL(const TDesC8 &aURI, const TDesC8 & aParentMapping ) 
+// ------------------------------------------------------------------------------------------------
+TInt CSCOMOAdapter::GetLeafLuidL(const TDesC8 &aURI,
+        const TDesC8 & aParentMapping)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+    TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+    TInt numSeqs( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+#else
+    TInt numSeqs(NSmlDmURI::NumOfURISegs(aURI) );
+#endif
+
+    TUint32 iluid( 0);
+    //TInt numSeqs( NSmlDmURI::NumOfURISegs( aURI ) );//Dipak
+
+    switch (numSeqs)
+        {
+        case 4: // must be a download leaf
+            {
+            iluid = GetLuidForUserIdL(aParentMapping, EDCSDownload) ;
+            break;
+            }
+        case 5: // download operation or delivered or deployed leaf
+            {
+            if (URISegsUpTo(aURI, 2, ETrue) == KDownloadURI)
+                {
+                RDEBUG8_2( "CSCOMOAdapter::GetLeafLuidL(): WARNING download operation leaf '%S'", &aURI );
+                //status = EOk; 
+                }
+            else
+                {
+                TPtrC8 start(URISegsUpTo(aURI, 3, ETrue) );
+                if (start == KDeliveredURI)
+                    {
+                    iluid = GetLuidForUserIdL(aParentMapping, EDCSDelivered) ;
+                    }
+                else
+                    if (start == KDeployedURI)
+                        {
+                        iluid = GetLuidForUserIdL(aParentMapping, EDCSActive) ;
+                        if ( (TInt32)iluid <= 0)
+                            {
+                            iluid = GetLuidForUserIdL(aParentMapping,
+                                    EDCSInactive) ;
+                            }
+                        }
+                    else
+                        {
+                        RDEBUG8_2( "CSCOMOAdapter::GetLeafLuidL(): WARNING strange uri '%S'", &aURI );
+                        }
+                }
+            break;
+            }
+        case 6: // delivered or deployed operation leaf
+            {
+            //iluid = GetLuidForUserIdL( parentMapping, EDCSDownload ) ;
+            //status = EOk;
+            RDEBUG8_2( "CSCOMOAdapter::GetLeafLuidL(): WARNING delivered or deployed operation leaf '%S'", &aURI );
+            break;
+            }
+        default: // illegal uri
+            {
+            RDEBUG8_2( "CSCOMOAdapter::GetLeafLuidL(): ERROR requested luid of illegal URI '%S'", &aURI );
+            break;
+            }
+        }
+    return iluid;
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aType, 
+//			CBufBase& aObject )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::FetchLeafObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+        const TDesC8& aType, const TInt aResultsRef, TInt aStatusRef)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+    TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+#else
+    //Nothing
+#endif
+
+    RDEBUG8_4("CSCOMOAdapter::FetchLeafObjectL('%S', '%S', '%S'): begin", &aURI, &aLUID, &aType );
+    SetAdapterValue(KAMSCOMOAdapter);
+    CheckStateChangesL();
+    TError status(EError);
+
+    CBufBase *currentList = CBufFlat::NewL( 128);
+    CleanupStack::PushL(currentList);
+
+    CBufBase *currentMime = CBufFlat::NewL( 128);
+    CleanupStack::PushL(currentMime);
+
+    TPtrC8 mapping(NSmlDmURI::LastURISeg(aURI) );
+    TPtrC8 parent(NSmlDmURI::RemoveLastSeg(aURI) );
+    TPtrC8 parentMapping(NSmlDmURI::LastURISeg(parent) );
+
+    HBufC8 *luid= NULL;
+    if (aLUID != KNullDesC8)
+        {
+        luid = aLUID.AllocLC();
+        }
+    else
+        { // try if we find it from download path
+        TBuf8<256> down;
+        down = KDownloadURI;
+        down.Append(parentMapping);
+        luid = Callback().GetLuidAllocL(down);
+        CleanupStack::PushL(luid);
+        if ( *luid != KNullDesC8)
+            {
+            // make it to found next time
+            DirectSetMappingL(parent, *luid);
+            MoveAclL(down, parent);
+
+            // remove old
+            DirectSetMappingL(down, KNullDesC8);
+            }
+        }
+    if ( *luid != KNullDesC8)
+        {
+        TUint32 iluid(DesToIntL( *luid ));
+        RDEBUG8_2( "CSCOMOAdapter::FetchLeafObjectL(): Luid is : %d", iluid );
+        GetComponentDataL(parent, mapping, iluid, *currentList, *currentMime,
+                status);
+        }
+    else
+        {
+        TUint32 iluid(GetLeafLuidL(aURI, parentMapping) );
+        if (iluid > 0)
+            {
+            HBufC8 *l = IntToDes8LC(iluid);
+            DirectSetMappingL(parent, *l);
+            CleanupStack::PopAndDestroy(l);
+            GetComponentDataL(parent, mapping, iluid, *currentList,
+                    *currentMime, status);
+            }
+        else
+            {
+            RDEBUG8_2( "CSCOMOAdapter::FetchLeafObjectL(): WARNING Faild to get luid allocation for '%S'", &parent );
+            if (aLUID == KNullDesC8)
+                {
+#ifdef __AM_LASTERROR_NODE
+                if (aURI == KAMLastErrorURI)
+                    {
+                    const TDesC8& error= LastError();
+                    RDEBUG8_2( "CSCOMOAdapter::FetchLeafObjectL(): Returning last error '%S'", &error );
+                    currentList->InsertL(0, error);
+                    status = EOk;
+                    }
+                else
+                    {
+                    status = ENotFound;
+                    }
+#else
+                status = ENotFound;
+#endif
+                }
+            }
+        }
+
+    SetStatusL(aStatusRef, status);
+    if (status == EOk)
+        {
+        if (iInAtomic)
+            {
+            iBuffer.Append(TAMCommandBufferElement(aStatusRef, aURI) );
+            }
+        Callback().SetResultsL(aResultsRef, *currentList,
+                ( (currentMime->Size() > 0) ? currentMime->Ptr(0) : aType ));
+        }
+    CleanupStack::PopAndDestroy(luid);
+    CleanupStack::PopAndDestroy(currentMime); //currentMime
+    CleanupStack::PopAndDestroy(currentList); //currentList
+    RDEBUG("CSCOMOAdapter::FetchLeafObjectL: end" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::IdListL( TDeploymentComponentState aState, 
+//					CBufBase *aCurrentList, TBool aAppend /* = EFalse */)
+// ------------------------------------------------------------------------------------------------
+CSCOMOAdapter::TError CSCOMOAdapter::IdListL(
+        TDeploymentComponentState aState, CBufBase &aCurrentList,
+        TBool aAppend /* = EFalse */)
+    {
+	RDEBUG_2( "CSCOMOAdapter::IdListL:Begin aState is %d", aState);
+    CSCOMOAdapter::TError ret(CSCOMOAdapter::EError);
+    RElementIdArray array;
+    TPtrC8 uriStart;
+    TBuf8<256> uri;
+	
+    switch (aState)
+        {
+        case EDCSDelivered:
+            uriStart.Set(KDeliveredURI);
+            break;
+        case EDCSActive:
+        case EDCSInactive:
+            uriStart.Set(KDeployedURI) ;
+            break;
+        case EDCSDownload:
+            uriStart.Set(KDownloadURI) ;
+            break;
+        default:
+            break;
+
+        }
+    TInt err(SessionL().DeploymentComponentIdsL(array, aState) );
+    if (err == KErrNone)
+        {
+        TInt count(array.Count() );
+		RDEBUG_2( "CSCOMOAdapter::IdListL: count is %d", count);
+        if (count && aAppend && aCurrentList.Size() )
+            {
+				RDEBUG("CSCOMOAdapter::IdListL: Inserting list size" );
+            aCurrentList.InsertL(aCurrentList.Size(), KAMSeparator8);
+            }
+        for (TInt i( 0); i < count; i++)
+            {
+            TUint32 el = array[i];
+            TDCUserId dc;
+            SessionL().DeploymentComponentUserIdL(el, dc);
+			RDEBUG_2("CSCOMOAdapter::IdListL: Node name is %S", &dc);
+            if (uriStart == KNullDesC8() )
+                {
+					RDEBUG("CSCOMOAdapter::IdListL: uriStart == KNullDesC8()" );
+                TDeploymentComponent comp;
+                err = SessionL().DeploymentComponent(el, comp) ;
+                if (err == KErrNone)
+                    {
+                    switch (comp.iState)
+                        {
+                        case EDCSDelivered:
+                            uriStart.Set(KDeliveredURI);
+                            break;
+                        case EDCSActive:
+                        case EDCSInactive:
+                            uriStart.Set(KDeployedURI) ;
+                            break;
+                        case EDCSDownload:
+                            uriStart.Set(KDownloadURI) ;
+                            break;
+                        default:
+                            break;
+                        }
+                    }
+                }
+            if (uriStart != KNullDesC8() )
+                {
+                uri.Copy(uriStart);
+                uri.Append(dc);
+                HBufC8 *luid = DirectGetLuidAllocLC(uri); //Callback().GetLuidAllocL( uri );
+				RDEBUG_2( "CSCOMOAdapter::IdListL: luid is %S", luid);
+                if (KNullDesC8() == *luid)
+                    {
+                    RDEBUG8_3( "CSCOMOAdapter::IdListL(): WARNING updating lost luid of '%S' %d", &uri, el );
+                    HBufC8 *l = IntToDes8LC(el);
+                    if ( *luid == *l)
+                        {
+                        RDEBUG( "CSCOMOAdapter::IdListL(): WARNING CANCEL (not really updating, they're the same already" );
+                        }
+                    else
+                        {
+							RDEBUG("CSCOMOAdapter::IdListL: DirectSetMappingL" );
+                        DirectSetMappingL(uri, *l);
+                        }
+                    CleanupStack::PopAndDestroy(l);
+                    }
+                CleanupStack::PopAndDestroy(luid);
+
+                }
+            else
+                {
+                RDEBUG_2( "CSCOMOAdapter::IdListL(): WARNING failed to get component state of id %d, cannot check mappings ", el );
+                }
+            aCurrentList.InsertL(aCurrentList.Size(), dc);
+            if (i + 1 < count)
+                {
+					RDEBUG("CSCOMOAdapter::IdListL: Adding Separator" );
+                aCurrentList.InsertL(aCurrentList.Size(), KAMSeparator8);
+                }
+            }
+        ret = EOk;
+        }
+    else
+        {
+        RDEBUG_2( "CSCOMOAdapter::IdListL(): Error %d", err );
+        }
+    array.Reset();
+	RDEBUG("CSCOMOAdapter::IdListL: end" );
+    return ret;
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::ChildURIListL( const TDesC8& aURI, const TDesC8& aParentLUID, 
+//			const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, const TInt aResultsRef, 
+//			TInt aStatusRef );
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::ChildURIListL(const TDesC8& aURI,
+        const TDesC8& aParentLUID,
+        const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/,
+        const TInt aResultsRef, TInt aStatusRef)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+    TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+#else
+    //Nothing
+#endif
+
+    RDEBUG8_3 ( "CSCOMOAdapter::ChildURIListL(): begin ('%S', '%S')" , &aURI, &aParentLUID );
+    CheckStateChangesL();
+
+    TError ret(EError);
+
+    CBufBase *currentList = CBufFlat::NewL( 128);
+    CleanupStack::PushL(currentList);
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	
+    TInt numSeqs( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+#else
+    TInt numSeqs(NSmlDmURI::NumOfURISegs(aURI) );
+#endif
+
+    TPtrC8 mapping(NSmlDmURI::LastURISeg(aURI) );
+    if (numSeqs == 1)
+        {
+        currentList->InsertL( 0, KAMRootChilds);
+        ret = EOk;
+        }
+    else
+        if (numSeqs == 2)
+            {
+            if (mapping == KAMInventoryNodeName)
+                {
+                currentList->InsertL( 0, KAMInventoryChilds);
+                ret = EOk;
+                }
+            else
+                if (mapping == KAMDownloadNodeName)
+                    {
+                    RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): Level 2 NODE %S", &aURI );
+                    TDeploymentComponentState state(EDCSDownload);
+                    ret = IdListL(state, *currentList);
+                    }
+                else
+                    {
+                    RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): ILLEGAL LEVEL 2 NODE %S", &aURI );
+                    User::Leave(KErrArgument);
+                    }
+            }
+        else
+            if (numSeqs == 3)
+                {
+                if (mapping == KAMDeliveredNodeName)
+                    {
+                    RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): Level 3 NODE %S", &aURI );
+                    TDeploymentComponentState state(EDCSDelivered);
+                    ret = IdListL(state, *currentList);
+                    }
+                else
+                    if (mapping == KAMDeployedNodeName)
+                        {
+                        TDeploymentComponentState state(EDCSActive);
+                        ret = IdListL(state, *currentList);
+                        if (ret == EOk)
+                            {
+                            state = EDCSInactive;
+                            ret = IdListL(state, *currentList, ETrue);
+                            }
+                        }
+                    else
+                        {
+                        if (aParentLUID != KNullDesC8)
+                            {
+                            if (CheckStateL(aURI, aParentLUID) )
+                                {
+                                TPtrC8
+                                        parent(NSmlDmURI::RemoveLastSeg(aURI) );
+                                TPtrC8
+                                        parentMapping(NSmlDmURI::LastURISeg(parent) );
+                                if (parentMapping == KAMDownloadNodeName)
+                                    {
+                                    currentList->InsertL( 0,
+                                            KAMDownloadDynaChilds);
+                                    ret = EOk;
+                                    }
+                                else
+                                    {
+                                    RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): ILLEGAL LEVEL 3 NODE %S", &aURI );
+                                    User::Leave(KErrArgument);
+                                    }
+                                }
+                            else
+                                {
+                                RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): DC has changed state %S", &aURI );
+                                ret = ENotFound;
+                                }
+                            }
+                        else
+                            {
+                            RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): Level3 Node not found %S", &aURI );
+                            ret = ENotFound;
+                            }
+                        }
+                }
+            else
+                if (numSeqs == 4)
+                    {
+                    TPtrC8 parent(NSmlDmURI::RemoveLastSeg(aURI) );
+                    TPtrC8 parentMapping(NSmlDmURI::LastURISeg(parent) );
+                    if (aParentLUID == KNullDesC8)
+                        {
+                        RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): WARNING possibly a illegal level 4 node %S", &aURI );
+                        ret = ENotFound;
+                        }
+
+                    if (parentMapping == KAMDeliveredNodeName)
+                        {
+                        if (GetLuid2L(aParentLUID, mapping, EDCSDelivered,
+                                ret) > 0)
+                            {
+                            currentList->InsertL( 0,
+                                    KAMInventoryDeliveredDynaChilds);
+                            ret = EOk;
+                            }
+                        }
+                    else
+                        if (parentMapping == KAMDeployedNodeName)
+                            {
+                            if (GetLuid2L(aParentLUID, mapping, EDCSActive,
+                                    ret) > 0)
+                                {
+                                currentList->InsertL( 0,
+                                        KAMInventoryDynaChilds);
+                                ret = EOk;
+                                }
+                            else
+                                if (GetLuid2L(aParentLUID, mapping,
+                                        EDCSInactive, ret) > 0)
+                                    {
+                                    currentList->InsertL( 0,
+                                            KAMInventoryDynaChilds);
+                                    ret = EOk;
+                                    }
+                            }
+                        else
+                            if (mapping == KAMOperationsNodeName)
+                                {
+                                if (GetLuid2L(aParentLUID, parentMapping,
+                                        EDCSDownload, ret) > 0)
+                                    {
+                                    if (CheckStateL(aURI, aParentLUID) )
+                                        {
+                                        currentList->InsertL( 0,
+                                                KAMDownloadOperationChilds);
+                                        ret = EOk;
+                                        }
+                                    else
+                                        {
+                                        RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): Level3 operations DC changed state '%S'", &aURI );
+                                        ret = ENotFound;
+                                        }
+                                    }
+                                }
+                            else
+                                {
+                                RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): Level4 Node not found '%S'", &aURI );
+                                ret = ENotFound;
+                                }
+                    }
+                else
+                    if (numSeqs == 5)
+                        {
+                        if (aParentLUID == KNullDesC8)
+                            {
+                            RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): WARNING possibly a illegal level 5 node %S", &aURI );
+                            ret = ENotFound;
+                            }
+                        if (mapping == KAMOperationsNodeName)
+                            {
+                            TPtrC8 parent(NSmlDmURI::RemoveLastSeg(aURI) );
+                            TPtrC8
+                                    parentMapping(NSmlDmURI::LastURISeg(parent) );
+                            TPtrC8 gparent(NSmlDmURI::RemoveLastSeg(parent) );
+                            TPtrC8
+                                    gparentMapping(NSmlDmURI::LastURISeg(gparent) );
+                            if (gparentMapping == KAMDeliveredNodeName)
+                                {
+                                if (GetLuid2L(aParentLUID, parentMapping,
+                                        EDCSDelivered, ret) > 0)
+                                    {
+                                    currentList->InsertL( 0,
+                                            KAMDeliveredOperationChilds);
+                                    ret = EOk;
+                                    }
+                                }
+                            else
+                                if (gparentMapping == KAMDeployedNodeName)
+                                    {
+                                    if (GetLuid2L(aParentLUID, parentMapping,
+                                            EDCSActive, ret) > 0)
+                                        {
+                                        currentList->InsertL( 0,
+                                                KAMDeployedOperationChilds);
+                                        ret = EOk;
+                                        }
+                                    else
+                                        if (GetLuid2L(aParentLUID,
+                                                parentMapping, EDCSInactive,
+                                                ret) > 0)
+                                            {
+                                            currentList->InsertL( 0,
+                                                    KAMDeployedOperationChilds);
+                                            ret = EOk;
+                                            }
+                                    }
+                                else
+                                    {
+                                    RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): Level5 Node not found wrong parent '%S'", &aURI );
+                                    ret = ENotFound;
+                                    }
+                            }
+                        else
+                            {
+                            RDEBUG8_2( "CSCOMOAdapter::ChildURIListL(): Level5 Node not found '%S'", &aURI );
+                            ret = ENotFound;
+                            }
+                        }
+                    else
+                        {
+                        RDEBUG8_3( "CSCOMOAdapter::ChildURIListL(): ILLEGAL LEVEL %d NODE %S", numSeqs, &aURI );
+                        ret = EError;
+                        }
+
+    SetStatusL(aStatusRef, ret);
+
+    if (ret == EOk)
+        {
+        if (iInAtomic)
+            {
+            iBuffer.Append(TAMCommandBufferElement(aStatusRef, aURI) );
+            }
+        Callback().SetResultsL(aResultsRef, *currentList, KNullDesC8);
+        }
+    CleanupStack::PopAndDestroy(); //currentList
+    }
+
+// ------------------------------------------------------------------------------------------------
+//  CSCOMOAdapter::DeliverOrDownloadL( const TDesC8 &aUserId, const TDesC8 &aURI, TInt aCnt, 
+//		const TDesC8 &aParentMapping, MSmlDmAdapter::TError &aStatus )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::DeliverOrDownloadL(const TDesC8 &aUserId,
+        const TDesC8 &aURI, TInt aCnt, const TDesC8 &aParentMapping,
+        MSmlDmAdapter::TError &aStatus)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+    TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+#else
+    //Nothing
+#endif
+
+    switch (aCnt)
+        {
+        case 3:
+            {
+            if (aParentMapping == KAMDownloadNodeName)
+                {
+                TUint32 luid(SessionL().DownloadL(aUserId) );
+                Callback().SetMappingL(aURI, *IntToDes8LC(luid) );
+                CleanupStack::PopAndDestroy();
+                aStatus = EOk;
+                }
+            else
+                {
+                RDEBUG( "CSCOMOAdapter::DeliverOrDownloadL(): ERROR Illegal parent");
+                }
+            break;
+            }
+        case 4:
+            {
+            if (aParentMapping == KAMDeliveredNodeName)
+                {
+                TUint32 luid(SessionL().DeliverL(aUserId) );
+                Callback().SetMappingL(aURI, *IntToDes8LC(luid) );
+                CleanupStack::PopAndDestroy();
+                aStatus = EOk;
+                }
+            else
+                {
+                RDEBUG( "CSCOMOAdapter::DeliverOrDownloadL(): ERROR Illegal parent");
+                }
+            break;
+            }
+        default:
+            {
+            RDEBUG( "CSCOMOAdapter::DeliverOrDownloadL(): ERROR Illegal URI");
+            break;
+            }
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::AddNodeObjectL( const TDesC8& aURI, const TDesC& aParentLUID )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::AddNodeObjectL(const TDesC8& aURI,
+        const TDesC8& aParentLUID, TInt aStatusRef)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY	//Done by Dipak
+    TPtrC8 uriPtrc = NSmlDmURI::RemoveDotSlash(aURI);
+    TPtrC8 mapping( NSmlDmURI::LastURISeg( uriPtrc ) );
+    TPtrC8 parent( NSmlDmURI::RemoveLastSeg( uriPtrc ) );
+    TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) );
+    TInt cnt( NSmlDmURI::NumOfURISegs( uriPtrc ) );
+#else
+    TPtrC8 mapping(NSmlDmURI::LastURISeg(aURI) );
+    TPtrC8 parent(NSmlDmURI::RemoveLastSeg(aURI) );
+    TPtrC8 parentMapping(NSmlDmURI::LastURISeg(parent) );
+    TInt cnt(NSmlDmURI::NumOfURISegs(aURI) );
+#endif
+
+    RDEBUG8_3( "CSCOMOAdapter::AddNodeObjectL(): begin '%S', '%S'", &aURI, &aParentLUID );
+    SetAdapterValue(KAMSCOMOAdapter);
+    CheckStateChangesL();
+    TError status(EError);
+    //	TPtrC8 mapping( NSmlDmURI::LastURISeg( aURI ) );//Dipak
+    //	TPtrC8 parent( NSmlDmURI::RemoveLastSeg( aURI ) );
+    //	TPtrC8 parentMapping( NSmlDmURI::LastURISeg( parent ) );
+    //	TInt cnt( NSmlDmURI::NumOfURISegs( aURI ) );
+	TUint32 iluid( GetLuidL( aParentLUID, mapping, (parentMapping == KAMDeliveredNodeName ? EDCSDelivered : ( parentMapping == KAMDownloadNodeName ? EDCSDownload : EDCSNone ) ) ) ) ;
+	if( !iluid)
+	    {
+            // This is added for avoiding duplicate node creation in Delivered/Download only.
+	    iluid = GetLuidL( aParentLUID, mapping, (parentMapping == KAMDeliveredNodeName ? EDCSDownload:EDCSDelivered ));
+	    }
+    if (iluid == 0)
+        {
+        // Not found, add it ... 
+        DeliverOrDownloadL(mapping, aURI, cnt, parentMapping, status);
+        }
+    else
+        {
+        RDEBUG_2( "CSCOMOAdapter::AddNodeObjectL(): WARNING May Already exists '%d'", iluid );
+        TDeploymentComponent comp;
+        TInt err(SessionL().DeploymentComponent(iluid, comp) );
+        if (err == KErrNone)
+            {
+            RDEBUG_2( "CSCOMOAdapter::AddNodeObjectL(): ERROR Already exists '%d'", iluid );
+            if (comp.iState == StateL(aURI) )
+                {
+                RDEBUG( "CSCOMOAdapter::AddNodeObjectL():    (state is ok) " );
+                }
+            else
+                {
+                RDEBUG( "CSCOMOAdapter::AddNodeObjectL():    (state is NOK) " );
+                }
+            status = EAlreadyExists;
+            }
+        else
+            {
+            if (err == KErrNotFound)
+                {
+                RDEBUG_2( "CSCOMOAdapter::AddNodeObjectL(): WARNING Already exists but not found '%d'", iluid );
+                DeliverOrDownloadL(mapping, aURI, cnt, parentMapping, status);
+                }
+            else
+                {
+
+                RDEBUG_2( "CSCOMOAdapter::AddNodeObjectL(): ERROR May exists, but failed to fetch get one? '%d'", err );
+                }
+            }
+        }
+    if (status == EOk)
+        {
+        if (iInAtomic)
+            {
+            iBuffer.Append(TAMCommandBufferElement(aStatusRef, aURI) );
+            }
+        }
+
+    //status = EAcceptedForProcessing;
+    //TInt error = 202;
+    SetStatusL(aStatusRef, status);
+    RDEBUG( "CSCOMOAdapter::AddNodeObject(): end" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::GetSizeL( const TDesC8& aURI, const TDesC& aParentLUID )
+// ------------------------------------------------------------------------------------------------
+TInt CSCOMOAdapter::GetSizeL(const TDeplCompAttrType aDataType,
+        const TInt aLuid, TError &aRet)
+    {
+    TInt size( 0);
+    if (aDataType == EDCStateValue)
+        {
+        TDeploymentComponent comp;
+        TInt err(SessionL().DeploymentComponent(aLuid, comp) );
+        if (err == KErrNone)
+            {
+            if (comp.iState == EDCSActive)
+                {
+                size = KAMStateValueActive().Length();
+                }
+            else if (comp.iState == EDCSDelivered)
+                {
+                size = KAMStateValueDelivered().Length();
+                }
+            else
+                {
+                size = KAMStateValueInactive().Length() ;
+                }
+            aRet = EOk;
+            }
+        }
+    else
+        {
+        size = SessionL().DeploymentComponentDataSizeL(aLuid, aDataType);
+        aRet = EOk;
+        }
+    return size;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC& aParentLUID )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::FetchLeafObjectSizeL(const TDesC8& aURI,
+        const TDesC8& aLUID, const TDesC8& aType, TInt aResultsRef,
+        TInt aStatusRef)
+    {
+
+    RDEBUG8_4("CSCOMOAdapter::FetchLeafObjectSizeL('%S', '%S', '%S'): begin", &aURI, &aLUID, &aType );
+    CheckStateChangesL();
+    TError status(EError);
+    CBufBase *currentList = CBufFlat::NewL( 128);
+    CleanupStack::PushL(currentList);
+
+    TPtrC8 mapping(NSmlDmURI::LastURISeg(aURI) );
+    TPtrC8 parent(NSmlDmURI::RemoveLastSeg(aURI) );
+    TPtrC8 parentMapping(NSmlDmURI::LastURISeg(parent) );
+    TInt size( 0);
+    HBufC8 *luid= NULL;
+    if (aLUID != KNullDesC8)
+        {
+        luid = aLUID.AllocLC();
+        }
+    else
+        { // try if we find it from download path
+        TBuf8<256> down;
+        down = KDownloadURI;
+        down.Append(parentMapping);
+        luid = Callback().GetLuidAllocL(down);
+        CleanupStack::PushL(luid);
+        if ( *luid != KNullDesC8)
+            {
+            // make it to found next time
+            DirectSetMappingL(parent, *luid);
+            MoveAclL(down, parent);
+
+            // remove old
+            DirectSetMappingL(down, KNullDesC8);
+            }
+        }
+    TDeplCompAttrType dataType(UpdateFlagFromMapping(mapping) );
+    if ( *luid != KNullDesC8)
+        {
+        TUint32 iluid(DesToIntL( *luid ));
+        RDEBUG_2( "CSCOMOAdapter::FetchLeafObjectSizeL(): Luid is : %d", iluid );
+        size = GetSizeL(dataType, iluid, status);
+        }
+    else
+        {
+        TUint32 iluid(GetLeafLuidL(aURI, parentMapping) );
+        if (iluid > 0)
+            {
+            HBufC8 *l = IntToDes8LC(iluid);
+            DirectSetMappingL(parent, *l);
+            CleanupStack::PopAndDestroy(l);
+            size = GetSizeL(dataType, iluid, status);
+            }
+        else
+            {
+            RDEBUG8_2( "CSCOMOAdapter::FetchLeafObjectSizeL(): WARNING Faild to get luid allocation for '%S'", &parent );
+            if (aLUID == KNullDesC8)
+                {
+                status = ENotFound;
+                }
+            }
+        }
+    SetStatusL(aStatusRef, status);
+    if (status == EOk && size > 0)
+        {
+        HBufC8 *hsize = IntToDes8LC(size);
+        currentList->InsertL( 0, *hsize);
+        if (iInAtomic)
+            {
+            iBuffer.Append(TAMCommandBufferElement(aStatusRef, aURI) );
+            }
+        Callback().SetResultsL(aResultsRef, *currentList, aType);
+        CleanupStack::PopAndDestroy(hsize);
+        }
+    CleanupStack::PopAndDestroy(luid);
+    CleanupStack::PopAndDestroy(currentList); //currentList	
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::ExecuteCommandL( const TDesC8& aURI, const TDesC& aParentLUID )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::ExecuteCommandL(const TDesC8& /*aURI*/,
+        const TDesC8& /*aLUID*/, RWriteStream*& /*aStream*/,
+        const TDesC8& /*aType*/, TInt /*aStatusRef*/)
+    {
+    RDEBUG("CSCOMOAdapter::ExecuteCommandL(stream): begin (NOT SUPPORTED)");
+    User::Leave(KErrNotSupported);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::CopyCommandL( const TDesC8& aURI, const TDesC& aParentLUID )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::CopyCommandL(const TDesC8& /*aTargetURI*/,
+        const TDesC8& /*aTargetLUID*/, const TDesC8& /*aSourceURI*/,
+        const TDesC8& /*aSourceLUID*/, const TDesC8& /*aType*/,
+        TInt aStatusRef)
+    {
+    RDEBUG("CSCOMOAdapter::CopyCommandL(): begin (NOT SUPPORTED)");
+    SetStatusL(aStatusRef, EError);
+
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::StartAtomicL(  )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::StartAtomicL()
+    {
+    RDEBUG("CSCOMOAdapter::StartAtomicL(): begin (NOT properly SUPPORTED)");
+    iInAtomic = ETrue;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::CommitAtomicL(  )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::CommitAtomicL()
+    {
+    RDEBUG("CSCOMOAdapter::CommitAtomicL(): begin (NOT SUPPORTED)");
+    iInAtomic = EFalse; // the initial statuses are already set
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::RollbackAtomicL(  )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::RollbackAtomicL()
+    {
+    RDEBUG("CSCOMOAdapter::RollbackAtomicL(): begin (NOT properly SUPPORTED)");
+    TInt count(iBuffer.Count() );
+    for (TInt i( 0); i < count; i++)
+        {
+        TAMCommandBufferElement &pm(iBuffer[i]);
+        SetStatusL(pm.iStatusRef, ERollbackFailed);
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::StreamingSupport( )
+// ------------------------------------------------------------------------------------------------
+TBool CSCOMOAdapter::StreamingSupport(TInt& aItemSize)
+    {
+    RDEBUG("CSCOMOAdapter::StreamingSupport(): begin");
+    //aItemSize = 1024;
+    
+    // After Generic alert is sent delete that entry from database and notify
+    // AM server to delete the appropriate entry in its database.
+    
+    if(aItemSize == KNSmlDMResetGenAlerts)
+    {
+      TSmlProfileId profId = 0;
+      HBufC8* serverId = NULL;
+      TRAP_IGNORE(GetServerInfoL( profId, serverId ));
+      
+    
+    TUint32 internalid;
+    RPointerArray<CAMDbItem> genericalerts;
+    
+
+    // Get generic alert entry from Database for particular server ID.
+    TRAPD(err, iAMdb->GetEntryForServerIDL(genericalerts, *serverId));
+
+    if (genericalerts.Count()!= KErrNone && err == KErrNone)
+        {
+          	for(TInt i=0; i<genericalerts.Count(); i++)
+    		{
+			internalid = genericalerts[i]->iLUID;
+			// Delete the all the generic alert details from SCOMO adapeter DB
+			// Also delete the appropriate entry from AM Server DB as well.
+            TRAP_IGNORE(iAMdb->DeleteFromDatabaseL(internalid));
+            TRAP_IGNORE(SessionL().GenericAlertSentL(internalid));
+    		}
+        }
+    
+
+    genericalerts.ResetAndDestroy();
+    delete serverId;
+
+    _LIT(KNull,"");
+    // No monitoring required after generic alert is sent
+    TInt err_rep = KErrNone;
+    CRepository *repository1 = NULL;
+
+    TRAP(err_rep, repository1 =CRepository::NewL ( KCRUidDeviceManagementInternalKeys ));
+  
+    if(err_rep == KErrNone)  
+    {
+    repository1 ->Set(KDevManServerIdKey ,KNull);
+    repository1 ->Set(KDevManIapIdKey, KErrNone);
+    repository1 ->Set(KDevManEnableDMNetworkMon, KErrNone);
+    }
+     
+    if(repository1)
+     delete repository1;
+      
+    }
+    aItemSize = 1024;
+    RDEBUG("CSCOMOAdapter::StreamingSupport(): end");
+    return ETrue;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::StreamCommittedL( )
+// ------------------------------------------------------------------------------------------------
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+void CSCOMOAdapter::StreamCommittedL( RWriteStream& /*aStream*/)
+#else
+void CSCOMOAdapter::StreamCommittedL()
+#endif
+    {
+    RDEBUG("CSCOMOAdapter::StreamCommittedL(): begin");
+
+    if (iStreamOpen)
+        {
+        iStream.CommitL();
+        }
+
+    MSmlDmAdapter::TError status = EOk;
+
+    TRAPD( err, _UpdateLeafObjectL( *iStreamedURI, *iStreamedLuid, KNullDesC8(), *iStreamedType, iStatusRef, status ) )
+    ;
+
+    if (err != KErrNone)
+        {
+        RDEBUG_2("CSCOMOAdapter::StreamCommittedL(): _UpdateLeafObjectL returned error (%d)", err);
+        }
+
+    iIsStreamedContent = EFalse;
+    iStreamOpen = EFalse;
+
+    Callback().SetStatusL(iStatusRef, status);
+
+    RDEBUG("CSCOMOAdapter::StreamCommittedL(): end");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::CloseStreaming( )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::CloseStreaming()
+    {
+    if (iStreamOpen)
+        {
+        RDEBUG("CSCOMOAdapter::CloseStreaming(): closing");
+        iStreamFile.Close(); // !!! Closing this will also close the iStreamRFs because it is adopted from server
+        iStreamOpen = EFalse;
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::CompleteOutstandingCmdsL()
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::CompleteOutstandingCmdsL()
+    {
+    RDEBUG("CSCOMOAdapter::CompleteOutstandingCmdsL(): begin");
+    /*	iManagement.Close();
+     iSessionOpened = EFalse ;*/
+    iBuffer.Reset();
+    RDEBUG("CSCOMOAdapter::CompleteOutstandingCmdsL(): Management session closed");
+    }
+
+// ------------------
+//
+// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+const TImplementationProxy ImplementationTable[] =
+    {
+    //
+            IMPLEMENTATION_PROXY_ENTRY( KAMAdapterImplUid, CSCOMOAdapter::NewL )
+    };
+
+// ------------------------------------------------------------------------------------------------
+//
+// ------------------------------------------------------------------------------------------------
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+    return ImplementationTable;
+    }
+
+// ------------------------------------------------------------------------------------------------
+//
+// ------------------------------------------------------------------------------------------------
+TInt CSCOMOAdapter::DesToIntL(const TDesC8& aLuid)
+    {
+    TLex8 lex(aLuid);
+    TInt value = 0;
+    User::LeaveIfError(lex.Val(value) );
+    return value;
+    }
+
+// ------------------------------------------------------------------------------------------------
+//
+// ------------------------------------------------------------------------------------------------
+HBufC8* CSCOMOAdapter::IntToDes8LC(const TInt aLuid)
+    {
+    HBufC8* buf = HBufC8::NewLC( 10); //10 = max length of 32bit integer
+    TPtr8 ptrBuf = buf->Des();
+    ptrBuf.Num(aLuid);
+    return buf;
+    }
+
+// ------------------------------------------------------------------------------------------------
+//
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::ConstructL()
+    {
+    iAMdb = CSCOMOAdapterDb::NewL();
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    iDbSession.ConnectL();
+#else
+    User::LeaveIfError(iDbSession.Connect());
+#endif
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::SetStatusL( TInt aStatusRef, MSmlDmAdapter::TError aErrorCode ) 
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::SetStatusL(TInt aStatusRef,
+        MSmlDmAdapter::TError aErrorCode)
+    {
+    RDEBUG_3("CSCOMOAdapter::SetStatusL( %d, %d )", aStatusRef, aErrorCode );
+    Callback().SetStatusL(aStatusRef, aErrorCode);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::SetResultsL( TInt aResultsRef, CBufBase& aObject, const TDesC8& aType )
+// ------------------------------------------------------------------------------------------------
+void CSCOMOAdapter::SetResultsL(TInt aResultsRef, CBufBase& aObject,
+        const TDesC8& aType)
+    {
+    Callback().SetResultsL(aResultsRef, aObject, aType);
+
+    }
+
+// -------------------------------------------------------------------------------------
+// CSCOMOAdapter::FillNodeInfoL()
+// Fills the node info in ddf structure
+// -------------------------------------------------------------------------------------
+void CSCOMOAdapter::FillNodeInfoL(MSmlDmDDFObject& aNode,
+        TSmlDmAccessTypes aAccTypes, MSmlDmDDFObject::TOccurence aOccurrence,
+        MSmlDmDDFObject::TScope aScope, MSmlDmDDFObject::TDFFormat aFormat,
+        const TDesC8& aDescription)
+    {
+    FillNodeInfoNoDefaultMimeL(aNode, aAccTypes, aOccurrence, aScope,
+            aFormat, aDescription);
+    if (aFormat!=MSmlDmDDFObject::ENode)
+        {
+        aNode.AddDFTypeMimeTypeL(KAMTextPlain);
+        }
+
+    }
+
+// -------------------------------------------------------------------------------------
+// CSCOMOAdapter::FillNodeInfoNoDefaultMimeL()
+// Fills the node info in ddf structure, without default mime type
+// -------------------------------------------------------------------------------------
+void CSCOMOAdapter::FillNodeInfoNoDefaultMimeL(MSmlDmDDFObject& aNode,
+        TSmlDmAccessTypes aAccTypes, MSmlDmDDFObject::TOccurence aOccurrence,
+        MSmlDmDDFObject::TScope aScope, MSmlDmDDFObject::TDFFormat aFormat,
+        const TDesC8& aDescription)
+    {
+    aNode.SetAccessTypesL(aAccTypes);
+    aNode.SetOccurenceL(aOccurrence);
+    aNode.SetScopeL(aScope);
+    aNode.SetDFFormatL(aFormat);
+
+    aNode.SetDescriptionL(aDescription);
+    }
+
+// -------------------------------------------------------------------------------------
+// CSCOMOAdapter::CheckStateChangesInternalL()
+// Updates the changed DC states to DM client mappings and ACLs
+// -------------------------------------------------------------------------------------
+void CSCOMOAdapter::CheckStateChangesInternalL()
+    {
+
+#ifdef __AM_CHECKSTATE_CHANGES
+    RDEBUG( "CSCOMOAdapter::CheckStateChangesLInternal(): begin" );
+    if ( !iUpdated)
+        {
+        RDEBUG( "CSCOMOAdapter::CheckStateChangesLInternal(): !iUpdated" );
+        RElementIdArray arr;
+        CleanupClosePushL(arr);
+		SessionL().CheckStatusNodesL();
+		RElementIdArray array;
+		TInt err( SessionL().DeploymentComponentIdsL( array, EDCSActive ) ); //to sync with SIS/Java registry
+		err = SessionL().DeploymentComponentIdsL( array, EDCSInactive ); //to sync with SIS/Java registry
+		CleanupClosePushL(array);
+        err = SessionL().StateChangingDCIdsL(arr);
+        if (err == KErrNone)
+            {
+            TInt c(arr.Count() );
+            for (TInt i( 0); i < c; i++)
+                {
+                TDeploymentComponent comp;
+                err = iManagement.DeploymentComponent(arr[i], comp);
+                if (err == KErrNone)
+                    {
+                    TDCUserId dc;
+                    SessionL().DeploymentComponentUserIdL(arr[i], dc);
+                    const TInt KNSmlDmMaxUriLength = 256;
+                    HBufC8 *uri = HBufC8::NewLC(KNSmlDmMaxUriLength);
+                    TPtr8 puri(uri->Des() );
+#ifdef __TARM_SYMBIAN_CONVERGENCY					
+                    RDmTreeNode uriNode;
+                    CleanupClosePushL(uriNode);
+
+                    RBuf8 acl;
+                    acl.CreateL(128);
+                    CleanupClosePushL(acl);
+
+                    HBufC8 *newUri = HBufC8::NewLC( KNSmlDmMaxUriLength );
+                    TPtr8 pnewUri( newUri->Des() );
+
+                    RDmTreeNode newUriNode;
+                    CleanupClosePushL(newUriNode);
+#else
+                    CBufBase* acl = CBufFlat::NewL( 128);
+                    CleanupStack::PushL(acl);
+
+                    HBufC8 *newUri = HBufC8::NewLC(KNSmlDmMaxUriLength);
+                    TPtr8 pnewUri(newUri->Des() );
+
+#endif
+
+                    switch (comp.iOldState)
+                        {
+                        case EDCSDelivered:
+                            {
+                            RDEBUG( "CSCOMOAdapter::CheckStateChangesLInternal(): Old State = EDCSDelivered" );
+                            puri.Copy(KDeliveredURI() );
+                            puri.Append(dc);
+
+                            HBufC8 *luid = DirectGetLuidAllocLC(puri);
+
+                            if ( *luid == KNullDesC8)
+                                { // probably moved already
+                                iManagement.StateChangeComplete(arr[i]);
+                                }
+                            else
+                                {
+                                // "Nullify" the old mapping 
+								//DirectSetMappingL( puri, KNullDesC8 );
+								DirectRemoveMappingL(puri);
+#ifdef __TARM_SYMBIAN_CONVERGENCY								
+                                iDbSession.OpenNodeL(puri, uriNode, RDmTree::EReadOnly);
+                                uriNode.DmPropertyL( DevMan::EACL, acl );
+#else
+                                err = iDbSession.GetAclL(puri, *acl, EFalse); // no need for inherited
+#endif										
+                                // Determine new uri 
+                                switch (comp.iState)
+                                    {
+                                    case EDCSActive:
+                                    case EDCSInactive: // both have same node
+                                        {
+                                        pnewUri.Copy(KDeployedURI() );
+                                        pnewUri.Append(dc);
+                                        DirectSetMappingL(pnewUri, *luid);
+                                        if (err == KErrNone)
+                                            {
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+                                            iDbSession.OpenNodeL(pnewUri, newUriNode, RDmTree::EReadOnly);
+                                            uriNode.RemoveDmPropertyL( DevMan::EACL );
+                                            newUriNode.SetDmPropertyL( DevMan::EACL, acl );
+#else
+                                            err = iDbSession.DeleteAclL(puri);
+
+                                            err = iDbSession.UpdateAclL(
+                                                    pnewUri, acl->Ptr( 0) );
+#endif
+                                            }
+                                        else
+                                            {
+                                            RDEBUG_2("CSCOMOAdapter::CheckStateChangesL: ERROR Failed to get acl from %d ", err );
+                                            }
+                                        iManagement.StateChangeComplete(arr[i]);
+                                        break;
+                                        }
+                                    default:
+                                        {
+
+                                        RDEBUG_2("CSCOMOAdapter::CheckStateChangesL: WARNING Illegal state change from delivered to %d ", comp.iState );
+
+                                        break;
+                                        }
+                                    }
+                                }
+                            CleanupStack::PopAndDestroy(luid);
+                            break;
+                            }
+                        case EDCSDownload:
+                            {
+                            RDEBUG( "CSCOMOAdapter::CheckStateChangesLInternal(): Old State = EDCSDownload" );
+                            puri.Copy(KDownloadURI() );
+                            //check DC contains SCOMODefault.
+                            TBuf8<256> staticnode;
+                            TInt staticnodeenabled = 0;
+                            CRepository* cenrep = CRepository::NewLC( KCRUidPrivateApplicationManagementKeys );
+                            cenrep->Get( KAMDownloadPredefinedNode, staticnode ); 
+                            cenrep->Get( KAMStaticNodeEnabled, staticnodeenabled );
+                            CleanupStack::PopAndDestroy(); //cenrep
+                            if (dc.Find(staticnode) != KErrNotFound && staticnodeenabled)
+                                {
+                                puri.Append(staticnode);
+                                }
+                            else
+                                {
+                                puri.Append(dc);
+                                }
+
+
+                            HBufC8 *luid = DirectGetLuidAllocLC(puri); //Callback().GetLuidAllocL( puri );
+                            //CleanupStack::PushL( luid );
+                            if ( *luid == KNullDesC8)
+                                { // probably moved already
+                                CleanupStack::PopAndDestroy(luid);
+                                puri.Copy(KDeliveredURI() );
+                                puri.Append(dc);
+                                luid = DirectGetLuidAllocLC(puri); //Callback().GetLuidAllocL( puri );
+                                if ( *luid == KNullDesC8)
+                                    { // probably moved already
+
+                                    iManagement.StateChangeComplete(arr[i]);
+
+                                    }
+                                }
+                            else
+                                {
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+                                iDbSession.OpenNodeL(puri, uriNode, RDmTree::EReadOnly);
+                                uriNode.DmPropertyL( DevMan::EACL, acl );
+#else
+                                err = iDbSession.GetAclL(puri, *acl, EFalse); // no need for inherited
+#endif							
+                                // "Nullify" the old mapping 
+								//DirectSetMappingL( puri, KNullDesC8 );
+								DirectRemoveMappingL(puri);
+                                switch (comp.iState)
+                                    {
+                                    case EDCSActive:
+                                    case EDCSInactive: // both have same node
+                                        {
+                                        pnewUri.Copy(KDeployedURI() );
+                                        pnewUri.Append(dc);
+                                        DirectSetMappingL(pnewUri, *luid);
+                                        if (err == KErrNone)
+                                            {
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+                                            iDbSession.OpenNodeL(pnewUri, newUriNode, RDmTree::EReadOnly);
+                                            uriNode.RemoveDmPropertyL( DevMan::EACL );
+                                            newUriNode.SetDmPropertyL( DevMan::EACL, acl );
+#else											
+                                            err = iDbSession.DeleteAclL(puri);
+                                            err = iDbSession.UpdateAclL(
+                                                    pnewUri, acl->Ptr( 0) );
+#endif
+                                            }
+                                        else
+                                            {
+                                            RDEBUG_2("CSCOMOAdapter::CheckStateChangesL: ERROR Failed to get acl from %d ", err );
+                                            }
+                                        iManagement.StateChangeComplete(arr[i]);
+                                        break;
+                                        }
+                                    case EDCSDelivered:
+                                        {
+                                        RDEBUG( "CSCOMOAdapter::CheckStateChangesLInternal(): Current State = EDCSDelivered" );
+                                        pnewUri.Copy(KDeliveredURI() );
+                                        pnewUri.Append(dc);
+                                        DirectSetMappingL(pnewUri, *luid);
+                                        if (err == KErrNone)
+                                            {
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+                                            iDbSession.OpenNodeL(pnewUri, newUriNode, RDmTree::EReadOnly);
+                                            uriNode.RemoveDmPropertyL( DevMan::EACL );
+                                            newUriNode.SetDmPropertyL( DevMan::EACL, acl );
+#else
+
+                                            err = iDbSession.DeleteAclL(puri);
+                                            err = iDbSession.UpdateAclL(
+                                                    pnewUri, acl->Ptr( 0) );
+#endif
+                                            }
+                                        else
+                                            {
+                                            RDEBUG_2("CSCOMOAdapter::CheckStateChangesL: ERROR Failed to get acl from %d ", err );
+                                            }
+                                        iManagement.StateChangeComplete(arr[i]);
+                                        break;
+                                        }
+                                    default:
+                                        {
+
+                                        RDEBUG_2("CSCOMOAdapter::CheckStateChangesL: WARNING Illegal state change from delivered to %d ", comp.iState );
+                                        break;
+                                        }
+                                    }
+
+                                }
+                            CleanupStack::PopAndDestroy(luid);
+                            break;
+                            }
+                        case EDCSActive:
+                        case EDCSInactive: // these both are in same node
+                            {
+
+                            RDEBUG_3("CSCOMOAdapter::CheckStateChangesL: No need to move anything in change from %d to %d ", comp.iOldState, comp.iState );
+                            iManagement.StateChangeComplete(arr[i]);
+                            break;
+                            }
+                        }
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+                    CleanupStack::PopAndDestroy( &newUriNode );
+                    CleanupStack::PopAndDestroy( newUri );
+                    CleanupStack::PopAndDestroy( &uriNode );
+                    CleanupStack::PopAndDestroy( &acl );
+                    CleanupStack::PopAndDestroy( uri );
+#else
+                    CleanupStack::PopAndDestroy(newUri);
+                    CleanupStack::PopAndDestroy(acl);
+                    CleanupStack::PopAndDestroy(uri);
+#endif
+                    }
+                else
+                    {
+                    RDEBUG_2("CSCOMOAdapter::CheckStateChangesL: ERROR Failed to get component: %d ", err );
+                    }
+                }
+            iUpdated = ETrue;
+            }
+        else
+            {
+            RDEBUG_2("CSCOMOAdapter::CheckStateChangesL: ERROR Failed to get state change dcs: %d ", err );
+            }
+        CleanupStack::PopAndDestroy( &array);
+        CleanupStack::PopAndDestroy( &arr);
+        }
+    else
+        {
+        RDEBUG("CSCOMOAdapter::CheckStateChangesL: Already updated! ");
+        }
+    RDEBUG( "CSCOMOAdapter::CheckStateChangesL(): end" );
+#else
+    DBG_ARGS8( "CSCOMOAdapter::CheckStateChangesL(): disabled" );
+#endif
+    }
+
+// -------------------------------------------------------------------------------------
+// CSCOMOAdapter::CheckStateChangesL()
+// Updates acl and mapping trees to match state changes
+// -------------------------------------------------------------------------------------
+void CSCOMOAdapter::CheckStateChangesL()
+    {
+    iCertRequired = EFalse;
+    RDEBUG( "CSCOMOAdapter::CheckStateChangesL(): iCertRequired = EFalse" );
+    TRAPD( err, CheckStateChangesInternalL() )
+    ;
+    if (err != KErrNone)
+        {
+        RDEBUG_2("CSCOMOAdapter::CheckStateChangesL(): warning failed to check state changes %d", err );
+        }
+    iCertRequired = ETrue;
+    RDEBUG( "CSCOMOAdapter::CheckStateChangesL(): iCertRequired = ETrue" );
+    if ( !iTrustAdded)
+        {
+        RDEBUG( "CSCOMOAdapter::CheckStateChangesL(): Adding Trust Closing Session" );
+        iManagement.Close();
+        iSessionOpened = EFalse;
+        RApplicationManagement &session = SessionL();
+        RDEBUG( "CSCOMOAdapter::CheckStateChangesL(): Adding Trust new session started" );
+        }
+    }
+
+// -------------------------------------------------------------------------------------
+// CSCOMOAdapter::URISegsUpTo(const TDesC8& aURI, TInt aUpTo)
+// -------------------------------------------------------------------------------------
+TPtrC8 CSCOMOAdapter::URISegsUpTo(const TDesC8& aURI, TInt aUpTo,
+        TBool aInclKeno/*=EFalse*/)
+    {
+
+    TPtrC8 ret;
+    TInt numOfURISegs( 0);
+    for (TInt i( 0); i < aURI.Length() && ret.Ptr() == NULL; i++)
+        {
+        if (aURI[i] == KNSmlDMUriSeparator)
+            {
+            numOfURISegs++;
+            if (aUpTo == numOfURISegs)
+                {
+                if (aInclKeno && aURI.Length() > i+1)
+                    {
+                    ret.Set(aURI.Left(i + 1) );
+                    }
+                else
+                    {
+                    ret.Set(aURI.Left(i) );
+                    }
+                }
+            }
+        }
+    return ret;
+    }
+
+// -------------------------------------------------------------------------------------
+// CSCOMOAdapter::DirectGetLuidAllocLC( const TDesC8 &aURI )
+// -------------------------------------------------------------------------------------	
+HBufC8 *CSCOMOAdapter::DirectGetLuidAllocLC(const TDesC8 &aURI)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    HBufC8 *ret = Callback().GetLuidAllocL( aURI );
+#else
+    HBufC8* ret = iDbSession.GetLuidAllocL(KAMAdapterImplUid, aURI);
+#endif
+
+    CleanupStack::PushL(ret);
+    return ret;
+    }
+
+// -------------------------------------------------------------------------------------
+// CSCOMOAdapter::DirectSetMappingL( const TDesC8 &aURI, const TDesC8 &aLUID )
+// -------------------------------------------------------------------------------------		
+TInt CSCOMOAdapter::DirectSetMappingL(const TDesC8 &aURI, const TDesC8 &aLUID)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    TRAPD( err, Callback().SetMappingL( aURI, aLUID ) );
+#else
+    TInt err(iDbSession.AddMappingInfoL(KAMAdapterImplUid, aURI, aLUID) );
+#endif
+    return err;
+    }
+
+// -------------------------------------------------------------------------------------
+// CSCOMOAdapter::MoveAclL( const TDesC8 &aFrom, const TDesC8 &aTo )
+// -------------------------------------------------------------------------------------		
+void CSCOMOAdapter::MoveAclL(const TDesC8 &aFrom, const TDesC8 &aTo)
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    RDmTreeNode from;
+    CleanupClosePushL(from);
+
+    RDmTreeNode to;
+    CleanupClosePushL(to);
+
+    RBuf8 acl;
+    acl.CreateL(128);
+    CleanupClosePushL(acl);
+
+    iDbSession.OpenNodeL(aFrom, from, RDmTree::EReadOnly);
+    TRAPD( err, from.DmPropertyL( DevMan::EACL, acl ) );
+    if ( err == KErrNone )
+        {
+        iDbSession.OpenNodeL(aTo, to, RDmTree::EReadOnly);
+        from.RemoveDmPropertyL( DevMan::EACL );
+        to.SetDmPropertyL( DevMan::EACL, acl );
+        }
+    CleanupStack::PopAndDestroy( 3, &from );
+#else
+    CBufBase *acl = CBufFlat::NewL( 128);
+    CleanupStack::PushL(acl);
+    TInt err(iDbSession.GetAclL(aFrom, *acl, EFalse) ); // no need for inherited
+    if (err == KErrNone)
+        {
+        err = iDbSession.DeleteAclL(aFrom);
+        err = iDbSession.UpdateAclL(aTo, acl->Ptr( 0) );
+        }
+    CleanupStack::PopAndDestroy(acl);
+#endif
+    }
+
+// -------------------------------------------------------------------------------------
+// CSCOMOAdapter::SetMappingL( const TDesC8 &aOriginalURI, 
+//	const TDeploymentComponentState aTargetState, const TDesC8 &aLUID )
+// -------------------------------------------------------------------------------------		
+void CSCOMOAdapter::SetMappingL(const TDesC8 &aOriginalURI,
+        const TDeploymentComponentState aTargetState, const TDesC8 &aLUID)
+    {
+
+    HBufC8 * targeturi= NULL;
+    SetMappingLC(aOriginalURI, aTargetState, aLUID, targeturi);
+    CleanupStack::PopAndDestroy(targeturi);
+    }
+
+// -------------------------------------------------------------------------------------
+// CSCOMOAdapter::SetMappingLC( const TDesC8 &aOriginalURI, 
+//	const TDeploymentComponentState aTargetState, const TDesC8 &aLUID, 
+//	HBufC8 *&aNewUri )
+// -------------------------------------------------------------------------------------		
+void CSCOMOAdapter::SetMappingLC(const TDesC8 &aOriginalURI,
+        const TDeploymentComponentState aTargetState, const TDesC8 &aLUID,
+        HBufC8 *&aNewUri)
+    {
+
+    // "Nullify" the mapping for argument
+    DirectSetMappingL(aOriginalURI, KNullDesC8);
+
+    // Determine new uri for aArgument
+    TPtrC8 puri;
+    if (aNewUri == NULL)
+        {
+        TPtrC8 argMapping(NSmlDmURI::LastURISeg(aOriginalURI) );
+        TPtrC8 target;
+        if (aTargetState == EDCSInactive || aTargetState == EDCSActive)
+            {
+            target.Set(KDeployedURI() );
+            }
+        else
+            if (aTargetState == EDCSDelivered)
+                {
+                target.Set(KDeliveredURI() );
+                }
+            else
+                {
+
+                User::Leave(KErrArgument);
+                }
+
+        aNewUri = HBufC8::NewLC(target.Length() + argMapping.Length() );
+        TPtr8 p(aNewUri->Des() );
+        p.Copy(target);
+        p.Append(argMapping);
+        puri.Set(p);
+        }
+    else
+        {
+        puri.Set( *aNewUri);
+        }
+    DirectSetMappingL(puri, aLUID);
+    MoveAclL(aOriginalURI, puri);
+    }
+
+#ifdef __AM_LASTERROR_NODE
+// ------------------------------------------------------------------------------------------------
+// CSCOMOAdapter::SetLastErrorL( const TDesC8& aLastError, const TInt aError )
+// ------------------------------------------------------------------------------------------------	
+void CSCOMOAdapter::SetLastErrorL(const TDesC8& aLastError, const TInt aError)
+    {
+    if (iLastError)
+        {
+        TPtrC8 p(*iLastError);
+        RDEBUG8_2( "CSCOMOAdapter::SetLastErrorL: clearing last error %S", &p);
+        delete iLastError;
+        iLastError = NULL;
+        }
+    iLastError = HBufC8::NewL(aLastError.Length() + 10);
+    iLastError->Des().Format(aLastError, aError);
+    }
+
+const TDesC8& CSCOMOAdapter::LastError()
+    {
+    return iLastError == NULL ? KNullDesC8() : *iLastError;
+    }
+
+#endif
+
+TPtrC8 CSCOMOAdapter::LastURISeg(const TDesC8& aURI)
+    {
+    TInt i;
+    for (i=aURI.Length()-1; i>=0; i--)
+        {
+        if (aURI[i]==KNSmlDMAMSeparatorDef)
+            {
+            break;
+            }
+        }
+    if (i==0)
+        {
+        return aURI;
+        }
+    else
+        {
+        return aURI.Mid(i+1);
+        }
+    }
+
+TInt CSCOMOAdapter::DesToInt(const TDesC8& aLuid)
+    {
+    TLex8 lex(aLuid);
+    TInt value = 0;
+    lex.Val(value);
+    return value;
+    }
+void CSCOMOAdapter::CheckAndAddPredefinedNodeL()
+    {
+
+    RDEBUG("CSCOMOAdapter::CheckAndAddPredefinedNodeL(): begin");
+
+    // Check if SCOMODefault node addition is enabled.
+    TInt staticnodeenabled = 0;
+    CRepository* cenrep = CRepository::NewLC( KCRUidPrivateApplicationManagementKeys );
+    cenrep->Get( KAMStaticNodeEnabled, staticnodeenabled ); 
+    CleanupStack::PopAndDestroy(); //cenrep
+        
+    RDEBUG("CSCOMOAdapter::CheckAndAddPredefinedNodeL(): step1");
+
+    if(staticnodeenabled)
+    {
+      TBuf8<KMaxFullName> temp;
+
+      RDEBUG("CSCOMOAdapter::CheckAndAddPredefinedNodeL(): step2");
+      GetPredefinedNodeL(temp);
+
+      RDEBUG("CSCOMOAdapter::CheckAndAddPredefinedNodeL(): step3");
+      if (temp.Length())
+        {
+
+
+        RDEBUG("CSCOMOAdapter::CheckAndAddPredefinedNodeL(): step4");
+        TBuf8<KMaxFullName> temp1;
+        temp1.Zero();
+        temp1.Copy(KAMNodeName);
+        temp1.Append(KAMSeparator8);
+        temp1.Append(KAMDownloadNodeName);
+        temp1.Append(KAMSeparator8);
+        temp1.Append(temp);
+       
+        HBufC8* luid = DirectGetLuidAllocLC(temp1);
+
+         RDEBUG("CSCOMOAdapter::CheckAndAddPredefinedNodeL(): step5");
+
+        if (luid->Length() > 0)
+            {
+            CleanupStack::PopAndDestroy(luid);
+            return;
+            }
+        else
+            {
+            RDEBUG("CSCOMOAdapter::CheckAndAddPredefinedNodeL(): step6");
+            // Not found, add node and mapping ... 
+            //TError status(EError);
+            TPtrC8 mapping(NSmlDmURI::LastURISeg(temp1) );
+            TPtrC8 parent(NSmlDmURI::RemoveLastSeg(temp1) );
+            TPtrC8 parentMapping(NSmlDmURI::LastURISeg(parent) );
+            TInt cnt(NSmlDmURI::NumOfURISegs(temp1) );
+             RDEBUG("CSCOMOAdapter::CheckAndAddPredefinedNodeL(): step7");
+            TUint32 newLuid(SessionL().DownloadL(mapping));
+            //Callback().SetMappingL( temp1, *IntToDes8LC( newLuid ) );
+            //CleanupStack::PopAndDestroy();
+            RDEBUG("CSCOMOAdapter::CheckAndAddPredefinedNodeL(): step8");
+            DirectSetMappingL(temp1, *IntToDes8LC(newLuid) );
+            RDEBUG("CSCOMOAdapter::CheckAndAddPredefinedNodeL(): step9");
+            CleanupStack::PopAndDestroy(); // for IntToDes8LC()
+            CleanupStack::PopAndDestroy(luid);
+            }
+        }
+    }
+    }
+// ---------------------------------------------------------------------------
+// CAmAdapter::GetPredefinedNodeL()
+// Gets  predefined node for Download object from cenrep 
+// ---------------------------------------------------------------------------
+//
+void CSCOMOAdapter::GetPredefinedNodeL(TDes8& aNode)
+	{
+	CRepository* centrep( NULL);
+	aNode.Zero();
+   	centrep = CRepository::NewLC( KCRUidPrivateApplicationManagementKeys );
+
+    if ( centrep )
+	    {
+        TBuf8<256> temp;
+		TInt err = centrep->Get( KAMDownloadPredefinedNode, temp );
+    	if (centrep->Get( KAMDownloadPredefinedNode, temp )==KErrNone && temp.Length() )
+			{
+			temp.Trim();
+			aNode.Copy(temp);
+			}
+		CleanupStack::PopAndDestroy(centrep);
+	    }
+	}
+// -------------------------------------------------------------------------------------
+// CAmAdapter::DirectRemoveMappingL( const TDesC8 &aURI )
+// -------------------------------------------------------------------------------------        
+TInt CSCOMOAdapter::DirectRemoveMappingL( const TDesC8 &aURI )
+    {
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    TRAPD( err, Callback().SetMappingL( aURI, aLUID ) );
+#else
+    TInt err( iDbSession.RemoveMappingInfoL( KAMAdapterImplUid, aURI, ETrue ) );
+#endif
+    return err;
+    }
+TInt CSCOMOAdapter::GetAdapterValue()
+    {
+    TInt adapterValue;
+    CRepository *repository = NULL;
+    TRAPD( err, repository = CRepository::NewL ( KCRUidPrivateApplicationManagementKeys ) );
+
+    RDEBUG_2("error reading cenrep %d", err);
+    if (err == KErrNone)
+        {
+        err = repository->Get(KAMAdapterValue, adapterValue);
+        }
+    delete repository;
+    repository = NULL;
+    return adapterValue;
+    }
+
+void CSCOMOAdapter::SetAdapterValue(TInt aAdapterValue)
+    {
+    CRepository *repository = NULL;
+    TRAPD( err, repository = CRepository::NewL ( KCRUidPrivateApplicationManagementKeys ) );
+    if (err == KErrNone)
+        {
+        err = repository->Set(KAMAdapterValue, aAdapterValue);
+        }
+    delete repository;
+    repository = NULL;
+    }
+TBool CSCOMOAdapter::RecognizeMimeType(const TDesC8& aMimeType)
+    {
+    TBool isSupportedMimeType = EFalse;
+    if ((aMimeType == KSisxMimeType )||(aMimeType == KSisMimeType )||(aMimeType == KPipMimeType )||
+            (aMimeType == KJadMIMEType )||(aMimeType == KJarMIMEType )||(aMimeType == KJavaMIMEType ))
+        {
+        isSupportedMimeType = ETrue;
+        }
+    return isSupportedMimeType;
+    }
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/src/omascomoadapter.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+ *
+ * Description:  Implementation of applicationmanagement components
+ *
+*/
+
+
+#include <registryinfo.rh>
+#define KSmlDMInterfaceUid 0x102018B4
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x20021335; //The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = KSmlDMInterfaceUid; // DM interface UID
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x20021336; // SCOMO DM Adapter implementation UID
+                version_no = 1; 
+                display_name = "Application Management DM Adapter";
+                default_data = "";
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+                opaque_data = "host=0x101F9A02";
+#else
+								opaque_data = "";
+#endif
+                }
+            };
+          }
+      };
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/omascomoadapter/src/omascomoadapterdb.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,447 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 applicationmanagement components
+ *
+*/
+
+
+// INCLUDE FILES
+#include <sysutil.h>
+#include <bautils.h>
+
+#include "omascomoadapterdb.h"
+#include "debug.h"
+
+// ============================ MEMBER FUNCTIONS =============================
+
+// ---------------------------------------------------------------------------
+//  CSCOMOAdapterDb::NewL()
+//  Creates a new instance of CSCOMOAdapterDb object.
+// ---------------------------------------------------------------------------
+// 
+CSCOMOAdapterDb* CSCOMOAdapterDb::NewL()
+    {
+    RDEBUG("CSCOMOAdapterDb::NewL(): begin");
+
+    CSCOMOAdapterDb* self = CSCOMOAdapterDb::NewLC();
+    CleanupStack::Pop(self);
+
+    RDEBUG("CSCOMOAdapterDb::NewL(): end");
+
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+//  CSCOMOAdapterDb::NewLC()
+//  Creates a new instance of CSCOMOAdapterDb object. 
+//  Pushes and leaves new instance onto CleanupStack.
+// ---------------------------------------------------------------------------
+// 
+CSCOMOAdapterDb* CSCOMOAdapterDb::NewLC()
+    {
+    RDEBUG("CSCOMOAdapterDb::NewLC(): begin");
+
+    CSCOMOAdapterDb* self = new( ELeave ) CSCOMOAdapterDb();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+
+    RDEBUG("CSCOMOAdapterDb::NewLC(): end");
+
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+//  CSCOMOAdapterDb::ConstructL()
+//  Second phase constructor.
+// ---------------------------------------------------------------------------
+// 
+void CSCOMOAdapterDb::ConstructL()
+    {
+    RDEBUG("CSCOMOAdapterDb::ConstructL(): begin");
+
+    TParse name;
+    TInt err;
+
+    User::LeaveIfError(iFsSession.Connect());
+    User::LeaveIfError(iRdbSession.Connect() );
+
+    iFsSession.SetSessionToPrivate(EDriveC);
+
+#ifdef SYMBIAN_SECURE_DBMS
+    name.Set(KAMAdapterDbName, NULL, NULL);
+    err = iDatabase.Open(iRdbSession, name.FullName(), KDBMSSecureID);
+#else
+    name.Set( KAMAdapterDbName, KNonSecureDbFullName, NULL );
+    err = iDatabase.Open(iRdbSession, DBFileName);
+#endif
+
+    if (err == KErrNotFound)
+        {
+        CreateandOpenL(name);
+        }
+    else
+        {
+
+        if ( (err == KErrEof ) || (err == KErrCorrupt ) || (err
+                == KErrArgument ))
+            {
+
+            iRdbSession.DeleteDatabase(name.FullName(), KAMPolicyUID);
+            CreateandOpenL(name);
+            }
+
+        }
+
+    RDEBUG("CSCOMOAdapterDb::ConstructL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CWPInternetAPDB::CreateandOpenL
+// -----------------------------------------------------------------------------
+//    
+void CSCOMOAdapterDb::CreateandOpenL(TParse& name)
+    {
+
+    TInt err;
+
+#ifdef SYMBIAN_SECURE_DBMS
+    iDatabase.Create(iRdbSession, name.FullName(), KDBMSSecureID);
+#else
+    if( SysUtil::FFSSpaceBelowCriticalLevelL( &iFsSession, KEmptyDbSizeEstimate ) )
+        {
+        User::Leave( KErrDiskFull );
+        }
+    iDatabase.Create(iFsSession, name.FullName());
+#endif	
+
+    CreateTableL(iDatabase);
+    iDatabase.Close();
+#ifdef SYMBIAN_SECURE_DBMS
+
+    err = iDatabase.Open(iRdbSession, name.FullName(), KDBMSSecureID);
+
+#else
+    err = iDatabase.Open(iFsSession, DBFileName);
+#endif
+
+    //Debug
+    if (err != KErrNone)
+        {
+
+        User::LeaveIfError(err);
+        }
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWPInternetAPDB::CreateTableL
+// -----------------------------------------------------------------------------
+//  
+void CSCOMOAdapterDb::CreateTableL(RDbDatabase& aDatabase)
+    {
+
+    // Create a table definition
+    CDbColSet* columns=CDbColSet::NewLC();
+
+    // Add Columns
+    TDbCol id(NCol1, EDbColInt32);
+
+    // automatic indexing for items,it is our key field.
+    id.iAttributes=id.EAutoIncrement;
+    columns->AddL(id);
+    columns->AddL(TDbCol(NCol2, EDbColInt32));
+    columns->AddL(TDbCol(NCol3, EDbColInt32));
+    columns->AddL(TDbCol(NCol4, EDbColText8, 255));
+    columns->AddL(TDbCol(NCol5, EDbColText8, 255));
+    columns->AddL(TDbCol(NCol6, EDbColText8, 255));
+    columns->AddL(TDbCol(NCol7, EDbColInt32));
+
+    //possibility of Panic 
+
+    // Create a table
+    TRAPD(err, aDatabase.CreateTable(KTableAMMgmtObject, *columns) );
+
+    if(err!=KErrNone)
+    User::Leave(err);
+
+    // cleanup the column set
+    CleanupStack::PopAndDestroy(columns);
+
+    }
+
+// ---------------------------------------------------------------------------
+//  CSCOMOAdapterDb::CSCOMOAdapterDb()
+//  Constructor.
+// ---------------------------------------------------------------------------
+// 
+CSCOMOAdapterDb::CSCOMOAdapterDb()
+    {
+    RDEBUG("CSCOMOAdapterDb::CSCOMOAdapterDb(): begin");
+    RDEBUG("CSCOMOAdapterDb::CSCOMOAdapterDb(): end");
+    }
+
+// ---------------------------------------------------------------------------
+//  CSCOMOAdapterDb::~CSCOMOAdapterDb()
+//  Destructor.
+// ---------------------------------------------------------------------------
+// 
+CSCOMOAdapterDb::~CSCOMOAdapterDb()
+    {
+    RDEBUG("CSCOMOAdapterDb::~CSCOMOAdapterDb(): begin");
+
+    iView.Close();
+
+    delete iColSet;
+    iAMObjectTable.Close();
+
+    iDatabase.Close();
+    iFsSession.Close();
+    iRdbSession.Close();
+
+    RDEBUG("CSCOMOAdapterDb::~CSCOMOAdapterDb(): ends");
+    }
+
+CAMDbItem::~CAMDbItem()
+    {
+    delete iServerID;
+    delete iCorrelator;
+    delete iSourceURI;
+    }
+
+void CSCOMOAdapterDb::GetEntryForServerIDL(RPointerArray<CAMDbItem>& aItemArray,
+        TDesC8& aValue)
+    {
+
+    aItemArray.Reset();// first reset the array
+
+    _LIT(KEqualToString,"='%S'");
+    _LIT(KQuery, "SELECT * FROM %S WHERE %S");
+
+    TBuf<256> serverid;
+    serverid.Copy(aValue);
+
+    TBuf<100> bufsql;
+    bufsql.Append(KQuery);
+    bufsql.Append(KEqualToString);
+    TBuf<100> bufsql1;
+    bufsql1.Format(bufsql, &KTableAMMgmtObject, &NCol4, &serverid);
+
+    ReadItemsL(aItemArray, bufsql1);
+
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CWPInternetAPDB::ReadItemsL
+// -----------------------------------------------------------------------------
+// 
+void CSCOMOAdapterDb::ReadItemsL(RPointerArray<CAMDbItem>& aItemArray,
+        TDesC& aSqlQuery)
+    {
+
+    RDbView view;
+    view.Prepare(iDatabase, TDbQuery(aSqlQuery));
+    CleanupClosePushL(view);
+    view.EvaluateAll();
+    view.FirstL();
+
+    while (view.AtRow())
+        {
+        view.GetL();
+
+        CAMDbItem *dbitem = new(ELeave) CAMDbItem;
+        dbitem->id = view.ColInt(1);
+        dbitem->iLUID = view.ColInt(2);
+        dbitem->iProfileId = view.ColInt(3);
+
+        dbitem->iServerID = (view.ColDes8(4)).AllocL();
+        dbitem->iCorrelator = (view.ColDes8(5)).AllocL();
+        dbitem->iSourceURI = (view.ColDes8(6)).AllocL();
+
+        dbitem->iRetryCount = view.ColInt(7);
+
+        aItemArray.Append(dbitem);
+        view.NextL();
+        }
+
+    CleanupStack::PopAndDestroy(); // view
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWPInternetAPDB::SaveToDatabaseL
+// -----------------------------------------------------------------------------
+//   
+void CSCOMOAdapterDb::SaveToDatabaseL(TInt& aIndex, TUint32 aLuid,
+        TInt aProfileid, TInt aRetryCount, const TDesC8& aSourceURI,
+        const TDesC8& aServerid, const TDesC8& aCorrelator)
+    {
+
+    BeginDatabaseTransaction();
+
+    TFileName sqlQuery;
+    sqlQuery.Copy(_L("SELECT * FROM "));
+    sqlQuery.Append(KTableAMMgmtObject);
+
+    RDbView view;
+    view.Prepare(iDatabase, TDbQuery(sqlQuery));
+    CleanupClosePushL(view);
+
+    view.InsertL();
+
+    view.SetColL(2, aLuid);
+    view.SetColL(3, aProfileid);
+    view.SetColL(4, aServerid);
+    view.SetColL(5, aCorrelator);
+    view.SetColL(6, aSourceURI);
+    view.SetColL(7, aRetryCount);
+
+    view.PutL();
+
+    aIndex = view.ColInt(1);// autoincrement gives us unique index.
+
+    CleanupStack::PopAndDestroy(1); // view
+    
+    CommitDatabaseTransaction();
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWPInternetAPDB::DeleteFromDatabaseL
+// -----------------------------------------------------------------------------
+//
+TBool CSCOMOAdapterDb::DeleteFromDatabaseL(TUint32 aLuid)
+    {
+
+    TBool rowsdeleted = EFalse;
+    TFileName sqlQuery;
+	
+	PrepareLuidQuery(aLuid, sqlQuery);
+	
+
+    BeginDatabaseTransaction();
+
+    RDbView view;
+    // query buffer with index finds only the selected item row.
+    view.Prepare(iDatabase, TDbQuery(sqlQuery));
+    CleanupClosePushL(view);
+
+    view.EvaluateAll();
+    view.FirstL();
+
+    if (!view.IsEmptyL())
+        {
+        // we have autoincrement in index so it should be unique
+        // but just to make sure, we use 'while', instead of 'if'
+        while (view.AtRow())
+            {
+            view.GetL();
+            view.DeleteL();
+            view.NextL();
+            }
+
+        
+        CommitDatabaseTransaction();
+        // compacts the databse, by physically removig deleted data.
+        iDatabase.Compact();
+        rowsdeleted = ETrue;
+        }
+    CleanupStack::PopAndDestroy(1); // view
+
+
+    return rowsdeleted;
+    }
+
+void CSCOMOAdapterDb::UpdateRetryCountForLuidL(TInt aLuid, TInt aRetryCount)
+{
+	TFileName sqlQuery;
+	
+	PrepareLuidQuery(aLuid, sqlQuery);
+	
+	BeginDatabaseTransaction();
+	
+	RDbView view;
+	view.Prepare(iDatabase, TDbQuery(sqlQuery));
+	CleanupClosePushL(view);
+	
+	view.EvaluateAll();
+	view.FirstL();
+	
+	if(view.AtRow())            
+	{			
+		view.UpdateL();
+		view.SetColL(7, aRetryCount);		
+		view.PutL();
+	}
+			
+	CleanupStack::PopAndDestroy(1); // view
+	
+    CommitDatabaseTransaction();
+}
+
+TInt CSCOMOAdapterDb::GetRetryCountForLuidL(TInt aLuid)
+{
+    TInt retrycount = KErrNone;
+	TFileName sqlQuery;
+    
+    PrepareLuidQuery(aLuid, sqlQuery);
+    
+    BeginDatabaseTransaction();
+    
+    RDbView view;
+    view.Prepare(iDatabase, TDbQuery(sqlQuery));
+    CleanupClosePushL(view);
+    view.EvaluateAll();
+    view.FirstL();
+
+    if (!view.IsEmptyL())
+    {
+    
+    if(view.AtRow())            
+	{
+    view.GetL();
+	}
+	
+    retrycount = view.ColInt(7);
+	
+    }
+
+	CleanupStack::PopAndDestroy(1); // view
+	
+	CommitDatabaseTransaction();
+
+	return retrycount;    
+    
+}
+
+void CSCOMOAdapterDb::PrepareLuidQuery(TInt aLuid, TDes& aSqlQuery)
+{
+	aSqlQuery.Copy(_L("SELECT * FROM "));
+    aSqlQuery.Append(KTableAMMgmtObject);
+    aSqlQuery.Append(_L(" WHERE "));
+    aSqlQuery.Append(NCol2);
+    aSqlQuery.Append(_L(" = "));
+    aSqlQuery.AppendNum(aLuid);
+}
+
+void CSCOMOAdapterDb::BeginDatabaseTransaction()
+{
+	iDatabase.Begin();
+}
+
+void CSCOMOAdapterDb::CommitDatabaseTransaction()
+{
+	iDatabase.Commit();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/options/BWINS/AMInstallOptionsu.def	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,8 @@
+EXPORTS
+	?ParseOptionsL@InstallOptionsParser@@SAXABVTDesC8@@AAUTAMInstallOptions@NApplicationManagement@@@Z @ 1 NONAME ; void InstallOptionsParser::ParseOptionsL(class TDesC8 const &, struct NApplicationManagement::TAMInstallOptions &)
+	?ParseOptionsL@InstallOptionsParser@@SAXABVTDesC8@@AAVTInstallOptions@SwiUI@@@Z @ 2 NONAME ; void InstallOptionsParser::ParseOptionsL(class TDesC8 const &, class SwiUI::TInstallOptions &)
+	?ParseOptionsL@InstallOptionsParser@@SAXABVTDesC8@@AAVTUninstallOptions@SwiUI@@@Z @ 3 NONAME ; void InstallOptionsParser::ParseOptionsL(class TDesC8 const &, class SwiUI::TUninstallOptions &)
+	?SerializeOptionsL@InstallOptionsParser@@SAXABUTAMInstallOptions@NApplicationManagement@@AAVCBufBase@@@Z @ 4 NONAME ; void InstallOptionsParser::SerializeOptionsL(struct NApplicationManagement::TAMInstallOptions const &, class CBufBase &)
+	?SerializeOptionsL@InstallOptionsParser@@SAXABVTInstallOptions@SwiUI@@AAVCBufBase@@@Z @ 5 NONAME ; void InstallOptionsParser::SerializeOptionsL(class SwiUI::TInstallOptions const &, class CBufBase &)
+	?SerializeOptionsL@InstallOptionsParser@@SAXABVTUninstallOptions@SwiUI@@AAVCBufBase@@@Z @ 6 NONAME ; void InstallOptionsParser::SerializeOptionsL(class SwiUI::TUninstallOptions const &, class CBufBase &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/options/eabi/AMInstallOptionsu.def	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,14 @@
+EXPORTS
+	_ZN20InstallOptionsParser13ParseOptionsLERK6TDesC8RN22NApplicationManagement17TAMInstallOptionsE @ 1 NONAME
+	_ZN20InstallOptionsParser13ParseOptionsLERK6TDesC8RN5SwiUI15TInstallOptionsE @ 2 NONAME
+	_ZN20InstallOptionsParser13ParseOptionsLERK6TDesC8RN5SwiUI17TUninstallOptionsE @ 3 NONAME
+	_ZN20InstallOptionsParser17SerializeOptionsLERKN22NApplicationManagement17TAMInstallOptionsER8CBufBase @ 4 NONAME
+	_ZN20InstallOptionsParser17SerializeOptionsLERKN5SwiUI15TInstallOptionsER8CBufBase @ 5 NONAME
+	_ZN20InstallOptionsParser17SerializeOptionsLERKN5SwiUI17TUninstallOptionsER8CBufBase @ 6 NONAME
+	_ZTI17CAMInstOptsParser @ 7 NONAME ; #<TI>#
+	_ZTI19CAMUninstOptsParser @ 8 NONAME ; #<TI>#
+	_ZTI21CAMInstOptsParserBase @ 9 NONAME ; #<TI>#
+	_ZTV17CAMInstOptsParser @ 10 NONAME ; #<VT>#
+	_ZTV19CAMUninstOptsParser @ 11 NONAME ; #<VT>#
+	_ZTV21CAMInstOptsParserBase @ 12 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/options/group/AMInstallOptions.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,45 @@
+/*
+* 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: Implementation of applicationmanagement components
+*
+*/
+  
+
+// To get the APP_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include "defaultcaps.hrh"
+
+TARGET        aminstalloptions.dll
+TARGETTYPE    dll
+UID           0x10207835
+CAPABILITY    CAP_GENERAL_DLL
+
+SOURCEPATH    ../src
+SOURCE        AMInstallOptions.cpp
+
+USERINCLUDE   ../inc 
+USERINCLUDE   ../../inc
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE /epoc32/include/xml
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+SYSTEMINCLUDE 	/epoc32/include/platform/xml
+#endif
+
+LIBRARY		    xmlframework.lib 
+LIBRARY		    euser.lib 
+LIBRARY		    bafl.lib
+LIBRARY 	    flogger.lib
+
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/options/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  build info file for application management options
+*
+*/
+
+
+#include <platform_paths.hrh>
+PRJ_EXPORTS
+../inc/aminstalloptions.h  |../../../inc/aminstalloptions.h
+../rom/aminstalloptions.iby				CORE_APP_LAYER_IBY_EXPORT_PATH(aminstalloptions.iby)
+
+PRJ_MMPFILES
+AMInstallOptions.mmp
+
+//PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/options/group/instopts_def.xml	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,124 @@
+<instoptexamples>
+<!-- 
+Each option can be left out (by commenting it away or removing). 
+The start tag above is only to make this file viewable using IE etc browsers.
+
+Empty or illegal (unknown) attribute values are interpreted as "no" was chosen 
+and installation will not be completed.
+
+-->
+
+<InstOpts>
+ <!-- 
+ value: Installation drive letter 
+ Special value: '!' uses any drive having enough space. 
+ -->
+ <StdOpt name="drive" value="e"/> 
+ 
+ <!-- ISO language code
+ Special value: '*' uses phone's default language 
+ -->   	
+ <StdOpt name="lang" value="FI" /> 
+ 
+ <!--	
+  Name: upgrade
+  Possible Values: yes | no 
+  Description: Tells what is answered to "Application exists, do you want to upgrade?" like question.
+  -->
+ <StdOpt name="upgrade" value="yes"/>
+ 
+ <!--	
+  Description: Kill existing application if running.
+  Possible Values: yes | no 
+  -->
+ <StdOpt name="kill" value="yes"/> 
+ 
+ <!--	
+  Description: Response to package info dialog. It also sets policy to
+  handle all other warnings than ocsp, and FileTexts and possible questions
+  in the package. 
+  Possible Values: yes | no 
+  -->
+ <StdSymOpt name="pkginfo" value="yes"/> 
+ 
+ <!--	
+  Description: Response to options dialog. 
+  This either selects all or none options.
+  Possible Values: yes | no 
+  -->
+ <StdSymOpt name="optionals" value="yes"/>  
+
+ <!--	
+  Description: Response to "grant capabilities" dialog.
+  Possible Values: yes | no 
+  NOTE: This has been commented out as an example. If now
+  	content package needs to be granted some capabilities,
+  	installation will fail because of missing option.
+  -->
+ <!-- <StdSymOpt name="capabilities" value="yes"/> --> 
+ 
+ <!--	
+  Description: Response to install untrusted application dialog.
+  Possible Values: yes | no
+  -->
+ <StdSymOpt name="untrusted" value="yes"/> 
+  
+  <!--	
+  Description: Determines whether OCSP check will be done automatically.
+  Possible Values: yes | no 
+  -->
+ <StdSymOpt name="ocsp" value="yes"/> 
+ 
+  <!--	
+  Description: Determines whether OCSP warnings will ignored automatically.
+  Possible Values: yes | no 
+  -->
+ <StdSymOpt name="ignoreocspwarn" value="yes"/> 
+ 
+  <!--	
+  Description: Determines whether files will be overwritten automatically,
+  if the file exists.
+  Possible Values: yes | no
+  -->
+ <StdSymOpt name="fileoverwrite" value="yes"/> 
+
+
+  <!--	
+  Description: Determines whether RMS data will be updated
+  in midlet (java) install.
+  Possible Values: yes | no 
+  -->
+ <StdSymOpt name="upgradedata" value="no"/>
+ 
+
+ <!-- Download username  -->
+ <StdOpt name="httpusername" value="username"/>
+  <!-- Download password  -->
+ <StdOpt name="httppassword" value="password"/>
+  <!-- Allow download 
+ Possible Values: yes | no  -->
+ <StdOpt name="download" value="yes"/>
+  <!-- 
+  Direct DM tree reference 
+ <StdOpt name="conref" value="./AP/APId011"/>
+-->
+</InstOpts>
+ 
+<UninstOpts>
+<!--	
+  Description: Kill existing application if running.
+  Possible Values: yes | no 
+  -->
+ <StdOpt name="kill" value="yes"/> 
+ 
+ <!--	
+  Description: Determines whether we should continue uninstall if any
+  of the component's dependendants still exist in device
+  Possible Values: yes | no 
+  -->
+ <StdSymOpt name="allowdependencybreak" value="yes"/> 
+ 
+ 
+</UninstOpts>
+
+</instoptexamples>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/options/inc/aminstalloptions.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 interface
+*
+*/
+
+
+#ifndef __AMINSTALLOPTIONSAPI_H__
+#define __AMINSTALLOPTIONSAPI_H__
+
+#include <SWInstDefs.h>
+namespace NApplicationManagement
+	{
+	const int KMaxConRef = 256;
+	struct TAMInstallOptions
+		{
+		TBuf8<KMaxConRef> iConRef;
+		TInt iIAP;
+		SwiUI::TInstallOptions iOptions;
+		TAMInstallOptions() : iConRef( KNullDesC8()),
+							  iIAP(-1), iOptions()
+			{
+			}
+		};
+
+	typedef TPckgBuf<TAMInstallOptions> TAMInstallOptionsPckgBuf;
+	typedef TPckg<TAMInstallOptions> TAMInstallOptionsPckg;
+
+	}
+	
+
+class InstallOptionsParser
+	{
+public:
+	IMPORT_C static void ParseOptionsL( const TDesC8 &aBuffer, SwiUI::TInstallOptions &aResult);
+	IMPORT_C static void SerializeOptionsL( const SwiUI::TInstallOptions &aOptions, CBufBase &aResult );
+	IMPORT_C static void ParseOptionsL( const TDesC8 &aBuffer, SwiUI::TUninstallOptions &aResult);
+	IMPORT_C static void SerializeOptionsL( const SwiUI::TUninstallOptions  &aOptions, CBufBase &aResult );
+	
+	IMPORT_C static void ParseOptionsL( const TDesC8 &aBuffer, NApplicationManagement::TAMInstallOptions &aResult);
+	IMPORT_C static void SerializeOptionsL( const NApplicationManagement::TAMInstallOptions &aOptions, CBufBase &aResult );
+	};    
+	
+    
+#endif
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/options/inc/aminstalloptionsint.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Internal header for ApplicationManagementOptions
+*
+*/
+
+
+#ifndef __AMINSTALLOPTIONSINT_H__
+#define __AMINSTALLOPTIONSINT_H__
+
+
+#include <parser.h>
+
+#include <contenthandler.h>
+#include <documentparameters.h>
+#include <SWInstDefs.h>
+
+
+class CAMInstOptsParserBase : public CBase, public Xml::MContentHandler
+	{
+public:
+	virtual ~CAMInstOptsParserBase();
+	void ParseL();
+protected:
+	const TDesC8 &iBuffer;
+	Xml::CParser *iParser ;
+	TInt iCustIndex ;
+	SwiUI::TPolicy iDefaultPolicy;
+	
+	CAMInstOptsParserBase( 
+		const TDesC8 &aBuffer, 
+		SwiUI::TPolicy aDefaultPolicy = SwiUI::EPolicyUserConfirm 
+	  )	: iBuffer( aBuffer ), iCustIndex(-1), iDefaultPolicy ( aDefaultPolicy )
+		{
+		
+		}
+
+	void SetPolicyValue( SwiUI::TPolicy &aPolicy, const TDesC8& aValue ) const;
+	void ConstructL();
+	
+
+	virtual void OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode);
+	virtual void OnEndDocumentL(TInt aErrorCode);
+	virtual void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, TInt aErrorCode);
+	virtual void OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode);
+	virtual void OnContentL(const TDesC8& aBytes, TInt aErrorCode);
+	virtual void OnStartPrefixMappingL(const RString& aPrefix, const RString& aUri, TInt aErrorCode);
+	virtual void OnEndPrefixMappingL(const RString& aPrefix, TInt aErrorCode);
+	virtual void OnIgnorableWhiteSpaceL(const TDesC8& aBytes, TInt aErrorCode);
+	virtual void OnSkippedEntityL(const RString& aName, TInt aErrorCode);
+	virtual void OnProcessingInstructionL(const TDesC8& aTarget, const TDesC8& aData, TInt aErrorCode);
+	virtual void OnError(TInt aErrorCode);
+	TAny* GetExtendedInterface(const TInt32 aUid);
+	
+	};	
+	
+class CAMInstOptsParser : public CAMInstOptsParserBase//, public Xml::MContentHandler
+	{
+	//SwiUI::TInstallOptions &iResult;
+	NApplicationManagement::TAMInstallOptions &iResult;
+
+	//void ParseL();
+	public:
+		
+			
+		static CAMInstOptsParser * NewL( const TDesC8 &aBuffer, NApplicationManagement::TAMInstallOptions &aResult );
+		static CAMInstOptsParser * NewLC( const TDesC8 &aBuffer, NApplicationManagement::TAMInstallOptions &aResult );
+		
+		CAMInstOptsParser( const TDesC8 &aBuffer, NApplicationManagement::TAMInstallOptions &aResult ) 
+			: CAMInstOptsParserBase ( aBuffer ), iResult( aResult )
+			{
+			
+			}
+		
+		virtual ~CAMInstOptsParser();
+	
+    	void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, TInt aErrorCode);
+	private:
+	};    			
+
+class CAMUninstOptsParser : public CAMInstOptsParserBase
+	{
+	SwiUI::TUninstallOptions &iResult; 
+	public:
+		static CAMUninstOptsParser * NewL( const TDesC8 &aBuffer, SwiUI::TUninstallOptions &aResult );
+		static CAMUninstOptsParser * NewLC( const TDesC8 &aBuffer, SwiUI::TUninstallOptions &aResult );
+		
+		CAMUninstOptsParser( const TDesC8 &aBuffer, SwiUI::TUninstallOptions &aResult ) 
+			: CAMInstOptsParserBase( aBuffer ), iResult( aResult )
+			{
+			
+			}
+		virtual ~CAMUninstOptsParser();
+	
+    	void OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, TInt aErrorCode);
+	private:
+	};    
+
+#endif // __AMINSTALLOPTIONSINT_H__
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/options/rom/aminstalloptions.iby	Tue Jul 13 04:01:20 2010 +0530
@@ -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: Implementation of applicationmanagement components
+*
+*/
+
+#ifndef __AMINSTALLOPTIONS_IBY__
+#define __AMINSTALLOPTIONS_IBY__
+
+file=ABI_DIR\BUILD_DIR\AMInstallOptions.dll     							SHARED_LIB_DIR\AMInstallOptions.dll
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/options/src/AMInstallOptions.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,927 @@
+/*
+* Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ApplicationManagementOptions implementation
+*
+*/
+
+
+
+#include <e32debug.h>
+#include <s32mem.h>
+#include "debug.h"
+#include "aminstalloptions.h"
+#include "aminstalloptionsint.h"
+	
+
+namespace AMXml
+	{
+	
+	struct TLangCodeMapping 
+		{
+		//const TText8 *const iCode ;
+		const TText8 * iCode ;
+		TLanguage iLang ;
+		};
+		
+	// Language options
+	const TLangCodeMapping KLangOptions[] = 
+		{
+		{_S8("EN"), ELangEnglish},
+		{_S8("FR"), ELangFrench},
+		{_S8("GE"), ELangGerman},
+		{_S8("SP"), ELangSpanish},
+		{_S8("IT"), ELangItalian},
+		{_S8("SW"), ELangSwedish},
+		{_S8("DA"), ELangDanish},
+		{_S8("NO"), ELangNorwegian},
+		{_S8("FI"), ELangFinnish},
+		{_S8("AM"), ELangAmerican},
+		{_S8("SF"), ELangSwissFrench},
+		{_S8("SG"), ELangSwissGerman},
+		{_S8("PO"), ELangPortuguese},
+		{_S8("TU"), ELangTurkish},
+		{_S8("IC"), ELangIcelandic},
+		{_S8("RU"), ELangRussian},
+		{_S8("HU"), ELangHungarian},
+		{_S8("DU"), ELangDutch},
+		{_S8("BL"), ELangBelgianFlemish},
+		{_S8("AU"), ELangAustralian},
+		{_S8("BF"), ELangBelgianFrench},
+		{_S8("AS"), ELangAustrian},
+		{_S8("NZ"), ELangNewZealand},
+		{_S8("IF"), ELangInternationalFrench},
+		{_S8("CS"), ELangCzech},
+		{_S8("SK"), ELangSlovak},
+		{_S8("PL"), ELangPolish},
+		{_S8("SL"), ELangSlovenian},
+		{_S8("TC"), ELangTaiwanChinese},
+		{_S8("HK"), ELangHongKongChinese},
+		{_S8("ZH"), ELangPrcChinese},
+		{_S8("JA"), ELangJapanese},
+		{_S8("TH"), ELangThai},
+		{_S8("AF"), ELangAfrikaans },
+		{_S8("SQ"), ELangAlbanian },
+		{_S8("AH"), ELangAmharic },
+		{_S8("AR"), ELangArabic },
+		{_S8("HY"), ELangArmenian },
+		{_S8("TL"), ELangTagalog },
+		{_S8("BE"), ELangBelarussian },
+		{_S8("BN"), ELangBengali },
+		{_S8("BG"), ELangBulgarian },
+		{_S8("MY"), ELangBurmese },
+		{_S8("CA"), ELangCatalan },
+		{_S8("HR"), ELangCroatian },
+		{_S8("CE"), ELangCanadianEnglish },
+		{_S8("IE"), ELangInternationalEnglish },
+		{_S8("SF"), ELangSouthAfricanEnglish },
+		{_S8("ET"), ELangEstonian },
+		{_S8("FA"), ELangFarsi },
+		{_S8("CF"), ELangCanadianFrench },
+		{_S8("GD"), ELangScotsGaelic },
+		{_S8("KA"), ELangGeorgian },
+		{_S8("EL"), ELangGreek },
+		{_S8("CG"), ELangCyprusGreek },
+		{_S8("GU"), ELangGujarati },
+		{_S8("HE"), ELangHebrew },
+		{_S8("HI"), ELangHindi },
+		{_S8("IN"), ELangIndonesian },
+		{_S8("GA"), ELangIrish },
+		{_S8("SZ"), ELangSwissItalian },
+		{_S8("KN"), ELangKannada },
+		{_S8("KK"), ELangKazakh },
+		{_S8("KM"), ELangKhmer },
+		{_S8("KO"), ELangKorean },
+		{_S8("LO"), ELangLao },
+		{_S8("LV"), ELangLatvian },
+		{_S8("LT"), ELangLithuanian },
+		{_S8("MK"), ELangMacedonian },
+		{_S8("MS"), ELangMalay },
+		{_S8("ML"), ELangMalayalam },
+		{_S8("MR"), ELangMarathi },
+		{_S8("MO"), ELangMoldavian },
+		{_S8("MN"), ELangMongolian },
+		{_S8("NN"), ELangNorwegianNynorsk },
+		{_S8("BP"), ELangBrazilianPortuguese },
+		{_S8("PA"), ELangPunjabi },
+		{_S8("RO"), ELangRomanian },
+		{_S8("SR"), ELangSerbian },
+		{_S8("SI"), ELangSinhalese },
+		{_S8("SO"), ELangSomali },
+		{_S8("OS"), ELangInternationalSpanish },
+		{_S8("LS"), ELangLatinAmericanSpanish },
+		{_S8("SH"), ELangSwahili },
+		{_S8("FS"), ELangFinlandSwedish },
+		//{_S8("??"), ELangReserved1 },
+		{_S8("TA"), ELangTamil },
+		{_S8("TE"), ELangTelugu },
+		{_S8("BO"), ELangTibetan },
+		{_S8("TI"), ELangTigrinya },
+		{_S8("CT"), ELangCyprusTurkish },
+		{_S8("TK"), ELangTurkmen },
+		{_S8("UK"), ELangUkrainian },
+		{_S8("UR"), ELangUrdu },
+		//{_S8("??"), ELangReserved2 },
+		{_S8("VI"), ELangVietnamese },
+		{_S8("CY"), ELangWelsh },
+		{_S8("ZU"), ELangZulu },
+		//{_S8("??"), ELangOther },
+		//{_S8("??"), ELangNone  }
+		};
+		
+	const TInt KNumLangOptions = (sizeof(KLangOptions)/sizeof(TLangCodeMapping));
+		
+	// boolean "value" attribute values
+	_LIT8( KIOValueTrue, "yes" );
+	_LIT8( KIOValueFalse, "no" );
+	// notimp _LIT8( KIOAsk, "askuser" );
+	
+	_LIT8( KIODefaultLanguage, "*");
+	
+	// notimp _LIT8( KIOMissingOptionPolicyValDefault, "usedefault" );
+	_LIT8( KIOMissingOptionPolicyValFail, "fail" );
+	// notimp _LIT8( KIOMissingOptionPolicyValAsk, "askuser" );
+	
+	// "Name" attribute values
+	_LIT8( KIODrive, "drive" );
+	_LIT8( KIOLanguage, "lang" );
+	_LIT8( KIOUpgrade, "upgrade" );
+	_LIT8( KIOKill, "kill" );
+	
+	// sym specific
+	_LIT8( KIOCapabilities, "capabilities" );
+	_LIT8( KIOUntrusted, "untrusted" );
+	_LIT8( KIOPkginfo, "pkginfo" );
+	_LIT8( KIOOptionalItems, "optionals" );
+	
+	_LIT8 ( KIOOCSP, "ocsp" );
+	_LIT8 ( KIOOCSPWarning, "ignoreocspwarn" );
+	_LIT8 ( KIOOverwrite, "fileoverwrite" );
+	
+	_LIT8 ( KIOUpgradeData, "upgradedata" ); // iUpgradeData
+	
+	_LIT8( KUIOBreakDependency, "allowdependencybreak" );
+	
+	_LIT8( KIOAttrNameDefaultPolicy, "missingoptionpolicy" );
+	
+	_LIT8( KIODownload, "download" );
+	_LIT8( KIOHttpUsername, "httpusername" );
+	_LIT8( KIOHttpPassword, "httppassword" );
+	_LIT8( KIOIAP, "conref" );
+	
+	namespace Reader
+		{
+		// XML node names
+		_LIT8( KIOStartElement, "InstOpts") ;
+		_LIT8( KIOStdOpt, "StdOpt");
+		_LIT8( KIOStdSymOpt, "StdSymOpt" );
+		_LIT8( KIOCustSymOpts, "CustSymOpts" );
+		// notimp _LIT8( KIOOpt, "Opt" );
+
+		// Xml attribute names
+		// notimp _LIT8( KIOOptAttrIndex, "index" );
+		_LIT8( KIOAttrName, "name" );
+		_LIT8( KIOAttrValue, "value" );
+		
+		}
+		
+	namespace Writer
+		{
+		_LIT8( KIOStartElement, "<InstOpts>") ;
+		_LIT8( KIOStdOptFormat, "<StdOpt name=\"%S\" value=\"%S\"/>" );
+		_LIT8( KIOStdSymOptFormat, "<StdSymOpt name=\"%S\" value=\"%S\"/>" );
+		// notimp _LIT8( KIOCustSymOptsStartFormat, "<CustSymOpts cnt=\"%d\">" );
+		// notimp _LIT8( KIOCustSymOptsEnd, "</CustSymOpts>" );
+		// notimp _LIT8( KIOOptFormat, "<Opt index=\"%d\" value=\"%S\"/>" );
+		_LIT8( KIOStartElementEnd, "</InstOpts>") ;		
+		
+		_LIT8( KUIOStartElement, "<UninstOpts>" );
+		_LIT8( KUIOStartElementEnd, "</UninstOpts>" );
+		}
+	}
+	
+///////////////////////////////////////////////////
+//
+// CAMInstOptsParserBase
+//
+///////////////////////////////////////////////////
+
+	
+CAMInstOptsParserBase::~CAMInstOptsParserBase()
+	{
+	delete iParser;
+	iParser = NULL;
+	}
+
+void CAMInstOptsParserBase::SetPolicyValue( SwiUI::TPolicy &aPolicy, const TDesC8& aValue ) const
+	{
+	using namespace AMXml;
+	
+	if ( aValue == KIOValueTrue )
+		{
+		aPolicy = SwiUI::EPolicyAllowed ;
+		}
+	else if ( aValue == KIOValueFalse )
+		{
+		aPolicy = SwiUI::EPolicyNotAllowed ;
+		}
+	else
+		{
+		aPolicy = iDefaultPolicy;
+		}
+	}
+void CAMInstOptsParserBase::ConstructL()
+	{
+	iParser = Xml::CParser::NewL( _L8( "text/xml"), *this );	
+	
+	}
+	
+void CAMInstOptsParserBase::ParseL()
+	{
+	Xml::ParseL( *iParser, iBuffer );
+	}	
+	
+void CAMInstOptsParserBase::OnStartElementL(const Xml::RTagInfo& /*aElement*/, 
+		const Xml::RAttributeArray& /*aAttributes*/, TInt aErrorCode)
+	{
+	RDEBUG("CAMInstOptsParserBase::OnStartElementL");
+	if( aErrorCode != KErrNone )
+		{
+		RDEBUG_2( "		->OnStartElementL (aErrorCode '%d')", aErrorCode );		
+		}
+	}
+	
+void CAMInstOptsParserBase::OnEndDocumentL(TInt aErrorCode)
+	{
+	RDEBUG("CAMInstOptsParserBase::OnEndDocumentL");
+	if( aErrorCode != KErrNone )
+		{
+		RDEBUG_2( "		->OnEndDocumentL (aErrorCode '%d')", aErrorCode );		
+		}
+	}
+
+void CAMInstOptsParserBase::OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode)
+	{
+	RDEBUG("CAMInstOptsParserBase::OnStartDocumentL");
+	if( aErrorCode != KErrNone )
+		{
+		const TDesC8 &d = aDocParam.CharacterSetName().DesC();
+		RDEBUG8_3( "	->OnStartDocumentL (aDocParam '%S', aErrorCode %d)" , 
+			&d,aErrorCode );	
+		}
+	}
+	
+void CAMInstOptsParserBase::OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode)
+	{
+	RDEBUG("CAMInstOptsParserBase::OnEndElementL");
+	if( aErrorCode != KErrNone )
+		{
+		const TDesC8 &d = aElement.LocalName().DesC();
+		RDEBUG8_3( "		->OnEndElementL (LocalName '%S', aErrorCode %d)", 
+			&d,aErrorCode );
+		}
+	}
+	
+void CAMInstOptsParserBase::OnContentL(
+		#ifdef _DEBUG 
+			const TDesC8& aBytes
+		#else 
+			const TDesC8& /*aBytes*/
+		#endif 
+	,TInt aErrorCode )
+	{
+	RDEBUG("CAMInstOptsParserBase::OnContentL");
+	if( aErrorCode != KErrNone )
+		{
+		#ifdef _DEBUG
+			RDEBUG8_3( "		->OnContentL (abytes '%S', aErrorCode %d)", 
+				&aBytes, aErrorCode );
+		#else
+			RDEBUG8_2( "		->OnContentL (aErrorCode %d)", aErrorCode );
+		#endif		
+		}
+	
+	}
+void CAMInstOptsParserBase::OnStartPrefixMappingL(const RString& /*aPrefix*/, 
+	const RString& /*aUri*/, TInt /*aErrorCode*/)
+	{
+	
+	}
+void CAMInstOptsParserBase::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt /*aErrorCode*/)
+	{
+	
+	}
+void CAMInstOptsParserBase::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
+	{
+	
+	}
+void CAMInstOptsParserBase::OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/)
+	{
+	
+	}
+void CAMInstOptsParserBase::OnProcessingInstructionL(const TDesC8& /*aTarget*/, 
+	const TDesC8& /*aData*/, TInt /*aErrorCode*/)
+	{
+	
+	}
+void CAMInstOptsParserBase::OnError(TInt aErrorCode)
+	{
+	RDEBUG("CAMInstOptsParserBase::OnError");
+	if( aErrorCode != KErrNone )
+		{
+		RDEBUG_2( "		->OnError ( aErrorCode %d)",aErrorCode );
+	}
+	}
+	
+
+	
+TAny* CAMInstOptsParserBase::GetExtendedInterface(const TInt32 /*aUid*/)
+	{
+	
+	return NULL;		
+	}
+
+
+///////////////////////////////////////////////////
+//
+// CAMInstOptsParser
+//
+///////////////////////////////////////////////////
+
+CAMInstOptsParser * CAMInstOptsParser::NewLC( const TDesC8 &aBuffer, NApplicationManagement::TAMInstallOptions &aResult )
+	{
+	CAMInstOptsParser *self = new ( ELeave ) CAMInstOptsParser( aBuffer, aResult );
+	CleanupStack::PushL( self );
+	self->ConstructL() ;
+	return self ;
+	}
+	
+CAMInstOptsParser *CAMInstOptsParser::NewL( const TDesC8 &aBuffer, 
+	NApplicationManagement::TAMInstallOptions &aResult )	
+	{
+	CAMInstOptsParser *self = NewLC ( aBuffer, aResult );
+	CleanupStack::Pop( self );
+	return self ;
+	}
+	
+CAMUninstOptsParser * CAMUninstOptsParser::NewLC( const TDesC8 &aBuffer, SwiUI::TUninstallOptions &aResult )
+	{
+	CAMUninstOptsParser *self = new ( ELeave ) CAMUninstOptsParser( aBuffer, aResult );
+	CleanupStack::PushL( self );
+	self->ConstructL() ;
+	return self ;
+	}
+	
+CAMUninstOptsParser *CAMUninstOptsParser::NewL( const TDesC8 &aBuffer, 
+	SwiUI::TUninstallOptions &aResult )	
+	{
+	CAMUninstOptsParser *self = NewLC ( aBuffer, aResult );
+	CleanupStack::Pop( self );
+	return self ;
+	}
+	
+	
+CAMInstOptsParser::~CAMInstOptsParser()
+	{
+	
+	}
+	
+	
+void CAMInstOptsParser::OnStartElementL(const Xml::RTagInfo& aElement, 
+		const Xml::RAttributeArray& aAttributes, 
+		#ifdef _DEBUG 
+			TInt aErrorCode
+		#else 
+			TInt /*aErrorCode*/
+		#endif 
+		)
+	{
+	
+#ifdef _DEBUG
+	RDEBUG8_3( "CAMInstOptsParser::OnStartElementL (LocalName '%S', aErrorCode %d)", 
+		&aElement.LocalName().DesC(),aErrorCode );
+	TInt count2( aAttributes.Count() );
+	for( TInt i( 0 ); i < count2; i++ )
+		{
+		RDEBUG8_5( "   Attribute %d, type=%d, '%S'='%S' ",i,aAttributes[i].Type(), 
+		 &aAttributes[i].Value().DesC(), &aAttributes[i].Attribute().LocalName().DesC() );
+		
+		}
+#endif
+
+	using namespace AMXml;
+
+	
+	const TPtrC8 name( aElement.LocalName().DesC() );
+	if ( name == Reader::KIOStartElement )
+		{
+		
+		if ( aAttributes.Count() == 1 )
+			{
+			TPtrC8 attrname( aAttributes[0].Attribute().LocalName().DesC() );
+			if ( attrname == KIOAttrNameDefaultPolicy)
+				{
+				
+				using namespace SwiUI;
+				TPtrC8 attrval( aAttributes[0].Value().DesC() );
+				if ( attrval == KIOMissingOptionPolicyValFail)
+					{
+					iDefaultPolicy = EPolicyNotAllowed;
+					}
+				else
+					{
+					iDefaultPolicy = EPolicyUserConfirm;
+					}
+				}
+			}
+		}
+	else if ( name != Reader::KIOCustSymOpts )
+		{
+		RDEBUG8_2( "   Processing element '%S'", &name );
+		TInt c( aAttributes.Count() );
+		if ( c == 2 )
+			{
+			TPtrC8 attrname( aAttributes[0].Attribute().LocalName().DesC() );
+			TPtrC8 attrnameval( aAttributes[0].Value().DesC() );
+			TPtrC8 attrval( aAttributes[1].Attribute().LocalName().DesC() );
+			TPtrC8 attrvalval( aAttributes[1].Value().DesC() );
+			RDEBUG8_5( "   Name '%S'='%S' Val '%S'='%S' ",&attrname, &attrnameval,
+				&attrval, &attrvalval );
+			if ( attrname == Reader::KIOAttrName )
+				{
+				if ( attrval == Reader::KIOAttrValue )
+					{
+					if ( name == Reader::KIOStdOpt )
+						{
+						if ( attrnameval == KIODrive )
+							{
+							TInt len = attrvalval.Length();
+							if (len == 0)
+								{
+								TChar KDefaultDrive = 'c';
+								iResult.iOptions.iDrive = KDefaultDrive;
+								//RDEBUG8_2( " Set drive to %c ", iResult.iOptions.iDrive );
+								}
+							else
+								{
+								RDEBUG8_2( " Setting drive to %c ", attrvalval[0] );
+								iResult.iOptions.iDrive = attrvalval[0];		
+								}
+							}
+						else if ( attrnameval == KIOLanguage )
+							{
+							if ( attrvalval == KIODefaultLanguage )
+								{
+								iResult.iOptions.iUsePhoneLang = ETrue;
+								}
+							else
+								{
+								for( TInt i( 0 ); i < KNumLangOptions; i++ )
+									{
+									if ( attrvalval == TPtrC8( KLangOptions[i].iCode ) )
+										{
+									#ifdef _DEBUG
+										TPtrC8 code( KLangOptions[i].iCode );
+										RDEBUG8_2( " OnStartElementL : Found language %S", &code);
+									#endif
+										iResult.iOptions.iLang = KLangOptions[i].iLang; 
+										break;
+										}
+									}	
+								}
+							
+							}
+						else if ( attrnameval == KIOUpgrade )
+							{
+							RDEBUG8_2( " Setting Upgrade to %S ", &attrvalval );
+							SetPolicyValue( iResult.iOptions.iUpgrade, attrvalval );
+							}
+						else if ( attrnameval == KIOKill )
+							{
+							RDEBUG8_2( " Setting iKillApp to %S ", &attrvalval );
+							SetPolicyValue( iResult.iOptions.iKillApp, attrvalval );
+							}
+						else if ( attrnameval == KIOHttpUsername )
+							{
+							RDEBUG8_2( " Setting iLogin to %S ", &attrvalval );
+							iResult.iOptions.iLogin.Copy( attrvalval.Left( SwiUI::KSWInstMaxUserNameLength ) );
+							}
+						else if ( attrnameval == KIOHttpPassword )
+							{
+							RDEBUG8_2( " Setting iPassword to %S ", &attrvalval );
+							iResult.iOptions.iPassword.Copy( attrvalval.Left( SwiUI::KSWInstMaxPasswordLength ) );
+							}
+						else if ( attrnameval == KIODownload )
+							{
+							RDEBUG8_2( " Setting iDownload to %S ", &attrvalval );
+							SetPolicyValue( iResult.iOptions.iDownload, attrvalval );
+							}
+						else if ( attrnameval == KIOIAP )
+							{
+							RDEBUG8_2( " Setting iConRef to %S ", &attrvalval );
+							iResult.iConRef = attrvalval;
+							
+							
+							}
+							/*
+	_LIT8( KIOIAP, "iap" );
+*/
+
+						else 
+							{
+							RDEBUG8_3( " WARNING Unsupported name attribute value: '%S' for '%S' ", &attrnameval, &name );
+							}
+						}
+					else if ( name == Reader::KIOStdSymOpt )
+						{
+						if ( attrnameval == KIOCapabilities )
+							{
+							RDEBUG8_2( " Setting iCapabilities to %S ", &attrvalval );
+							SetPolicyValue( iResult.iOptions.iCapabilities, attrvalval );
+							}
+						else if ( attrnameval == KIOUntrusted )
+							{
+							RDEBUG8_2( " Setting iUntrusted to %S ", &attrvalval );
+							SetPolicyValue( iResult.iOptions.iUntrusted, attrvalval );
+							}
+						else if ( attrnameval == KIOPkginfo )
+							{
+							RDEBUG8_2( " Setting iPackageInfo to %S ", &attrvalval );
+							SetPolicyValue( iResult.iOptions.iPackageInfo, attrvalval );
+							}
+						else if ( attrnameval == KIOOCSP )
+							{
+							RDEBUG8_2( " Setting iOCSP to %S ", &attrvalval );
+							SetPolicyValue( iResult.iOptions.iOCSP, attrvalval );
+							}
+						else if ( attrnameval == KIOOCSPWarning )
+							{
+							RDEBUG8_2( " Setting iIgnoreOCSPWarnings to %S ", &attrvalval );
+							SetPolicyValue( iResult.iOptions.iIgnoreOCSPWarnings, attrvalval );
+							}
+						else if ( attrnameval == KIOOptionalItems )
+							{
+							RDEBUG8_2( " Setting iOptionalItems to %S ", &attrvalval );
+							SetPolicyValue( iResult.iOptions.iOptionalItems, attrvalval );
+							}
+						else if ( attrnameval == KIOOverwrite )
+							{
+							RDEBUG8_2( " Setting iOverwrite to %S ", &attrvalval );
+							SetPolicyValue( iResult.iOptions.iOverwrite, attrvalval );
+							}	
+						else if ( attrnameval == KIOUpgradeData )
+							{
+							RDEBUG8_2( " Setting iUpgradeData to %S ", &attrvalval );
+							SetPolicyValue( iResult.iOptions.iUpgradeData, attrvalval );
+							}	
+							
+						else
+							{
+							RDEBUG8_3( " WARNING Unsupported name sym attribute value: '%S' for '%S' ", &attrnameval, &name );
+							}
+						}
+					else
+						{
+						RDEBUG("WARNING, unsupported name attribute!");
+						}
+					}
+				else
+					{
+					RDEBUG8_3( " ERROR invalid second attribute!: '%S', expteced: '%S' ", &attrval, &Reader::KIOAttrValue() );
+					}
+				}
+			else
+				{
+				RDEBUG8_3( " ERROR invalid first attribute!: '%S', expteced: '%S' ", &attrname, &Reader::KIOAttrName() );
+				}
+			}
+		else
+			{
+			RDEBUG8_3( " ERROR unsupported count of attributes!!: '%d' for '%S' ", c, &name);
+			}
+		}
+	else
+		{
+		RDEBUG( " ERROR custom options not implemented!!!!" );
+	
+		}
+	}
+	
+
+///////////////////////////////////////////////////
+//
+// CAMUninstOptsParser
+//
+///////////////////////////////////////////////////
+
+CAMUninstOptsParser::~CAMUninstOptsParser()
+	{
+	
+	}
+	
+void CAMUninstOptsParser::OnStartElementL(const Xml::RTagInfo& aElement, 
+		const Xml::RAttributeArray& aAttributes, 
+		#ifdef _DEBUG 
+			TInt aErrorCode
+		#else 
+			TInt /*aErrorCode*/
+		#endif 
+		)
+	{
+	
+#ifdef _DEBUG
+	RDEBUG8_3( "CAMUninstOptsParser::OnStartElementL (LocalName '%S', aErrorCode %d)", 
+		&aElement.LocalName().DesC(),aErrorCode );
+	TInt count2( aAttributes.Count() );
+	for( TInt i( 0 ); i < count2; i++ )
+		{
+		RDEBUG8_5( "   Attribute %d, type=%d, '%S'='%S' ",i,aAttributes[i].Type(), 
+		 &aAttributes[i].Value().DesC(), &aAttributes[i].Attribute().LocalName().DesC() );
+		
+		}
+#endif
+
+	using namespace AMXml;
+
+	
+	const TPtrC8 name( aElement.LocalName().DesC() );
+	if ( name == Reader::KIOStartElement )
+		{
+		
+		}
+	else if ( name != Reader::KIOCustSymOpts )
+		{
+		RDEBUG8_2( "   Processing element '%S'", &name );
+		TInt c( aAttributes.Count() );
+		if ( c == 2 )
+			{
+			TPtrC8 attrname( aAttributes[0].Attribute().LocalName().DesC() );
+			TPtrC8 attrnameval( aAttributes[0].Value().DesC() );
+			TPtrC8 attrval( aAttributes[1].Attribute().LocalName().DesC() );
+			TPtrC8 attrvalval( aAttributes[1].Value().DesC() );
+			RDEBUG8_5( "   Name '%S'='%S' Val '%S'='%S' ",&attrname, &attrnameval,
+				&attrval, &attrvalval );
+			if ( attrname == Reader::KIOAttrName )
+				{
+				if ( attrval == Reader::KIOAttrValue )
+					{
+					if ( name == Reader::KIOStdOpt )
+						{
+						if ( attrnameval == KIOKill )
+							{
+							RDEBUG8_2( " Setting iKillApp to %S ", &attrvalval );
+							SetPolicyValue( iResult.iKillApp, attrvalval );
+							}
+						else 
+							{
+							RDEBUG8_3( " WARNING Unsupported name attribute value: '%S' for '%S' ", &attrnameval, &name );
+							}
+						}
+					else if ( name == Reader::KIOStdSymOpt )
+						{
+						if ( attrnameval == KUIOBreakDependency )
+							{
+							RDEBUG8_2( " Setting iDependecyBreak to %S ", &attrvalval );
+							SetPolicyValue( iResult.iBreakDependency, attrvalval );
+							}
+						else
+							{
+							RDEBUG8_3( " WARNING Unsupported name attribute value: '%S' for '%S' ", &attrnameval, &name );
+							}
+						}
+					else
+						{
+						RDEBUG("WARNING, unsupported name attribute value");
+						}
+					}
+				else
+					{
+					RDEBUG8_3( " ERROR invalid second attribute!: '%S', expteced: '%S' ", &attrval, &Reader::KIOAttrValue() );
+					}
+				}
+			else
+				{
+				RDEBUG8_3( " ERROR invalid first attribute!: '%S', expteced: '%S' ", &attrname, &Reader::KIOAttrName() );
+				}
+			}
+		else
+			{
+			RDEBUG8_3( " ERROR unsupported count of attributes!!: '%d' for '%S' ", c, &name);
+			}
+		}
+	else
+		{
+		RDEBUG( " ERROR custom options not implemented!!!!" );
+		
+		}
+	}
+	
+
+///////////////////////////////////////////////////
+//
+// InstallOptionsParser
+//
+///////////////////////////////////////////////////
+
+EXPORT_C void InstallOptionsParser::ParseOptionsL( const TDesC8 &aBuffer, SwiUI::TInstallOptions &aResult)
+	{
+	NApplicationManagement::TAMInstallOptions opts;
+	opts.iOptions.iUsePhoneLang = EFalse;
+	CAMInstOptsParser *parser = CAMInstOptsParser::NewLC( aBuffer, opts );
+	parser->ParseL();
+	aResult = opts.iOptions;
+	CleanupStack::PopAndDestroy( parser );
+	}
+	
+EXPORT_C void InstallOptionsParser::ParseOptionsL( const TDesC8 &aBuffer, NApplicationManagement::TAMInstallOptions &aResult)
+	{
+	aResult.iOptions.iUsePhoneLang = EFalse;
+	CAMInstOptsParser *parser = CAMInstOptsParser::NewLC( aBuffer, aResult );
+	parser->ParseL();
+	CleanupStack::PopAndDestroy( parser );
+	}
+	
+EXPORT_C void InstallOptionsParser::ParseOptionsL( const TDesC8 &aBuffer, SwiUI::TUninstallOptions &aResult)
+	{
+	CAMUninstOptsParser *parser = CAMUninstOptsParser::NewLC( aBuffer, aResult );
+	parser->ParseL();
+	CleanupStack::PopAndDestroy( parser );
+	}
+	
+EXPORT_C void InstallOptionsParser::SerializeOptionsL( const SwiUI::TUninstallOptions  &aOptions, CBufBase &aResult )
+	{
+	using namespace AMXml;
+	using namespace AMXml::Writer;
+	using namespace SwiUI;
+
+	aResult.InsertL(aResult.Size(), Writer::KUIOStartElement );
+	
+	HBufC8 *tmp = HBufC8::NewLC( 128 );
+	TPtr8 ptmp( tmp->Des() );
+	
+	if ( aOptions.iKillApp != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdOptFormat, &KIOKill, ( aOptions.iKillApp == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}
+	if ( aOptions.iBreakDependency != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdSymOptFormat, &KUIOBreakDependency, ( aOptions.iKillApp == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}
+	aResult.InsertL(aResult.Size(), Writer::KUIOStartElementEnd );
+	
+	CleanupStack::PopAndDestroy( tmp );
+	}
+
+EXPORT_C void InstallOptionsParser::SerializeOptionsL( const SwiUI::TInstallOptions &aOptions, CBufBase &aResult )
+	{
+	NApplicationManagement::TAMInstallOptions options;
+	options.iOptions = aOptions;
+	SerializeOptionsL( options, aResult );
+	}
+	
+EXPORT_C void InstallOptionsParser::SerializeOptionsL( const NApplicationManagement::TAMInstallOptions &aOptions, CBufBase &aResult )
+	{
+		
+	using namespace AMXml;
+	using namespace AMXml::Writer;
+	using namespace SwiUI;
+	
+	const SwiUI::TInstallOptions &options = aOptions.iOptions;
+	
+	aResult.InsertL(aResult.Size(), Writer::KIOStartElement );
+	
+	HBufC8 *tmp = HBufC8::NewLC( 128 );
+	TPtr8 ptmp( tmp->Des() );
+	TBuf8<1> b ;
+	b.Append( options.iDrive );
+	ptmp.Format( KIOStdOptFormat, &KIODrive, &b );
+	aResult.InsertL( aResult.Size(), ptmp );
+	
+	if( options.iUsePhoneLang )
+		{
+		ptmp.Format( KIOStdOptFormat, &KIOLanguage, &KIODefaultLanguage )	;
+		}
+	else
+		{
+		if( options.iLang != ELangNone )
+			{
+			TBool found( EFalse );
+			for( TInt i( 0 ); !found && i < KNumLangOptions; i++ )
+				{
+				if ( KLangOptions[i].iLang == options.iLang )
+					{
+				#ifdef _DEBUG
+		 		 	TPtrC8 code( KLangOptions[i].iCode );
+				 	RDEBUG8_2( " InstallOptionsParser::SerializeOptionsL : Found language %S", &code );
+				#endif
+					TPtrC8 p( KLangOptions[i].iCode );
+					ptmp.Format( KIOStdOptFormat, &KIOLanguage, &p )	;
+					
+					found = ETrue;
+					}
+				}
+			if ( !found )
+				{
+				ptmp.Format( KNullDesC8() );
+				}
+			}
+		else
+			{
+			ptmp.Format( KNullDesC8() );
+			}
+		}
+	aResult.InsertL( aResult.Size(), ptmp );
+	
+	if ( options.iUpgrade != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdOptFormat, &KIOUpgrade, ( options.iUpgrade == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		
+		}
+	if ( options.iKillApp != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdOptFormat, &KIOKill, ( options.iKillApp == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}
+	if ( options.iPackageInfo != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdSymOptFormat, &KIOPkginfo, ( options.iPackageInfo == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}	
+	if ( options.iCapabilities != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdSymOptFormat, &KIOCapabilities, ( options.iCapabilities == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}
+	if ( options.iUntrusted != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdSymOptFormat, &KIOUntrusted, ( options.iUntrusted == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}	
+	if ( options.iOCSP != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdSymOptFormat, &KIOOCSP, ( options.iOCSP == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}	
+	if ( options.iIgnoreOCSPWarnings != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdSymOptFormat, &KIOOCSPWarning, ( options.iIgnoreOCSPWarnings == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}	
+	if ( options.iOptionalItems != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdSymOptFormat, &KIOOptionalItems, ( options.iOptionalItems == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}	
+	if ( options.iOverwrite != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdSymOptFormat, &KIOOverwrite, ( options.iOverwrite == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}	
+	if ( options.iUpgradeData != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdSymOptFormat, &KIOUpgradeData, ( options.iUpgradeData == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}	
+	if ( options.iDownload != EPolicyUserConfirm )
+		{
+		ptmp.Format( KIOStdOptFormat, &KIODownload, ( options.iDownload == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}
+	if ( options.iPassword != KNullDesC() )
+		{
+        TBuf8<KSWInstMaxPasswordLength> password;        
+		password.Copy( options.iPassword );
+		ptmp.Format( KIOStdOptFormat, &KIOHttpPassword, &password );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}
+	if ( options.iLogin != KNullDesC() )
+		{
+		TBuf8<KSWInstMaxUserNameLength> login;
+		login.Copy( options.iLogin );
+		ptmp.Format( KIOStdOptFormat, &KIOHttpUsername, &login );
+		aResult.InsertL( aResult.Size(), ptmp );
+		}	
+	if ( aOptions.iConRef != KNullDesC8() )
+		{
+		ptmp.Format( KIOStdOptFormat, &KIOIAP, &aOptions.iConRef);
+		aResult.InsertL( aResult.Size(), ptmp );
+		}
+	aResult.InsertL( aResult.Size(), KIOStartElementEnd );
+	
+	CleanupStack::PopAndDestroy( tmp );
+	}
+	
+// End of File
Binary file applicationmanagement/rom/1020781C.txt has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/rom/appmgmt.iby	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation of applicationmanagement components
+*
+*/
+
+#ifndef __APPLICATIONMANAGEMENT_IBY__
+#define __APPLICATIONMANAGEMENT_IBY__
+
+//#if defined(__SAP_APPLICATION_MANAGEMENT)
+	
+	S60_APP_EXE(ApplicationManagementServer)
+
+  S60_APP_RESOURCE( ApplicationManagementServer )
+      
+      // _reg.rsc has to be in "import" folder to allow updating application exe with a SISX-file
+  data=\EPOC32\DATA\Z\private\10003a3f\import\apps\ApplicationManagementServer_reg.RSC \private\10003a3f\import\apps\ApplicationManagementServer_reg.RSC
+
+	file=ABI_DIR\BUILD_DIR\ApplicationManagementClient.dll		SHARED_LIB_DIR\ApplicationManagementClient.dll
+	
+	ECOM_PLUGIN(RfsAppMgmtPlugin.dll,102073BF.rsc)
+  ECOM_PLUGIN(omascomoadapter.dll, omascomoadapter.rsc)
+
+  data=ZPRIVATE\100012a5\policy\20021335.spd      PRIVATE\100012a5\policy\20021335.spd
+  data=ZPRIVATE\100012a5\policy\200267FB.spd      PRIVATE\100012a5\policy\200267FB.spd
+
+	
+//#endif // #ifdef __SAP_APPLICATION_MANAGEMENT
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/conf/applicationmanagement.qrc	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,11 @@
+<RCC>
+    <qresource prefix="/xml">
+        <file>downloaddialog.docml</file>
+        <file>installdialog.docml</file>
+        <file>sample.docml</file>
+        <file>error_notes.docml</file>
+    </qresource>
+    <qresource prefix="/icon">
+        <file>qgn_prop_sml_http.svg</file>
+    </qresource>
+</RCC>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/conf/downloaddialog.docml	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="0.9">
+    <object name="qtl_dialog_softkey_2_left" type="HbAction">
+        <string name="role" value="HbDialog:primaryAction"/>
+        <string name="text" value="OK"/>
+    </object>
+    <object name="qtl_dialog_softkey_2_right" type="HbAction">
+        <string name="role" value="HbDialog:secondaryAction"/>
+        <string name="text" value="Cancel"/>
+    </object>
+    <widget name="dialog" type="HbDialog">
+        <sizehint height="42.08955un" type="PREFERRED" width="50.5un"/>
+        <widget name="qtl_dialog_pri_heading" role="HbDialog:headingWidget" type="HbLabel">
+            <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+            <string name="plainText" value="Popup title"/>
+            <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+        </widget>
+        <widget name="qtl_dialog_pri5_large_graphic" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="container" type="HbWidget">
+                <widget name="qtl_dialog_pri5" type="HbLabel">
+                    <enums name="textWrapping" value="TextWordWrap"/>
+                    <sizehint height="4.62687un" type="PREFERRED" width="36.41791un"/>
+                    <bool name="visible" value="TRUE"/>
+                    <string name="plainText" value="Lorem ipsum sed dolor sit amet. Consectetur adipiscing. Proin auctor ante dolorr sit amet. Consectetur adipiscing."/>
+                    <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+                </widget>
+                <widget name="icon" type="HbLabel">
+                    <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+                    <icon iconName="note_warning" name="icon"/>
+                    <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                    <sizehint height="var(hb-param-graphic-size-primary-large)" type="FIXED" width="var(hb-param-graphic-size-primary-large)"/>
+                    <bool name="visible" value="TRUE"/>
+                </widget>
+                <widget name="qtl_dialog_pri5_1" type="HbLabel">
+                    <enums name="textWrapping" value="TextWordWrap"/>
+                    <real name="z" value="1"/>
+                    <sizehint height="5.22388un" type="PREFERRED" width="36.41791un"/>
+                    <bool name="visible" value="TRUE"/>
+                    <string name="plainText" value="Lorem ipsum sed dolor sit amet. Consectetur adipiscing. Proin auctor ante dolorr sit amet. Consectetur adipiscing."/>
+                    <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+                </widget>
+                <real name="z" value="0"/>
+                <sizehint height="20.8806un" type="PREFERRED" width="23.8806un"/>
+                <layout type="anchor">
+                    <anchoritem dst="qtl_dialog_pri5" dstEdge="TOP" spacing="4.32836un" src="" srcEdge="TOP"/>
+                    <anchoritem dst="qtl_dialog_pri5" dstEdge="RIGHT" spacing="-1.22388un" src="" srcEdge="RIGHT"/>
+                    <anchoritem dst="icon" dstEdge="LEFT" spacing="1.04478un" src="" srcEdge="LEFT"/>
+                    <anchoritem dst="icon" dstEdge="TOP" spacing="6.41791un" src="" srcEdge="TOP"/>
+                    <anchoritem dst="qtl_dialog_pri5_1" dstEdge="TOP" spacing="10.74627un" src="" srcEdge="TOP"/>
+                    <anchoritem dst="qtl_dialog_pri5_1" dstEdge="RIGHT" spacing="-1.22388un" src="" srcEdge="RIGHT"/>
+                </layout>
+            </widget>
+            <real name="z" value="0"/>
+            <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+            <layout type="grid">
+                <griditem column="0" itemname="container" row="0"/>
+            </layout>
+        </widget>
+        <ref object="qtl_dialog_softkey_2_left" role="HbWidget:addAction"/>
+        <ref object="qtl_dialog_softkey_2_right" role="HbWidget:addAction"/>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/conf/error_notes.docml	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="0.9">
+    <object name="qtl_dialog_softkey_2_left" type="HbAction">
+        <string name="role" value="HbDialog:primaryAction"/>
+        <string name="text" value="OK"/>
+    </object>
+    <object name="qtl_dialog_softkey_2_right" type="HbAction">
+        <string name="role" value="HbDialog:secondaryAction"/>
+        <string name="text" value="Cancel"/>
+    </object>
+    <widget name="dialog" type="HbDialog">
+        <sizehint height="42.08955un" type="PREFERRED" width="50.5un"/>
+        <widget name="heading_text" role="HbDialog:headingWidget" type="HbLabel">
+            <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+            <string name="plainText" value="Popup title"/>
+            <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+        </widget>
+        <widget name="qtl_dialog_pri5_large_graphic" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="icon" type="HbLabel">
+                <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+                <icon iconName="note_warning" name="icon"/>
+                <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                <sizehint height="var(hb-param-graphic-size-primary-large)" type="FIXED" width="var(hb-param-graphic-size-primary-large)"/>
+                <bool name="visible" value="TRUE"/>
+            </widget>
+            <widget name="content_text" type="HbLabel">
+                <enums name="textWrapping" value="TextWordWrap"/>
+                <bool name="visible" value="TRUE"/>
+                <string name="plainText" value="Lorem ipsum sed dolor sit amet. Consectetur adipiscing. Proin auctor ante dolorr sit amet. Consectetur adipiscing."/>
+                <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+            </widget>
+            <real name="z" value="0"/>
+            <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+            <layout orientation="Horizontal" spacing="var(hb-param-margin-gene-popup)" type="linear">
+                <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+                <linearitem itemname="icon"/>
+                <linearitem itemname="content_text"/>
+            </layout>
+        </widget>
+        <ref object="qtl_dialog_softkey_2_left" role="HbWidget:addAction"/>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <resource location="TemplateIcons.qrc"/>
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/conf/installdialog.docml	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="0.9">
+    <object name="qtl_dialog_softkey_2_left" type="HbAction">
+        <string name="role" value="HbDialog:primaryAction"/>
+        <string name="role" value="HbDialog:primaryAction"/>
+        <string name="text" value="OK"/>
+    </object>
+    <object name="qtl_dialog_softkey_2_right" type="HbAction">
+        <string name="role" value="HbDialog:secondaryAction"/>
+        <string name="role" value="HbDialog:secondaryAction"/>
+        <string name="text" value="Cancel"/>
+    </object>
+    <widget name="dialog" type="HbDialog">
+        <widget name="qtl_dialog_pri_heading" role="HbDialog:headingWidget" type="HbLabel">
+            <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+            <string name="plainText" value="Popup title"/>
+            <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+        </widget>
+        <widget name="qtl_dialog_pri5_large_graphic" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="label" type="HbLabel">
+                <real name="z" value="1"/>
+                <sizehint height="3.8806un" type="PREFERRED" width="32.38806un"/>
+                <bool name="visible" value="TRUE"/>
+                <string name="plainText" value="Size"/>
+            </widget>
+            <widget name="icon" type="HbLabel">
+                <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+                <icon iconName="note_warning" name="icon"/>
+                <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                <sizehint height="var(hb-param-graphic-size-primary-large)" type="FIXED" width="var(hb-param-graphic-size-primary-large)"/>
+                <bool name="visible" value="TRUE"/>
+            </widget>
+            <widget name="label_1" type="HbLabel">
+                <real name="z" value="5"/>
+                <sizehint height="3.8806un" type="PREFERRED" width="34.77612un"/>
+                <bool name="visible" value="TRUE"/>
+                <string name="plainText" value="Install to"/>
+            </widget>
+            <widget name="qtl_dialog_pri5" type="HbLabel">
+                <enums name="textWrapping" value="TextWordWrap"/>
+                <sizehint height="3.8806un" type="PREFERRED" width="43.8806un"/>
+                <bool name="visible" value="TRUE"/>
+                <string name="plainText" value="App_name"/>
+                <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+            </widget>
+            <widget name="combobox" type="HbComboBox">
+                <real name="z" value="5"/>
+                <sizehint type="PREFERRED" width="44.02985un"/>
+                <bool name="visible" value="TRUE"/>
+            </widget>
+            <real name="z" value="0"/>
+            <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+            <layout type="anchor">
+                <anchoritem dst="label" dstEdge="LEFT" spacing="12.83582un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="label" dstEdge="TOP" spacing="1.34328un" src="" srcEdge="TOP"/>
+                <anchoritem dst="icon" dstEdge="LEFT" spacing="1.34328un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="icon" dstEdge="TOP" spacing="0.59701un" src="" srcEdge="TOP"/>
+                <anchoritem dst="label_1" dstEdge="LEFT" spacing="12.53731un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="label_1" dstEdge="TOP" spacing="6.1194un" src="" srcEdge="TOP"/>
+                <anchoritem dst="combobox" dstEdge="LEFT" spacing="1.34328un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="combobox" dstEdge="TOP" spacing="19.70149un" src="" srcEdge="TOP"/>
+                <anchoritem dst="qtl_dialog_pri5" dstEdge="LEFT" spacing="1.14925un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="qtl_dialog_pri5" dstEdge="TOP" spacing="12.04478un" src="" srcEdge="TOP"/>
+            </layout>
+        </widget>
+        <rect height="45.97015un" name="geometry" width="50.5un" x="1.49254un" y="23.28358un"/>
+        <sizepolicy horizontalPolicy="Preferred" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
+        <sizehint height="50.08955un" type="PREFERRED" width="50.5un"/>
+        <ref object="qtl_dialog_softkey_2_left" role="HbDialog:primaryAction"/>
+        <ref object="qtl_dialog_softkey_2_right" role="HbDialog:secondaryAction"/>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD portrait" unit="un">
+        <resource location="TemplateIcons.qrc"/>
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/conf/qgn_prop_sml_http.svg	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg width="84" height="58" viewBox="-1.091 -0.148 84 58">
+<linearGradient id="_14" gradientUnits="userSpaceOnUse" x1="34.09" y1="6.03" x2="14.42" y2="34.84">
+<stop stop-color="#A2C2DD" offset="0.1"/>
+<stop stop-color="#6C83BB" offset="0.71"/>
+<stop stop-color="#003D6D" offset="0.99"/>
+</linearGradient>
+<path fill="url(#_14)" d="M26.636,8.969c-8.63,3.226-17.035,9.366-17.035,15.963c0.214,4.915,3.531,10.465,8.251,12.718 l-0.479-3.623c0,0-0.724-0.627-0.81-0.883c-0.188-0.759-0.284-1.485-0.284-2.174c0-5.745,6.096-9.069,11.15-11.158 c0.009,0.183,0.051,0.972,0.051,0.972L45.146,9.552L26.33,3.983C26.33,3.983,26.609,8.522,26.636,8.969z"/>
+<linearGradient id="_15" gradientUnits="userSpaceOnUse" x1="24.74" y1="26.75" x2="17.03" y2="21.63">
+<stop stop-color="#E6EEF4" offset="0"/>
+<stop stop-color="#4A9900" offset="0.44"/>
+<stop stop-color="#0E4E58" offset="0.94"/>
+</linearGradient>
+<path fill="url(#_15)" d="M16.72,34.797c-3.745-9.36,6.649-13.8,12.099-15.924c-0.684-1.658-0.453-1.881-1.138-3.54 C15.51,20.074,11.009,27.005,16.72,34.797"/>
+<path fill="#17594C" d="M17.049,34.241c-4.707-2.647-7.327-6.673-7.02-9.781c-0.262,4.508,3.185,10.516,7.391,12.587L17.049,34.241z "/>
+<linearGradient id="_16" gradientUnits="userSpaceOnUse" x1="20.59" y1="-1.22" x2="27.45" y2="18.88">
+<stop stop-color="#DCE8E4" offset="0"/>
+<stop stop-color="#43910A" offset="1"/>
+</linearGradient>
+<path fill="url(#_16)" d="M17.049,34.241C2.5,25.984,12.553,14.503,27.001,9.198L26.71,4.46l17.599,5.209L27.8,20.168 l-0.243-4.601C16.511,19.874,10.398,27.3,17.049,34.241z"/>
+<linearGradient id="_17" gradientUnits="userSpaceOnUse" x1="43.22" y1="9" x2="55.94" y2="35.39">
+<stop stop-color="#FFFFFF" offset="0"/>
+<stop stop-color="#A2C2DD" offset="0.35"/>
+<stop stop-color="#6C83BB" offset="0.7"/>
+<stop stop-color="#003D6D" offset="1"/>
+</linearGradient>
+<path fill="url(#_17)" d="M32.83,10.989l4.54-2.407C37.34,8.6,42.864,6.358,47.59,7.587c4.566,1.189,7.303,3.673,9.93,7.732 c2.629,4.055,3.246,11.162,1.51,14.948c-1.74,3.786-3.346,5.118-4.619,6.318L32.83,10.989z"/>
+<radialGradient id="_18" gradientUnits="userSpaceOnUse" cx="32.63" cy="14.14" r="22.73">
+<stop stop-color="#FFFFFF" offset="0.05"/>
+<stop stop-color="#A2C2DD" offset="1"/>
+</radialGradient>
+<path fill="url(#_18)" d="M55.877,26.643c0.453,9.102-6.096,16.178-14.625,15.811c-8.535-0.366-15.818-8.057-16.269-17.161 C24.53,16.191,31.08,9.11,39.611,9.477C48.145,9.853,55.426,17.542,55.877,26.643z"/>
+<linearGradient id="_19" gradientUnits="userSpaceOnUse" x1="54.5" y1="36.08" x2="61.89" y2="50.64">
+<stop stop-color="#A2C2DD" offset="0.1"/>
+<stop stop-color="#6C83BB" offset="0.71"/>
+<stop stop-color="#003D6D" offset="0.99"/>
+</linearGradient>
+<path fill="url(#_19)" d="M59.74,15.102c-0.096,0.239,0.225,0.462,0.225,0.462c4.405,2.811,7.194,6.907,6.558,10.752 c-0.598,4.594-5.178,8.876-11.973,11.272c-0.04-0.773-0.247-4.723-0.247-4.723l-17.22,11.053l0.428,3.709l18.586,5.84l-0.076-3.953 c0,0-0.034-0.178-0.067-0.352c2.115-0.857,16.265-7.052,16.265-19.209c0-6.524-2.87-11.62-11.938-15.01 C60.28,14.944,59.868,14.782,59.74,15.102z M71.948,27.023l-0.004-0.033C71.945,26.994,71.948,27.016,71.948,27.023z"/>
+<linearGradient id="_20" gradientUnits="userSpaceOnUse" x1="68.14" y1="39.97" x2="57.59" y2="32.79">
+<stop stop-color="#E6EEF4" offset="0"/>
+<stop stop-color="#2F8E9A" offset="0.44"/>
+<stop stop-color="#003D6D" offset="0.94"/>
+</linearGradient>
+<path fill="url(#_20)" d="M70.831,24.163c0,0-16.184,20.426-16.186,20.426c0.002,0,0.82,4.387,0.82,4.387 C55.94,48.841,76.676,40.753,70.831,24.163z"/>
+<linearGradient id="_21" gradientUnits="userSpaceOnUse" x1="36.23" y1="44.22" x2="63.23" y2="55.05">
+<stop stop-color="#E6EEF4" offset="0"/>
+<stop stop-color="#2F8E9A" offset="0.44"/>
+<stop stop-color="#003D6D" offset="0.94"/>
+</linearGradient>
+<polygon fill="url(#_21)" points="55.67,49.522 55.737,52.988 37.832,47.363 37.455,44.095 "/>
+<linearGradient id="_22" gradientUnits="userSpaceOnUse" x1="46.81" y1="16.39" x2="69.94" y2="71.96">
+<stop stop-color="#E6EEF4" offset="0"/>
+<stop stop-color="#2F8E9A" offset="0.44"/>
+<stop stop-color="#003D6D" offset="0.94"/>
+</linearGradient>
+<path fill="url(#_22)" d="M60.157,15.272C80.184,22.76,71.2,40.558,54.784,45.103l0.887,4.419l-18.216-5.427l16.53-10.607 l0.24,4.602C66.877,33.846,72.247,23.227,60.157,15.272z"/>
+<linearGradient id="_23" gradientUnits="userSpaceOnUse" x1="20.98" y1="20.82" x2="56.48" y2="28.57">
+<stop stop-color="#E6EEF4" offset="0"/>
+<stop stop-color="#4A9900" offset="0.44"/>
+<stop stop-color="#0E4E58" offset="0.94"/>
+</linearGradient>
+<path fill="url(#_23)" d="M36.105,20.456c-0.228-0.055-0.781-0.188-0.781-0.188l0.035,2.071c0,0,0.566,0.139,0.779,0.192 c0.015,0.826,0.068,4.305,0.068,4.305c0.01,0.767,0.022,1.561,0.357,2.31c0.543,1.21,1.694,1.48,2.808,1.74l0.982,0.242 l-0.018-2.047l-0.591-0.133c-0.459-0.095-0.978-0.202-1.253-0.461c-0.261-0.245-0.302-0.685-0.302-1.123 c0-0.102-0.037-3.818-0.045-4.346c0.422,0.104,1.844,0.45,1.844,0.45l-0.027-2.084c0,0-1.6-0.385-1.895-0.457 c-0.004-0.317-0.028-2.414-0.028-2.414l-1.969-0.468C36.068,18.045,36.099,19.988,36.105,20.456z"/>
+<path fill="url(#_23)" d="M41.199,21.68c-0.232-0.057-0.793-0.191-0.793-0.191l0.022,2.069c0,0,0.578,0.142,0.793,0.194 c0.004,0.284,0.047,4.353,0.047,4.353c0.006,0.779,0.014,1.588,0.356,2.348c0.561,1.243,1.821,1.533,2.939,1.787l0.918,0.221 l-0.006-2.058l-0.617-0.14c-0.414-0.087-0.884-0.187-1.184-0.399c-0.334-0.237-0.383-0.724-0.383-1.209 c0-0.104-0.023-3.96-0.027-4.403c0.423,0.105,1.869,0.457,1.869,0.457l-0.018-2.083c0,0-1.643-0.394-1.941-0.466 c-0.002-0.319-0.012-2.435-0.012-2.435l-1.994-0.475C41.172,19.246,41.195,21.211,41.199,21.68z"/>
+<path fill="url(#_23)" d="M46.247,23.199l0.071,12.329l2.024,0.539c0,0-0.013-2.584-0.013-3.092 c0.101,0.026,0.21,0.057,0.21,0.057l1.49,0.337c1.579,0.19,2.729-0.736,3.078-2.476c0.604-3.01-0.406-6.449-3.502-7.192 l-3.361-0.808L46.247,23.199z M48.297,25.547c0.119,0.024,0.242,0.052,0.242,0.052c0.777,0.157,1.658,0.335,2.049,0.909 c0.459,0.67,0.461,1.79,0.463,2.389c0,0.543,0,1.555-0.438,2.004c-0.459,0.477-1.352,0.212-2.066,0.002c0,0-0.115-0.032-0.229-0.064 C48.319,30.519,48.301,26.064,48.297,25.547z"/>
+<path fill="url(#_23)" d="M28.745,28.12l1.901,0.494L30.492,21.6c-0.002-0.014-0.002-0.044,0.063-0.097 c0.234-0.188,0.798-0.237,0.956-0.197c1.321,0.319,1.304,1.901,1.29,3.171l0.08,4.717l1.979,0.514l-0.099-5.563 c-0.01-0.802-0.022-1.63-0.291-2.43c-0.32-0.945-0.956-1.723-1.741-2.128c-0.681-0.354-1.577-0.531-2.285-0.192 c-0.014-0.653-0.084-3.854-0.084-3.854l-1.919-0.436L28.745,28.12z"/>
+</svg>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/conf/sample.docml	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+    <object name="qtl_dialog_softkey_2_left" type="HbAction">
+        <string name="text" value="OK"/>
+    </object>
+    <object name="qtl_dialog_softkey_2_right" type="HbAction">
+        <string name="text" value="Cancel"/>
+    </object>
+    <widget name="dialog" type="HbDialog">
+        <sizehint height="42.08955un" type="PREFERRED" width="50.5un"/>
+        <widget name="qtl_dialog_pri_heading" role="HbDialog:headingWidget" type="HbLabel">
+            <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+            <string name="plainText" value="Popup title"/>
+            <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+        </widget>
+        <widget name="qtl_dialog_pri5_large_graphic" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="qtl_dialog_pri5" type="HbLabel">
+                <real name="z" value="6"/>
+                <sizehint height="3.8806un" type="PREFERRED" width="34.77612un"/>
+                <bool name="visible" value="TRUE"/>
+                <string name="plainText"/>
+            </widget>
+            <widget name="combobox" type="HbComboBox">
+                <real name="z" value="7"/>
+                <sizehint type="PREFERRED" width="44.02985un"/>
+                <bool name="visible" value="TRUE"/>
+            </widget>
+            <widget name="container" type="HbWidget">
+                <widget name="label_1" type="HbLabel">
+                    <real name="z" value="3"/>
+                    <sizehint height="3.78158un" type="PREFERRED" width="23.15381un"/>
+                    <bool name="visible" value="TRUE"/>
+                    <string name="plainText"/>
+                </widget>
+                <widget name="icon" type="HbLabel">
+                    <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+                    <icon iconName="note_warning" name="icon"/>
+                    <real name="z" value="1"/>
+                    <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                    <sizehint height="var(hb-param-graphic-size-primary-large)" type="FIXED" width="var(hb-param-graphic-size-primary-large)"/>
+                    <bool name="visible" value="TRUE"/>
+                    <string name="plainText"/>
+                </widget>
+                <widget name="label" type="HbLabel">
+                    <enums name="textWrapping" value="TextWordWrap"/>
+                    <real name="z" value="2"/>
+                    <sizehint height="8un" type="PREFERRED" width="22.99545un"/>
+                    <bool name="visible" value="TRUE"/>
+                    <string name="plainText"/>
+                    <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+                </widget>
+                <real name="z" value="0"/>
+                <sizehint height="9.8806un" type="PREFERRED" width="23.8806un"/>
+                <layout type="anchor">
+                    <anchoritem dst="icon" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+                    <anchoritem dst="icon" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                    <anchoritem dst="label" dstEdge="LEFT" spacing="2un" src="icon" srcEdge="RIGHT"/>
+                    <anchoritem dst="label" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                    <anchoritem dst="label" dstEdge="RIGHT" spacing="-1un" src="" srcEdge="RIGHT"/>
+                    <anchoritem dst="label" dstEdge="BOTTOM" spacing="0un" src="icon" srcEdge="CENTERV"/>
+                    <anchoritem dst="label_1" dstEdge="LEFT" spacing="2un" src="icon" srcEdge="RIGHT"/>
+                    <anchoritem dst="label_1" dstEdge="TOP" spacing="1un" src="icon" srcEdge="CENTERV"/>
+                    <anchoritem dst="label_1" dstEdge="RIGHT" spacing="-1un" src="" srcEdge="RIGHT"/>
+                </layout>
+            </widget>
+            <real name="z" value="0"/>
+            <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+            <layout type="grid">
+                <contentsmargins bottom="1.04328un" left="1.34328un" right="1.34328un" top="1.34328un"/>
+                <griditem column="0" column_span="2" itemname="container" row="0"/>
+                <griditem column="0" column_span="2" itemname="qtl_dialog_pri5" row="1"/>
+                <griditem column="0" column_span="2" itemname="combobox" row="2"/>
+            </layout>
+        </widget>
+        <ref object="qtl_dialog_softkey_2_left" role="HbWidget:addAction"/>
+        <ref object="qtl_dialog_softkey_2_right" role="HbWidget:addAction"/>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
Binary file applicationmanagement/server/group/200267FB.txt has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/AMAppHideUtil.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,103 @@
+/*
+ * 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: Implementation of applicationmanagement components
+ *
+ */
+
+
+#ifndef __AMAPPHIDEUTIL_H__
+#define __AMAPPHIDEUTIL_H__
+
+#include <e32base.h>
+
+namespace NApplicationManagement
+    {
+
+    typedef RArray<TUid> RUidArray;
+
+    class CAMAppHideUtil : public CBase
+        {
+        RUidArray iHiddenUids; // The hidden uid list
+        TBool iChanged;
+        /**
+         * Constructor
+         */
+        CAMAppHideUtil();
+
+
+        /**
+         * Second phase constructor. Loads the uid list from centrep.
+         */
+        void ConstructL();
+
+
+
+        void ParseUids( RUidArray &aUid, const TDesC8& aUidList );
+
+        /**
+         * Loads uids from centrep
+         */
+        void LoadUidsL();
+
+        /**
+         * Parses uid, returning KErrNone if successful
+         */ 
+        TInt ParseUid( TLex &aLex, TUid &aUid ) const;
+
+        /**
+         * Skips delimiter, returning ETrue if delimiter is expected one.
+         */
+        TBool SkipDelim( TLex &aLex ) const;
+
+        /**
+         * Puts aUid to aBuf and if aHasMore also adds delimiter
+         */
+        void PersistUid( const TUid &aUid, TDes &aBuf, TBool aHasMore ) const;
+    public:
+        /**
+         * Destructor
+         */
+        virtual ~CAMAppHideUtil();
+
+        /**
+         * Creates new CAMAppHideUtil instance
+         */
+        static CAMAppHideUtil* CAMAppHideUtil::NewL();
+
+        /**
+         * Adds uid to list, and updates the repository if needed
+         */
+        void AddUidL(const TUid& aUid, TBool aPersist = EFalse );
+
+        /**
+         * Removed uid from list, and updates the repository if needed
+         */
+        void RemoveUidL( const TUid& aUid, TBool aPersist = EFalse );
+
+        /**
+         * Writes uids to centrep
+         */
+        void PersistUidsL();
+
+        /**
+         * Resets the hidden uid array
+         */
+        void Reset();
+        };
+
+    }
+
+#endif // #ifdef __AMAPPHIDEUTIL_H__
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/AMDeploymentComponent.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,321 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+
+#ifndef __CAMDEPLOYMENTCOMPONENT__
+#define __CAMDEPLOYMENTCOMPONENT__
+
+#include <e32base.h>
+#include <centralrepository.h>
+#include <f32file.h> 
+#include <SyncMLDef.h>
+#include "ApplicationManagementCommon.h"
+#include "aminstalloptions.h"
+#include "amdeploymentcomponentdata.h"
+
+
+namespace NApplicationManagement
+    {
+    _LIT8( KAMDCDelimiter, "|" );
+
+    // FORWARD DECLARATIONS
+    class CDeploymentComponent;
+    class CAMDownload;
+
+      class MAMDownloadStateObserver
+        {
+public:
+        /**
+         * StatusUpdateL Sets the current download status. This is 
+         *	currently HTTP status code 
+         *	(200 is success, 400+ failure, 100-199 in progress)
+         * @param	aNewStatus	The new download status 
+         */
+        virtual void StatusUpdateL(TInt aNewStatus) = 0;
+        virtual void SuccessStatusUpdateL(const TDesC &aDlFileName,
+                const TDesC8& aDlMimeType) = 0;
+        };
+
+
+    class MDownloadCallback
+        {
+    public:
+        virtual void DownloadComplete( class CDeploymentComponent *aComponent, TInt aStatus ) = 0;
+        virtual TBool UidExistsL( const TUid &aUid, CDeploymentComponent *& aCompo, CDeploymentComponent *aIgnored ) = 0;
+        };
+
+    class CDeploymentComponent : public CBase, public MAMDownloadStateObserver
+        {
+
+    public: // From MAMDownloadStateObserver	
+        void StatusUpdateL( TInt aNewStatus );
+        void SuccessStatusUpdateL( const TDesC &aDlFileName, const TDesC8& aDlMimeType );
+
+        void SetStatusNode(const TSCOMOStatusNodeStates &aStatus) const;
+    private:
+        // Data
+        TDeploymentComponentId iId;
+        TDeploymentComponentName iName;
+        TDeploymentComponentVersion iVersion;
+        TDeploymentComponentState iState;
+        TDeploymentComponentDescription iDescription;
+        TDeploymentComponentPkgId iPkgID;
+        TDeploymentComponentPkgIdRef iPkgIDRef;
+        TDeploymentComponentPkgType iPkgType;
+        TDeploymentComponentName iMidletName;
+        TDeploymentComponentName iMideltVendorName;
+        TDeploymentComponentVersion iMidletVersion;
+        TUint32 iInternalId;
+        TUid iUid;
+        TDCUserId iUserId;
+        
+        CDeploymentComponentData *iMetaData;
+        CDeploymentComponentData *iData;
+        TAMInstallOptions iInstallOpts;
+        TBool iInstallOptsSet;
+        TUint32 iPkgVersion;
+        TBool iRemovableApp;
+        TBool iDriveSelection;
+        TInt iComponentId;
+        TInt iDownloadStatus;
+        mutable TInt iStatus;
+        TBuf8<KMaxUrlLength> iDownloadURI;
+        TDownloadTarget iDownloadTarget;
+        SwiUI::TUninstallOptions iUninstallOpts;
+
+        TInt iOwner; // TCertInfo index in CAMStorage::iCertificates
+        TDeploymentComponentState iOldState;
+        MDownloadCallback *iCallback; // not owned
+
+        TSmlProfileId iOwnerProfile; // profile stored only runtime until download has completed
+        CRepository *iRepository;
+
+        // Constructors	
+        CDeploymentComponent( TInt iInternalId ); 
+        static CDeploymentComponent* NewL( TInt iInternalId, const TDCUserId &aUserId);
+        static CDeploymentComponent* NewLC( TInt iInternalId, const TDCUserId &aUserId );
+        static CDeploymentComponent* LoadL( TInt iInternalId, const TDesC8 &aBuffer );
+        static CDeploymentComponent* LoadLC( TInt iInternalId, const TDesC8 &aBuffer );
+
+        void ConstructL( const TDCUserId &aUserId );
+        void ConstructLoadL( const TDesC8 &aBuffer );
+
+        void SetAttr( TDes8 &aAttr, const TDesC8 &aNewVal ) const;
+
+        /**
+         * @param aState The new state
+         * @return TInt KErrNone if all ok, system error code if visiblity change failed
+         */
+
+        TInt SetState( const TDeploymentComponentState &aState ) ;
+        /**
+	Returns number of bytes written to aBuffer
+         */
+        virtual TInt SerializedFormL( RWriteStream &aBuffer ) const;
+        /**
+	Returns length of serizlied form
+         */
+        virtual TInt SerializedFormLength() const;
+        HBufC8* IntToDes8LC( const TInt aLuid );
+    public:
+        virtual ~CDeploymentComponent();
+        TInt DownloadStatus() const;
+        inline const TDeploymentComponentId &ComponentId() const;
+
+        inline const TDeploymentComponentName &ComponentName() const;
+
+        inline const TDeploymentComponentVersion &ComponentVersion() const;
+
+        inline TDeploymentComponentState State() const;
+
+        inline TUint32 InternalId() const;
+
+        inline const TUid & Uid() const;
+
+        //inline const TInt DownloadStatus() const;
+
+        inline const TDesC8 &DownloadURI() const ;
+
+        inline const TDeploymentComponentPkgId& PkgId() const ;
+
+        inline const TDeploymentComponentDescription& Description() const;
+
+        inline const TDeploymentComponentPkgIdRef& PkgIDRef() const;
+
+        inline const TDeploymentComponentPkgType& PkgType() const;
+
+        inline const TMidletnameName& MidletName() const;
+        inline const TMidletVendorName& MidletVendor() const;
+        inline const TMidletVersion& MidletVersion() const;
+
+
+
+        virtual void PersistL( CRepository &aRepository ) const;
+
+        virtual void DestroyL( CRepository &aRepository ) ;
+        /**
+	Copies current state to argument
+         */
+        void CopyStateTo( TDeploymentComponent &aInfo ) const;
+
+        void SetUid( const TUid aUid );
+
+        void Set( const TDeploymentComponent &aInfo );
+
+        void SetDownloadURIL( const TDesC8 &aURI );
+
+        void SetDownloadTarget( const TDownloadTarget& aDownloadTarget );
+
+        void SetDescriptionL( const TDesC8 &aVersion );
+
+        void SetPkgIDL( const TDesC8 &aPkgID );
+
+        void SetPkgTypeL( const TDesC8 &aPkgType );
+
+        void SetMidletNameL( const TDesC8 &aMidletName );
+
+        void SetMidletVendorL( const TDesC8 &aMidletVendor );
+
+        void SetMidletVersionL( const TDesC8 &aMidletVersion );
+
+        void SetAppRemovableStatus(const TBool &aRemovable);
+        
+        void SetDriveSelectionStatus(const TBool &aDriveSelection);
+        
+        void SetComponentId(const TInt &aComponentId);
+
+        void SetCallback( MDownloadCallback *aListener )
+            {
+            iCallback = aListener;
+            }
+
+
+        /**
+	UserId returns the id specified by user
+         */
+        inline const TDesC8& UserId() const;
+        /*
+         * Returns the status Node value of the Component ID.
+         * */
+        inline TInt Status() const;
+
+        CDeploymentComponent &operator=( const CDeploymentComponent &aData );
+
+
+
+        /**
+         * SetIAPL Sets the iap
+         * @param The new iap id
+         */
+        void SetIAPL( const TInt aIap );
+
+
+        /**
+         * @return The iap id
+         */
+        TInt GetIAP() const;
+
+        /**
+         * IsJavaMimeL
+         * @return ETrue if mime is recognised Java mime
+         */
+        static TBool IsJavaMimeL( const TDesC8& aMime );
+        /**
+                 * IsSisMimeL
+                 * @return ETrue if mime is recognised Sis mime
+                 */
+                static TBool IsSisMimeL( const TDesC8& aMime );
+
+        /**
+         * DownloadFailed
+         * @return ETrue if download status is such that it indicates failure, EFalse otherwise
+         */
+        TBool DownloadFailed() const;
+
+        /**
+         * OwnerProfile returns the owner profile - -1 if there's no such
+         */
+        const TSmlProfileId& OwnerProfile() const;
+
+        /**
+         * OwnerProfile 
+         */
+        void SetOwnerProfile( TSmlProfileId aOwnerProfile);
+
+
+        /**
+         * MimeType
+         * @return Component mimetype. This can be mimetype from data or metadata. Usually metadata mimetype is returned in Java case.
+         * In case of Java if both Jad and Jar exist, then it is Jad mimetype.
+         * In case of Java if only Jar exist, then it is Jar mimetype.
+         * In case of Java if only Jad exist, the it is Jad mimetype.
+         */
+        const TDesC8& MimeType() const;
+
+
+    protected:
+
+        static CDeploymentComponent *LoadComponentL (  TInt aInternalId, const TDesC8 &aBuffer ) ;
+    public:
+        CDeploymentComponentData &Data();
+        const CDeploymentComponentData &Data() const;
+        CDeploymentComponentData &MetaData();
+        const CDeploymentComponentData &MetaData() const;
+        const TAMInstallOptions &InstallOpts() const;
+        const SwiUI::TUninstallOptions &UninstallOpts() const;
+        TBool InstallOptsSet() const;
+        TBool AppRemovable() const;
+        TBool DriveSelected() const;
+        TInt GetComponentId() const;
+        void SetDataL( const TDesC8 &aMimeType );
+        void SetMetaDataL( const TDesC8 &aMimeType );
+        void SetDataL( const TDesC8 &aData, const TDesC8 &aMimeType );
+        void SetDataL( const TDesC &aFileName, const TDesC8 &aMimeType );
+        void SetMetaDataL( const TDesC8 &aMetaData, const TDesC8 &aMimeType );
+        void SetInstallOptsL( const TDesC8 &aInstallOptions );
+        void ResetDataL( RFs &aFs );
+
+        void SetIdL( const TDesC8 &aId );
+        void SetNameL( const TDesC8 &aName );
+        void SetVersionL( const TDesC8 &aVersion );
+        void SetMimeTypeL( const TDesC8 &aMimeType );
+        void SetOwner( const TInt &aCertInfoId );
+        TInt Owner( ) const
+        {
+        return iOwner;
+        }
+        TDownloadTarget DownloadTarget() const
+        {
+        return iDownloadTarget;
+        }
+
+        inline const TDeploymentComponentState& OldState() const;
+
+        inline void StateChangeComplete();
+
+
+        friend class CDeliveryComponentStorage;
+        };
+
+#include "amdeploymentcomponent.inl"
+
+    }
+
+
+#endif	
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/AMDownloadStore.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Implementation of applicationmanagement components
+ *
+ */
+
+#ifndef __CAMDOWNLOADSTORE_H__
+#define __CAMDOWNLOADSTORE_H__
+
+#include <e32base.h>
+#include <qobject.h>
+#include "AMDeploymentComponent.h"
+#include "appmgmtdownloadmgr.h"
+
+
+namespace NApplicationManagement
+    {
+
+    
+    // FORWARD DECLARATIONS
+    class CDeploymentComponent;
+    class CAMDwnldQTWrap;
+    
+    
+    class MDownloadMngrObserver
+          {
+    public:
+          virtual void ComponentDownloadComplete(
+                  class CDeploymentComponent *aComponent, TInt iapid,
+                  HBufC8* aServerId) = 0;
+          virtual TBool HasUidL(const TUid &aUid,
+                  CDeploymentComponent *& aCompo,
+                  CDeploymentComponent *aIgnored) = 0;
+          };
+    
+    
+
+    class CAMDownloadStore : public CActive
+        {
+
+    private:
+        /**
+         * C++ default constructor.
+         */
+        CAMDownloadStore(MDownloadMngrObserver& aObserver);
+
+        /**
+         * By default Symbian 2nd phase constructor is private.
+         */
+        void ConstructL();
+
+    public:
+        // Constructors and destructor
+
+        /**
+         * Two-phased constructor.
+         */
+        static CAMDownloadStore* NewL(MDownloadMngrObserver& aObserver);
+        /**
+         * Destructor.
+         */
+        virtual ~CAMDownloadStore();
+
+    public:
+
+        void AddDownloadL(CDeploymentComponent *aComponent);
+        
+        void RunL();
+        
+        void DoCancel();
+
+        void StartDownload();
+        
+        TInt DownloadCount();
+
+        RPointerArray<CAMDwnldQTWrap> iDwnldStore;
+        MDownloadMngrObserver& iObserver;
+
+        };
+
+    class CAMDwnldQTWrap : public CBase, public MDownloadCallback, public MDownloadMgrQTCallback
+        {
+    private:
+        /**
+         * C++ default constructor.
+         */
+        CAMDwnldQTWrap(MDownloadMngrObserver& aObserver, CDeploymentComponent *aComponent);
+
+        /**
+         * By default Symbian 2nd phase constructor is private.
+         */
+        void ConstructL();
+
+    public:
+        // Constructors and destructor
+
+        /**
+         * Two-phased constructor.
+         */
+        static CAMDwnldQTWrap* NewL(MDownloadMngrObserver& aObserver, CDeploymentComponent *aComponent);
+        /**
+         * Destructor.
+         */
+        virtual ~CAMDwnldQTWrap();
+        
+    public:
+        void StartDownload(CDeploymentComponent *aComponent, TRequestStatus& aStatus);
+        
+        TInt getPendingDownloads();
+
+
+    public:
+        void DownloadCompleteL(CDeploymentComponent *aComponent);
+	  void DownloadCompleted();
+	  void DownloadFailed(TInt aDownloaderr);
+	  void SetStatus(TInt aStatus);
+        
+        
+    public:
+        void DownloadComplete(class CDeploymentComponent *aComponent,
+                TInt aStatus);
+        TBool UidExistsL(const TUid &aUid, CDeploymentComponent *& aCompo,
+                CDeploymentComponent *aIgnored);
+        
+    public:
+        appmgmtdownloadmgr* appdwnld;
+        MDownloadMngrObserver& iObserver;
+        CDeploymentComponent *iComponent;
+        HBufC8* serverid;
+	  TInt iap;
+        };
+
+    }
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/AMDownloaddb.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+ *
+ * Description:  Implementation of applicationmanagement components
+ *
+*/
+
+
+#ifndef __AMDownloaddb_H
+#define __AMDownloaddb_H
+
+// INCLUDE FILES
+
+#include <e32std.h>
+#include <e32base.h>
+#include <d32dbms.h>
+#include <f32file.h>
+#include <SyncMLDef.h>
+
+// CONSTANTS
+
+// null final result value
+const TInt KAMNullResult = 0;
+
+// Database name & location
+const TInt KAMDownloaddbDrive = EDriveC;
+const TUid KAMPolicyUID =
+    {
+    0x200267FB
+    };
+const TInt KAMMaxPkgURLLength( 2048);
+const TInt KAMMaxPkgNameLength( 80);
+const TInt KAMMaxPkgVersionLength( 80);
+
+_LIT( KDBMSSecureID, "secure[200267FB]" );
+
+_LIT( KAMDownloaddbName, "c:TARMAppMgmtDownloadDB.db" );
+
+// Table and column names
+_LIT( KTableAMMgmtObject, "AMMgmtObject" );
+
+_LIT(NCol1, "Id");
+_LIT(NCol2, "LUID");
+_LIT(NCol3, "Result");
+_LIT(NCol4, "TargetURI");
+_LIT(NCol5, "IAPId");
+
+class CAMDbItem : public CBase
+    {
+public:
+    static CAMDbItem* NewL();
+    ~CAMDbItem();
+
+    TInt id;
+    TUint32 iLUID;
+    TInt iResult;
+
+    HBufC8* iTargetURI;
+
+    TUint32 iapid;
+
+    };
+
+// CLASS DECLARATION
+
+/**
+ *  CAMDownloaddb provides an interface for accessing AM database.
+ *  
+ *  @lib AMadapter.lib
+ *  
+ */
+class CAMDownloaddb : public CBase
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @return A pointer to the newly created instance.
+     */
+    static CAMDownloaddb* NewL();
+
+    /**
+     * Two-phased constructor. Pushes the pointer onto the CleanupStack.
+     * @return A pointer to the newly created instance.
+     */
+    static CAMDownloaddb* NewLC();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CAMDownloaddb();
+
+    void CreateTableL(RDbDatabase& aDatabase);
+
+    void CreateandOpenL(TParse& name);
+
+    TBool DeleteFromDatabaseL(TUint32 aLUID);
+
+    void SaveToDatabaseL(TInt& aIndex, TUint32 aLuid, TInt aResult,
+            const TDesC8& aTargetURI, TUint32 aIapid);
+
+    void ReadItemsL(RPointerArray<CAMDbItem>& aItemArray, TDesC& aQueryBuffer);
+
+    void ReadDbItemsL(RPointerArray<CAMDbItem>& aItemArray);
+
+    void GetEntryForLUIDL(RPointerArray<CAMDbItem>& aItemArray, TDesC& aValue);
+
+    /**
+     * Second phase construction.
+     */
+    void ConstructL();
+
+    /**
+     * Constructor.
+     */
+    CAMDownloaddb();
+
+private:
+
+    RDbNamedDatabase iDatabase;
+    RFs iFsSession;
+    RDbs iRdbSession;
+
+    RDbTable iAMObjectTable;
+    CDbColSet* iColSet;
+    RDbView iView;
+
+    };
+
+#endif // __AMDownloaddb_H   
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/AMPreInstallApp.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#ifndef AMPREINSTALLAPP_H_
+#define AMPREINSTALLAPP_H_
+
+#include <e32base.h>
+#include <badesca.h> 
+#include <f32file.h>
+#include "ApplicationManagementCommon.h"
+#include "amstorage.h"
+
+
+_LIT(KPreInstallPath, "\\private\\10202dce\\");
+
+namespace NApplicationManagement
+    {
+    
+    class TPreInstalledAppParams
+        {
+public:
+        TUid iPreInstalledAppUid;
+#if 1
+       TPreInstalledAppName iPreInstalledAppame;
+       TPreInstalledAppVendorName iPreInstalledAppVendorName;
+       TPreInstalledVersion iVersion;
+       TMimeType iMimeType;
+#endif
+        //TPreInstalledVersion bufVersion;
+#if 0
+        HBufC* iPreInstalledAppame;
+        HBufC* iPreInstalledAppVendorName;
+#endif
+        };
+    
+    class CAMPreInstallApp : public CBase
+        {
+
+public:
+        ~CAMPreInstallApp();
+        static CAMPreInstallApp* NewL();
+        static CAMPreInstallApp* NewLC();
+        void ListPreInstalledAppL(const TDesC& installDocPath);
+        void ListPreInstalledAppL();
+        TBool RecognizeL(TDesC& aPathAndName, HBufC* aMimeType);
+        void MakeAllInstallPathsL();
+        void GetPreInstalledAppsL(RPointerArray<TPreInstalledAppParams> &aPreInstalledAppParams);
+        void Listallapps();
+private:
+        CAMPreInstallApp();
+
+        void ConstructL();
+
+private:
+
+        TFileName iPreInstallPath; // Path where to scan for pre-install files
+#ifdef RD_MULTIPLE_DRIVE        
+        CDesCArray* iInstallDocPathArray;
+#else        
+        TFileName iPreInstallDocumentPath; // Path where to scan for pre-install files  
+#endif // RD_MULTIPLE_DRIVE
+
+        RFs iFs;
+        CDeliveryComponentStorage *iStorage;
+        RPointerArray<TPreInstalledAppParams> iPreInstalledAppParams;
+
+        };
+
+
+
+    }
+
+#endif /*AMPREINSTALLAPP_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/ApplicationManagementJavaUtility.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+ *
+ * Description:  Implementation of applicationmanagement components
+ *
+*/
+
+
+#ifndef __APPLICATIONMANAGEMENTJAVAUTILITY_H__
+#define __APPLICATIONMANAGEMENTJAVAUTILITY_H__
+
+//  EXTERNAL INCLUDES
+#include <e32base.h>
+#include <javaregistryincludes.h>
+using namespace Java;
+//  INTERNAL INCLUDES
+#include "ApplicationManagementUtility.h"
+
+namespace NApplicationManagement
+    {
+
+    //  CLASS DEFINITION
+    /**
+     *
+     *   
+     *
+     */
+    class CApplicationManagementJavaUtility :
+        public CApplicationManagementUtility
+        {
+
+public:
+        // Constructors and destructors
+
+        static CApplicationManagementJavaUtility* NewL(); // Static constructor
+        static CApplicationManagementJavaUtility* NewLC(); // Static constructor
+        ~CApplicationManagementJavaUtility(); // Destructor
+
+private:
+        // Constructors and destructors
+
+        CApplicationManagementJavaUtility(); // Default constructor
+        void ConstructL(); // Second phase construct
+
+public:
+        // New methods
+
+        TBool FindInstalledJavaUidL(const TUid &aUid) const;
+
+        void InstalledSuiteUidsL(RArray <TUid>&);
+
+        void JavaUidsL(RArray<TUid> &aUids);
+
+        void RefreshJavaRegistryL();
+        void GetInstalledMidletParametersL(
+                TMidletParameters& aMidletParameters);
+
+private:
+        // Data
+
+        CJavaRegistry* iJavaRegistry;
+        };
+
+    }
+
+#endif      //  __ApplicationManagementJavaUtility_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/ApplicationManagementServer.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,461 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#ifndef __APPLICATIONMANAGEMENTSERVER_H__
+#define __APPLICATIONMANAGEMENTSERVER_H__
+
+// INCLUDES
+#include <SyncMLClient.h>
+#include <e32base.h>
+#include <centralrepository.h>
+#include <SWInstApi.h>
+#include <ssl.h>
+#include <swi/launcher.h>
+#include <swi/sisregistrysession.h>
+#include <swi/sisregistrypackage.h>
+#include <swi/sisregistryentry.h>
+#include <HbProgressDialog.h>
+#include <hbmainwindow.h>
+#include <hbaction.h>
+#include <usif/sif/sif.h>
+#include <SWInstApi.h>
+#include <QGraphicsLinearLayout>
+#include "ApplicationManagementClientServer.h"
+#include "PlatformSecurityPolicies.h"
+#include "AMDeploymentComponent.h"
+#include "amstorage.h"
+#include "ApplicationManagementUtility.h"
+#include "AMDownloaddb.h"
+#include "amwaitprogdialog.h"
+#include "AMDownloadStore.h"
+
+// CONSTANTS
+const TUid NProperty = {0x200267FB};
+const TUint32 NInteger = 0x00000001;
+const TInt KBase64BufSize = 131072;
+const QString path = "z:/resource/qt/translations/";
+class CAppMgmtSrvApp;
+_LIT(KIndicatorParamDownloading, "Downloading");
+namespace NApplicationManagement
+    {
+
+    // -----------------------------------------------------------
+    // ApplicationManagement server panic codes
+    // -----------------------------------------------------------
+    enum TApplicationManagementPanic
+        {
+        EPanicGeneral,
+        EBadSubsessionHandle,
+        EPanicIllegalFunction,
+        EBadDescriptor
+        };
+    // -----------------------------------------------------------
+    // Wait dialog types
+    // -----------------------------------------------------------
+    enum TDialogType
+        {
+        EInstallWaitDlg,
+        EUninstallWaitDlg
+        };
+    // FUNCTION PROTOTYPES
+
+    void PanicClient(const RMessagePtr2& aMessage,
+            TApplicationManagementPanic aPanic);
+
+    // CLASS DECLARATION     
+    class CShutdown : public CTimer
+        {
+        enum
+            {
+            KApplicationManagementShutdownDelay = 0x3000000 // approx 30s
+            };
+public:
+        inline CShutdown();
+        inline void ConstructL();
+        inline void Start();
+	inline void Stop();
+private:
+        void RunL();
+        };
+
+    /**
+     *  CApplicationManagementServer 
+     *  Description.
+     */
+
+    class CApplicationManagementServer : public CPolicyServer,
+        public MDownloadMngrObserver,public MInstallerCallBack
+        {
+public:
+        static CServer2* NewL(HbMainWindow *mainWindow);
+        ~CApplicationManagementServer();
+
+        void Panic(TInt aPanicCode);
+        void AddSession();
+        void DropSession();
+        
+        CPolicyServer::TCustomResult CreateServiceSecurityCheckL(
+                TUid aServiceType, const RMessage2& aMsg, TInt& aAction,
+                TSecurityInfo& aMissing);
+private:
+
+        CApplicationManagementServer();
+        virtual void ConstructL(HbMainWindow *mainWindow);
+        CSession2* NewSessionL(const TVersion& aVersion, 
+         const RMessage2& aMessage) const;
+
+        //From CPolicyServer
+        CPolicyServer::TCustomResult
+                CustomSecurityCheckL(const RMessage2& aMsg, TInt& aAction,
+                        TSecurityInfo& aMissing);
+
+        // browses sis registry
+        void LookupSisRegistryL();
+
+        //New methods	
+        void DownloadCompleteL(CDeploymentComponent *aComponent, TInt iapid,
+                HBufC8* aServerId);
+
+        void InstallCompleteL(const CDeploymentComponent &aCompo,
+                const TBool &aInstallSuccess=ETrue);
+                
+        TInt GetErrorStatus(TInt aErrorDownload, TInt aErrorInstall);
+        
+        void EnableDMNetworkMonL(TInt iapid, HBufC8 *aServerId);
+
+public:
+
+        /**
+         * 	Storage Returns the storage
+         * @return The storage pointer
+         */
+        inline CDeliveryComponentStorage *Storage()
+            {
+            return iStorage;
+            }
+
+        /**
+         * UninstallL Uninstalls the given deployment component.
+         * @param aComponent The component to be uninstalled
+         * @param aStatus TRequestStatus of the call
+         */
+        void UninstallL(const CDeploymentComponent &aComponent,
+                TRequestStatus &aStatus);
+
+        void AddDownloadL(CDeploymentComponent *aComponent);
+
+        void PerformRFSL();
+        void RemoveInternalL(const CDeploymentComponent &aCompo,
+                TBool aDoUninstall = ETrue);
+
+        TBool CheckCertL(const TCertInfo &aInfo) const;
+        void DoTheInstallL(CDeploymentComponent &aCompo);
+
+        void GetAMServerDownloadDBL(TUint32 internalid, TInt& finalresult,
+                TDes8& atargetURI);
+                
+        TBool IsOMASCOMOEnabledL();
+
+        /**
+         * JavaUidsL Returns java uids.
+         * @param aUids the array to hold uids
+         */
+        void JavaUidsL(RArray<TUid> &aUids) const;
+
+        /**
+         * FullUpdateL updates target with source
+         * @param sid Source deployment component id
+         * @param tid Target deployment component id
+         */
+        void FullUpdateL(const TUint32 sid, const TUint32 tid);
+
+        /**
+         * SetDataL sets data to deployment component and checks possible uid overlaps
+         * @param aCompo deployment component where data is set
+         * @param aData new data to be set
+         * @param aMime mimetype of the new data to be set
+         */
+        void SetDataL(CDeploymentComponent &aCompo, const TDesC8 &aData,
+                const TDesC8 &aMime);
+        /**
+         * Checks of data in file is Base64 decoded.
+         * @param aFile file to be checked if data is encoded
+         * @param aLength data length in file
+         * @return ETrue if given data in file is Base64 encoded
+         */
+        TBool IsDataFileB64EncodedL(RFile &aFile, TInt& aLength);
+
+        /**
+         * Checks of data is Base64 decoded.
+         * @param aData data to be checked for encoding
+         * @return ETrue if given data is Base64 encoded
+         */
+        TBool CheckB64Encode(const TDesC8& aData);
+
+        /**
+         * B64 Decodes data in aData and return decoded data
+         * @param aSourceFile file containing decoded data
+         * @param aDestinationFile file where to decode data
+         */
+        void DecodeB64DataFileL(RFile& aSourceFile, RFile& aDestinationFile);
+
+        /**
+         * B64 Decodes data in aData and return decoded data
+         * @param aData decoded data
+         * @return Decoded data
+         */
+        HBufC8* DecodeB64DataLC(const TDesC8 &aData);
+
+        /**
+         * B64 Encodes data in aData to aTarget
+         * @param aData data which is encoded
+         * @param aTarget encoded data buffer
+         */
+        void EncodeDataL(const TDesC8& aData, CBufBase &aTarget);
+        void HandleAllClientsClosed();
+
+        void DeleteGenericAlertForIDL(TUint32 internalid);
+        void CheckforDuplicateMidletsL(TMidletParameters& amidletParameters);
+
+public:
+        // from MDownloadMngrObserver
+
+        /**
+         * 
+         * @param aComponent 
+         * @param aStatus 
+         */
+        void ComponentDownloadComplete(CDeploymentComponent *aComponent,
+                TInt iapid, HBufC8 *aServerId);
+
+        /**
+         * Looks all deployments components and sis & java registries
+         * to find out whether given uid is already used...
+         * @param aUid The uid to be looked for
+         * @return ETrue if uid is found, EFalse otherwise
+         */
+        TBool HasUidL(const TUid &aUid, CDeploymentComponent *& aCompo,
+                CDeploymentComponent *aIgnored);
+
+        void ComponentDownloadFailed(CDeploymentComponent *aComponent,
+                TInt aReason);
+
+        void StartShutDownTimerL();
+
+        TBool IsInstalledAppRemovableL(TDriveNumber &iDrive);
+
+	  void InstallationCancelled();
+private:
+
+        /**
+         * FullUpdateL updates target with source
+         * @param sid Source deployment component 
+         * @param tid Target deployment component 
+         */
+        void FullUpdateL(CDeploymentComponent &scompo,
+                const CDeploymentComponent &tcompo);
+
+        /**
+         * InstallL Installs the given deployment component. Async version.
+         * @param aComponent The component to be installed
+         * @param aStatus TRequestStatus of the call
+         */
+        void InstallL(const CDeploymentComponent &aComponent,
+                TRequestStatus &aStatus);
+        /**
+         * InstallL Installs the given deployment component. Syncronized version.
+         * @param aComponent The component to be installed
+         */
+        void InstallL(const CDeploymentComponent &aComponent);
+
+        /**
+         * PrepareInstallL Prepares install of given component.
+         * @param aComponent The component to be installed
+         * @param aFileName	If call is successful, will contain 
+         * the name of file ready to be installed
+         * @return ETrue if preparation is successful, EFalse otherwise
+         */
+        TBool PrepareInstallL(const CDeploymentComponent &aComponent,
+                TFileName &aFileName);
+
+        /**
+         * Finds whether the given uid is found in sis or java registry.
+         * Searches first sis registry and uses FindJavaUidL if not found
+         */
+        TBool FindInstalledSisUidL(const TUid &aUid) const;
+
+        /**
+         * Finds whether the given uid is found in java registry
+         */
+        TBool FindInstalledJavaUidL(const TUid &aUid) const;
+        void SetSisAppVersionAndDriveL(CDeploymentComponent &aCompo);
+        void JavaInstallL(CDeploymentComponent &aCompo);
+        void SisInstallL(const CDeploymentComponent &aCompo);
+        TUid FindNewUid(const RArray<TUid> &aUidsOrig,
+                const RArray<TUid> &aUidsNew) const;
+
+        /**
+         * Reads Jar file name from Jad file
+         * @param aFile file handle for Jad file where to find Jar filename
+         * @return aFileName	If call is successful, will contain the name of file ready to be installed
+         */
+        TFileName ReadJarFileNameL(RFile& aFile) const;
+
+        /**
+         * Reads line of data from file.
+         * @param aStream stream handle where to read data
+         * @param aLineBuffer buffer where function appends read data for line. Return a full line at time.
+         */
+        void ReadLineL(RReadStream& aStream, TDes8& aLineBuffer) const;
+
+        /**
+         * DoDataUpdateCheck checks whether there's dc having same data uid
+         * @return The conflicting DC or NULL
+         */
+        CDeploymentComponent * DoDataUpdateCheckL(
+                CDeploymentComponent &aCompo);
+
+        // Functions used to generate temporary files Java installation use case
+        // where both Jad and Jar files are delivered to phone and Jad file is used to install 
+        // the Java application from local Jar file.
+        void GenerateTempJarFileNameL(RFs &aFs, const TDesC& aMetaSource,
+                TFileName &aFileName) const;
+
+        void GenerateTempFileNameL(const RFs &aFs, const TDesC& aSource,
+                TFileName &aFileName) const;
+
+        void GenerateTempFileNameL(RFs &aFs,
+                const CDeploymentComponent& aCompo, TFileName& aSource,
+                TFileName &aMetaSource, TFileName &aFileName,
+                TFileName &aMetaFileName) const;
+
+        void GenerateTempFileNameL(RFs &aFs,
+                const CDeploymentComponent& aCompo, TFileName &aFileName,
+                TFileName &aMetaFileName) const;
+
+        CApaAppServiceBase* CreateServiceL(TUid aServiceType) const;
+public:
+        CAppMgmtSrvApp* iParentApp;
+private:
+        TInt iSessionCount;
+        CShutdown iShutdown;
+        CApplicationManagementUtility* iUtility;
+        CDeliveryComponentStorage *iStorage;
+        TBool iInstallInProgress;
+
+        Usif::RSoftwareInstall iInstaller;
+        Usif::COpaqueNamedParams *iArgu;
+        Usif::COpaqueNamedParams *iResults;
+        SwiUI::TInstallOptionsPckg iInstallOptions;
+        SwiUI::TUninstallOptionsPckg iUninstallOptions;
+        SwiUI::TInstallReqPckg iInstallReq;
+        TFileName iAppname;
+        RFs iInstallRFs;
+        RFile iInstallFile;
+        CAMDownloadStore* iDownloadMngr;
+        CAMDownloaddb* iAMServerDB;
+        TBool iOMASCOMOEnabled;
+        
+        appmgmtdownloadmgr* m_DownloadMngr;
+        QString m_appName;
+        AMWaitProgDialog* m_Dlg;
+        CDeploymentComponent* iComp;
+        HbMainWindow* m_Window;
+        int mUserCancelled;
+        };
+
+    namespace NPolicyConstants
+        {
+
+        // "CSF" + CA + SerialNumber + Fingerprint) ;
+        //_LIT( KSubjectFormat, "CSF%S%S%S" );
+        namespace NActions
+            {
+            _LIT8( KUse, "Use" );
+            }
+        _LIT8( KResourceValue, "ApplicationManagement" );
+        }
+
+    class CApplicationManagementSession : public CSession2
+        {
+public:
+        inline CApplicationManagementSession();
+        inline CApplicationManagementSession(const TCertInfo &aInfo);
+        void CreateL();
+private:
+        ~CApplicationManagementSession();
+        inline CApplicationManagementServer& Server() const;
+
+        void ServiceL(const RMessage2& aMessage);
+        TBool PreDispatchMessageL(const RMessage2 &aMessage);
+        void DispatchMessageL(const RMessage2& aMessage);
+        void ServiceError(const RMessage2& aMessage, TInt aError);
+
+        void ComponentCountL(const RMessage2& aMessage);
+        void ComponentIdsL(const RMessage2& aMessage) const;
+        void Deliver2L(const RMessage2& aMessage) const;
+        void DeliverCompleteL(const RMessage2& aMessage) const;
+        void GetComponentL(const RMessage2& aMessage) const;
+        void InstallL(const RMessage2 &aMessage) const;
+        void UpdateL(const RMessage2 &aMessage) const;
+        void GetDataL(const RMessage2 &aMessage) const;
+        void GetDataLengthL(const RMessage2 &aMessage) const;
+        void RemoveL(const RMessage2 &aMessage) const;
+        void UpdateDataL(const RMessage2 &aMessage) const;
+        void UpdateStreamedDataL(const RMessage2& aMessage) const;
+        void DownloadL(const RMessage2 &aMessage) const;
+        void AddTrustL(const RMessage2 &aMessage);
+        void FullUpdateL(const RMessage2 &aMessage) const;
+        void GetUserIdL(const RMessage2 &aMessage) const;
+        void StartDownloadL(const RMessage2& aMessage) const;
+        void StateChangeComponentIdsL(const RMessage2& aMessage) const;
+        void StateChangeComponentIdsCountL(const RMessage2& aMessage) const;
+        void StateChangeCompleteL(const RMessage2& aMessage) const;
+        void ActivateL(const RMessage2& aMessage) const;
+        void DeactivateL(const RMessage2& aMessage) const;
+        void GetTemporaryInstFileL(const RMessage2 &aMessage) const;
+        void GetFinalResultForGAL(const RMessage2 &aMessage);
+
+        TInt PackageSizeL(Swi::RSisRegistrySession& aSession,
+                Swi::RSisRegistryEntry& aEntry);
+        TInt AugmentationSizeL(Swi::RSisRegistrySession& aSession,
+                const Swi::CSisRegistryPackage& aPackage);
+
+        void RemoveInternalL(const TUint32 &aId) const;
+
+        /**
+         * Collects active components in aArrt and places them in aArr
+         */
+        void ActiveComponentsL(const RComponentIdArray &aArrt,
+                RComponentIdArray &aArr,TDeploymentComponentState &aState) const;
+
+        void GenericAlertSentForIdL(const RMessage2& aMessage) const;
+
+        void CheckStatusNodesValuesL();
+
+private:
+        void LookupSisRegistryL();
+
+        TCertInfo iCertInfo;
+        TBool iTrustAdded;
+        
+        };
+
+    }
+#endif //__APPLICATIONMANAGEMENTSERVER_H__
+//  End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/ApplicationManagementUtility.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Implementation of applicationmanagement components
+ *
+ */
+
+#ifndef __CApplicationManagementUtility_H__
+#define __CApplicationManagementUtility_H__
+
+//  EXTERNAL INCLUDES
+#include <e32base.h>
+#include <hbdialog.h>
+#include "ApplicationManagementCommon.h"
+#include "javaregistryentry.h"
+
+
+namespace NApplicationManagement
+    {
+
+    //  CLASS DEFINITION
+    /**
+     *
+     *   
+     *
+     */
+
+    class TMidletParameters
+        {
+public:
+        TUid iMidletUid;
+        TMidletnameName iMidletName;
+        TMidletVendorName iMidletVenorName;
+        TMidletVersion bufVersion;
+        TDriveNumber iDrive;
+
+        };
+    class CApplicationManagementUtility : public CBase
+        {
+
+public:
+        // Constructors and destructors
+
+        static CApplicationManagementUtility* NewL(); // Static constructor
+        static CApplicationManagementUtility* NewLC(); // Static constructor
+        ~CApplicationManagementUtility(); // Destructor
+
+protected:
+
+        CApplicationManagementUtility(); // Default constructor
+
+private:
+        // Constructors and destructors
+
+        void ConstructL(); // Second phase construct
+
+
+public:
+        // New methods
+
+        virtual TBool FindInstalledJavaUidL(const TUid &aUid) const;
+
+        virtual void InstalledSuiteUidsL(RArray <TUid>);
+
+        virtual void JavaUidsL(RArray<TUid> &aUids);
+
+        virtual void RefreshJavaRegistryL();
+        virtual void GetInstalledMidletParametersL(
+                TMidletParameters& aMidletParameters);
+
+	static void SetFileName(const TFileName& aFileName);
+	static void GetFileName(TFileName& aFileName);
+        
+public:
+        static TInt mHidden;
+        static HbDialog* mCurrDlg;
+        static TInt iSilentSession;
+        static TFileName iFileName;
+        
+        };
+
+    }
+
+#endif      //  __CApplicationManagementUtility_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/ApplicationManagementUtilityFactory.h	Tue Jul 13 04:01:20 2010 +0530
@@ -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: Implementation of applicationmanagement components
+ *
+ */
+#ifndef __APPLICATIONMANAGEMENTUTILITYFACTORY_H__
+#define __APPLICATIONMANAGEMENTUTILITYFACTORY_H__
+
+//  INTERNAL INCLUDES
+#include "ApplicationManagementUtility.h"
+
+namespace NApplicationManagement
+    {
+
+    //  CLASS DEFINITION
+    /**
+     *
+     *   
+     *
+     */
+    class ApplicationManagementUtilityFactory
+    //: public CBase
+        {
+
+public:
+        // New methods
+
+        /**
+         *	
+         *	@param 
+         *	@return 
+         */
+        static CApplicationManagementUtility* CreateManagementUtilityL();
+
+        };
+
+    }
+
+#endif      //  __APPLICATIONMANAGEMENTUTILITYFACTORY_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/PlatformSecurityPolicies.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#ifndef __PLATFORM_SECURITY_POLICIES__
+#define __PLATFORM_SECURITY_POLICIES__
+
+// INCLUDES
+
+#include <e32base.h>
+#include "ApplicationManagementClientServer.h"
+
+// CONSTANTS
+
+const TUint KApplicationManagementRangeCount = 3;
+
+const TInt KApplicationManagementRanges[KApplicationManagementRangeCount] =
+    {
+
+    NApplicationManagement::EAddTrust, //For Management
+            NApplicationManagement::EPerformRfs,
+            NApplicationManagement::ELast
+,//ENotSupported
+};
+
+const TUint8
+        KApplicationManagementSecurityElementsIndex[KApplicationManagementRangeCount] =
+            {
+            0, //applies to 1st range 
+                    1,
+                    CPolicyServer::ENotSupported
+            };
+
+//capability checks
+const CPolicyServer::TPolicyElement KApplicationManagementSecurityElements[] =
+    {
+        {
+        _INIT_SECURITY_POLICY_C1(ECapabilityTrustedUI), CPolicyServer::EFailClient
+        },
+        {
+        _INIT_SECURITY_POLICY_S1(0x101f9a02, ECapabilityDiskAdmin), CPolicyServer::EFailClient
+        }
+    };
+
+//Package all the above together into a policy
+//CPolicyServer::TPolicy KApplicationManagementSecurityPolicy;
+
+#endif
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/ServicePluginLogger.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,152 @@
+/*
+* 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 defines logging interface macros
+*
+*/
+
+
+#ifndef __LOGGER_H__
+#define __LOGGER_H__
+
+// Set logging on only for debug builds as Paos filter is a critical component
+// when considering browser performance
+#ifdef _DEBUG
+    #define LOGGING_ENABLED
+#endif
+#ifdef LOGGING_ENABLED          // This must be enabled to use logging system
+
+#define LOGGER_LOGGING          // Log to Logger
+
+
+
+#ifdef LOGGER_LOGGING
+
+//  INCLUDES
+#include <flogger.h>
+
+// LOG SETTINGS 
+_LIT( KLogFolder, "PnP" );
+_LIT( KLogFile, "ServicePlugin.TXT" );
+
+#endif
+
+// CONSTANTS  
+// None.
+
+// MACROS
+/*
+-----------------------------------------------------------------------------
+
+    INTERNAL MACROs. 
+
+    DO NOT USE THESE DIRECTLY !!! 
+    SEE EXTERNAL MACROS
+
+-----------------------------------------------------------------------------
+*/
+
+#ifdef LOGGER_LOGGING
+
+
+#define INTRLOGTEXT( AAA )                                                                                        \
+    {                                                                                                            \
+    RFileLogger::Write( KLogFolder(), KLogFile(), EFileLoggingModeAppend, AAA );            \
+    }
+#define INTRLOGSTRING( AAA )                                                                                    \
+    {                                                                                                            \
+    _LIT( tempLogDes, AAA );                                                                                    \
+    RFileLogger::Write( KLogFolder(), KLogFile(), EFileLoggingModeAppend, tempLogDes() );    \
+    }
+#define INTRLOGSTRING2( AAA, BBB )                                                                                \
+    {                                                                                                            \
+    _LIT( tempLogDes, AAA );                                                                                    \
+    RFileLogger::WriteFormat( KLogFolder(), KLogFile(), EFileLoggingModeAppend, TRefByValue<const TDesC>( tempLogDes()), BBB ); \
+    }
+#define INTRLOGSTRING3( AAA, BBB, CCC )                                                                            \
+    {                                                                                                            \
+    _LIT( tempLogDes, AAA );                                                                                    \
+    RFileLogger::WriteFormat( KLogFolder(), KLogFile(), EFileLoggingModeAppend, TRefByValue<const TDesC>( tempLogDes()), BBB, CCC ); \
+    }
+
+#define INTRLOGRSTRING( AAA, BBB ) \
+    { \
+    TPtrC8 string8 = BBB.DesC(); \
+    HBufC* buf = HBufC::NewLC( string8.Length() ); \
+    buf->Des().Copy( string8 ); \
+    LOGSTRING2( AAA, buf ); \
+    CleanupStack::PopAndDestroy( buf ); \
+    }
+
+#else
+#define INTRLOGTEXT( AAA )
+#define INTRLOGSTRING( AAA )
+#define INTRLOGSTRING2( AAA, BBB )
+#define INTRLOGSTRING3( AAA, BBB, CCC )
+#define INTRLOGRSTRING( AAA, BBB )
+#endif
+
+/*
+-----------------------------------------------------------------------------
+
+    EXTERNAL MACROs
+
+    USE THESE MACROS IN YOUR CODE !
+
+-----------------------------------------------------------------------------
+*/
+
+
+#define LOGTEXT( AAA )                { \
+                                    INTRLOGTEXT( AAA ); \
+                                    }   // Example: LOGTEXT( own_desc );
+
+#define LOGSTRING( AAA )            { \
+                                    INTRLOGSTRING( AAA ); \
+                                    }   // Example: LOGSTRING( "Test" );
+
+#define LOGSTRING2( AAA, BBB )        { \
+                                    INTRLOGSTRING2( AAA, BBB ); \
+                                    }  // Example: LOGSTRING( "Test %i", aValue );
+
+#define LOGSTRING3( AAA, BBB, CCC )    { \
+                                    INTRLOGSTRING3( AAA, BBB, CCC ); \
+                                    } // Example: LOGSTRING( "Test %i %i", aValue1, aValue2 );
+
+#define LOGRSTRING( AAA, BBB )    { \
+                                    INTRLOGRSTRING( AAA, BBB ); \
+                                    } // Example: LOGRSTRING( "Test %i", RString1 );
+
+#else   // LOGGING_ENABLED
+
+#define LOGTEXT( AAA ) 
+#define LOGSTRING( AAA ) 
+#define LOGSTRING2( AAA, BBB )    
+#define LOGSTRING3( AAA, BBB, CCC )    
+#define LOGRSTRING( AAA, BBB )
+
+#endif  // LOGGING_ENABLED
+
+// DATA TYPES
+// None.
+
+// FUNCTION PROTOTYPES
+// None.
+
+// FORWARD DECLARATIONS
+// None.
+
+// CLASS DECLARATION
+// None.
+
+#endif  // __LOGGER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/amdeploymentcomponent.inl	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Implementation of applicationmanagement components
+ *
+ */
+#include "amdeploymentcomponentdata.h"
+
+inline const TDesC8 &CDeploymentComponent::DownloadURI() const
+    {
+    return iDownloadURI;
+    }
+
+inline const TUid & CDeploymentComponent::Uid() const
+    {
+    return iUid;
+    }
+
+inline const TDeploymentComponentId &CDeploymentComponent::ComponentId() const
+    {
+    return iId;
+    }
+
+inline const TDeploymentComponentName &CDeploymentComponent::ComponentName() const
+    {
+    return iName;
+    }
+
+inline const TDeploymentComponentVersion &CDeploymentComponent::ComponentVersion() const
+    {
+    return iVersion;
+    }
+
+inline TDeploymentComponentState CDeploymentComponent::State() const
+    {
+    return iState;
+    }
+
+inline TUint32 CDeploymentComponent::InternalId() const
+    {
+    return iInternalId;
+    }
+
+inline const TDesC8& CDeploymentComponent::UserId() const
+    {
+    return iUserId;
+    }
+
+inline const TDeploymentComponentState& CDeploymentComponent::OldState() const
+    {
+    return iOldState;
+    }
+
+inline void CDeploymentComponent::StateChangeComplete()
+    {
+    iOldState = EDCSNone;
+    }
+inline TInt CDeploymentComponent::Status() const
+    {
+    return iStatus;
+    }
+inline const TDeploymentComponentPkgId& CDeploymentComponent::PkgId() const
+    {
+    return iPkgID;
+    }
+inline const TDeploymentComponentDescription& CDeploymentComponent::Description() const
+    {
+    return iDescription;
+    }
+inline const TDeploymentComponentPkgIdRef& CDeploymentComponent::PkgIDRef() const
+    {
+    return iPkgIDRef;
+    }
+inline const TDeploymentComponentPkgType& CDeploymentComponent::PkgType() const
+    {
+    return iPkgType;
+    }
+
+inline const TMidletnameName& CDeploymentComponent::MidletName() const
+    {
+    return iMidletName;
+    }
+inline const TMidletVendorName& CDeploymentComponent::MidletVendor() const
+    {
+    return iMideltVendorName;
+    }
+inline const TMidletVersion& CDeploymentComponent::MidletVersion() const
+    {
+    return iMidletVersion;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/amdeploymentcomponentdata.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#ifndef __AMDEPLOYMENTCOMPONENTDATA_H__
+#define __AMDEPLOYMENTCOMPONENTDATA_H__
+
+#include <e32base.h>
+#include <f32file.h> 
+#include <s32strm.h>
+#include "ApplicationManagementCommon.h"
+const TInt KMaxUrlLength = 2048;
+namespace NApplicationManagement
+    {
+
+    /**
+     *  Data class to Data access
+     */
+    class CDeploymentComponentData : public CBase
+        {
+public:
+        enum TType
+            {
+            EData,
+            EInstallOptions,
+            EMetaData
+            };
+private:
+        CDeploymentComponentData(TType aType, const TDesC8 &aDataFile);
+        CDeploymentComponentData();
+
+        void ConstructL(const TDesC8 &aData, const TDesC8 &aMime);
+        void ConstructLoadL(RReadStream &aStream);
+        /**
+         Possibly changes mutable iData
+         */
+        void LoadDataL() const;
+        
+        TBool IsSISInstallFile(const TDesC8 &aMimeType);
+
+public:
+        static CDeploymentComponentData* NewL(TType aType,
+                const TDesC8 &aData, const TDesC8 &aMime,
+                const TDesC8 &aDataFile);
+
+        static CDeploymentComponentData* NewLC(TType aType,
+                const TDesC8 &aData, const TDesC8 &aMime,
+                const TDesC8 &aDataFile);
+
+        static CDeploymentComponentData* LoadL(RReadStream &aStream);
+
+        static CDeploymentComponentData* LoadLC(RReadStream &aStream);
+
+        virtual ~CDeploymentComponentData();
+
+        void SerializedFormL(RWriteStream &aBuffer) const;
+        TInt SerializedFormLength() const;
+
+        const TDesC8 &Data() const;
+        const TDesC8 &DataFileName() const;
+        void ResetData(RFs &aFs);
+        TInt DataLengthL() const;
+        inline TType Type() const;
+
+        TUid SetDataL(const TDesC8& aMimeType);
+        TUid SetDataL(const TDesC8 &aData, const TDesC8& aMimeType);
+        TUid SetDataL(const TFileName &aData, const TDesC8& aMimeType);
+        void SetDataFileNameL(const TDesC8 &aNewFileName);
+        void SetMimeTypeL(const TDesC8 &aMimeType);
+        inline const TDesC8 &MimeType() const;
+
+        void PersistL(RFs &aFs);
+        void DestroyL(RFs &aFs) const;
+
+        CDeploymentComponentData &operator=(
+                const CDeploymentComponentData &aData);
+
+        TUid ResolveUidL(RFs &aFs);
+
+        TUid ParseUidFromSisFileL(RFile& aHandleToFile);
+
+private:
+        mutable HBufC8 *iData;
+        TBuf8<KMaxFileName> iDataFileName;
+        TMimeType iMimeType;
+        TType iType;
+        TBuf<15> iExtn;
+        };
+
+    inline CDeploymentComponentData::TType CDeploymentComponentData::Type() const
+        {
+        return iType;
+        }
+
+    inline const TDesC8 &CDeploymentComponentData::MimeType() const
+        {
+        return iMimeType;
+        }
+    }
+
+#endif
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/amsmlhelper.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#ifndef __AMSMLHELPER_H__
+#define __AMSMLHELPER_H__
+
+#include <SyncMLDef.h>
+#include <SyncMLTransportProperties.h>
+#include <SyncMLClient.h>
+#include <SyncMLClientDM.h>
+
+namespace NApplicationManagement
+    {
+
+    /**
+     * Utility class that wraps access to DM client functionality
+     */
+    class SmlHelper
+        {
+public:
+
+        // NOTE: this enum must match with property array described in 
+        // SyncML_Sync_Agent_Client_API_Specification.doc.
+        enum TNSmlSyncTransportProperties
+            {
+            EPropertyIntenetAccessPoint = 0,
+            EPropertyHttpUsed = 5,
+            EPropertyHttpUserName = 6,
+            EPropertyHttpPassword = 7
+            };
+
+        /**
+         * GetCurrentProfileIdL Finds out the current syncml DM session profile id.
+         * @param aProfile Will contain the current profile id if call is successfull
+         * @return Success status (KErrNone if successful)
+         */
+        static TInt GetCurrentProfileIdL(TSmlProfileId &aProfile);
+        /**
+         * LaunchSessionL Launches SyncML DM session using given profile id.
+         * @param aProfile The id of profile which is to be used to start DM session
+         * @return Success status (KErrNone if successful)
+         */
+        static TInt LaunchSessionL(TSmlProfileId &aProfile);
+
+        /**
+         * Fetch the default IAP used by the currently active DM profile
+         * @param aDefaultIAP on successfull return contains the default IAP number
+         */
+
+        static void GetDefaultIAPFromDMProfileL(TInt& aDefaultIAP);
+
+        static void GetConnectionPropertyNameL(RSyncMLSession& aSyncSession,
+                TDes8& aText, TInt aPropertyPos);
+
+        static TInt StrToInt(const TDesC& aText, TInt& aNum);
+
+        static HBufC8* GetCurrentServerIDL();
+
+        };
+
+    }
+	
+	
+#endif
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/amstorage.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#ifndef __AMDSTORAGE_H__
+#define __AMDSTORAGE_H__
+
+#include <e32base.h>
+#include <ssl.h>
+#include <s32mem.h>
+#include "ApplicationManagementCommon.h"
+
+class CRepository;
+
+namespace NApplicationManagement
+    {
+
+    class CDeploymentComponent;
+    class CAMAppHideUtil;
+
+    class RComponentIdArray : public RArray<TUint32>
+        {
+public:
+        void SetListL(const TDesC8& aChilds);
+        void GetListLC(HBufC8 *& aChilds, TInt &aLength);
+        void RemoveByValue(TUint32 aValue);
+        };
+
+    typedef TPckgBuf<TCertInfo> TCertInfoPckg;
+
+    class RCertArray : public RPointerArray<TCertInfoPckg>
+        {
+public:
+        void ExternalizeL(RWriteStream& aStream) const;
+        void InternalizeL(RReadStream& aStream);
+        TInt FindByValue(const TCertInfoPckg &aPckg);
+        };
+    /**
+     *  Factory class to Data component creation
+     */
+    class CDeliveryComponentStorage : public CBase
+        {
+        /**
+         * Constructor
+         */
+        CDeliveryComponentStorage();
+
+        /**
+         * 2nd phase constructor. Loads compontns
+         */
+        void ConstructL();
+
+        /**
+         * Saves the state to disk
+         */
+        void PersistStateL();
+
+        /**
+         * Loads components from disk
+         */
+        void LoadComponentsL();
+
+        /**
+         * Creates and returns next free deployment component id
+         */
+        TInt NextKey();
+
+        /**
+         * Loads certificate array
+         */
+        void LoadCertsL();
+
+        /**
+         * Saves and closes certificate array
+         */
+        void CloseCertificatesL();
+
+public:
+
+        /**
+         * Creates new storage object and constructs it
+         */
+        static CDeliveryComponentStorage* NewL();
+
+        /**
+         * Creates new storage object and constructs it, leaving it
+         * on the cleanup stack
+         */
+        static CDeliveryComponentStorage* NewLC();
+
+        /**
+         * Destructor
+         */
+        virtual ~CDeliveryComponentStorage();
+
+        /**
+         * GetComponentIds Returns the const id array of component ids.
+         */
+        const RComponentIdArray &GetComponentIds() const;
+
+        /**
+         * Places all those component's ids in array who have possibly changed
+         * state and no StateChangedL for that id called afterwards.
+         * @param aArray array to hold the ids
+         */
+        void GetStateChangeComponentIdsL(RComponentIdArray &aArray);
+
+        /**
+         * StateChangedL Confirms that state change has been acknowledged by user
+         * @param aInternalId The id whose state change is confirmed.
+         */
+        void StateChangedL(TUint32 aInternalId);
+
+        /**
+         * Creates new deployment component object having given state and user id
+         * and constructs it. Optionally component may have owning certificate.
+         * @param aState the state of to-be-created component
+         * @param aUserId the user id of to-be-created component
+         * @param aCertInfo the certificate of the owner of to-be-created component
+         */
+        CDeploymentComponent *NewComponentL(
+                const TDeploymentComponentState &aState,
+                const TDCUserId &aUserId, const TCertInfo *aCertInfo = NULL);
+
+        /**
+         * DeliverL makes the given component ot delivered state
+         * @param aComponent the component that'll be delivered
+         */
+        void DeliverL(CDeploymentComponent &aComponent);
+
+        /**
+         * UpdateL updates the given component permanently
+         * @param aComponent the component that'll be persisted
+         */
+        void UpdateL(const CDeploymentComponent &aComponent);
+
+        /**
+         * RemoveL Removes the deployment component having given id. The related object
+         * will be invalid after call.
+         * @param aInternalId the to-be-removed component's id
+         */
+        void RemoveL(TUint32 aInternalId);
+
+        /**
+         * InstalledL updates the given component state 
+         * @param aComponent the component that'll be persisted
+         */
+        void InstalledL(CDeploymentComponent &aComponent);
+
+    //Update Deplyoment Components State variable
+	void SetDeploymentComponentState(CDeploymentComponent &aComponent,TDeploymentComponentState aState);
+        CDeploymentComponent &ComponentL(TUint32 aInternalId);
+        void ActivateL(CDeploymentComponent &aComponent);
+        void DeactivateL(CDeploymentComponent &aComponent);
+
+        void CheckForDuplicateNodesInDeployedL(
+                CDeploymentComponent &aComponent);
+        HBufC8* IntToDes8LC(const TInt aLuid);
+
+        const RCertArray &Certificates() const
+            {
+            return iCertificates;
+            }
+protected:
+
+        CDeploymentComponent *LoadComponentL(TInt aInternalId,
+                const TDesC8 &aBuffer) const;
+private:
+        CRepository *iRepository;
+        RPointerArray<CDeploymentComponent> iComponents;
+        RComponentIdArray iComponentIds;
+        TInt iNextId;
+        RCertArray iCertificates;
+        CAMAppHideUtil *iHidder;
+        };
+
+    }
+
+#endif __AMDELIVERYCOMPSTORAGE_H__
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/amview.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#ifndef AMVIEW_H_
+#define AMVIEW_H_
+
+#include <hbview.h>
+#include <QObject>
+#include "ApplicationManagementUtility.h"
+
+class AMView : public HbView
+    {
+    Q_OBJECT
+
+public:
+    AMView();
+    ~AMView();
+    
+    //Handles the incoming events
+    bool eventFilter(QObject *object, QEvent *event);
+    };
+#endif /* AMVIEW_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/amwaitprogdialog.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#ifndef AMWAITPROGDIALOG_H_
+#define AMWAITPROGDIALOG_H_
+
+#include <QObject>
+#include <hbprogressdialog.h>
+#include <hbindicator.h>
+#include <usif/sif/sif.h>
+#include "ApplicationManagementUtility.h"
+
+class MInstallerCallBack
+        {
+    public:
+        virtual void InstallationCancelled()=0;
+        };
+class AMWaitProgDialog : public QObject
+    {
+    Q_OBJECT
+
+public:
+    AMWaitProgDialog(QString aAppName,MInstallerCallBack& aCallback );
+    ~AMWaitProgDialog();
+    
+    void createWaitDialog(TInt aType);
+    void closeAMWaitDialog();
+    void startIndicator();
+    void registerInstallRequest(TRequestStatus &aStat);
+public slots:
+    void hideAMWaitDialog();
+    void cancelWaitDialog();
+
+private:
+    HbProgressDialog* mDlg;
+    HbIndicator* mIndi;
+    TRequestStatus* m_Stat;
+    QString m_appname;
+    TInt mType;
+    int mIndicatorDeactive;
+    MInstallerCallBack& m_callback;
+    };
+
+#endif 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/appmgmtdownloadmgr.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#include <QObject>
+#include <qtimeline.h>
+#include <QTimer>
+#include <QWidget>
+#include <hbcombobox.h>
+#include <downloadevent.h>
+#include <downloadmanager.h>
+#include <hbdocumentloader.h>
+#include "appmgmtprogdialog.h"
+#include "AMDeploymentComponent.h"
+#include "appmgmtnotifier.h"
+#define  KOmaDMAppUid   0x101F6DE5
+const TReal KSizeDivisor = 1024.0;
+
+const TUint32 KDownloadActive = 0x0000008;
+enum TDriveSize
+    {
+    EKb = -1,
+    EMb = 0,
+    EGb = 1
+    };
+
+using namespace WRT;
+
+namespace NApplicationManagement
+    {
+
+    class MDownloadMgrQTCallback
+        {
+    public:
+        virtual void DownloadCompleted()=0;
+        virtual void DownloadFailed(TInt aDownloaderr)=0;
+        virtual void SetStatus(TInt aStatus)=0;
+        };
+    
+    class CDialogWait : public CActive
+        {
+    public:
+        static CDialogWait* NewL();
+        CDialogWait();
+        void ConstructL();
+        ~CDialogWait();
+        void StartWait();
+        void Stop();
+    protected:
+        void DoCancel();
+        void RunL();
+        TInt RunError(TInt aError);
+    private:
+        CActiveSchedulerWait* iWait;
+        };
+    
+    class appmgmtdownloadmgr : public QWidget
+        {
+
+    Q_OBJECT
+
+    public:
+        appmgmtdownloadmgr(QWidget* parent, MDownloadMgrQTCallback& wrapper, TRequestStatus& aStatus);
+        ~appmgmtdownloadmgr();
+        
+        void startDownload(CDeploymentComponent *aComponent);
+        void showDialog(CDeploymentComponent *aComponent);
+        void showUninstallDialog(const CDeploymentComponent &aCompo, TRequestStatus &s);
+        void updateProgress(TInt32 aDownloadedSize, TInt32 aContentSize);
+        void closeProgress();
+        void setUri();
+        void getUri();
+        void setState();
+        void getState();
+        void MimeType(QString& aMimeType);
+        void FileName(QString& afilename);
+	  void SetMimeType();
+        void sendSrvToBg();
+        QString convertSize();
+        int currDwnldStatForGenericAlert(int dwnldstatus);
+        
+    public slots:
+        bool downloadMgrEventRecieved(DownloadManagerEvent *event);
+        bool downloadEventRecieved(DownloadEvent *event);
+        void dialogSlot(HbAction*);
+        void defaultDriveChanged(int);
+    private:
+        void getAvailableDrives();
+        void showInstalltoDialog();
+        void showDownloadDialog();
+    private:
+        QStringList m_drivList;
+        QString m_appName;
+        HbAction* mOkButton;
+        HbAction* mCancel;
+        QString mSize;
+        QString mSizeFormat;
+        QString mNotifierdata, mDialogData;
+        QString m_sizeStr;
+        QString m_mimetype;
+        HbComboBox* mDriveBox;
+        HbDialog* mDialog;
+    public:
+        // Functions from base classes
+        TBuf<256> drilist;
+        DownloadManager* iDownloadManager;
+        Download* iDl;
+        int m_inProgress;
+        int m_currentDownloadedSize;
+        int m_totalSize;
+        CDialogWait* iWait;
+        TUint32 iProgStarted;
+        TUint32 iSetFinalValue;
+		int m_downloadStatus;
+        AppMgmtProgDialog *iProgressNote;
+        TDownloadTarget iOperationType;
+    private:
+        // Data
+        MDownloadMgrQTCallback& m_callback;
+        CDeploymentComponent* iComp;
+        HBufC *iFileName;
+        HBufC8 *iContentType;
+        HBufC8 *iURI;
+        TBool iProgressCancelled;
+        TBool iDialogAccepted;
+        TRequestStatus& iStatus;
+        AppMgmtNotifier* mNote;
+        int mEndReported;
+        int mNetworkLoss;
+        };
+
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/appmgmtnotifier.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#ifndef APPMGMTNOTIFIERS_H_
+#define APPMGMTNOTIFIERS_H_
+
+#include <QObject>
+#include <hbdevicenotificationdialog.h>
+#include <hbdocumentloader.h>
+#include <hbdialog.h>
+#include <hblabel.h>
+#include <hbaction.h>
+#include <hbcombobox.h>
+#include "AMDeploymentComponent.h"
+
+using namespace NApplicationManagement;
+
+class AppMgmtNotifier : public QWidget
+    {
+    Q_OBJECT
+    
+public:
+    AppMgmtNotifier(QString aAppName = 0);
+    ~AppMgmtNotifier();
+    
+    void getAvailableDrives();
+    void showInstallSuccessNote();
+    void showInstallFailedNote();
+    void showUninstallDialog(const CDeploymentComponent &aCompo, TRequestStatus &s);
+    void showInstallDialog(CDeploymentComponent *aCompo, TRequestStatus &s);
+    void showUnInstallSuccessNote();
+    void showUnInstallFailedNote();
+    bool showDownloadFailedNote(QString aNotifierdata);
+    void showDownloadSuccessNote();
+    void sendServerToBackground();
+    void bringServerToForeground();
+    void registerStatus(TRequestStatus &stat);
+public slots:
+    void dlgSlot(HbAction* action);
+    void dialogUnSlot(HbAction* action);
+    void successSlot(HbAction* reaction);
+    void defaultDriveChanged(int i);
+private:
+    CDeploymentComponent* iComp;
+    TRequestStatus *iStat;
+    
+    QString m_appname; 
+    HbAction* m_OkButton;
+    HbAction* m_Cancel;
+    HbDialog* m_Dialog;  
+    TBuf<256> m_Drilist;
+    TRequestStatus* m_Stat;
+    HbComboBox* m_DriveBox;   
+    };
+//}
+#endif /* APPMGMTNOTIFIERS_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/appmgmtprogdialog.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#include <QObject>
+#include <QTimeLine>
+#include <hbprogressdialog.h>
+#include <hbindicator.h>
+#include <download.h>
+
+using namespace WRT;
+class AppMgmtProgDialog : public QObject
+    {
+    Q_OBJECT
+
+public:
+    AppMgmtProgDialog(QString aAppData, Download &mdl,int &aUserCancelled);
+    ~AppMgmtProgDialog();
+    void startDialog(int aContentSize,int aDownloaded);
+    void closeAMProgDialog();
+    void updateProgress(int aProgress);
+public slots:
+    void hideAMProgDialog();
+    void cancelDialog();
+private:
+    void sendServerToBackground();
+private:
+    int iContentSize;
+    int mUsrCancel;
+    Download* iDl;
+    QString m_Data;
+    HbProgressDialog* m_Dlg;
+    QString m_Name;
+    QString m_SizeStr;
+    HbIndicator* m_Indi;
+    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/nsmldmiapmatcher.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,116 @@
+/*
+ * 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:  DM Tree module
+ *
+ */
+
+#ifndef __NSMLDMIAPMATCHER_H__
+#define __NSMLDMIAPMATCHER_H__
+
+// ------------------------------------------------------------------------------------------------
+// Includes
+// ------------------------------------------------------------------------------------------------
+#include <e32base.h>
+#include "nsmldmuri.h"
+
+//CLASS FORWARDS
+class MSmlDmCallback;
+
+_LIT8( KNSmlDMIAPUri, "AP" );
+_LIT8( KNSmlDMSeparator8, "/" );
+_LIT8( KNSmlDMIAPUriDotSlash, "./" );
+
+const TUint8 KNSmlDMSlash = 0x2f; //forward slash
+/**
+ * CNSmlDMIAPMatcher contains services for generating URI from IAPId and
+ * vice versa in DM plug-in adapters. The class needs the working
+ * MSmlDmCallback callback interface for operating, so ths can be used only
+ * by DM plug-in adapters
+ *
+ *  @since
+ */
+class CNSmlDMIAPMatcher : public CBase
+    {
+public:
+    /**
+     * Destructor
+     */
+    ~CNSmlDMIAPMatcher();
+
+    /**
+     * Two-phased constructor
+     * @param	aDmCallback			Pointer to callback interface
+     * @return						Pointer to newly created module instance
+     */
+    static CNSmlDMIAPMatcher* NewL(MSmlDmCallback* aDmCallback);
+
+    /**
+     * Two-phased constructor, pushes pointer to cleanup stack.
+     * @param	aDmCallback			Pointer to callback interface
+     * @return						Pointer to newly created module instance
+     */
+    static CNSmlDMIAPMatcher* NewLC(MSmlDmCallback* aDmCallback);
+
+    /**
+     * Gets the IAP id which corresponds to given URI
+     * @param	aURI				Accespoint URI
+     * @return						Accespoint id in AP database
+     */
+    TInt IAPIdFromURIL(const TDesC8& aURI);
+
+    /**
+     * Generates the URI which corresponds to given IAP Id
+     * @param	aIAPId				Accespoint Id
+     * @return						Accesspoint URI in DM
+     */
+    HBufC8* URIFromIAPIdL(TInt aIAPId);
+
+private:
+    /**
+     * Second phase constructor
+     * @param	aDmCallback			Pointer to callback interface
+     */
+    void ConstructL(MSmlDmCallback* aDmCallback);
+
+    /**
+     * Changes the given descriptor to Integer
+     * @param	aLuid				Luid in descriptor format
+     * @return						Luid in TInt type
+     */
+    TInt DesToInt(const TDesC8& aLuid);
+
+    /**
+     * Return the URI without ./ at the beginning, if those exist
+     * @param	aURI		Uri
+     * @return 		 		Uri without ./
+     */
+    TPtrC8 RemoveDotSlash(const TDesC8& aURI) const;
+
+    /**
+     * Return the last uri segment of the aURI
+     * @param	aURI		Uri
+     * @return 		 		The last uri segment
+     */
+    TPtrC8 LastURISeg(const TDesC8& aURI) const;
+
+private:
+
+    /**
+     * Pointer to callback interface
+     */
+    MSmlDmCallback* iCallback;
+
+    };
+
+#endif // __NSMLDMIAPMATCHER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/inc/nsmldmuri.h	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  DM tree etc.
+ *
+ */
+
+#ifndef __NSMLDMURI_H
+#define __NSMLDMURI_H
+
+#include <e32std.h>
+#include <e32base.h>
+
+#define KNSmlDMUriSeparator '/'
+_LIT8(KNSmlDmRootUri, ".");
+_LIT8(KNSmlDmUriDotSlash, "./");
+_LIT8( KNSmlDmQuestionMark, "?" );
+
+// ===========================================================================
+// NSmlDmURI
+// ===========================================================================
+class NSmlDmURI
+    {
+public:
+    static TPtrC8 ParentURI(const TDesC8& aURI);
+    static TPtrC8 LastURISeg(const TDesC8& aURI);
+    static TPtrC8 RemoveDotSlash(const TDesC8& aURI);
+    static TPtrC8 RemoveProp(const TDesC8& aURI);
+    static TPtrC8 RemoveLastSeg(const TDesC8& aURI);
+    static TPtrC8
+            URISeg(const TDesC8& aURI, TInt aLocation, TInt aSegCount=1);
+    static TInt NumOfURISegs(const TDesC8& aURI);
+    };
+
+#endif // __NSMLDMURI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/server.pro	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,141 @@
+#
+# 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: Implementation of applicationmanagement components
+ #
+ #
+ 
+symbian: { 
+    SYMBIAN_PLATFORMS = WINSCW \
+        ARMV5
+    :BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>"
+    :BLD_INF_RULES.prj_exports += "./src/200267FB.SPD /epoc32/release/armv5/udeb/z/private/100012a5/policy/200267FB.SPD"
+    :BLD_INF_RULES.prj_exports += "./src/200267FB.SPD /epoc32/release/armv5/urel/z/private/100012a5/policy/200267FB.SPD"
+    :BLD_INF_RULES.prj_exports += "./src/200267FB.SPD /epoc32/release/winscw/udeb/z/private/100012a5/policy/200267FB.SPD"
+    :BLD_INF_RULES.prj_exports += "./src/200267FB.SPD /epoc32/release/winscw/urel/z/private/100012a5/policy/200267FB.SPD"
+    :BLD_INF_RULES.prj_exports += "./src/200267FB.SPD /epoc32/data/z/private/100012a5/policy/200267FB.SPD"
+    :BLD_INF_RULES.prj_exports += "./group/200267FB.txt /epoc32/data/z/private/10202be9/200267FB.txt"
+    TARGET.UID2 = 0x100039CE
+    TARGET.UID3 = 0x200267FB
+    TARGET.CAPABILITY = CAP_SERVER \
+        TrustedUI \
+        AllFiles \
+        NetworkControl
+    LIBS += -lWrtDownloadMgr \
+        -lwrtserviceipcclient \
+        -leuser \
+        -ldrmhelper \
+        -ldrmlicensemanager \
+        -ledbms \
+        -lsysutil \
+        -lefsrv \
+        -lesock \
+        -lbafl \
+        -lcentralrepository \
+        -lestor \
+        -lsisregistryclient \
+        -laminstalloptions \
+        -limut \
+        -lswinstcli \
+        -lezip \
+        -lplatformenv \
+        -lecom \
+        -lcaf \
+        -lnsmldmtreedbhandler \
+        -lsyncmlclientapi \
+        -lnsmldmmodule \
+        -lnsmldmtreedbclient \
+        -lconnmon \
+        -lcommonengine \
+        -lnsmltransporthandler \
+        -lnsmltransport \
+        -lcone \
+        -ljavaregistryclient \
+        -lapparc \
+        -lfeatmgr \
+        -lpolicyengine \
+        -lflogger \ 
+        -lapengine \
+        -lcommdb \
+        -lapgrfx \
+        -lws32 \
+        -lapmime \ 
+        -lsif
+}
+TEMPLATE = app
+TARGET = applicationmanagementserver
+DEPENDPATH += ./inc
+INCLUDEPATH += . \
+    ../inc \
+    ../options/inc \
+    ../installer/inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE \
+    /epoc32/include/mw/cwrt \
+    /epoc32/include/devman \
+    /epoc32/include/platform/mw/swi \
+    /epoc32/include/swi \
+    /epoc32/include/ecom \
+    /epoc32/include/mw/usif \
+    /epoc32/include/platform/mw/cwrt
+CONFIG += hb
+RESOURCES += ./conf/applicationmanagement.qrc
+
+SERVICE.OPTIONS = embeddable
+SERVICE.OPTIONS += hidden
+
+# Input
+HEADERS +=./inc/amview.h \
+    ./inc/amwaitprogdialog.h \
+    ./inc/ServicePluginLogger.h \
+    ./inc/AMDownloadStore.h \
+    ./inc/ServicePluginLogger.h \
+    ./inc/AMAppHideUtil.h \
+    ./inc/AMDeploymentComponent.h \
+    ./inc/amdeploymentcomponent.inl \
+    ./inc/amdeploymentcomponentdata.h \ 
+    ./inc/AMDownloaddb.h \ 
+    ./inc/AMPreInstallApp.h \
+    ./inc/amsmlhelper.h \
+    ./inc/amstorage.h \
+    ./inc/ApplicationManagementJavaUtility.h \
+    ./inc/ApplicationManagementServer.h \
+    ./inc/ApplicationManagementUtility.h \
+    ./inc/ApplicationManagementUtilityFactory.h \
+    ./inc/nsmldmiapmatcher.h \
+    ./inc/appmgmtdownloadmgr.h \
+    ./inc/nsmldmuri.h \
+    ./inc/ServicePluginLogger.h \
+    ./inc/appmgmtprogdialog.h \
+    ./inc/PlatformSecurityPolicies.h \
+    ./inc/AMDownloadStore.h \
+    ./inc/appmgmtnotifier.h
+SOURCES += ./src/amview.cpp \
+    ./src/amwaitprogdialog.cpp \
+    ./src/AMAppHideUtil.cpp \
+    ./src/AMDeploymentComponent.cpp \
+    ./src/amdeploymentcomponentdata.cpp \ 
+    ./src/AMDownloaddb.cpp \ 
+    ./src/AMPreInstallApp.cpp \
+    ./src/amsmlhelper.cpp \
+    ./src/amstorage.cpp \
+    ./src/ApplicationManagementJavaUtility.cpp \
+    ./src/ApplicationManagementServer.cpp \
+    ./src/ApplicationManagementUtility.cpp \
+    ./src/ApplicationManagementUtilityFactory.cpp \
+    ./src/nsmldmiapmatcher.cpp \
+    ./src/appmgmtdownloadmgr.cpp \
+    ./src/nsmldmuri.cpp \
+    ./src/appmgmtprogdialog.cpp \
+    ./src/AMDownloadStore.cpp \
+    ./src/main.cpp \
+    ./src/appmgmtnotifier.cpp
Binary file applicationmanagement/server/src/1020781C.SPD has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/1020781C.txt	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,10 @@
+[database]
+read
+capability = ReadDeviceData
+write
+capability = WriteDeviceData
+schema
+capability = WriteDeviceData
+
+[backup]
+SID = 101F8597
Binary file applicationmanagement/server/src/200267FB.SPD has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/AMAppHideUtil.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,214 @@
+/*
+ * 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: Implementation of applicationmanagement components
+ *
+ */
+
+#include <centralrepository.h>
+#include "AMAppHideUtil.h"
+#include "debug.h"
+
+using namespace NApplicationManagement;
+
+// The uid list delimiter
+static const TChar KUidDelimiter = ',';
+
+// -----------------------------------------------------------------------------
+// CAMAppHideUtil::CAMAppHideUtil()
+// -----------------------------------------------------------------------------
+CAMAppHideUtil::CAMAppHideUtil() :
+    iChanged(EFalse)
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// CAMAppHideUtil::ConstructL()
+// -----------------------------------------------------------------------------
+void CAMAppHideUtil::ConstructL()
+    {
+    LoadUidsL();
+    }
+
+// -----------------------------------------------------------------------------
+// CAMAppHideUtil::~CAMAppHideUtil()
+// -----------------------------------------------------------------------------
+CAMAppHideUtil::~CAMAppHideUtil()
+    {
+    iHiddenUids.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CAMAppHideUtil::NewL()
+// -----------------------------------------------------------------------------
+CAMAppHideUtil* CAMAppHideUtil::NewL()
+    {
+    CAMAppHideUtil *me = new ( ELeave ) CAMAppHideUtil();
+    CleanupStack::PushL(me);
+    me->ConstructL();
+    CleanupStack::Pop(me);
+    return me;
+    }
+
+// -----------------------------------------------------------------------------
+// CAMAppHideUtil::AddUidL(const TUid& aUid )
+// -----------------------------------------------------------------------------
+void CAMAppHideUtil::AddUidL(const TUid& aUid, TBool aPersist /*= EFalse */)
+    {
+    TInt idx(iHiddenUids.Find(aUid));
+    if (idx == KErrNotFound)
+        {
+        TInt err(iHiddenUids.Append(aUid) );
+        if (err == KErrNone)
+            {
+            iChanged = ETrue;
+            if (aPersist)
+                {
+                PersistUidsL();
+                }
+            }
+        else
+            {
+            RDEBUG_2( "Failed to append uid to hidden list: %d", err );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CAMAppHideUtil::RemoveUidL( const TUid& aUid )
+// -----------------------------------------------------------------------------
+void CAMAppHideUtil::RemoveUidL(const TUid& aUid, TBool aPersist /*= EFalse */)
+    {
+    TInt idx(iHiddenUids.Find(aUid));
+    if (idx != KErrNotFound)
+        {
+        iHiddenUids.Remove(idx);
+        iChanged = ETrue;
+        if (aPersist)
+            {
+            PersistUidsL();
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CAMAppHideUtil::PersistUid( const TUid &aUid, TDes &aBuf, TBool aHasMore )
+// -----------------------------------------------------------------------------
+void CAMAppHideUtil::PersistUid(const TUid &aUid, TDes &aBuf, TBool aHasMore) const
+    {
+    aBuf.AppendNumFixedWidth(aUid.iUid, EHex, 8);
+    if (aHasMore)
+        {
+        aBuf.Append(KUidDelimiter);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CAMAppHideUtil::PersistUidsL()
+// -----------------------------------------------------------------------------
+void CAMAppHideUtil::PersistUidsL()
+    {
+    TInt err = KErrNone;
+    if (iChanged)
+        {
+        TBuf<NCentralRepositoryConstants::KMaxUnicodeStringLength> buf;
+        RDEBUG_2( "PersistUids: count %d", iHiddenUids.Count() );
+        for (TInt i(iHiddenUids.Count() - 1); i >= 0; --i)
+            {
+            RDEBUG_3( "PersistUids: cur %d %x", i,iHiddenUids[i].iUid );
+            PersistUid(iHiddenUids[i], buf, i > 0) ;
+            }
+        /*CRepository *rep = CRepository::NewLC(KCRUidMenu);
+        TInt err(rep->Set(KMenuHideApplication, buf) );
+        CleanupStack::PopAndDestroy(rep);*/
+        if (err != KErrNone)
+            {
+            RDEBUG_2( "PersistUids: ERROR failed to set key: %d", err );
+            User::Leave(err);
+            }
+        RDEBUG_2( "CAMAppHideUtil::PersistUidsL - Saved '%S'", &buf);
+        iChanged = EFalse;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CAMAppHideUtil::ParseUid( TLex &, TUid &aUid ) 
+// -----------------------------------------------------------------------------
+TInt CAMAppHideUtil::ParseUid(TLex &aLex, TUid &aUid) const
+    {
+    aUid = TUid::Null();
+    aLex.Mark();
+    while (aLex.Peek().IsHexDigit() )
+        {
+        aLex.Inc();
+        }
+    TPtrC uidToken = aLex.MarkedToken();
+    TLex uidLex(uidToken);
+    TInt err(uidLex.Val( (TUint32& )aUid.iUid, EHex) );
+    return err;
+    }
+
+// ------------------------------------------------------------------------------
+// CAMAppHideUtil::SkipDelim( TLex & )
+// -----------------------------------------------------------------------------
+TBool CAMAppHideUtil::SkipDelim(TLex &aLex) const
+    {
+    TBool ret(EFalse);
+    if (aLex.Peek() == KUidDelimiter)
+        {
+        aLex.Inc();
+        ret = ETrue;
+        }
+    return (ret );
+    }
+
+// -----------------------------------------------------------------------------
+// CAMAppHideUtil::LoadUidsL()
+// -----------------------------------------------------------------------------
+void CAMAppHideUtil::LoadUidsL()
+    {
+    TInt err = KErrNone;
+    TBuf<NCentralRepositoryConstants::KMaxUnicodeStringLength> buf;
+    /*CRepository *rep = CRepository::NewLC(KCRUidMenu);
+    TBuf<NCentralRepositoryConstants::KMaxUnicodeStringLength> buf;
+    TInt err(rep->Get(KMenuHideApplication, buf) );
+    CleanupStack::PopAndDestroy(rep);*/
+    if (err == KErrNone)
+        {
+        RDEBUG_2( "CAMAppHideUtil::LoadUidsL - Loading '%S'", &buf);
+        TLex lex(buf);
+        TUid aUid(TUid::Null());
+        do
+            {
+            err = ParseUid(lex, aUid) ;
+            }
+        while (err == KErrNone && iHiddenUids.Append(aUid) == KErrNone
+                && !lex.Eos() && SkipDelim(lex) );
+        }
+    RDEBUG_2( "CAMAppHideUtil::LoadUidsL-Loaded (last parsing status: %d)", err);
+    }
+
+// -----------------------------------------------------------------------------
+// CAMAppHideUtil::Reset()
+// -----------------------------------------------------------------------------
+void CAMAppHideUtil::Reset()
+    {
+    if (iHiddenUids.Count() > 0)
+        {
+        iChanged = ETrue;
+        }
+    iHiddenUids.Reset();
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/AMDeploymentComponent.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,885 @@
+/*
+ * 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: Implementation of applicationmanagement components
+ *
+ */
+
+#include <e32debug.h>
+#include <s32mem.h>
+#include <featmgr.h>
+#include <ssl.h>
+#include <APGCLI.H>
+#include <APMREC.h>
+#include <APMSTD.H>
+#ifdef __SERIES60_30__
+#include <CMenuClient.h>
+#endif
+#include "amsmlhelper.h"
+#include "amprivateCRKeys.h"
+#include "AMDeploymentComponent.h"
+#include "debug.h"
+
+
+using namespace NApplicationManagement;
+
+_LIT8( KAMDCDataSuffix, "_D.txt");
+_LIT8( KAMDCMetaDataSuffix, "_M.txt");
+
+
+/***************************************************
+ // CDeploymentComponent
+ ***************************************************/
+
+CDeploymentComponent* CDeploymentComponent::NewLC(TInt aInternalId,
+        const TDCUserId &aUserId)
+    {
+    CDeploymentComponent *self = new ( ELeave ) CDeploymentComponent( aInternalId );
+    CleanupStack::PushL(self) ;
+    self->ConstructL(aUserId) ;
+    return self;
+    }
+
+CDeploymentComponent* CDeploymentComponent::NewL(TInt aInternalId,
+        const TDCUserId &aUserId)
+    {
+    CDeploymentComponent *self = NewLC(aInternalId, aUserId);
+    CleanupStack::Pop(self) ;
+    return self;
+    }
+
+CDeploymentComponent* CDeploymentComponent::LoadLC(TInt aInternalId,
+        const TDesC8 &aBuffer)
+    {
+    CDeploymentComponent *self = new ( ELeave ) CDeploymentComponent(aInternalId);
+    CleanupStack::PushL(self) ;
+    self->ConstructLoadL(aBuffer) ;
+    return self;
+    }
+
+CDeploymentComponent* CDeploymentComponent::LoadL(TInt aInternalId,
+        const TDesC8 &aBuffer)
+    {
+    CDeploymentComponent *self = LoadLC(aInternalId, aBuffer);
+    CleanupStack::Pop(self) ;
+    return self;
+    }
+
+CDeploymentComponent::CDeploymentComponent(TInt aInternalId) :
+iInternalId(aInternalId), iPkgVersion( 3), iOwner( -1),
+iOwnerProfile( -1)
+        {
+        iUninstallOpts.iKillApp = SwiUI::EPolicyAllowed;
+        SwiUI::TInstallOptions &opts = iInstallOpts.iOptions;
+        opts.iUpgrade = SwiUI::EPolicyNotAllowed;
+        opts.iOptionalItems = SwiUI::EPolicyNotAllowed;
+        opts.iOCSP = SwiUI::EPolicyNotAllowed;
+        opts.iIgnoreOCSPWarnings = SwiUI::EPolicyNotAllowed;
+        //    iIgnoreOtherWarnings = SwiUI::EPolicyNotAllowed;
+        opts.iUntrusted = SwiUI::EPolicyNotAllowed;
+        opts.iPackageInfo = SwiUI::EPolicyNotAllowed;
+        opts.iCapabilities = SwiUI::EPolicyNotAllowed;
+        opts.iKillApp = SwiUI::EPolicyNotAllowed;
+        opts.iOverwrite = SwiUI::EPolicyNotAllowed;
+        opts.iDownload = SwiUI::EPolicyNotAllowed;
+        opts.iDrive = SwiUI::EPolicyNotAllowed;
+        opts.iLang = ELangNone;
+        opts.iUsePhoneLang = EFalse;
+        }
+
+CDeploymentComponent::~CDeploymentComponent()
+    {
+    RDEBUG8_3( "CDeploymentComponent::~CDeploymentComponent 0x%X - 0x%X",
+            reinterpret_cast<TUint>(this), reinterpret_cast<TUint>(this)+sizeof( CDeploymentComponent ) );
+    delete iData;
+    iData = NULL;
+
+    delete iMetaData;
+    iMetaData = NULL;
+    }
+
+CDeploymentComponent &CDeploymentComponent::operator=( const CDeploymentComponent &aData )
+    {
+    if( &aData != this )
+        {
+        *iData = aData.Data();
+        *iMetaData = aData.MetaData();
+        iId = aData.ComponentId();
+        iName = aData.ComponentName();
+        iVersion = aData.iVersion;
+        iState = aData.State();
+        iInternalId = aData.InternalId();
+        iUid = aData.Uid();
+        iUserId = aData.iUserId;
+        iOwner = aData.iOwner;
+        iInstallOpts = aData.InstallOpts();
+        iPkgID = aData.PkgId();
+        iDescription = aData.Description();
+        iPkgIDRef = aData.PkgIDRef();
+        iPkgType = aData.PkgType();
+        iRemovableApp = aData.AppRemovable();
+        iDriveSelection = aData.DriveSelected();
+        iComponentId = aData.iComponentId;
+        iInstallOptsSet = aData.InstallOptsSet();
+        iPkgVersion = aData.iPkgVersion;
+        iDownloadStatus = aData.iDownloadStatus;
+        iDownloadURI = aData.iDownloadURI;
+        iUninstallOpts = aData.UninstallOpts();
+        iOwnerProfile = aData.OwnerProfile();
+        }
+    return *this;
+    }
+
+void CDeploymentComponent::PersistL(CRepository &aRepository) const
+    {
+    CBufBase *buf = CBufFlat::NewL( 32);
+    CleanupStack::PushL(buf);
+    TInt length(SerializedFormLength() );
+    buf->ExpandL(0, length+1);
+    TPtr8 p3(buf->Ptr(0) );
+    RDesWriteStream stream(p3);
+    TInt len(SerializedFormL(stream) );
+    TBuf8< NCentralRepositoryConstants::KMaxBinaryLength> tbuf;
+
+    TInt err(aRepository.Get(iInternalId, tbuf) );
+    if (err == KErrNotFound)
+        {
+        err = aRepository.Create(iInternalId, buf->Ptr(0) );
+        RDEBUG_3( "CDeploymentComponent::PersistL:  Created %d to centrep with status %d", iInternalId, err );
+        }
+    else
+        {
+        User::LeaveIfError(err) ;
+        err = aRepository.Set(iInternalId, buf->Ptr(0) );
+        RDEBUG_3( "CDeploymentComponent::PersistL:  Persisted %d to centrep with status %d", iInternalId, err );
+        }
+    User::LeaveIfError(err) ;
+    CleanupStack::PopAndDestroy(buf);
+    RFs fs;
+    User::LeaveIfError(fs.Connect() );
+    CleanupClosePushL(fs);
+    iData->PersistL(fs);
+    iMetaData->PersistL(fs);
+    CleanupStack::PopAndDestroy( &fs) ;
+    }
+
+void CDeploymentComponent::CopyStateTo(TDeploymentComponent &aInfo) const
+    {
+    aInfo.iId = iId;
+    aInfo.iName = iName;
+    aInfo.iVersion = iVersion;
+    aInfo.iDescription = iDescription;
+    aInfo.iPkgID = iPkgID;
+    aInfo.iPkgIDRef = iPkgIDRef;
+    aInfo.iPkgType = iPkgType;
+    aInfo.iState = iState;
+    aInfo.iOldState = iOldState;
+    }
+
+TBool CDeploymentComponent::IsJavaMimeL(const TDesC8& aMime)
+    {
+
+    FeatureManager::InitializeLibL();
+    TBool supported = EFalse;
+
+    if (FeatureManager::FeatureSupported(KFeatureIdJavaMIDP20) )
+        {
+        supported = ((aMime == SwiUI::KJarMIMEType || aMime
+                == SwiUI::KJadMIMEType || aMime == SwiUI::KJarxMIMEType
+                || aMime == SwiUI::KJavaMIMEType) ? ETrue : EFalse );
+        }
+    FeatureManager::UnInitializeLib();
+
+    return supported;
+    }
+
+TBool CDeploymentComponent::IsSisMimeL(const TDesC8& aMime)
+    {
+
+    
+    TBool supported = EFalse;
+
+    supported = ((aMime == SwiUI::KSisxMimeType || aMime
+                == SwiUI::KSisMimeType || aMime == SwiUI::KPipMimeType) ? ETrue : EFalse );
+   
+    return supported;
+    }
+
+void CDeploymentComponent::ConstructL(const TDCUserId &aUserId)
+    {
+    iUserId = aUserId;
+    RFs fs;
+    User::LeaveIfError(fs.Connect() );
+    CleanupClosePushL(fs);
+    TInt e(fs.CreatePrivatePath(KDefaultDrive) );
+    User::LeaveIfError(e);
+    TBuf<30> privatePath;
+    fs.PrivatePath(privatePath);
+    CleanupStack::PopAndDestroy( &fs);
+
+    TInt privPathLength(privatePath.Length() );
+    TBuf8<10> buf;
+    buf.NumFixedWidth(iInternalId, EHex, 10);
+
+    TBuf8 <30> path;
+    path.Copy(privatePath);
+    HBufC8 *afilename = HBufC8::NewLC(privPathLength + 10 + KAMDCDataSuffix().Length());
+    *afilename = path;
+    TPtr8 afn(afilename->Des() );
+    afn.Append(buf);
+    afn.Append(KAMDCDataSuffix) ;
+    iData = CDeploymentComponentData::NewL(CDeploymentComponentData::EData,
+            KNullDesC8, KNullDesC8, afn);
+
+    afn.Replace(privPathLength + 10, KAMDCMetaDataSuffix().Length(), KAMDCMetaDataSuffix);
+    iMetaData = CDeploymentComponentData::NewL(
+            CDeploymentComponentData::EMetaData, KNullDesC8, KNullDesC8, afn);
+
+    CleanupStack::PopAndDestroy(afilename);
+    }
+
+TInt CDeploymentComponent::SerializedFormLength() const
+    {
+    //   0			1		2		3		4		5			6			7	8			9			10		11
+    // iUserId , iState, iPkgVer, iUid, iIdLen, iNameLen, iVersLen, iDownState, iOwner, iOldState ,iDownUriLen, iInstallOptsset
+    return (20*4)+iUserId.Length() + iId.Length() + iName.Length()
+            + iVersion.Length() +
+            
+    iMidletName.Length() + iMideltVendorName.Length()
+            + iMidletVersion.Length()+ iDownloadURI.Length()
+            + iDescription.Length()+ iPkgID.Length()+iPkgIDRef.Length()
+            +iPkgType.Length()+ sizeof(iRemovableApp)+sizeof(iDriveSelection)+sizeof(iComponentId) + iData->SerializedFormLength()
+            + iMetaData->SerializedFormLength() + sizeof(TAMInstallOptions);
+    }
+
+TInt CDeploymentComponent::SerializedFormL(RWriteStream &aBuffer) const
+    {
+#ifdef _DEBUG
+    RDEBUG_2( "Offset before uint: %d", aBuffer.Sink()->TellL( MStreamBuf::EWrite ).Offset() );
+#endif
+
+    aBuffer.WriteUint32L(iPkgVersion);
+
+#ifdef _DEBUG
+    RDEBUG_2( "Offset after uint: %d" , aBuffer.Sink()->TellL( MStreamBuf::EWrite ).Offset() );
+#endif
+
+    aBuffer.WriteUint32L(iState);
+    aBuffer.WriteUint32L(iStatus);
+    aBuffer.WriteUint32L(iUid.iUid);
+    aBuffer.WriteUint32L(iUserId.Length() );
+    aBuffer.WriteL(iUserId);
+    aBuffer.WriteUint32L(iId.Length() );
+    aBuffer.WriteL(iId);
+    aBuffer.WriteUint32L(iName.Length() );
+    aBuffer.WriteL(iName);
+    aBuffer.WriteUint32L(iVersion.Length() );
+    aBuffer.WriteL(iVersion);
+    aBuffer.WriteUint32L(iMidletName.Length() );
+    aBuffer.WriteL(iMidletName);
+    aBuffer.WriteUint32L(iMideltVendorName.Length() );
+    aBuffer.WriteL(iMideltVendorName);
+    aBuffer.WriteUint32L(iMidletVersion.Length() );
+    aBuffer.WriteL(iMidletVersion);
+    aBuffer.WriteInt32L(iDownloadStatus);
+    aBuffer.WriteInt32L(iOwner);
+    aBuffer.WriteUint32L(iOldState);
+    aBuffer.WriteUint32L(iDownloadURI.Length() );
+    aBuffer.WriteL(iDownloadURI);
+    aBuffer.WriteUint32L(iDescription.Length() );
+    aBuffer.WriteL(iDescription);
+    aBuffer.WriteUint32L(iPkgID.Length() );
+    aBuffer.WriteL(iPkgID);
+    aBuffer.WriteUint32L(iPkgIDRef.Length() );
+    aBuffer.WriteL(iPkgIDRef);
+    aBuffer.WriteUint32L(iPkgType.Length() );
+    aBuffer.WriteL(iPkgType);
+    aBuffer.WriteUint32L(iRemovableApp);
+    aBuffer.WriteUint32L(iDriveSelection);
+    aBuffer.WriteInt32L(iComponentId);
+    iData->SerializedFormL(aBuffer);
+    iMetaData->SerializedFormL(aBuffer);
+    aBuffer.WriteUint32L(iInstallOptsSet);
+    TPckg<TAMInstallOptions> opts(iInstallOpts);
+    aBuffer.WriteL(opts);
+    return aBuffer.Sink()->TellL( MStreamBuf::EWrite ).Offset();
+    }
+
+void CDeploymentComponent::ConstructLoadL(const TDesC8 &aBuffer)
+    {
+    RDEBUG( "CDeploymentComponent::ConstructLoadL ");
+    TDeploymentComponent aRes;
+    TMimeType aType;
+
+    RDesReadStream stream(aBuffer);
+    iPkgVersion = stream.ReadUint32L();
+
+    iState = static_cast<TDeploymentComponentState>(stream.ReadUint32L() );
+    iStatus = static_cast<TSCOMOStatusNodeStates>(stream.ReadUint32L() );
+    iUid.iUid = stream.ReadUint32L();
+
+    TUint32 len(stream.ReadUint32L() );
+    stream.ReadL(iUserId, len);
+
+    len = stream.ReadUint32L();
+    stream.ReadL(iId, len);
+
+    len = stream.ReadUint32L();
+    stream.ReadL(iName, len);
+
+    len = stream.ReadUint32L();
+    stream.ReadL(iVersion, len);
+
+    len = stream.ReadUint32L();
+    stream.ReadL(iMidletName, len);
+
+    len = stream.ReadUint32L();
+    stream.ReadL(iMideltVendorName, len);
+
+    len = stream.ReadUint32L();
+    stream.ReadL(iMidletVersion, len);
+
+    iDownloadStatus = stream.ReadInt32L();
+
+    if (iPkgVersion > 1)
+        {
+        iOwner = stream.ReadInt32L();
+        }
+    if (iPkgVersion > 2)
+        {
+        iOldState = TDeploymentComponentState(stream.ReadUint32L() );
+        }
+
+    len = stream.ReadUint32L() ;
+    stream.ReadL(iDownloadURI, len);
+
+    len = stream.ReadUint32L();
+    stream.ReadL(iDescription, len);
+
+    len = stream.ReadUint32L();
+    stream.ReadL(iPkgID, len);
+
+    len = stream.ReadUint32L();
+    stream.ReadL(iPkgIDRef, len);
+
+    len = stream.ReadUint32L();
+    stream.ReadL(iPkgType, len);
+
+    iRemovableApp = stream.ReadUint32L();
+    iDriveSelection = stream.ReadUint32L();
+    iComponentId = stream.ReadInt32L();
+    iData = CDeploymentComponentData::LoadL(stream);
+    iMetaData = CDeploymentComponentData::LoadL(stream);
+
+    //using namespace SwiUI;
+    iInstallOptsSet = stream.ReadUint32L();
+    TAMInstallOptionsPckg opts(iInstallOpts);
+    stream.ReadL(opts, opts.Length() );
+    RDEBUG( "CDeploymentComponent::ConstructLoadL end");
+    }
+
+CDeploymentComponentData &CDeploymentComponent::Data()
+    {
+    return *iData;
+    }
+
+const CDeploymentComponentData &CDeploymentComponent::Data() const
+    {
+    return *iData;
+    }
+
+CDeploymentComponentData &CDeploymentComponent::MetaData()
+    {
+    return *iMetaData;
+    }
+
+const CDeploymentComponentData &CDeploymentComponent::MetaData() const
+    {
+    return *iMetaData;
+    }
+
+const TAMInstallOptions &CDeploymentComponent::InstallOpts() const
+    {
+    return iInstallOpts;
+    }
+
+const SwiUI::TUninstallOptions &CDeploymentComponent::UninstallOpts() const
+    {
+    return iUninstallOpts;
+    }
+
+TBool CDeploymentComponent::InstallOptsSet() const
+    {
+    return iInstallOptsSet;
+    }
+
+TBool CDeploymentComponent::AppRemovable() const
+    {
+    return iRemovableApp;
+    }
+
+TBool CDeploymentComponent::DriveSelected() const
+        {
+        return iDriveSelection;
+        }
+
+TInt CDeploymentComponent::GetComponentId() const
+        {
+        return iComponentId;
+        }
+void CDeploymentComponent::SetMetaDataL(const TDesC8 &aMimeType)
+    {
+    iMetaData->DataFileName();
+    iMetaData->SetDataL(aMimeType);
+    }
+
+void CDeploymentComponent::SetMetaDataL(const TDesC8 &aMetaData,
+        const TDesC8 &aMimeType)
+    {
+    iMetaData->SetDataL(aMetaData, aMimeType);
+    }
+
+void CDeploymentComponent::SetAppRemovableStatus(const TBool &aRemovable)
+    {
+    iRemovableApp = aRemovable;
+    }
+
+void CDeploymentComponent::SetDriveSelectionStatus(const TBool &aDriveSelection)
+    {
+    iDriveSelection = aDriveSelection;
+    }
+
+void CDeploymentComponent::SetInstallOptsL(const TDesC8 &aInstallOpts)
+    {
+    using namespace SwiUI;
+    if (aInstallOpts != KNullDesC8)
+        {
+        RDEBUG8_2( "CDeploymentComponent::SetInstallOptsL: '%S'", &aInstallOpts );
+        TInt tmpIAP(iInstallOpts.iIAP);
+        TAMInstallOptionsPckg pckg(iInstallOpts);
+        pckg.Copy(aInstallOpts);
+        iInstallOptsSet= ETrue;
+
+        if (iInstallOpts.iIAP == -1 && tmpIAP > -1)
+            {
+            RDEBUG8_2( "CDeploymentComponent::SetInstallOptsL: using IAPid %d", tmpIAP );
+            iInstallOpts.iIAP = tmpIAP;
+            }
+        }
+
+    }
+
+void CDeploymentComponent::ResetDataL(RFs &aFs)
+    {
+    iData->ResetData(aFs);
+    iMetaData->ResetData(aFs);
+    }
+
+void CDeploymentComponent::SetAttr(TDes8 &aAttr, const TDesC8 &aNewVal) const
+    {
+    if (aNewVal.Length() > aAttr.MaxLength() )
+        {
+        aAttr = aNewVal.Left(aAttr.MaxLength() );
+        }
+    else
+        {
+        aAttr = aNewVal;
+        }
+    }
+
+void CDeploymentComponent::SetIdL(const TDesC8 &aId)
+    {
+    SetAttr(iId, aId);
+    }
+
+void CDeploymentComponent::SetNameL(const TDesC8 &aName)
+    {
+    if (iName != aName)
+        {
+        SetAttr(iName, aName);
+        }
+    }
+
+void CDeploymentComponent::SetVersionL(const TDesC8 &aVersion)
+    {
+    SetAttr(iVersion, aVersion);
+    }
+void CDeploymentComponent::SetMimeTypeL( const TDesC8 &aMimeType )
+{
+	iData->SetMimeTypeL(aMimeType);
+}
+
+void CDeploymentComponent::SetDescriptionL(const TDesC8 &aDescription)
+    {
+    SetAttr(iDescription, aDescription);
+    }
+
+void CDeploymentComponent::SetPkgIDL(const TDesC8 &aPkgID)
+    {
+    // PkgID and PkgIDRef should be same and Get done on PkgID
+    // when state is in Download or Delivered and PkgIDRef is
+    // returned when state is in Deployed state
+    SetAttr(iPkgID, aPkgID);
+    SetAttr(iPkgIDRef, aPkgID);
+    }
+
+void CDeploymentComponent::SetPkgTypeL(const TDesC8 &aPkgType)
+    {
+
+    SetAttr(iPkgType, aPkgType);
+
+    }
+void CDeploymentComponent::SetMidletNameL(const TDesC8 &aMidletName)
+    {
+    SetAttr(iMidletName, aMidletName);
+    }
+
+void CDeploymentComponent::SetMidletVendorL(const TDesC8 &aMidletVendor)
+    {
+    SetAttr(iMideltVendorName, aMidletVendor);
+    }
+
+void CDeploymentComponent::SetMidletVersionL(const TDesC8 &aMidletVersion)
+    {
+    SetAttr(iMidletVersion, aMidletVersion);
+    }
+
+void CDeploymentComponent::SetUid(const TUid aUid)
+    {
+    RDEBUG8_2("CDeploymentComponent::SetUid 0x%x", aUid.iUid );
+    iUid = aUid;
+    iId.Zero();
+    if (iUid != TUid::Null() )
+        {
+        iId.AppendNumFixedWidth(iUid.iUid, EHex, 8);
+        }
+    }
+
+void CDeploymentComponent::SetOwnerProfile(TSmlProfileId aOwnerProfile)
+    {
+    iOwnerProfile = aOwnerProfile;
+    }
+
+TInt CDeploymentComponent::SetState(const TDeploymentComponentState &aState)
+    {
+    RDEBUG_2( "CDeploymentComponent::SetState - set to state (%d)", aState );
+
+    TInt ret(KErrNone);
+    iOldState = iState;
+    iState = aState;
+#ifdef __SERIES60_30__
+    if( iState != iOldState && iState != EDCSDownload && iState != EDCSDelivered )
+        {
+        if ( iUid != TUid::Null() )
+            {
+            RMenuServSession ses;
+            TBool visible( EFalse );
+            if ( iState == EDCSActive )
+                {
+                visible = ETrue;
+                }
+            TRAP( ret, ses.SetApplicationVisibilityL( iUid.iUid, visible ) );
+            if (ret != KErrNone )
+                {
+                RDEBUG_2( "CDeploymentComponent::SetState - failed to set visiblity %d", ret );
+                }
+            else
+                {
+                RDEBUG_2( "CDeploymentComponent::SetState - Set visiblity to %d", visible );
+                }
+            }
+        else
+            {
+            RDEBUG( "CDeploymentComponent::SetState - No need to set visibility to null uid" );
+            }
+
+        }
+    else
+        {
+        RDEBUG( "CDeploymentComponent::SetState - No need to change visibility " );
+        }
+#endif	
+    return ret;
+    }
+
+void CDeploymentComponent::SetStatusNode(
+        const TSCOMOStatusNodeStates &aStatus) const
+    {
+    iStatus = aStatus;
+    CRepository *repository=NULL;
+
+    TRAPD( erx, repository = CRepository::NewL ( KCRUidPrivateApplicationManagementKeys ) )
+    ;
+    if (erx!=KErrNone)
+        return;
+
+    TRAPD(err, PersistL(*repository))
+    ;
+
+    delete repository;
+
+    if (err!=KErrNone)
+        return;
+
+    }
+
+void CDeploymentComponent::Set(const TDeploymentComponent &aInfo)
+    {
+    iId = aInfo.iId;
+    iName = aInfo.iId;
+    iVersion = aInfo.iVersion;
+    iDescription = aInfo.iDescription;
+    iPkgID = aInfo.iPkgID;
+    iPkgIDRef = aInfo.iPkgIDRef;
+    iPkgType = aInfo.iPkgType;
+    }
+
+void CDeploymentComponent::SetDownloadURIL(const TDesC8 &aURI)
+    {
+    if (iState == EDCSDownload)
+        {
+        iDownloadURI = aURI;
+        }
+    else
+        {
+        RDEBUG_2( "CDeploymentComponent::SetDownloadURIL: ERROR Illegal state: %d", iState );
+        User::Leave(KErrNotSupported) ;
+        }
+    }
+
+void CDeploymentComponent::SetDownloadTarget(
+        const TDownloadTarget& aDownloadTarget)
+    {
+    RDEBUG_2("CDeploymentComponent::SetDownloadTarget: (%d)", aDownloadTarget);
+    iDownloadTarget = aDownloadTarget;
+    }
+
+void CDeploymentComponent::SetDataL(const TDesC8 &aData,
+        const TDesC8 &aMimeType)
+    {
+    iUid = iData->SetDataL(aData, aMimeType);
+    iId.Zero();
+    if (iUid != TUid::Null() )
+        {
+        iId.AppendNumFixedWidth(iUid.iUid, EHex, 8);
+        }
+    }
+
+void CDeploymentComponent::SetDataL(const TDesC &aFileName,
+        const TDesC8 &aMimeType)
+    {
+    SetUid(iData->SetDataL(aFileName, aMimeType) );
+    }
+
+void CDeploymentComponent::SetDataL(const TDesC8 &aMimeType)
+    {
+    SetUid(iData->SetDataL(aMimeType) );
+    }
+
+// ----------------------------------------------------------------------------------------
+// CDeploymentComponent::StatusUpdateL
+// ----------------------------------------------------------------------------------------	
+void CDeploymentComponent::StatusUpdateL(TInt aNewStatus)
+    {
+    RDEBUG( "CDeploymentComponent::StatusUpdateL : begin");
+    RDEBUG_2( "CDeploymentComponent::StatusUpdateL %d", aNewStatus );
+
+    if (State() == EDCSDownload)
+        {
+        iDownloadStatus = aNewStatus;
+        RDEBUG_2( "CDeploymentComponent::StatusUpdate: Set status to: %d", iDownloadStatus );
+
+        if (DownloadFailed() )
+            {
+            SetStatusNode(EDownload_DownloadFailed);
+            RDEBUG8_2( "CDeploymentComponent::StatusUpdate: ERROR Failed to download URI: '%S' ", &iDownloadURI );
+            }
+
+        if (iCallback)
+            {
+            iCallback->DownloadComplete( this, iDownloadStatus);
+            }
+        }
+    else
+        {
+        RDEBUG_2( "CDeploymentComponent::StatusUpdate: ERROR Illegal state: %d", State() );
+        }
+    RDEBUG( "CDeploymentComponent::StatusUpdateL : end");
+    }
+
+// ----------------------------------------------------------------------------------------
+// CDeploymentComponent::SuccessStatusUpdateL
+// ----------------------------------------------------------------------------------------	
+void CDeploymentComponent::SuccessStatusUpdateL(const TDesC &aDlFileName,
+        const TDesC8& aDlMimeType)
+    {
+    RDEBUG( "CDeploymentComponent::SuccessStatusUpdateL : start");
+    
+   
+    
+    TBuf<256> FileType;
+    TBuf8<256> FileType8;
+    
+    RApaLsSession RSession;      
+    if(RSession.Connect() == KErrNone)        
+        {  
+        TUid uid;
+        TDataType datatype;
+        RSession.AppForDocument(aDlFileName,uid, datatype );
+         
+        FileType.Copy(datatype.Des()); 
+        RDEBUG_2( "CDeploymentComponent::Pkg Id: %d ", uid.iUid);  
+        RDEBUG_2( "CDeploymentComponent::Pkg MIME: '%S' ", &FileType);  
+        }
+    RSession.Close();
+    
+    FileType8.Copy(FileType);
+    
+    SetDataL(aDlFileName, FileType8);
+    
+    
+    
+    //SetDataL(FileType8);
+
+    RDEBUG8_2( "CDeploymentComponent::Pkg MIME: '%S' ", &FileType8);
+
+    
+    // Set PkgID same as MiME type of downloaded content
+    SetPkgTypeL(FileType8);
+
+    CDeploymentComponent* conflict( NULL);
+    TBool dlOk(ETrue);
+    if (iUid != TUid::Null() )
+        {
+        __ASSERT_DEBUG( iCallback, User::Invariant() );
+        if (iCallback->UidExistsL(iUid, conflict, this) )
+            {
+            }
+        }
+    else
+        {
+        RDEBUG( "CDeploymentComponent::StatusUpdateL - WARNING cannot detect uid" );
+        if (IsJavaMimeL(FileType8) ||IsSisMimeL(FileType8) )
+            {
+            RDEBUG( "CDeploymentComponent::StatusUpdateL - Ignoring prev warning because it's java" );
+            }
+        else
+            {
+            dlOk = EFalse;
+            //The Operation has been rejected because the device does not support this MIME type.
+            iDownloadStatus = KStatusUnSupportedEnvironment;
+            }
+        }
+
+    if (dlOk)
+        {
+        /*for Predefined static node, append static node name with Internal ID before 
+         * moving to delivered state to avoid duplicates
+         */
+        TBuf8<256> staticnode;
+        TInt staticnodeenabled = 0;
+        CRepository* cenrep = CRepository::NewLC( KCRUidPrivateApplicationManagementKeys );
+        cenrep->Get( KAMDownloadPredefinedNode, staticnode ); 
+        cenrep->Get( KAMStaticNodeEnabled, staticnodeenabled );
+        CleanupStack::PopAndDestroy(); //cenrep
+        if (iUserId.Compare(staticnode) == 0 && staticnodeenabled)
+            {
+            iUserId.Append(*IntToDes8LC(iInternalId));
+            CleanupStack::PopAndDestroy(); // for IntToDes8LC()
+            }
+
+        //Reset the value of DownloadStatus for success update
+        iDownloadStatus = 0;
+                
+        SetState(EDCSDelivered);
+        SetStatusNode(EIdle);
+        }
+
+    if (iCallback)
+        {
+        iCallback->DownloadComplete( this, iDownloadStatus);
+        }
+
+    RDEBUG( "CDeploymentComponent::SuccessStatusUpdateL : end");
+    }
+
+const TSmlProfileId& CDeploymentComponent::OwnerProfile() const
+    {
+    return iOwnerProfile;
+    }
+
+const TDesC8& CDeploymentComponent::MimeType() const
+    {
+    if (iMetaData->MimeType().Length() )
+        {
+        return iMetaData->MimeType();
+        }
+    return iData->MimeType();
+    }
+
+TBool CDeploymentComponent::DownloadFailed() const // http or symbian error
+    {
+    return (iDownloadStatus >= 400 || iDownloadStatus < 0) ? ETrue : EFalse;
+    }
+
+TInt CDeploymentComponent::DownloadStatus() const
+    {
+    return iDownloadStatus;
+    }
+
+void CDeploymentComponent::DestroyL(CRepository &aRepository)
+    {
+    TDeploymentComponentState st(State() );
+    if ( !(st == EDCSActive || st == EDCSInactive))
+        {
+        RFs fs;
+        User::LeaveIfError(fs.Connect() );
+        CleanupClosePushL(fs);
+        iMetaData->DestroyL(fs);
+        iData->DestroyL(fs);
+        CleanupStack::PopAndDestroy( &fs) ;// fs
+        }
+
+    TInt err(aRepository.Delete(iInternalId) );
+    RDEBUG_3( "CDeploymentComponent::DestroyL:  Deleting %d in centrep resulted with status %d", iInternalId, err );
+    }
+
+void CDeploymentComponent::SetOwner(const TInt &aInfo)
+    {
+    iOwner = aInfo;
+    }
+
+void CDeploymentComponent::SetComponentId(const TInt &aComponentId)
+    {
+    iComponentId = aComponentId;
+    }
+
+void CDeploymentComponent::SetIAPL(const TInt aIap)
+    {
+    RDEBUG8_2( "CDeploymentComponent::SetIAPL: %d ", aIap );
+    iInstallOpts.iIAP = aIap;
+    }
+
+TInt CDeploymentComponent::GetIAP() const
+    {
+    return iInstallOpts.iIAP;
+    }
+HBufC8* CDeploymentComponent::IntToDes8LC(const TInt aLuid)
+    {
+    HBufC8* buf = HBufC8::NewLC( 10); //10 = max length of 32bit integer
+    TPtr8 ptrBuf = buf->Des();
+    ptrBuf.Num(aLuid);
+    return buf;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/AMDeploymentComponentData.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,567 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#include <bautils.h>
+#include <DRMLicenseManager.h>
+#include <pathinfo.h>
+#include <zipfilemember.h>
+#include "amdeploymentcomponentdata.h"
+#include "debug.h"
+
+_LIT8( KSisxMimeType, "x-epoc/x-sisx-app" );
+_LIT( KTempDir, "piptemp\\" );
+_LIT8( KPipMimeType, "application/x-pip" );
+_LIT8( KDrmMessageMimeType, "application/vnd.oma.drm.message" );
+_LIT8( KDrmContentMimeType, "application/vnd.oma.drm.content" );
+_LIT8( KSisMimeType, "application/vnd.symbian.install");
+_LIT8( KJadMIMEType, "text/vnd.sun.j2me.app-descriptor" );
+_LIT8( KJarMIMEType, "application/java-archive" );
+_LIT8( KJavaMIMEType, "application/java" );
+
+using namespace NApplicationManagement;
+
+/**
+ *  Data class to Data access
+ */
+CDeploymentComponentData::CDeploymentComponentData()
+    {
+    }
+
+CDeploymentComponentData::CDeploymentComponentData(TType aType,
+        const TDesC8 &aDataFile) :
+    iDataFileName(aDataFile), iType(aType)
+    {
+    }
+
+void CDeploymentComponentData::ConstructL(const TDesC8 &aData,
+        const TDesC8 &aMime)
+    {
+    SetDataL(aData, aMime);
+    }
+
+CDeploymentComponentData &CDeploymentComponentData::operator=(
+        const CDeploymentComponentData &aData )
+    {
+    if( &aData != this )
+        {
+        SetDataL( aData.Data(), aData.MimeType() );
+        iType = aData.iType;
+        iDataFileName = aData.iDataFileName;
+        }
+    return *this;
+    }
+
+void CDeploymentComponentData::ConstructLoadL(RReadStream &aStream)
+    {
+    TUint32 len(aStream.ReadUint32L() );
+    aStream.ReadL(iDataFileName, len);
+
+    len = aStream.ReadUint32L();
+    aStream.ReadL(iMimeType, len);
+    }
+
+CDeploymentComponentData* CDeploymentComponentData::NewL(TType aType,
+        const TDesC8 &aData, const TDesC8 &aMime, const TDesC8 &aDataFile)
+    {
+    CDeploymentComponentData *self = CDeploymentComponentData::NewLC(aType,
+            aData, aMime, aDataFile);
+    CleanupStack::Pop();
+    return self;
+    }
+
+CDeploymentComponentData* CDeploymentComponentData::NewLC(TType aType,
+        const TDesC8 &aData, const TDesC8 &aMime, const TDesC8 &aDataFile)
+    {
+    CDeploymentComponentData *self = new ( ELeave ) CDeploymentComponentData( aType, aDataFile);
+    CleanupStack::PushL(self) ;
+    self->ConstructL(aData, aMime);
+    return self;
+    }
+
+CDeploymentComponentData* CDeploymentComponentData::LoadL(
+        RReadStream &aBuffer)
+    {
+    CDeploymentComponentData *self =
+            CDeploymentComponentData::LoadLC(aBuffer);
+    CleanupStack::Pop();
+    return self;
+    }
+
+CDeploymentComponentData* CDeploymentComponentData::LoadLC(
+        RReadStream &aBuffer)
+    {
+    CDeploymentComponentData *self = new ( ELeave ) CDeploymentComponentData();
+    CleanupStack::PushL(self) ;
+    self->ConstructLoadL(aBuffer);
+    return self;
+    }
+
+CDeploymentComponentData::~CDeploymentComponentData()
+    {
+    RDEBUG8_3("CDeploymentComponentData::~CDeploymentComponentData 0x%X - 0x%X", reinterpret_cast<TUint>(this),
+            reinterpret_cast<TUint>(this)+sizeof( CDeploymentComponentData ) );
+
+    delete iData;
+    iData = NULL;
+    }
+
+TInt CDeploymentComponentData::DataLengthL() const
+    {
+    TInt ret( 0);
+    if (iData == NULL)
+        {
+        if (iDataFileName.Length() > 0)
+            {
+            RFs fs;
+            User::LeaveIfError(fs.Connect() );
+            CleanupClosePushL(fs); // 1
+            TEntry entry;
+            TFileName fileName;
+            fileName.Copy(iDataFileName);
+            User::LeaveIfError(fs.Entry(fileName, entry) );
+            ret = entry.iSize;
+            CleanupStack::PopAndDestroy( &fs);
+            }
+        }
+    else
+        {
+        ret = iData->Length();
+        }
+    return ret;
+    }
+
+const TDesC8 &CDeploymentComponentData::Data() const
+    {
+    if (iData == NULL)
+        {
+        TRAPD( err, LoadDataL() )
+        ;
+        if (err != KErrNone)
+            {
+            return KNullDesC8();
+            }
+        }
+    if (iData != NULL)
+        {
+        return *iData;
+        }
+    else
+        {
+        return KNullDesC8();
+        }
+    }
+
+void CDeploymentComponentData::LoadDataL() const
+    {
+
+    if (iDataFileName.Length() > 0)
+        {
+        RFs fs;
+        User::LeaveIfError(fs.Connect() );
+        CleanupClosePushL(fs); // 1
+        RFile file;
+        TFileName fileName;
+        fileName.Copy(iDataFileName);
+        TInt err(file.Open(fs, fileName, EFileRead) );
+        if (err == KErrNone)
+            {
+            CleanupClosePushL(file); // 2
+            TInt fsize;
+            User::LeaveIfError(file.Size(fsize) );
+            iData = HBufC8::NewL(fsize);
+            TPtr8 ptr(iData->Des() );
+            User::LeaveIfError(file.Read(ptr) );
+            CleanupStack::PopAndDestroy( &file);
+            }
+        else
+            {
+            RDEBUG_3( "ERROR Leaving CDeploymentComponentData::Data - SEVERE Could not open data file '%S': %d!",
+                    &fileName, err );
+            User::Leave(KErrNotFound) ;
+            }
+        CleanupStack::PopAndDestroy( &fs);
+        }
+    else
+        {
+        RDEBUG( "ERROR Leaving CDeploymentComponentData::LoadDataL() - No file to load!" );
+        User::Leave(KErrNotFound) ;
+        }
+    }
+
+TUid CDeploymentComponentData::SetDataL(const TDesC8& aMimeType)
+    {
+    RDEBUG8_2("CDeploymentComponentData::SetDataL() aMimeType: (%S)", &aMimeType);
+
+    TUid ret(TUid::Null());
+    iMimeType = aMimeType.Left(KMaxMimeLength);
+
+    if (aMimeType.Length()!=NULL)
+        {
+        TUid ret(TUid::Null());
+        RFs fs;
+        User::LeaveIfError(fs.Connect());
+        CleanupClosePushL(fs);
+        CFileMan *fm = CFileMan::NewL(fs);
+        CleanupStack::PushL(fm);
+        TFileName oldfilepath;
+        oldfilepath.Copy(iDataFileName);
+        
+        
+        RDEBUG("App Mgmt before copy start");
+        TInt maxLength = iDataFileName.Length();
+        TChar charvaldot = '.';
+        TChar charvalslash = '\\';
+        //TFileName oldfilepath;
+        TInt pos = iDataFileName.LocateReverse(charvaldot);
+
+        TInt lengthDeleted = maxLength - pos;
+
+        iDataFileName.Delete(pos, lengthDeleted);
+        
+        if (iMimeType == KSisxMimeType)
+            {
+            _LIT16(KExt,".sisx");
+            iExtn.Append(KExt);
+            }
+        if(iMimeType==KSisMimeType)
+            {
+            _LIT16(KExt,".sis");
+            iExtn.Append(KExt);
+            }
+        if(iMimeType==KPipMimeType)
+            {
+            _LIT16(KExt,".pip");
+            iExtn.Append(KExt);
+            }
+        if(iMimeType==KJadMIMEType)
+            {
+            _LIT16(KExt,".jad");
+            iExtn.Append(KExt);
+            }
+        if(iMimeType==KJarMIMEType)
+            {
+            _LIT16(KExt,".jar");
+            iExtn.Append(KExt);
+            }
+        if(iMimeType==KJavaMIMEType)
+            {
+            _LIT16(KExt,".jar");
+            iExtn.Append(KExt);
+            }
+        iDataFileName.Append(iExtn);//file name with sisx extension
+        TFileName newfilepath;
+        newfilepath.Copy(iDataFileName);
+        User::LeaveIfError(fm->Rename(oldfilepath, newfilepath));
+        CleanupStack::PopAndDestroy(fm);
+        CleanupStack::PopAndDestroy( &fs);
+        //RDEBUG_2(" filename: %S", iDataFileName );
+        }
+    if (IsSISInstallFile(aMimeType) )
+        {
+        RFs fs;
+        User::LeaveIfError(fs.Connect() );
+        CleanupClosePushL(fs);     
+        ret = ResolveUidL(fs);
+        CleanupStack::PopAndDestroy( &fs);
+        }
+    RDEBUG8_2("CDeploymentComponentData::SetDataL() UID: (0x%x)", ret.iUid);
+    return ret;
+    }
+
+TUid CDeploymentComponentData::SetDataL(const TFileName &aData,
+        const TDesC8& aMimeType)
+    {
+    RDEBUG_2("CDeploymentComponentData::SetDataL() TFileName: (%S)", &aData);
+    
+    _LIT(KNewPath, "c:\\private\\200267FB\\");
+
+    TUid ret(TUid::Null());
+    iMimeType = aMimeType.Left(KMaxMimeLength) ;
+    RFs fs;
+    User::LeaveIfError(fs.Connect() );
+    CleanupClosePushL(fs);
+    CFileMan *fm = CFileMan::NewL(fs);
+    CleanupStack::PushL(fm);
+    TFileName fn;
+    fn.Copy(iDataFileName);
+
+    RDEBUG("App Mgmt before copy start");
+
+    
+    TInt maxLength = iDataFileName.Length();
+    TChar charvaldot = '.';
+    TChar charvalslash = '\\';
+    
+    TInt pos = iDataFileName.LocateReverse(charvaldot);
+    
+    TInt lengthDeleted = maxLength-pos;
+    
+    iDataFileName.Delete(pos, lengthDeleted);
+    
+    TInt srcpos = aData.LocateReverse(charvaldot);
+    
+    TBuf<15> extn(aData.Mid(srcpos));
+    
+    iDataFileName.Append(extn);
+    
+    TFileName newfilepath;
+    newfilepath.Copy(iDataFileName);
+    
+    User::LeaveIfError(fm->Move(aData,KNewPath()));
+    
+    TFileName oldfilepath(KNewPath());
+    oldfilepath.Append(aData.Mid(aData.LocateReverse(charvalslash)));
+    
+    User::LeaveIfError(fm->Rename(oldfilepath, newfilepath));
+   
+    
+    //User::LeaveIfError(fm->Copy(aData, fn) );
+
+    RDEBUG("App Mgmt before copy End");
+
+
+    if (IsSISInstallFile(aMimeType) )
+        {
+        ret = ResolveUidL(fs);
+        }
+
+    CleanupStack::PopAndDestroy(fm);
+    CleanupStack::PopAndDestroy( &fs);
+    RDEBUG_2("CDeploymentComponentData::SetDataL() (%d)", ret.iUid);
+
+    return ret;
+    }
+
+TUid CDeploymentComponentData::SetDataL(const TDesC8 &aData,
+        const TDesC8 &aMimeType)
+    {
+    TUid ret(TUid::Null());
+    if (iData)
+        {
+        delete iData;
+        iData = NULL;
+        }
+    iData = aData.AllocL();
+    ret = SetDataL(aMimeType);
+    return ret;
+    }
+
+TBool CDeploymentComponentData::IsSISInstallFile(const TDesC8 &aMimeType)
+    {
+    TBool isSIS(EFalse);
+
+    if (aMimeType == KSisxMimeType || aMimeType == KPipMimeType || aMimeType
+            == KDrmMessageMimeType || aMimeType == KDrmContentMimeType || aMimeType == KSisMimeType)
+        {
+        isSIS = ETrue;
+        }
+
+    return isSIS;
+    }
+
+TUid CDeploymentComponentData::ResolveUidL(RFs& aFs)
+    {
+    RDEBUG("CDeploymentComponentData::ResolveUidL()");
+
+    TUid ret(TUid::Null() );
+    HBufC* buf = HBufC::NewLC(KMaxFileName);
+    TPtr16 ptr = buf->Des();
+    ptr.Copy(iDataFileName);
+
+    // if PIP/DRM package, we need to use license manager to extract the sis file
+    if (iMimeType == KPipMimeType || iMimeType == KDrmMessageMimeType
+            || iMimeType == KDrmContentMimeType)
+        {
+        RDEBUG8_2("	-> mime: %S", &iMimeType );
+
+        RFile originalFile;
+        RFile decryptedFile;
+        TFileName decryptedTempFileName;
+
+        RDEBUG_2("	-> opening original file: %S", &ptr );
+        // leave if can not open the original file
+        User::LeaveIfError(originalFile.Open(aFs, ptr, EFileWrite) );
+        RDEBUG("	-> done");
+
+        // First construct the temp path
+        User::LeaveIfError(aFs.PrivatePath(decryptedTempFileName) );
+        // set drive letter into the path
+        decryptedTempFileName.Insert( 0, TParsePtrC( PathInfo::PhoneMemoryRootPath() ).Drive() );
+        // append "piptemp\\"	
+        decryptedTempFileName.Append(KTempDir);
+        // create the folder
+        aFs.MkDir(decryptedTempFileName);
+
+        // Use license manager to extract files from the pip package
+        CDRMLicenseManager* licenseMgr = CDRMLicenseManager::NewL();
+        CleanupStack::PushL(licenseMgr);
+        // decryp from the original file into the temp file   
+        RDEBUG_2("	-> extracting SIS file into: %S", &decryptedTempFileName);
+        User::LeaveIfError(licenseMgr->ExtractSISFileL(originalFile,
+                decryptedTempFileName) );
+        RDEBUG("	-> done");
+
+        // Get the sis file name 
+        decryptedTempFileName.Append( *(licenseMgr->GetSISMemberL()->Name() ));
+        // open temporary handle to it.
+        RDEBUG_2("	-> opening decrypted file: %S", &decryptedTempFileName );
+        User::LeaveIfError(decryptedFile.Open(aFs, decryptedTempFileName,
+                EFileShareAny) );
+        RDEBUG("	-> done");
+        // parse the uid from the file
+        ret = ParseUidFromSisFileL(decryptedFile);
+
+        // no use anymore for the decrypted file
+        decryptedFile.Close();
+        // delete the temp file
+        TInt err = aFs.Delete(decryptedTempFileName);
+        if (err != KErrNone)
+            {
+            RDEBUG_2("**** ERROR, unable to delete temporary file: %S", &decryptedTempFileName );
+            }
+
+        CleanupStack::PopAndDestroy(licenseMgr);
+        decryptedFile.Close();
+        originalFile.Close();
+        }
+    else
+        if (iMimeType == KSisxMimeType || iMimeType == KSisMimeType )
+            {
+            RDEBUG("	-> mime: x-epoc/x-sisx-app");
+            RFile originalFile;
+            RDEBUG_2("	-> opening file: %S", &ptr );
+            User::LeaveIfError(originalFile.Open(aFs, ptr, EFileRead) );
+            RDEBUG("	-> opened ok");
+            ret = ParseUidFromSisFileL(originalFile);
+            originalFile.Close();
+            }
+
+        else
+            {
+            RDEBUG8_2( "**** ERROR - CDeploymentComponentData::ResolveUidL( ) - cannot get uid from mime type: %S", &iMimeType );
+            }
+
+    CleanupStack::PopAndDestroy(buf);
+    return ret;
+    }
+
+void CDeploymentComponentData::SerializedFormL(RWriteStream &aBuffer) const
+    {
+    aBuffer.WriteUint32L(iDataFileName.Length() );
+    aBuffer.WriteL(iDataFileName);
+
+    aBuffer.WriteUint32L(iMimeType.Length() );
+    aBuffer.WriteL(iMimeType);
+
+    }
+
+void CDeploymentComponentData::DestroyL(RFs &aFs) const
+    {
+    TFileName fn;
+    fn.Copy(iDataFileName);
+    aFs.Delete(fn) ;
+    }
+
+const TDesC8 &CDeploymentComponentData::DataFileName() const
+    {
+    return iDataFileName;
+    }
+
+void CDeploymentComponentData::PersistL(RFs &aFs)
+    {
+    if (iData)
+        {
+        RFile file;
+        TFileName aFile;
+        aFile.Copy(iDataFileName) ;
+        RDEBUG_3( "CDeploymentComponentData::PersistL() - Saving '%S', dataLenght %d", &aFile, (iData ? iData->Length() : 0) );
+        User::LeaveIfError(file.Replace(aFs, aFile, EFileWrite) );
+        CleanupClosePushL(file) ;
+
+        file.Write( *iData) ;
+        file.Flush();
+        delete iData;
+        iData = NULL;
+        CleanupStack::PopAndDestroy( &file) ; // file
+        }
+    else
+        {
+        RDEBUG( "CDeploymentComponentData::PersistL() - Already persisted" );
+        }
+    RDEBUG( "CDeploymentComponentData::PersistL() - Done" );
+    }
+
+TInt CDeploymentComponentData::SerializedFormLength() const
+    {
+    return iDataFileName.Length() + (2 * 4) + iMimeType.Length();
+    }
+
+void CDeploymentComponentData::SetDataFileNameL(const TDesC8 &aNewFileName)
+    {
+    if (aNewFileName.Length() > 0)
+        {
+        RFs fs;
+        User::LeaveIfError(fs.Connect() );
+        CleanupClosePushL(fs);
+        TFileName newfile;
+        newfile.Copy(aNewFileName);
+        TFileName oldfile;
+        oldfile.Copy(iDataFileName);
+        User::LeaveIfError(BaflUtils::RenameFile(fs, oldfile, newfile) );
+        CleanupStack::PopAndDestroy( &fs);
+        iDataFileName = aNewFileName;
+        }
+    else
+        {
+        RDEBUG( "CDeploymentComponentData::SetDataFileNameL - ERROR Cannot set empty filename!" );
+        User::Leave(KErrArgument);
+        }
+    }
+void CDeploymentComponentData::SetMimeTypeL(const TDesC8 &aMimeType)
+{
+	iMimeType = aMimeType.Left(KMaxMimeLength) ;
+}
+void CDeploymentComponentData::ResetData(RFs &aFs)
+    {
+    TRAP_IGNORE(DestroyL( aFs ));
+    iDataFileName = KNullDesC8();
+    delete iData;
+    iData = NULL;
+    }
+
+TUid CDeploymentComponentData::ParseUidFromSisFileL(RFile& aHandleToFile)
+    {
+    RDEBUG("CDeploymentComponentData::ParseUidFromSisFileL");
+
+    TUid appUid;
+    TInt uidLen = sizeof(TInt32);
+    TInt seekLen = sizeof(TInt32) + sizeof(TInt32);
+    User::LeaveIfError(aHandleToFile.Seek(ESeekStart, seekLen));
+    TPckg<TInt32> uid1(appUid.iUid);
+    User::LeaveIfError(aHandleToFile.Read(uid1, uidLen));
+
+    if (uid1.Length() != uidLen)
+        {
+        RDEBUG("**** ERROR - uid length inconsistency - underflow");
+        User::Leave(KErrUnderflow);
+        }
+
+    RDEBUG_2("	-> returning SIS UID: %d", appUid.iUid );
+    return appUid;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/AMDownloadStore.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  Implementation of applicationmanagement components
+ *
+ */
+
+#include "AMDownloadStore.h"
+#include "debug.h"
+#include "ApplicationManagementUtility.h"
+#include "amsmlhelper.h"
+
+using namespace NApplicationManagement;
+
+CAMDownloadStore::CAMDownloadStore(MDownloadMngrObserver& aObserver) :
+    CActive(CActive::EPriorityStandard),iObserver(aObserver)
+    {
+
+    }
+
+void CAMDownloadStore::ConstructL()
+    {
+    CActiveScheduler::Add(this);
+    }
+
+CAMDownloadStore* CAMDownloadStore::NewL(MDownloadMngrObserver& aObserver)
+    {
+    CAMDownloadStore* self = new (ELeave) CAMDownloadStore(aObserver);
+
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+CAMDownloadStore::~CAMDownloadStore()
+    {
+    iDwnldStore.ResetAndDestroy();
+    }
+
+void CAMDownloadStore::AddDownloadL(CDeploymentComponent *aComponent)
+    {
+    CAMDwnldQTWrap *download = CAMDwnldQTWrap::NewL(iObserver, aComponent);
+    iDwnldStore.Append(download);
+    StartDownload();
+    }
+
+void CAMDownloadStore::StartDownload()
+    {
+    if (!IsActive())
+        {
+
+        iStatus = KRequestPending;
+
+        TInt downldcount = iDwnldStore.Count();
+        CAMDwnldQTWrap *download = iDwnldStore[downldcount - 1];
+
+        download->StartDownload(download->iComponent, iStatus);
+
+        SetActive();
+        }
+    }
+
+TInt CAMDownloadStore::DownloadCount()
+    {
+    return iDwnldStore.Count();
+    }
+
+void CAMDownloadStore::RunL()
+    {
+    TInt downldcount = iDwnldStore.Count();
+
+    iDwnldStore.Remove(downldcount - 1);
+
+    if (iDwnldStore.Count() > 0)
+        StartDownload();
+    }
+
+void CAMDownloadStore::DoCancel()
+    {
+
+    }
+
+CAMDwnldQTWrap::CAMDwnldQTWrap(MDownloadMngrObserver& aObserver,
+        CDeploymentComponent *aComponent) :
+    iObserver(aObserver), iComponent(aComponent)
+    {
+
+    }
+
+void CAMDwnldQTWrap::ConstructL()
+    {
+
+    serverid = SmlHelper::GetCurrentServerIDL();
+
+    iap = -1;
+    TRAPD( err, SmlHelper::GetDefaultIAPFromDMProfileL( iap ) );
+    if (err != KErrNone)
+        {
+        iap = -1;
+        RDEBUG_2("CAMDwnldQTWrap::ConstructL iapid to : %d", err );
+        }
+
+    }
+
+CAMDwnldQTWrap* CAMDwnldQTWrap::NewL(MDownloadMngrObserver& aObserver,
+        CDeploymentComponent *aComponent)
+    {
+    RDEBUG( "CAMDwnldQTWrap::NewL Start" );
+
+    CAMDwnldQTWrap* self = new (ELeave) CAMDwnldQTWrap(aObserver, aComponent);
+
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    RDEBUG( "CAMDwnldQTWrap::NewL End" );
+
+    return self;
+    }
+
+CAMDwnldQTWrap::~CAMDwnldQTWrap()
+    {
+    if (serverid)
+        delete serverid;
+    }
+
+void CAMDwnldQTWrap::StartDownload(CDeploymentComponent *aComponent,
+        TRequestStatus& aStatus)
+    {
+    RDEBUG( "CAMDwnldQTWrap::StartDownload Start" );
+
+    aComponent->SetCallback(this);
+    appdwnld = new appmgmtdownloadmgr(0, *this, aStatus);
+    appdwnld->startDownload(aComponent);
+
+    RDEBUG( "CAMDwnldQTWrap::StartDownload End" );
+
+    }
+
+void CAMDwnldQTWrap::DownloadComplete(CDeploymentComponent *aComponent,
+        TInt aStatus)
+    {
+
+    TInt err(KErrNone);
+    TRAP( err, DownloadCompleteL( aComponent ));
+
+    }
+
+// ----------------------------------------------------------------------------------------
+// CAMDownloadManager::DownloadCompleteL
+// ---------------------------------------------------------------------------------------- 
+void CAMDwnldQTWrap::DownloadCompleteL(CDeploymentComponent *aComponent)
+    {
+    iObserver.ComponentDownloadComplete(aComponent, iap, serverid);
+    }
+
+// ----------------------------------------------------------------------------------------
+// CAMDownloadManager::UidExistsL
+// ---------------------------------------------------------------------------------------- 
+TBool CAMDwnldQTWrap::UidExistsL(const TUid &aUid,
+        CDeploymentComponent *& aCompo, CDeploymentComponent *aIgnored)
+    {
+    TBool uidExist(EFalse);
+    uidExist = iObserver.HasUidL(aUid, aCompo, aIgnored);
+    return uidExist;
+    }
+
+// ---------------------------------------------------------------------------
+// DownloadCompleted
+// ---------------------------------------------------------------------------
+void CAMDwnldQTWrap::DownloadCompleted()
+    {
+
+    TInt err(KErrNone);
+    QString filename;
+    QString mimetype;
+
+    QString path("c:\\system\\appmgr\\");
+
+    QString filefullpath(path);
+
+    appdwnld->FileName(filename);
+    appdwnld->MimeType(mimetype);
+
+    filefullpath.append(filename);
+
+    TPtrC filenamefullpathptr(
+            reinterpret_cast<const TUint16*> (filefullpath.utf16()));
+    TPtrC8 mimetypeptr(
+            reinterpret_cast<const TUint8*> (mimetype.toUtf8().constData()));
+
+    CApplicationManagementUtility::SetFileName(filenamefullpathptr);
+
+    TRAP( err, iComponent->SuccessStatusUpdateL( filenamefullpathptr, mimetypeptr) );
+
+    if (err != KErrNone)
+        {
+        RDEBUG_2(" ->iComponent::StatusUpdateL: %d", err );
+        }
+    RDEBUG_2( "CAMDownload::DownloadCompleted: end Download delete ERROR (%d)", err );
+    }
+
+void CAMDwnldQTWrap::DownloadFailed(TInt aDwnldStatus)
+    {
+    RDEBUG( "CAMDownload::DownloadFailed: start");
+    //TInt err(KErrNone);
+    //TInt32 errorCode = iDownloader->DownloadStatusCodeL(aDownloadState);
+    TRAPD( err, iComponent->StatusUpdateL( aDwnldStatus ) );
+
+    if (err != KErrNone)
+        {
+        RDEBUG_2(" ->iComponent::StatusUpdateL: %d", err );
+        }
+    RDEBUG_2( "CAMDownload::DownloadFailed: end Download delete ERROR (%d)", err );
+    }
+
+void CAMDwnldQTWrap::SetStatus(TInt aStatus)
+    {
+    TRAPD( err, iComponent->StatusUpdateL( aStatus ) );
+    if (err != KErrNone)
+        {
+        RDEBUG_2(" ->iComponent::StatusUpdateL: %d", err );
+        }
+    RDEBUG_2( "CAMDownload::DownloadFailed: end Download delete ERROR (%d)", err );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/AMDownloaddb.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,388 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies 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 applicationmanagement components
+ *
+*/
+
+// INCLUDE FILES
+#include <sysutil.h>
+#include <bautils.h>
+
+#include "AMDownloaddb.h"
+#include "debug.h"
+
+// ============================ MEMBER FUNCTIONS =============================
+
+// ---------------------------------------------------------------------------
+//  CAMDownloaddb::NewL()
+//  Creates a new instance of CAMDownloaddb object.
+// ---------------------------------------------------------------------------
+// 
+CAMDownloaddb* CAMDownloaddb::NewL()
+    {
+    RDEBUG("CAMDownloaddb::NewL(): begin");
+
+    CAMDownloaddb* self = CAMDownloaddb::NewLC();
+    CleanupStack::Pop(self);
+
+    RDEBUG("CAMDownloaddb::NewL(): end");
+
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+//  CAMDownloaddb::NewLC()
+//  Creates a new instance of CAMDownloaddb object. 
+//  Pushes and leaves new instance onto CleanupStack.
+// ---------------------------------------------------------------------------
+// 
+CAMDownloaddb* CAMDownloaddb::NewLC()
+    {
+    RDEBUG("CAMDownloaddb::NewLC(): begin");
+
+    CAMDownloaddb* self = new( ELeave ) CAMDownloaddb();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+
+    RDEBUG("CAMDownloaddb::NewLC(): end");
+
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+//  CAMDownloaddb::ConstructL()
+//  Second phase constructor.
+// ---------------------------------------------------------------------------
+// 
+void CAMDownloaddb::ConstructL()
+    {
+    RDEBUG("CAMDownloaddb::ConstructL(): begin");
+
+    TParse name;
+    TInt err;
+
+    User::LeaveIfError(iFsSession.Connect());
+    User::LeaveIfError(iRdbSession.Connect() );
+
+    iFsSession.SetSessionToPrivate(EDriveC);
+
+#ifdef SYMBIAN_SECURE_DBMS
+    name.Set(KAMDownloaddbName, NULL, NULL);
+    err = iDatabase.Open(iRdbSession, name.FullName(), KDBMSSecureID);
+#else
+    name.Set( KAMDownloaddbName, KNonSecureDbFullName, NULL );
+    err = iDatabase.Open(iRdbSession, DBFileName);
+#endif
+
+    if (err == KErrNotFound)
+        {
+        CreateandOpenL(name);
+        }
+    else
+        {
+
+        if ( (err == KErrEof ) || (err == KErrCorrupt ) || (err
+                == KErrArgument ))
+            {
+            // something seriously wrong with the db, delete it and try 
+            // to create new
+            iRdbSession.DeleteDatabase(name.FullName(), KAMPolicyUID);
+            CreateandOpenL(name);
+            }
+
+        }
+
+    RDEBUG("CAMDownloaddb::ConstructL(): end");
+    }
+
+// -----------------------------------------------------------------------------
+// CWPInternetAPDB::CreateandOpenL
+// -----------------------------------------------------------------------------
+//    
+void CAMDownloaddb::CreateandOpenL(TParse& name)
+    {
+
+    TInt err;
+
+#ifdef SYMBIAN_SECURE_DBMS
+    iDatabase.Create(iRdbSession, name.FullName(), KDBMSSecureID);
+#else
+    if( SysUtil::FFSSpaceBelowCriticalLevelL( &iFsSession, KEmptyDbSizeEstimate ) )
+        {
+        User::Leave( KErrDiskFull );
+        }
+    iDatabase.Create(iFsSession, name.FullName());
+#endif	
+
+    CreateTableL(iDatabase);
+    iDatabase.Close();
+#ifdef SYMBIAN_SECURE_DBMS
+
+    err = iDatabase.Open(iRdbSession, name.FullName(), KDBMSSecureID);
+
+#else
+    err = iDatabase.Open(iFsSession, DBFileName);
+#endif
+
+    //Debug
+    if (err != KErrNone)
+        {
+
+        User::LeaveIfError(err);
+        }
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWPInternetAPDB::CreateTableL
+// -----------------------------------------------------------------------------
+//  
+void CAMDownloaddb::CreateTableL(RDbDatabase& aDatabase)
+    {
+
+    // Create a table definition
+    CDbColSet* columns=CDbColSet::NewLC();
+
+    // Add Columns
+    TDbCol id(NCol1, EDbColInt32);
+
+    // automatic indexing for items,it is our key field.
+    id.iAttributes=id.EAutoIncrement;
+    columns->AddL(id);
+    columns->AddL(TDbCol(NCol2, EDbColInt32));
+    columns->AddL(TDbCol(NCol3, EDbColInt32));
+    columns->AddL(TDbCol(NCol4, EDbColText8, 255));
+    columns->AddL(TDbCol(NCol5, EDbColInt32));
+
+    // Create a table
+    TRAPD(err, aDatabase.CreateTable(KTableAMMgmtObject, *columns) )
+    ;
+
+    if (err!=KErrNone)
+        User::Leave(err);
+
+    // cleanup the column set
+    CleanupStack::PopAndDestroy(columns);
+
+    }
+
+// ---------------------------------------------------------------------------
+//  CAMDownloaddb::CAMDownloaddb()
+//  Constructor.
+// ---------------------------------------------------------------------------
+// 
+CAMDownloaddb::CAMDownloaddb()
+    {
+    RDEBUG("CAMDownloaddb::CAMDownloaddb(): begin");
+    RDEBUG("CAMDownloaddb::CAMDownloaddb(): end");
+    }
+
+// ---------------------------------------------------------------------------
+//  CAMDownloaddb::~CAMDownloaddb()
+//  Destructor.
+// ---------------------------------------------------------------------------
+// 
+CAMDownloaddb::~CAMDownloaddb()
+    {
+    RDEBUG("CAMDownloaddb::~CAMDownloaddb(): begin");
+
+    iView.Close();
+
+    delete iColSet;
+    iAMObjectTable.Close();
+
+    iDatabase.Close();
+    iFsSession.Close();
+    iRdbSession.Close();
+
+    RDEBUG("CAMDownloaddb::~CAMDownloaddb(): ends");
+    }
+
+CAMDbItem::~CAMDbItem()
+    {
+    delete iTargetURI;
+
+    }
+
+void CAMDownloaddb::GetEntryForLUIDL(RPointerArray<CAMDbItem>& aItemArray,
+        TDesC& aValue)
+    {
+    RDEBUG( "CAMDownloaddb::GetEntryForLUIDL: Step1" );
+    aItemArray.Reset();// first reset the array
+
+    _LIT(KEqualToString,"=%d");
+    _LIT(KQuery, "SELECT * FROM %S WHERE %S");
+
+    RDEBUG( "CAMDownloaddb::GetEntryForLUIDL: Step2" );
+
+    TBuf<100> bufsql;
+    bufsql.Append(KQuery);
+    bufsql.Append(KEqualToString);
+    TLex lex(aValue);
+
+    RDEBUG( "CAMDownloaddb::GetEntryForLUIDL: Step3" );
+
+    TInt value;
+    lex.Val(value);
+
+    TBuf<100> bufsql1;
+    bufsql1.Format(bufsql, &KTableAMMgmtObject, &NCol2, value);
+
+    RDEBUG( "CAMDownloaddb::GetEntryForLUIDL: Step4" );
+
+    ReadItemsL(aItemArray, bufsql1);
+
+    RDEBUG( "CAMDownloaddb::GetEntryForLUIDL: Step5" );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWPInternetAPDB::ReadDbItemsL
+// -----------------------------------------------------------------------------
+//   
+void CAMDownloaddb::ReadDbItemsL(RPointerArray<CAMDbItem>& aItemArray)
+    {
+
+    aItemArray.Reset();// first reset the array
+
+    TFileName sqlQuery;
+
+    // just get all columns & rows of same originator
+    sqlQuery.Copy(_L("SELECT * FROM "));
+    sqlQuery.Append(KTableAMMgmtObject);
+
+    ReadItemsL(aItemArray, sqlQuery);
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWPInternetAPDB::ReadItemsL
+// -----------------------------------------------------------------------------
+// 
+void CAMDownloaddb::ReadItemsL(RPointerArray<CAMDbItem>& aItemArray,
+        TDesC& asqlQuery)
+    {
+
+    RDEBUG( "CAMDownloaddb::ReadItemsL: Step1" );
+
+    RDbView view;
+    view.Prepare(iDatabase, TDbQuery(asqlQuery));
+    CleanupClosePushL(view);
+    view.EvaluateAll();
+    view.FirstL();
+
+    while (view.AtRow())
+        {
+        view.GetL();
+
+        CAMDbItem *dbitem = new(ELeave) CAMDbItem;
+        CleanupStack::PushL(dbitem);
+        dbitem->id = view.ColInt(1);
+        dbitem->iLUID = view.ColInt(2);
+        dbitem->iResult = view.ColInt(3);
+
+        dbitem->iTargetURI= (view.ColDes8(4)).AllocL();
+
+        dbitem->iapid = view.ColInt(5);
+        aItemArray.Append(dbitem);
+        CleanupStack::Pop(dbitem);
+        view.NextL();
+        }
+
+    CleanupStack::PopAndDestroy(); // view
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWPInternetAPDB::SaveToDatabaseL
+// -----------------------------------------------------------------------------
+//   
+void CAMDownloaddb::SaveToDatabaseL(TInt& aIndex, TUint32 aLuid,
+        TInt aResult, const TDesC8& aTargetURI, TUint32 aIapid)
+    {
+
+    iDatabase.Begin();
+
+    TFileName sqlQuery;
+    sqlQuery.Copy(_L("SELECT * FROM "));
+    sqlQuery.Append(KTableAMMgmtObject);
+
+    RDbView view;
+    view.Prepare(iDatabase, TDbQuery(sqlQuery));
+    CleanupClosePushL(view);
+
+    view.InsertL();
+
+    view.SetColL(2, aLuid);
+    view.SetColL(3, aResult);
+    view.SetColL(4, aTargetURI);
+    view.SetColL(5, aIapid);
+
+    view.PutL();
+
+    aIndex = view.ColInt(1);// autoincrement gives us unique index.
+
+    CleanupStack::PopAndDestroy(1); // view
+    iDatabase.Commit();
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWPInternetAPDB::DeleteFromDatabaseL
+// -----------------------------------------------------------------------------
+//
+TBool CAMDownloaddb::DeleteFromDatabaseL(TUint32 aLUID)
+    {
+
+    TBool rowsdeleted = EFalse;
+    TFileName sqlQuery;
+    sqlQuery.Copy(_L("SELECT * FROM "));
+    sqlQuery.Append(KTableAMMgmtObject);
+    sqlQuery.Append(_L(" WHERE "));
+    sqlQuery.Append(NCol2);
+    sqlQuery.Append(_L(" = "));
+    sqlQuery.AppendNum(aLUID);
+
+    iDatabase.Begin();
+
+    RDbView view;
+    // query buffer with index finds only the selected item row.
+    view.Prepare(iDatabase, TDbQuery(sqlQuery));
+    CleanupClosePushL(view);
+
+    view.EvaluateAll();
+    view.FirstL();
+
+    if (!view.IsEmptyL())
+        {
+        // we have autoincrement in index so it should be unique
+        // but just to make sure, we use 'while', instead of 'if'
+        while (view.AtRow())
+            {
+            view.GetL();
+            view.DeleteL();
+            view.NextL();
+            }
+
+        iDatabase.Commit();
+        // compacts the databse, by physically removig deleted data.
+        iDatabase.Compact();
+        rowsdeleted = ETrue;
+        }
+    CleanupStack::PopAndDestroy(1); // view
+
+
+    return rowsdeleted;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/AMPreInstallApp.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,301 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+
+#include <pathinfo.h>
+#include <driveinfo.h>
+#include <apmstd.h>  //for KMaxDataTypeLength
+#include <sisregistrysession.h>
+#include <sisregistrypackage.h>
+#include <e32cmn.h> 
+#include <utf.h>
+#include <sisregistryentry.h>
+#include <caf/caf.h>
+#include <apgcli.h>
+#include <SWInstDefs.h>
+
+#include "AMPreInstallApp.h"
+#include "debug.h"
+
+using namespace NApplicationManagement;
+CAMPreInstallApp* CAMPreInstallApp::NewL()
+    {
+    CAMPreInstallApp* self = CAMPreInstallApp::NewLC();
+    CleanupStack::Pop(self);
+    return self;
+
+    }
+
+
+CAMPreInstallApp* CAMPreInstallApp::NewLC()
+    {
+    CAMPreInstallApp *self = new (ELeave) CAMPreInstallApp();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+
+    }
+CAMPreInstallApp::CAMPreInstallApp()
+    {
+    }
+CAMPreInstallApp::~CAMPreInstallApp()
+    {
+    delete iStorage;
+    iFs.Close();
+    #ifdef RD_MULTIPLE_DRIVE        
+ 		  delete iInstallDocPathArray;
+    #endif    
+    iPreInstalledAppParams.ResetAndDestroy();
+    }
+void CAMPreInstallApp::ConstructL()
+    {
+    iStorage = CDeliveryComponentStorage::NewL();
+    User::LeaveIfError(iFs.Connect() );
+    TPtrC mmcDrive(TParsePtrC( PathInfo::MemoryCardRootPath() ).Drive());
+      iPreInstallPath.Append(mmcDrive);
+      iPreInstallPath.Append(KPreInstallPath);
+    }
+void CAMPreInstallApp::GetPreInstalledAppsL(RPointerArray<
+        TPreInstalledAppParams> &aPreInstalledAppParams)
+    {
+
+    MakeAllInstallPathsL();
+    ListPreInstalledAppL();
+    aPreInstalledAppParams = iPreInstalledAppParams;
+    }
+
+
+void CAMPreInstallApp::ListPreInstalledAppL(const TDesC& installDocPath)
+    {
+
+    RDEBUG("Clist_PreInstallAppUi: ListPreInstalledApp: <<<<");
+    CDir* dir= NULL;
+    TInt err = iFs.GetDir(installDocPath, KEntryAttNormal, ESortByName, dir);
+   // _LIT(KInstallpath,"C:\\private\\10202dce\\");
+    //TInt err = iFs.GetDir(KInstallpath, KEntryAttNormal, ESortByName, dir);
+    RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: err in getting dir list : %d",err);
+    
+    if (err==KErrNone)
+        {
+        CleanupStack::PushL(dir);
+        RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: no of dir's : %d",dir->Count());
+        for (TInt i(0); i < dir->Count(); i++)
+            {
+
+	    RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: <<<< dir entry %d", i);
+            TEntry entry;
+            entry = (*dir)[i];
+            HBufC* pathAndName = HBufC::NewLC(installDocPath.Length()
+                    + entry.iName.Length() );
+            TPtr ptrPathAndName = pathAndName->Des();
+            ptrPathAndName.Append(installDocPath);
+            ptrPathAndName.Append(entry.iName);
+
+            HBufC* mimeType = HBufC::NewLC(KMaxDataTypeLength);
+            //Recognize     
+            if (!RecognizeL(*pathAndName, mimeType))
+                {
+                CleanupStack::PopAndDestroy(mimeType);
+                CleanupStack::PopAndDestroy(pathAndName);
+                continue;
+                }
+
+#ifdef RD_MULTIPLE_DRIVE
+            if (TParsePtrC(installDocPath).Path().CompareF(KPreInstallPath)
+                    == 0)
+#else
+            if (installDocPath.CompareF(iPreInstallPath) == 0)
+#endif
+                {
+
+		RDEBUG("Clist_PreInstallAppUi: ListPreInstalledApp: <<<< Entered installDocPath.CompareF(iPreInstallPath)");
+                Swi::RSisRegistrySession regSession;
+                CleanupClosePushL(regSession);
+                User::LeaveIfError(regSession.Connect() );
+
+                RArray<TUid> uids;
+                CleanupClosePushL(uids);
+
+                regSession.InstalledUidsL(uids);
+
+                RFile temp;
+                User::LeaveIfError(temp.Open(iFs, *pathAndName,
+                        EFileShareReadersOnly | EFileRead) );
+                CleanupClosePushL(temp);
+
+                TUid appUid;
+                TInt uidLen = sizeof(TInt32);
+                TInt seekLen = sizeof(TInt32) + sizeof(TInt32);
+
+                User::LeaveIfError(temp.Seek(ESeekStart, seekLen));
+
+                TPckg<TInt32> uid1(appUid.iUid);
+                User::LeaveIfError(temp.Read(uid1, uidLen));
+                if (uid1.Length() != uidLen)
+                    {
+                    User::Leave(KErrUnderflow);
+                    }
+
+                //checking whether this is installed or not
+                TBool installed = regSession.IsInstalledL(appUid);
+                Swi::RSisRegistryEntry registryEntry;
+                TInt regEntryError = registryEntry.Open(regSession, appUid);
+		RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: RegEntryError : %d",regEntryError);
+
+		//User::LeaveIfError(regEntryError);
+		if (regEntryError == KErrNone)
+		    {
+                CleanupClosePushL(registryEntry);
+                TBool isPreInstalled = registryEntry.PreInstalledL();
+               // TBool isPreInstalled = ETrue;
+
+                RDEBUG_4("Clist_PreInstallAppUi: ListPreInstalledApp: UID is : '0x%X', installed:, preinstalled %d  %d",appUid,installed,isPreInstalled);
+
+                for (TInt i(0); isPreInstalled && i < uids.Count(); i++)
+                    {
+                    if (appUid == uids[i])
+                        {
+
+			RDEBUG("Clist_PreInstallAppUi: appUid == uids[i]");
+                        Swi::CSisRegistryPackage* sisRegistry = NULL;
+                        TRAPD( err, sisRegistry = regSession.SidToPackageL( uids[i] ) ) ;
+                        //User::LeaveIfError(err);
+			if(err == KErrNone)
+			{
+
+			RDEBUG("Clist_PreInstallAppUi: err == KErrNone");
+                        TPreInstalledAppParams *params =
+                                new (ELeave) TPreInstalledAppParams;
+                        params->iPreInstalledAppame.Copy(sisRegistry->Name());
+                        params->iPreInstalledAppVendorName.Copy(
+                                sisRegistry->Vendor());
+                        params->iPreInstalledAppUid = sisRegistry->Uid();
+                        params->iMimeType.Copy(*mimeType);
+                        //Get version
+                        TVersion version = registryEntry.VersionL();
+                        TBuf8<KVersionLength> pkgDes;
+                        pkgDes.AppendNum(version.iMajor);
+                        pkgDes.Append(KLiteralPeriod);
+                        pkgDes.AppendNum(version.iMinor);
+                        params->iVersion.Copy(pkgDes);
+
+                        iPreInstalledAppParams.Append(params);
+
+                        RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App UID is : '0x%X'",appUid);
+                        RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App Name is: %S",&(sisRegistry->Name()));
+                        RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App Vendor is: %S",&(sisRegistry->Vendor()));
+                        RDEBUG_2("Clist_PreInstallAppUi: ListPreInstalledApp: Installed App UID is : '0x%X'",sisRegistry->Uid());
+                        delete sisRegistry;
+			}
+                        continue;
+                        }
+                    }
+
+                CleanupStack::PopAndDestroy(&registryEntry);
+		    }
+                CleanupStack::PopAndDestroy(&temp);
+                CleanupStack::PopAndDestroy(&uids);
+                CleanupStack::PopAndDestroy(&regSession);
+                CleanupStack::PopAndDestroy(mimeType);
+                CleanupStack::PopAndDestroy(pathAndName);
+                }
+            }
+         CleanupStack::PopAndDestroy(dir);
+        }
+    }
+void CAMPreInstallApp::ListPreInstalledAppL()
+    {
+    iPreInstalledAppParams.Reset();
+#ifdef RD_MULTIPLE_DRIVE
+    TInt count = iInstallDocPathArray->Count();
+    for ( TInt index(0); index < count; index++ )
+        {
+        if ( (*iInstallDocPathArray)[index].Length()> 0 )
+            {
+            ListPreInstalledAppL( (*iInstallDocPathArray)[index] );
+            }
+        }
+#else   
+    if (iPreInstallDocumentPath.Length() > 0)
+        {
+        ListPreInstalledAppL(iPreInstallDocumentPath);
+        //_LIT(KInstallpath,"C:\\private\\10202dce\\");
+        //ListPreInstalledAppL(KInstallpath);
+        }
+#endif
+
+    }
+    
+TBool CAMPreInstallApp::RecognizeL(TDesC& aPathAndName, HBufC* aMimeType)
+    {
+    TBool IsOK(ETrue);
+    ContentAccess::CContent* pkgContent = ContentAccess::CContent::NewLC(
+            aPathAndName, ContentAccess::EContentShareReadWrite);
+    
+    TPtr mimePtr(aMimeType->Des());
+    pkgContent->GetStringAttribute(ContentAccess::EMimeType, mimePtr);
+
+    HBufC8* tmpMime8 = HBufC8::NewLC(aMimeType->Length());
+    tmpMime8->Des().Copy(*aMimeType);
+    TPtr8 mimePtr8(tmpMime8->Des());
+
+    if ((mimePtr8 != SwiUI::KSisxMimeType) && (mimePtr8
+            != SwiUI::KSisMimeType) && (mimePtr8 != SwiUI::KPipMimeType))
+        {
+        IsOK = EFalse;
+        }
+    CleanupStack::PopAndDestroy(tmpMime8);
+    CleanupStack::PopAndDestroy(pkgContent);
+    return IsOK;
+
+    }
+void CAMPreInstallApp::MakeAllInstallPathsL()
+    {
+#ifdef RD_MULTIPLE_DRIVE        
+    iInstallDocPathArray = new (ELeave) CDesCArrayFlat( 2 );
+    TDriveList driveList;
+    TInt driveCount = 0;
+    //User::LeaveIfError(iFs.Connect() );
+    User::LeaveIfError( DriveInfo::GetUserVisibleDrives(iFs, driveList,driveCount));
+    TUint driveStatus = 0;
+    for (TInt index(0); index < KMaxDrives; index++)
+        {
+        if (driveList[index])
+            {
+            User::LeaveIfError( DriveInfo::GetDriveStatus(iFs, index,
+                    driveStatus));
+            TFileName path;
+            TDriveUnit driveUnit(index);
+            if ( !(driveStatus & DriveInfo::EDriveRemote ))
+                {
+                if (driveStatus & DriveInfo::EDriveRemovable)
+                    {
+                    path.Zero();
+                    path.Append(driveUnit.Name() );
+                    path.Append(KPreInstallPath);
+                    iInstallDocPathArray->AppendL(path);
+                    }
+                }
+            }
+        }
+    //iFs.Close();
+#else   
+    TPtrC mmcDrive(TParsePtrC( PathInfo::MemoryCardRootPath() ).Drive());
+    iPreInstallDocumentPath.Append(mmcDrive);
+    iPreInstallDocumentPath.Append(KPreInstallPath);
+#endif //RD_MULTIPLE_DRIVE 
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/AMSmlHelper.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,326 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+
+#include <SyncMLClientDM.h>
+#include <rconnmon.h> 
+#include "amsmlhelper.h"
+#include "debug.h"
+
+#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <es_sock.h>
+#else
+#include <es_sock.h>
+#include <es_enum_internal.h>
+#include <es_sock_partner.h>
+#endif
+#include <es_enum.h>
+
+const TUid KUidNSmlMediumTypeInternet =
+    {
+    0x101F99F0
+    };
+const TUid KSosServerUid =
+    {
+    0x101F99FB
+    };
+
+const TInt KBufSize32 = 32;
+
+using namespace NApplicationManagement;
+
+/*
+ void CApplicationManagementServer::StartDMSessionL( )
+ {
+ RSyncMLSession ses;
+ ses.OpenL() ;
+ 
+ CleanupClosePushL( ses );
+ TSmlJobId jid;
+ TSmlUsageType jtype;
+ ses.CurrentJobL(jid, jtype );
+ RSyncMLDevManJob job;
+ job.OpenL( ses, jid );
+ CleanupClosePushL( job ) ;
+ TSmlProfileId pid( job.Profile() );
+ RSyncMLDevManProfile prof;
+ prof.OpenL( ses, pid, ESmlOpenRead );
+ 
+ TBuf<64> serverid;
+ serverid.Copy( prof.ServerId()) ;
+ prof.Close();
+ 
+ CleanupStack::PopAndDestroy( &job )	;
+ CleanupStack::PopAndDestroy( &ses )	;
+ }
+ */
+
+TInt SmlHelper::GetCurrentProfileIdL(TSmlProfileId &aProfile)
+    {
+    RSyncMLSession ses;
+    ses.OpenL() ;
+    CleanupClosePushL(ses);
+    TSmlJobId jid;
+    TSmlUsageType jtype;
+    ses.CurrentJobL(jid, jtype);
+    RSyncMLDevManJob job;
+    job.OpenL(ses, jid);
+    CleanupClosePushL(job) ;
+    TSmlProfileId pid(job.Profile() );
+    aProfile = pid;
+
+    CleanupStack::PopAndDestroy( &job) ;
+    CleanupStack::PopAndDestroy( &ses) ;
+    return 0;
+    }
+
+HBufC8* SmlHelper::GetCurrentServerIDL()
+    {
+    HBufC8 *serverid;
+    //TBufC<256> serverid;
+    RSyncMLSession ses;
+    ses.OpenL() ;
+    CleanupClosePushL(ses);
+    TSmlJobId jid;
+    TSmlUsageType jtype;
+    ses.CurrentJobL(jid, jtype);
+    RSyncMLDevManJob job;
+    job.OpenL(ses, jid);
+    CleanupClosePushL(job) ;
+    TSmlProfileId pid(job.Profile() );
+    //aProfile = pid;
+    RSyncMLDevManProfile syncProfile;
+    syncProfile.OpenL(ses, pid);
+    RDEBUG("	5/8");
+    CleanupClosePushL(syncProfile);
+
+    serverid = syncProfile.ServerId().AllocLC();
+
+    CleanupStack::Pop(); // serverid
+
+    CleanupStack::PopAndDestroy( &syncProfile);
+    CleanupStack::PopAndDestroy( &job) ;
+    CleanupStack::PopAndDestroy( &ses) ;
+
+    return serverid;
+    }
+
+TInt SmlHelper::LaunchSessionL(TSmlProfileId &aProfile)
+    {
+    if (aProfile > -1)
+        {
+        RSyncMLSession syncSession;
+        RSyncMLConnection conn;
+        RSyncMLDevManJob dmJob;
+        RSyncMLDevManProfile dmProfile;
+
+        //TSmlProfileId id ;
+        TSmlConnectionId cid;
+        syncSession.OpenL();
+        CleanupClosePushL(syncSession);
+
+        TRAPD( err, dmProfile.OpenL( syncSession, aProfile, ESmlOpenRead ) )
+        if (err == KErrNone)
+            {
+            CleanupClosePushL(dmProfile);
+            conn.OpenL(dmProfile, KUidNSmlMediumTypeInternet.iUid);
+            CleanupStack::PopAndDestroy( &dmProfile) ;
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+            cid = conn.Identifier();
+#else
+            cid = conn.ConnectionId();
+#endif
+            conn.Close();
+            dmJob.CreateL(syncSession, aProfile, cid);
+            dmJob.Close();
+            }
+        CleanupStack::PopAndDestroy( &syncSession) ; //
+        return err;
+        }
+    else
+        {
+        return KErrArgument;
+        }
+    }
+
+void SmlHelper::GetDefaultIAPFromDMProfileL(TInt& aDefaultIAP)
+    {
+    RDEBUG("ApplicationManagementServer::GetDefaultIAPFromDMProfileL() - start");
+
+    // first try to obtain the current profile id
+    RSyncMLSession ses;
+    ses.OpenL();
+    RDEBUG("	1/8");
+    CleanupClosePushL(ses);
+
+    TSmlJobId jid;
+    TSmlUsageType jtype;
+    ses.CurrentJobL(jid, jtype);
+    RDEBUG("	2/8");
+    RSyncMLDevManJob job;
+    job.OpenL(ses, jid);
+    RDEBUG("	3/8");
+    CleanupClosePushL(job);
+    // get profile id
+    TSmlProfileId pid(job.Profile() );
+    CleanupStack::PopAndDestroy( &job);
+
+    TBuf8<KBufSize32> key;
+    TBuf<KBufSize32> value;
+    TInt num = KErrNotFound;
+
+    // get connection property name first
+    GetConnectionPropertyNameL(ses, key, EPropertyIntenetAccessPoint);
+    RDEBUG("	4/8");
+    // we need to open sync profile in ordere to open the RSyncMLConnection
+    RSyncMLDevManProfile syncProfile;
+    syncProfile.OpenL(ses, pid);
+    RDEBUG("	5/8");
+    CleanupClosePushL(syncProfile);
+
+    TSmlTransportId transport;
+    RArray<TSmlTransportId> connections;
+    _LIT8( KNSmlIAPId, "NSmlIapId" );
+
+    // now open the syncML connection
+    RSyncMLConnection syncConnection;
+    syncProfile.ListConnectionsL(connections);
+
+    transport = connections[0];
+    syncConnection.OpenL(syncProfile, transport);
+    RDEBUG("	6/8");
+    CleanupClosePushL(syncConnection);
+
+    const TDesC8& source(syncConnection.GetPropertyL(KNSmlIAPId) );
+    RDEBUG("	7/8");
+    value.Copy(source.Left(value.MaxLength() ) );
+    User::LeaveIfError(StrToInt(value, num) );
+    RDEBUG("	8/8");
+
+    aDefaultIAP = num;
+
+    // If there is no default Access point in DM profile then use
+    // currently used access point by DM session
+
+    if (aDefaultIAP == -2)
+        {
+
+        TInt sockIapid = -1;
+
+        RSocketServ serv;
+        CleanupClosePushL(serv);
+        User::LeaveIfError(serv.Connect() );
+
+        RConnection conn;
+        CleanupClosePushL(conn);
+        User::LeaveIfError(conn.Open(serv) );
+
+        TUint count( 0);
+        User::LeaveIfError(conn.EnumerateConnections(count) );
+        // enumerate connections
+        for (TUint idx=1; idx<=count; ++idx)
+            {
+            TConnectionInfo connectionInfo;
+            TConnectionInfoBuf connInfo(connectionInfo);
+
+            TInt err = conn.GetConnectionInfo(idx, connInfo); // iapid
+            if (err != KErrNone)
+                {
+                CleanupStack::PopAndDestroy( 2); // conn, serv
+                User::Leave(err);
+                }
+            // enumerate connectionclients
+            TConnectionEnumArg conArg;
+            conArg.iIndex = idx;
+            TConnEnumArgBuf conArgBuf(conArg);
+            err=conn.Control(KCOLConnection, KCoEnumerateConnectionClients,
+                    conArgBuf);
+            if (err != KErrNone)
+                {
+                CleanupStack::PopAndDestroy( 2); // conn, serv
+                User::Leave(err);
+                }
+            TInt cliCount = conArgBuf().iCount;
+            for (TUint j=1; j<=cliCount; ++j)
+                {
+                TConnectionGetClientInfoArg conCliInfo;
+                conCliInfo.iIndex = j;
+                TConnGetClientInfoArgBuf conCliInfoBuf(conCliInfo);
+                err=conn.Control(KCOLConnection, KCoGetConnectionClientInfo,
+                        conCliInfoBuf);
+
+                if (err != KErrNone)
+                    {
+                    CleanupStack::PopAndDestroy( 2); // conn, serv
+                    User::Leave(err);
+                    }
+                TConnectionClientInfo conCliInf = conCliInfoBuf().iClientInfo;
+                TUid uid = conCliInf.iUid;
+                if (uid == KSosServerUid)
+                    {
+                    sockIapid = connInfo().iIapId;
+
+                    }
+
+                }
+            }
+        CleanupStack::PopAndDestroy( 2); // conn, serv		
+
+        aDefaultIAP = sockIapid;
+
+        }
+    // get profile's server id
+    //aServerId = syncProfile.ServerId().AllocL();
+
+    CleanupStack::PopAndDestroy( &syncConnection);
+    CleanupStack::PopAndDestroy( &syncProfile);
+
+    CleanupStack::PopAndDestroy( &ses);
+    connections.Close();
+    RDEBUG("ApplicationManagementServer::GetDefaultIAPFromDMProfileL() - end");
+    }
+
+void SmlHelper::GetConnectionPropertyNameL(RSyncMLSession& aSyncSession,
+        TDes8& aText, TInt aPropertyPos)
+    {
+    RDEBUG("ApplicationManagementServer::GetConnectionPropertyNameL() - start");
+
+    // at the moment RSyncMLTransport is only needed
+    // for internet connection settings
+    RSyncMLTransport transport;
+    CleanupClosePushL(transport);
+    transport.OpenL(aSyncSession, KUidNSmlMediumTypeInternet.iUid);
+
+    const CSyncMLTransportPropertiesArray& arr = transport.Properties();
+
+    __ASSERT_DEBUG( arr.Count()> aPropertyPos, User::Panic(_L("invalid count"), KErrGeneral) );
+
+    const TSyncMLTransportPropertyInfo& info = arr.At(aPropertyPos);
+    aText = info.iName;
+    CleanupStack::PopAndDestroy( &transport);
+
+    RDEBUG("ApplicationManagementServer::GetConnectionPropertyNameL() - end");
+    }
+
+TInt SmlHelper::StrToInt(const TDesC& aText, TInt& aNum)
+    {
+    TLex lex(aText);
+    TInt err = lex.Val(aNum);
+    return err;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/ApplicationManagementJavaUtility.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -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: Implementation of applicationmanagement components
+ *
+ */
+
+//	CLASS HEADER
+
+#include <e32property.h>
+#include <javadomainpskeys.h>
+#include <javaregistryincludes.h>
+#include <appversion.h>
+#include "ApplicationManagementJavaUtility.h"
+#include "debug.h"
+//  INTERNAL INCLUDES
+
+
+using namespace NApplicationManagement;
+
+//----------------------------------------------------------------------------
+// 
+//----------------------------------------------------------------------------
+// CONSTRUCTION
+CApplicationManagementJavaUtility* CApplicationManagementJavaUtility::NewL()
+    {
+    CApplicationManagementJavaUtility* self =
+            CApplicationManagementJavaUtility::NewLC();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+//----------------------------------------------------------------------------
+// 
+//----------------------------------------------------------------------------
+//
+CApplicationManagementJavaUtility* CApplicationManagementJavaUtility::NewLC()
+    {
+    CApplicationManagementJavaUtility* self = new( ELeave ) CApplicationManagementJavaUtility();
+    CleanupStack::PushL(self);
+
+    self->ConstructL();
+    return self;
+    }
+
+//----------------------------------------------------------------------------
+// 
+//----------------------------------------------------------------------------
+// Destructor (virtual by CBase)
+CApplicationManagementJavaUtility::~CApplicationManagementJavaUtility()
+    {
+
+    if (iJavaRegistry)
+        {
+        delete iJavaRegistry;
+        }
+    }
+
+//----------------------------------------------------------------------------
+// 
+//----------------------------------------------------------------------------
+// Default constructor
+CApplicationManagementJavaUtility::CApplicationManagementJavaUtility()
+    {
+    }
+
+//----------------------------------------------------------------------------
+// 
+//----------------------------------------------------------------------------
+// Second phase construct
+void CApplicationManagementJavaUtility::ConstructL()
+    {
+    RefreshJavaRegistryL();
+    }
+
+//  METHODS
+
+//----------------------------------------------------------------------------
+// 
+//----------------------------------------------------------------------------
+//
+TBool CApplicationManagementJavaUtility::FindInstalledJavaUidL(
+        const TUid &aUid) const
+    {
+    TBool ret;
+    ret = iJavaRegistry->RegistryEntryExistsL(aUid);
+    return ret;
+
+    }
+
+//----------------------------------------------------------------------------
+// 
+//----------------------------------------------------------------------------
+//
+void CApplicationManagementJavaUtility::InstalledSuiteUidsL(
+        RArray <TUid>& aUids)
+    {
+    iJavaRegistry->GetRegistryEntryUidsL(aUids);
+    }
+
+//----------------------------------------------------------------------------
+// 
+//----------------------------------------------------------------------------
+//
+void CApplicationManagementJavaUtility::JavaUidsL(RArray<TUid> &aUids)
+    {
+    iJavaRegistry->GetRegistryEntryUidsL(aUids);
+    }
+
+//----------------------------------------------------------------------------
+// 
+//----------------------------------------------------------------------------
+//
+void CApplicationManagementJavaUtility::RefreshJavaRegistryL()
+    {
+    if (iJavaRegistry)
+        {
+        delete iJavaRegistry;
+        iJavaRegistry = NULL;
+        }
+
+    iJavaRegistry = CJavaRegistry::NewL();
+    }
+void CApplicationManagementJavaUtility::GetInstalledMidletParametersL(
+        TMidletParameters& aMidletParameters)
+    {
+    RDEBUG( "CApplicationManagementJavaUtility::GetInstalledMidletParametersL: Start");
+    TInt suiteUid = 0;
+    // Get UID for the latest installed Midlet suite
+    // KPSUidJavaLatestInstallation = 0x10282567
+    RProperty::Get(KUidSystemCategory, KPSUidJavaLatestInstallation, suiteUid);
+
+    if ( !suiteUid)
+        {
+        User::Leave(KErrNotFound);
+        }
+
+    RArray<TUid> uids;
+    CleanupClosePushL(uids);
+
+    Java::CJavaRegistry* javaRegistry;
+    javaRegistry = Java::CJavaRegistry::NewLC();
+
+    Java::CJavaRegistryEntry* regEntry =
+            javaRegistry->RegistryEntryL(TUid::Uid(suiteUid) );
+
+    if (regEntry)
+        {
+        CleanupStack::PushL(regEntry);
+        Java::TJavaRegistryEntryType entryType = regEntry->Type();
+
+        if ( (entryType >= Java::EGeneralPackage ) && (entryType
+                < Java::EGeneralApplication))
+            {
+            //package entry
+            Java::CJavaRegistryPackageEntry * regPackageEntry =
+                    static_cast<Java::CJavaRegistryPackageEntry*>(regEntry );
+            regPackageEntry->GetEmbeddedEntries(uids);
+
+            aMidletParameters.iMidletUid = uids[0]; // conidered the first application from the suite
+            aMidletParameters.iMidletName.Copy(regPackageEntry->Name());
+            aMidletParameters.iMidletVenorName.Copy(regPackageEntry->Vendor());
+
+            TAppVersion version;
+            version = regPackageEntry->Version();
+            _LIT8(KDot,".");
+            aMidletParameters.bufVersion.Num(version.iMajor);
+            aMidletParameters.bufVersion.Append(KDot);
+            aMidletParameters.bufVersion.AppendNum(version.iMinor);
+            }
+        else
+            {
+            //application entry
+            uids.AppendL(regEntry->Uid() );
+            aMidletParameters.iMidletUid = regEntry->Uid();
+            aMidletParameters.iMidletName.Copy(regEntry->Name());
+            //How to get Vendor& version name for java application
+            aMidletParameters.iMidletVenorName.Copy(KNullDesC8);
+            TAppVersion version(0,0,0);
+            _LIT8(KDot,".");
+            aMidletParameters.bufVersion.Num(version.iMajor);
+            aMidletParameters.bufVersion.Append(KDot);
+            aMidletParameters.bufVersion.AppendNum(version.iMinor);
+            }
+        CleanupStack::PopAndDestroy(regEntry);
+        }
+    CleanupStack::PopAndDestroy(javaRegistry);
+    CleanupStack::PopAndDestroy( &uids);
+    RDEBUG( "CApplicationManagementJavaUtility::GetInstalledMidletParametersL: End");
+    }
+//  END OF FILE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/ApplicationManagementJavaUtilityFactory.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -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: Implementation of applicationmanagement components
+ *
+ */
+
+//	CLASS HEADER
+#include "ApplicationManagementUtilityFactory.h"
+#include "ApplicationManagementJavaUtility.h"
+
+using namespace NApplicationManagement;
+
+//  METHODS
+CApplicationManagementUtility* ApplicationManagementUtilityFactory::CreateManagementUtilityL()
+    {
+    return CApplicationManagementJavaUtility::NewL();
+    }
+
+//  END OF FILE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/ApplicationManagementServer.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,3962 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#define __INCLUDE_CAPABILITY_NAMES__
+#include <e32svr.h>
+#include <badesca.h>
+#include <e32cmn.h>
+#include <bautils.h> 
+#include <featmgr.h>
+#include <imcvcodc.h>
+#include <uikon.hrh>
+#include <e32property.h>
+#include <DriveInfo.h>
+#include <SWInstDefs.h>
+#include <PolicyEngineClient.h>
+#include <PolicyEngineXACML.h>
+#include <eikenv.h>
+#include <hbapplication.h>
+#include <apgwgnam.h>
+#include <nsmldmconst.h>
+#include <DevManInternalCRKeys.h>
+#include <apgtask.h>
+#include <apgwgnam.h>
+#include "ampskeys.h"
+#include "amprivateCRKeys.h"
+#include "ApplicationManagementConst.h"
+#include "ApplicationManagementCommon.h"
+#include "ApplicationManagementClientServer.h"
+#include "ApplicationManagementServer.h"
+#include "AMDeploymentComponent.h"
+#include "amsmlhelper.h"
+#include "ApplicationManagementUtility.h"
+#include "ApplicationManagementUtilityFactory.h"
+#include "debug.h"
+#include "coemain.h"
+#include "AMPreInstallApp.h"
+#include "amview.h"
+#include "appmgmtnotifier.h"
+
+using namespace NApplicationManagement;
+
+#ifdef __AM_CONNECT_INSTALLER_ONSTARTUP_	
+
+#pragma message("AM Connecting installer at startup")
+#else
+#pragma message("AM Connecting installer when needed")
+#endif
+// Needed only for jad+jar installation  
+_LIT( KInstallDir, "c:\\temp\\" );
+_LIT8(KMIDletJarURL, "MIDlet-Jar-URL");
+//OMA SCOMO Specific
+_LIT8(KDownloadState, "./SCOMO/Download/");
+_LIT8(KDeliveredState, "./SCOMO/Inventory/Delivered/");
+_LIT8(KDeployedState, "./SCOMO/Inventory/Deployed/");
+
+//Package all the above together into a policy
+CPolicyServer::TPolicy KApplicationManagementSecurityPolicy;
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::ComponentDownloadComplete()
+// ------------------------------------------------------------------------------------------------
+void CApplicationManagementServer::ComponentDownloadComplete(
+        CDeploymentComponent *aComponent, TInt iapid, HBufC8 *aServerId)
+    {
+    TInt err = KErrNone;
+    TRAP( err, DownloadCompleteL( aComponent, iapid, aServerId ));
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::DownloadCompleteL()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::DownloadCompleteL(
+        CDeploymentComponent *aComponent, TInt iapid, HBufC8 *aServerId)
+    {
+    RDEBUG( "ApplicationManagementServer DownloadComplete - start" );
+    __ASSERT_DEBUG( aComponent, User::Invariant() );
+    iComp = aComponent;
+    iStorage->UpdateL(*aComponent);
+    TInt errdownload = KErrNone;
+    TInt errInstall = KErrNone;
+    TInt status = KStatusSuccess;
+
+    if (!aComponent->DownloadFailed())
+        {
+        CDeploymentComponent *old = DoDataUpdateCheckL(*aComponent);
+        TDownloadTarget trgt = aComponent->DownloadTarget();
+        switch (trgt)
+            {
+            case EDeliver:
+                {
+                break;
+                }
+            case EInstall:
+            case EInstallAndActivate:
+                {
+
+                TRAP(errInstall,DoTheInstallL( *aComponent));
+RDEBUG_2( "ApplicationManagementServer DownloadComplete - start %d", errInstall);
+
+                if (trgt == EInstall && errInstall == KErrNone)
+                    {
+                    iStorage->DeactivateL(*aComponent);
+                    }
+                break;
+                }
+
+            case EUpdate:
+            case EUpdateAndActivate:
+                {
+                if (old)
+                    {
+                    FullUpdateL(*aComponent, *old);
+                    if (trgt == EUpdate)
+                        {
+                        iStorage->DeactivateL(*aComponent);
+                        }
+                    }
+                break;
+                }
+            default:
+                {
+                break;
+                }
+            }
+        }
+    else
+        {
+        errdownload = aComponent->DownloadStatus();
+        }
+
+    RDEBUG( "ApplicationManagementServer DownloadComplete - Start Send to background" );
+    //Download Completed/ Failed or installation success/ failure Send server to Background.
+
+    iOMASCOMOEnabled = IsOMASCOMOEnabledL();
+    
+    m_Window->lower();
+    
+    if (iOMASCOMOEnabled)
+        {
+        status = GetErrorStatus(errdownload, errInstall);
+
+        TInt ASyncSupported = -1;
+
+        CRepository *repository = CRepository::NewLC(
+                KUidPSApplicationManagementKeys);
+        repository->Get(KAsyncEnabled, ASyncSupported);
+        CleanupStack::PopAndDestroy();
+
+        // For Sync Reporting
+        if (!ASyncSupported)
+            {
+            // Update Central Repository with proper error code for Sync
+
+            CRepository *repository = CRepository::NewLC(
+                    KUidPSApplicationManagementKeys);
+            repository->Set(KAMSyncStatus, status);
+            CleanupStack::PopAndDestroy();
+
+            RProperty counter;
+
+            TInt r = counter.Attach(KUidPSApplicationManagementKeys,
+                    KSyncNotifier, EOwnerThread);
+            User::LeaveIfError(r);
+
+            TInt err = counter.Set(KErrCancel);
+            User::LeaveIfError(err);
+            counter.Close();
+            }
+        else// Do AsyncReporting
+            {
+
+            RDEBUG( "CApplicationManagementServer::ASync Reporting Step 1" );
+
+            // Get deployement component entries
+            TInt internalid = aComponent->InternalId();
+
+            RDEBUG( "CApplicationManagementServer::ASync Reporting Step 2" );
+
+            TBuf8<256> targetURI;
+
+            TDeploymentComponentState state = aComponent->State();
+
+            RDEBUG( "CApplicationManagementServer::ASync Reporting Step 3" );
+
+            if (state == EDCSDownload)
+                {
+
+                RDEBUG( "CApplicationManagementServer::ASync EDCSDownload Start" );
+
+                targetURI.Append(KDownloadState);
+                targetURI.Append(aComponent->UserId());
+
+                RDEBUG( "CApplicationManagementServer::ASync EDCSDownload End" );
+
+                }
+            else if (state == EDCSDelivered)
+                {
+                RDEBUG( "CApplicationManagementServer::ASync EDCSDelivered Start" );
+
+                targetURI.Append(KDeliveredState);
+                targetURI.Append(aComponent->UserId());
+
+                RDEBUG( "CApplicationManagementServer::ASync EDCSDelivered End" );
+
+                }
+            else if (state == EDCSActive || state == EDCSInactive)
+                {
+
+                RDEBUG( "CApplicationManagementServer::ASync EDCSActive Start" );
+
+                targetURI.Append(KDeployedState);
+                targetURI.Append(aComponent->UserId());
+
+                RDEBUG( "CApplicationManagementServer::ASync EDCSActive End" );
+                }
+
+            //Save Entry to database with status and target URI of deployment component
+            TInt iapidval = 2;
+            TRAPD( err1, SmlHelper::GetDefaultIAPFromDMProfileL( iapid ) );
+            if (err1 == KErrNone)
+                {
+                RDEBUG_2("Application Mgmt Server service::DownloadCompleteL iapid to : %d", iapid );
+                }
+
+            TInt index;
+            iAMServerDB->SaveToDatabaseL(index, internalid, status,
+                    targetURI, iapidval);
+
+            RDEBUG( "CApplicationManagementServer::ASync SaveToDatabaseL completed" );
+
+            EnableDMNetworkMonL(iapid, aServerId);
+            }
+        }
+    int value = 0 ;
+    int err = RProperty::Set(TUid::Uid(KOmaDMAppUid), KDownloadActive, value);
+    RDEBUG_2("RProperty set (%d)", err  );
+    if (iDownloadMngr->DownloadCount() == 0)
+        {
+
+        RDEBUG_2( "CApplicationManagementServer::ConstructL - ERROR leaving cannot connect installer: %d", iSessionCount );
+
+        // Is session count is not modified whenever there is error then at the end of download complete decrement
+        //  the session count.
+
+        if (status != KStatusSuccess && iSessionCount != 0)
+            {
+            iSessionCount--;
+            }
+
+        if (iSessionCount == 0)
+            {
+            iShutdown.Start();    
+            }
+        }
+    aComponent->SetDriveSelectionStatus(false);
+    RDEBUG( "ApplicationManagementServer DownloadComplete - end" );
+    }
+
+void CApplicationManagementServer::InstallationCancelled()
+	{
+		iInstaller.CancelOperation();
+	}
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::IsOMASCOMOEnabledL()
+// ------------------------------------------------------------------------------------------------
+
+TBool CApplicationManagementServer::IsOMASCOMOEnabledL()
+    {
+    RDEBUG( "CApplicationManagementServer::IsOMASCOMOEnabledL Start" );
+
+    TInt adapterValue;
+
+    CRepository *repository = CRepository::NewLC(
+            KCRUidPrivateApplicationManagementKeys);
+    repository->Get(KAMAdapterValue, adapterValue);
+    CleanupStack::PopAndDestroy();
+
+    RDEBUG( "CApplicationManagementServer::IsOMASCOMOEnabledL End" );
+
+    if (adapterValue == 0 || adapterValue == 1)
+        return EFalse;
+    else
+        return ETrue;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::GetErrorStatus()
+// ------------------------------------------------------------------------------------------------
+TInt CApplicationManagementServer::GetErrorStatus(TInt aErrorDownload,
+        TInt aErrorInstall)
+    {
+    TInt status = KStatusSuccess;
+
+    if (aErrorDownload != KErrNone)
+        {
+        if (aErrorDownload == KStatusUserCancelled || aErrorDownload
+                == KStatusDowloadFailedOOM || aErrorDownload
+                == KStatusUnSupportedEnvironment || aErrorDownload
+                == KStatusAlternateDownldAuthFail || aErrorDownload
+                == KStatusAltDowldUnavailable)
+            {
+            status = aErrorDownload;
+            }
+        else
+            status = KStatusDownloadFailed;
+        }
+
+    else if (aErrorInstall != KErrNone)
+        {
+        if (aErrorInstall == SwiUI::KSWInstErrSecurityFailure)
+            status = KStatusPkgValidationFailed;
+        if (aErrorInstall == SwiUI::KSWInstErrInsufficientMemory)
+            status = KStatusInstallFailedOOM;
+	  if (aErrorInstall == KStatusUserCancelled)
+		status = KStatusUserCancelled;
+        else
+            status = KStatusInstallFailed;
+
+        }
+
+    return status;
+
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::EnableDMNetworkMonL()
+// ------------------------------------------------------------------------------------------------
+void CApplicationManagementServer::EnableDMNetworkMonL(TInt iapid,
+        HBufC8 *aServerId)
+    {
+    TInt retryenabled = 1;
+    _LIT( KNetMon,"\\dmnetworkmon.exe" );
+
+    // Enable DM Network Monitoring for retry of Generic alert in case of N/W loss
+
+    CRepository *repository = CRepository::NewLC(
+            KCRUidDeviceManagementInternalKeys);
+    TInt err_val = repository->Set(KDevManEnableDMNetworkMon, retryenabled);
+    RDEBUG_2( "CApplicationManagementServer::EnableDMNetworkMonL Retry enabled err: %d", err_val );
+    RDEBUG_2( "CApplicationManagementServer::EnableDMNetworkMonL Retry enabled value: %d", retryenabled );
+
+    err_val = repository->Set(KDevManIapIdKey, iapid);
+    RDEBUG_2( "CApplicationManagementServer::EnableDMNetworkMonL devmaniapid: %d", err_val );
+    RDEBUG_2( "CApplicationManagementServer::EnableDMNetworkMonL iap id: %d", iapid );
+
+    err_val = repository->Set(KDevManServerIdKey, *aServerId);
+    RDEBUG_2( "CApplicationManagementServer::EnableDMNetworkMonL serveridkey: %d", err_val );
+
+    TBuf<256> buf1;
+    buf1.Copy(*aServerId);
+    RDEBUG_2( "Server ID -  '%S'", &buf1);
+
+    CleanupStack::PopAndDestroy();
+
+    // create NetMon EXE
+    RProcess rp;
+    TInt err = rp.Create(KNetMon, KNullDesC);
+    User::LeaveIfError(err);
+    TRequestStatus stat;
+    rp.Rendezvous(stat);
+
+    if (stat != KRequestPending)
+        rp.Kill(0); // abort startup
+    else
+        rp.Resume(); // logon OK - start the server
+    TInt r = (rp.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
+    rp.Close();
+
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::CApplicationManagementServer
+// ------------------------------------------------------------------------------------------------
+
+inline CApplicationManagementServer::CApplicationManagementServer() :
+    CPolicyServer(0, KApplicationManagementSecurityPolicy, ESharableSessions)
+    {
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::AddSession()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::AddSession()
+    {
+    // A new session is being created
+    RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::AddSession" );
+    ++iSessionCount;
+
+    // Cancel the shutdown timer if it was running
+    iShutdown.Cancel();
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::DropSession()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::DropSession()
+    {
+    // A session is being destroyed
+    RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::DropSession" );
+
+    // Start the shutdown timer if it is the last session
+    if (--iSessionCount == 0)
+        {
+        if (iDownloadMngr->DownloadCount() > 0)
+            {
+            RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::DropSession download in progress" );
+            }
+        else
+            {
+            iShutdown.Start();
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::AddDownloadL( CDeploymentComponent *aComponent )
+// -----------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::AddDownloadL(
+        CDeploymentComponent *aComponent)
+    {
+    __ASSERT_DEBUG( aComponent, User::Invariant() );
+
+    RDEBUG( "CApplicationManagementServer::AddDownloadL Start" );
+
+    iDownloadMngr->AddDownloadL(aComponent);
+
+    RDEBUG( "CApplicationManagementServer::AddDownloadL End" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer
+// -----------------------------------------------------------------------------
+
+CServer2* CApplicationManagementServer::NewL(HbMainWindow *mainWindow)
+    {
+    //specifies all connect attempts should pass
+    KApplicationManagementSecurityPolicy.iOnConnect
+            = CPolicyServer::EAlwaysPass;
+    KApplicationManagementSecurityPolicy.iRangeCount
+            = KApplicationManagementRangeCount; //number of ranges                                   
+    KApplicationManagementSecurityPolicy.iRanges
+            = KApplicationManagementRanges;
+    KApplicationManagementSecurityPolicy.iElementsIndex
+            = KApplicationManagementSecurityElementsIndex;
+    KApplicationManagementSecurityPolicy.iElements
+            = KApplicationManagementSecurityElements;
+
+    RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::NewLC" );
+
+    CApplicationManagementServer* self =
+            new (ELeave) CApplicationManagementServer;
+    CleanupStack::PushL(self);
+
+    self->ConstructL(mainWindow);
+    CleanupStack::Pop();
+    return self;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CApplicationManagementServer::~CApplicationManagementServer
+// ------------------------------------------------------------------------------------------------
+
+CApplicationManagementServer::~CApplicationManagementServer()
+    {
+    RDEBUG_3("CApplicationManagementServer::~CApplicationManagementServer 0x%X - 0x%X", reinterpret_cast<TUint>(this ),
+            reinterpret_cast<TUint>(this)+sizeof( CApplicationManagementServer ) );
+    FeatureManager::UnInitializeLib();
+    iInstaller.Close();
+    delete iStorage;
+
+    delete iUtility;
+    delete iAMServerDB;
+
+    RProperty::Delete(KUidPSApplicationManagementKeys, KAMServerUIEnabled);
+
+    RProperty::Delete(KUidPSApplicationManagementKeys, KAMOperationNonSilent);
+
+    RProperty::Delete(KUidPSApplicationManagementKeys, KSyncNotifier);
+
+    RProperty::Delete(KUidPSApplicationManagementKeys, KDMUINotClosed);
+
+    iInstallFile.Close();
+    iInstallRFs.Close();
+
+    delete iDownloadMngr;
+
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::HandleAllClientsClosed
+// ------------------------------------------------------------------------------------------------
+void CApplicationManagementServer::HandleAllClientsClosed()
+    {
+    // Do Nothing
+    RDEBUG( "CApplicationManagementServer::HandleAllClientsClosed" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::ConstructL
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::ConstructL(HbMainWindow* aWindow)
+    {
+
+    // 2nd phase construction - ensure the timer and server objects are running
+    RDEBUG( "CApplicationManagementServer::ConstructL - Start" );
+
+    iOMASCOMOEnabled = ETrue;
+    mUserCancelled = 0;
+    TRAPD( errf, FeatureManager::InitializeLibL() );
+    if (errf != KErrNone)
+        {
+        User::Leave(errf);
+        }
+    m_Window = aWindow;
+    RDEBUG( "CApplicationManagementServer::ConstructL - start" );
+    StartL(KApplicationManagementServerName);
+    iStorage = CDeliveryComponentStorage::NewL();
+
+    iUtility
+            = ApplicationManagementUtilityFactory::CreateManagementUtilityL();
+    iDownloadMngr = CAMDownloadStore::NewL(*this);
+    iAMServerDB = CAMDownloaddb::NewL();
+
+    // Define P&S Keys
+    RProperty::Define(KUidPSApplicationManagementKeys, KAMServerUIEnabled,
+            RProperty::EInt);
+
+    RProperty::Define(KUidPSApplicationManagementKeys, KAMOperationNonSilent,
+            RProperty::EInt);
+
+    RProperty::Define(KUidPSApplicationManagementKeys, KSyncNotifier,
+            RProperty::EInt);
+
+    RProperty::Define(KUidPSApplicationManagementKeys, KDMUINotClosed,
+            RProperty::EInt);
+
+    RProperty syncproperty;
+
+    //Ignore error status
+    syncproperty.Attach(KUidPSApplicationManagementKeys, KSyncNotifier,
+            EOwnerThread);
+    syncproperty.Set(KErrNone);
+    syncproperty.Close();
+
+#ifdef __AM_CONNECT_INSTALLER_ONSTARTUP_	
+    TInt err( iInstaller.Connect() );
+    if ( err != KErrNone )
+        {
+        RDEBUG_2( "CApplicationManagementServer::ConstructL - ERROR leaving cannot connect installer: %d", err );
+        User::LeaveIfError( err );
+        }
+#endif	
+    iShutdown.ConstructL();
+    // ensure that the server still exits even if the 1st client fails to connect
+    iShutdown.Start();
+
+    RDEBUG( "CApplicationManagementServer::ConstructL - end" );
+    }
+//---------------------------------------------------------------------------
+// Create a new client session. 
+//---------------------------------------------------------------------------
+CSession2* CApplicationManagementServer::NewSessionL(
+        const TVersion& aVersion, const RMessage2& /*aMessage */) const
+    {
+    RDEBUG( "ApplicationManagementServer: CApplicationManagementServer::NewSessionL" );
+    TVersion ver(KAMVerMajor, KAMVerMinor, KAMVerBuild);
+    if (!User::QueryVersionSupported(ver, aVersion))
+        {
+        RDEBUG( "CApplicationManagementServer::NewSessionL(): wrong version offered -> BAIL OUT!" );
+        User::Leave(KErrNotSupported);
+        }
+    return new (ELeave) CApplicationManagementSession();
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::CustomSecurityCheckL()
+// ------------------------------------------------------------------------------------------------
+
+CPolicyServer::TCustomResult CApplicationManagementServer::CustomSecurityCheckL(
+        const RMessage2& /*aMsg*/, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/)
+    {
+    return EPass;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::InstallCompleteL()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::InstallCompleteL(
+        const CDeploymentComponent& aCompo, const TBool &aInstallSuccess)
+    {
+    RDEBUG_2("CApplicationManagementServer::InstallCompleteL start (%d)", aInstallSuccess);
+
+    iInstallFile.Close();
+    // if java jad + jar install, remove files from c:\temp directory
+    if (CDeploymentComponent::IsJavaMimeL(aCompo.MetaData().MimeType() ) && CDeploymentComponent::IsJavaMimeL(aCompo.Data().MimeType() ) )
+        {
+        TFileName fn, fn2;
+        GenerateTempFileNameL(iInstallRFs, aCompo, fn, fn2);
+        RDEBUG_3("CApplicationManagementServer::InstallCompleteL delete files: (%S) (%S)", &fn, &fn2);
+        User::LeaveIfError(iInstallRFs.Delete(fn));
+        User::LeaveIfError(iInstallRFs.Delete(fn2));
+        }
+         TInt silentsession = 0;
+        TInt r2 = RProperty::Get(KPSUidNSmlSOSServerKey, KNSmlDMSilentJob,
+                silentsession);
+
+	  if(r2 == KErrNone)
+		CApplicationManagementUtility::iSilentSession = silentsession;
+
+        if (!CApplicationManagementUtility::iSilentSession)
+        	{
+    AppMgmtNotifier* note = new AppMgmtNotifier(m_appName);
+    if (aInstallSuccess)
+        {
+        note->showInstallSuccessNote();
+        // Remove temporary files from private directory 
+        const_cast<CDeploymentComponent&> (aCompo).ResetDataL(iInstallRFs);
+        }
+    else if(mUserCancelled == 0)
+        {
+        note->showInstallFailedNote();
+        m_Window->lower();
+        }
+        
+    delete note;
+     }
+     else
+     	{
+     		 if (aInstallSuccess)
+        {
+        
+        const_cast<CDeploymentComponent&> (aCompo).ResetDataL(iInstallRFs);
+        m_Window->lower();
+        }
+     	}
+     
+    iInstallRFs.Close();
+
+    iInstallInProgress = EFalse;
+#ifndef __AM_CONNECT_INSTALLER_ONSTARTUP_	
+    iInstaller.Close();
+#endif
+    RDEBUG("CApplicationManagementServer::InstallCompleteL end");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::GenerateTempJarFileNameL()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::GenerateTempJarFileNameL(RFs &aFs,
+        const TDesC& aMetaSource, TFileName &aFileName) const
+    {
+    if (aMetaSource != KNullDesC)
+        {
+        RFile file;
+        User::LeaveIfError(file.Open(aFs, aMetaSource, EFileRead));
+        CleanupClosePushL(file);
+        TFileName temp;
+        temp = ReadJarFileNameL(file);
+        GenerateTempFileNameL(aFs, temp, aFileName);
+        CleanupStack::PopAndDestroy(&file);
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::GenerateTempFileNameL()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::GenerateTempFileNameL(const RFs &aFs,
+        const TDesC& aSource, TFileName &aFileName) const
+    {
+    if (aSource != KNullDesC)
+        {
+        aFileName.Copy(KInstallDir);
+        TParse p;
+        User::LeaveIfError(aFs.Parse(aSource, p));
+        aFileName.Append(p.NameAndExt());
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::GenerateTempFileNameL()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::GenerateTempFileNameL(RFs &aFs,
+        const CDeploymentComponent& aCompo, TFileName& aSource,
+        TFileName &aMetaSource, TFileName &aFileName,
+        TFileName &aMetaFileName) const
+    {
+    if (!BaflUtils::FolderExists(aFs, KInstallDir))
+        {
+        aFs.MkDirAll(KInstallDir);
+        }
+
+    aMetaSource.Copy(aCompo.MetaData().DataFileName());
+    GenerateTempFileNameL(aFs, aMetaSource, aMetaFileName);
+    aSource.Copy(aCompo.Data().DataFileName());
+    GenerateTempJarFileNameL(aFs, aMetaSource, aFileName);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::GenerateTempFileNameL()
+// ------------------------------------------------------------------------------------------------	
+
+void CApplicationManagementServer::GenerateTempFileNameL(RFs &aFs,
+        const CDeploymentComponent& aCompo, TFileName &aFileName,
+        TFileName &aMetaFileName) const
+    {
+    TFileName ftemp, msource;
+    GenerateTempFileNameL(aFs, aCompo, ftemp, msource, aFileName,
+            aMetaFileName);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::ReadJarFileNameL()
+// ------------------------------------------------------------------------------------------------
+
+TFileName CApplicationManagementServer::ReadJarFileNameL(RFile& aFile) const
+    {
+    TFileName jarFileName;
+    HBufC8* lineBuffer = HBufC8::NewLC(KMaxFileName + 72); // lets hope all lines fit to this
+    TPtr8 linePtr(lineBuffer->Des());
+    TInt length(0);
+    aFile.Size(length);
+    HBufC8* data = HBufC8::NewLC(length);
+    TPtr8 ptr(data->Des());
+    aFile.Read(ptr);
+    RDesReadStream stream(*data);
+    CleanupClosePushL(stream);
+    TInt colonIndex = -1;
+    TInt err(KErrNone);
+    TInt found(KErrNotFound);
+    const TInt KJadNameValueSeparator = 0x3A; //':' 
+
+    for (;;)
+        {
+        TRAP( err, ReadLineL(stream, linePtr) );
+        if (err == KErrNone)
+            {
+            RDEBUG8_2("Read line: (%S)", &linePtr);
+            found = linePtr.Find(KMIDletJarURL);
+            if (found != KErrNotFound && found == 0) // found
+                {
+                TPtrC8 filename(linePtr);
+                colonIndex = linePtr.Locate(KJadNameValueSeparator);
+                if (colonIndex != KErrNotFound)
+                    {
+                    filename.Set(linePtr.Mid(colonIndex + 1)); // get jar filename, format is: MIDlet-Jar-URL: bomber.jar
+                    jarFileName.Copy(filename);
+                    jarFileName.Trim();
+                    break;
+                    }
+                }
+            }
+        else
+            {
+            User::Leave(err);
+            }
+        }
+    CleanupStack::PopAndDestroy(3, lineBuffer); // stream, data
+    return jarFileName;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::ReadLineL()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::ReadLineL(RReadStream& aStream,
+        TDes8& aLineBuffer) const
+    {
+    TBuf8<1> input;
+    const TUint32 LF = 10;
+    const TUint32 CR = 13;
+    TBool endOfLine(EFalse);
+    TInt errRead(KErrNone);
+
+    // reset
+    aLineBuffer.Zero();
+
+    while (!endOfLine)
+        {
+        TRAP(errRead, aStream.ReadL(input, 1));
+
+        if (errRead == KErrEof)
+            {
+            // EOF
+            User::Leave(KErrEof);
+            }
+        // check special characters	
+        if (input[0] == LF)
+            {
+            // End of line
+            endOfLine = ETrue;
+            }
+        else if (input[0] == CR)
+            {
+            // Only end of line if not followed by a LF
+            }
+        else
+            {
+            // We put any other character in the buffer
+            if (aLineBuffer.Length() < aLineBuffer.MaxLength())
+                {
+                aLineBuffer.Append(input[0]);
+                }
+            }
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::PrepareInstallL()
+// ------------------------------------------------------------------------------------------------	
+
+TBool CApplicationManagementServer::PrepareInstallL(
+        const CDeploymentComponent &aComponent, TFileName &aFileName)
+    {
+    RDEBUG( "CApplicationManagementServer::PrepareInstallL" );
+    TBool res(ETrue);
+
+#ifndef __AM_CONNECT_INSTALLER_ONSTARTUP_
+    TInt err(iInstaller.Connect());
+    if (err != KErrNone)
+        {
+        RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - ERROR leaving cannot connect installer: %d", err );
+        User::LeaveIfError(err);
+        }
+    CleanupClosePushL(iInstaller);
+#endif
+
+    RDEBUG( "CApplicationManagementServer::PrepareInstallL - connected to installer" );
+    // Copy data file name (install file)
+    if (aComponent.Data().DataFileName().Length() > 0)
+        {
+        aFileName.Copy(aComponent.Data().DataFileName());
+        }
+    else
+        {
+        // data file has not been created for component!	
+        User::Leave(KErrNotFound);
+        }
+    // Open RFs session
+    User::LeaveIfError(iInstallRFs.Connect());
+    User::LeaveIfError(iInstallRFs.ShareProtected());
+
+    // set installoptions and correct mime type
+    using namespace SwiUI;
+    iInstallOptions = aComponent.InstallOpts().iOptions;
+    TInstallReq req;
+    if (aComponent.Data().MimeType() == SwiUI::KSisMimeType)
+        {
+        //convert if MIME type is application/vnd.symbian.install to x-epoc/x-sisx-app
+        //as installer doesn't support application/vnd.symbian.install MIME type from S60 3rd edition onwards.
+        req.iMIME = SwiUI::KSisxMimeType;
+        }
+    else
+        {
+        req.iMIME = aComponent.Data().MimeType();
+        }
+
+    if (CDeploymentComponent::IsJavaMimeL(aComponent.MetaData().MimeType()))
+        {
+        // Check if both jad and jar files already exist in the phone	
+        if (CDeploymentComponent::IsJavaMimeL(aComponent.Data().MimeType())
+                && aComponent.MetaData().MimeType() == SwiUI::KJadMIMEType)
+            {
+            // Move both files to temporary location and use jad to install java application
+            CFileMan *fm = CFileMan::NewL(iInstallRFs);
+            CleanupStack::PushL(fm);
+            TFileName source, metasource, metatarget;
+            aFileName.Copy(KNullDesC8()); // reset
+            GenerateTempFileNameL(iInstallRFs, aComponent, source,
+                    metasource, aFileName, metatarget);
+
+            RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - temp jar file '%S'", &aFileName );
+            RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - temp jad file '%S'", &metatarget );
+
+            // Copy datafile (jar)
+            TInt copyer(fm->Copy(source, aFileName));
+
+            // Copy metadatafile (jad)
+            TInt copyer2(fm->Copy(metasource, metatarget));
+
+            CleanupStack::PopAndDestroy(fm);
+
+            RDEBUG_3( "CApplicationManagementServer::PrepareInstallL - (%d)-(%d)", copyer, copyer2 );
+
+            if (copyer == KErrNone && copyer2 == KErrNone)
+                {
+                res = ETrue;
+                aFileName = metatarget;
+                req.iMIME = aComponent.MetaData().MimeType();
+                }
+            else
+                {
+                User::Leave(KErrWrite);
+                }
+            }
+        else if (aComponent.MetaData().MimeType() == SwiUI::KJadMIMEType)
+            {
+            aFileName.Copy(aComponent.MetaData().DataFileName());
+            req.iMIME = aComponent.MetaData().MimeType();
+            RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - Using Jad file to install java application: %S", &aFileName );
+            }
+        }
+
+    if (aComponent.GetIAP() > -1)
+        {
+        req.iIAP = aComponent.GetIAP();
+        RDEBUG_2( "CApplicationManagementServer::PrepareInstallL: setting iap to %d", req.iIAP );
+        }
+    else
+        {
+        TInt iap = KErrNotFound;
+        TRAPD( err, SmlHelper::GetDefaultIAPFromDMProfileL( iap ) );
+        if (err == KErrNone)
+            {
+            req.iIAP = iap;
+            RDEBUG_2("	-> using DM profile default IAP: %d", iap);
+            }
+        else
+            {
+            RDEBUG_2("**** ERROR while fetching DM profile default iap: %d", err );
+            }
+        }
+
+    iInstallReq = SwiUI::TInstallReqPckg(req);
+    RDEBUG8_2( "CApplicationManagementServer::PrepareInstallL: mime type is (%S)", &req.iMIME);
+    RDEBUG_2( "CApplicationManagementServer::PrepareInstallL - Using temp file '%S'", &aFileName );
+
+    User::LeaveIfError(iInstallFile.Open(iInstallRFs, aFileName, EFileRead));
+    TInt sz;
+    User::LeaveIfError(iInstallFile.Size(sz));
+    if (!(sz > 0))
+        {
+        res = EFalse;
+        RDEBUG( "CApplicationManagementServer::PrepareInstallL - ERROR size of source file is 0!" );
+        }
+
+#ifndef __AM_CONNECT_INSTALLER_ONSTARTUP_   
+    CleanupStack::Pop(&iInstaller);
+#endif
+
+    RDEBUG( "CApplicationManagementServer::PrepareInstallL end" );
+
+    iAppname = aFileName;
+    
+    return res;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::InstallL()
+// ------------------------------------------------------------------------------------------------	
+
+void CApplicationManagementServer::InstallL(
+        const CDeploymentComponent &aComponent, TRequestStatus &aStatus)
+    {
+    RDEBUG( "CApplicationManagementServer::InstallL (async): begin" );
+
+    if (iInstallInProgress == EFalse)
+        {
+        TFileName fn;
+        TInt type = EInstallWaitDlg;
+        TInt silentsession = 0;
+        TInt r2 = RProperty::Get(KPSUidNSmlSOSServerKey, KNSmlDMSilentJob,
+                silentsession);
+
+	  if(r2 == KErrNone)
+		CApplicationManagementUtility::iSilentSession = silentsession;
+
+        if (!CApplicationManagementUtility::iSilentSession)
+            {
+            m_Dlg = new AMWaitProgDialog(m_appName, *this);
+            m_Dlg->createWaitDialog(type);
+            if (CApplicationManagementUtility::mHidden == 1)
+                {
+                m_Dlg->startIndicator();
+                }
+            else
+                {
+                m_Window->raise();
+                CApplicationManagementUtility::mCurrDlg->setVisible(true);
+                }
+            }
+        if (PrepareInstallL(aComponent, fn))
+            {	  
+            if (m_Dlg)
+                m_Dlg->registerInstallRequest(aStatus);
+            delete iArgu;
+            iArgu = NULL;
+            iArgu = Usif::COpaqueNamedParams::NewL();
+            iArgu->AddIntL(Usif::KSifInParam_InstallSilently, 1);
+            TAMInstallOptions opts = aComponent.InstallOpts();
+            TChar drive = opts.iOptions.iDrive;
+            RFs iFs;
+            TInt driveNumber;
+            iFs.CharToDrive(drive,driveNumber);
+
+            iArgu->AddIntL(Usif::KSifInParam_Drive, driveNumber);  
+
+            delete iResults;
+            iResults = NULL;
+            iResults = Usif::COpaqueNamedParams::NewL();
+
+            RDEBUG_3( "CApplicationManagementServer::InstallL: Install '%S' sizeof opts: %d", &fn, sizeof (aComponent.InstallOpts()));
+		TRAPD( err ,iInstaller.Install( iInstallFile, *iArgu, *iResults, aStatus ) );
+
+            RDEBUG_2( "CApplicationManagementServer::InstallL: status: %d", err);
+            User::LeaveIfError(err);
+            iInstallInProgress = ETrue;
+            }
+        else
+            {
+            RDEBUG( "CApplicationManagementServer::InstallL - PrepareInstallL failed, leaving" );
+            User::Leave(KErrArgument);
+            }
+        }
+    else
+        {
+        RDEBUG( "CApplicationManagementServer::InstallL (async): previous install still in progress...bailing out" );
+        TRequestStatus * status = &aStatus;
+        User::RequestComplete(status, KErrInUse);
+        }
+    RDEBUG( "CApplicationManagementServer::InstallL (async): end" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::PrepareInstallL()
+// ------------------------------------------------------------------------------------------------	
+
+void CApplicationManagementServer::InstallL(
+        const CDeploymentComponent &aComponent)
+    {
+    RDEBUG( "CApplicationManagementServer::InstallL: begin" );
+
+    if (iInstallInProgress == EFalse)
+        {
+        TFileName fn;
+        if (PrepareInstallL(aComponent, fn))
+            {
+            iInstallInProgress = ETrue;
+            RDEBUG_2( "CApplicationManagementServer::InstallL: Install '%S' ", &fn);
+            SwiUI::TInstallOptionsPckg pkg(aComponent.InstallOpts().iOptions);
+            iInstallInProgress = EFalse;
+            }
+        else
+            {
+            RDEBUG( "CApplicationManagementServer::InstallL - PrepareInstallL failed, leaving" );
+            User::Leave(KErrArgument);
+            }
+        }
+    RDEBUG( "CApplicationManagementServer::InstallL: end" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::UninstallL()
+// ------------------------------------------------------------------------------------------------	
+
+void CApplicationManagementServer::UninstallL(
+        const CDeploymentComponent &aComponent, TRequestStatus &aStatus)
+    {
+    RDEBUG( "CApplicationManagementServer::UninstallL: begin" );
+    if (iInstallInProgress == EFalse)
+        {
+        TInt err(iInstaller.Connect());
+        User::LeaveIfError(err);
+        RDEBUG_2( "CApplicationManagementServer::UninstallL: UninstallL '0x%X' ", aComponent.Uid());
+        using namespace SwiUI;
+        iUninstallOptions = aComponent.UninstallOpts();
+
+        delete iArgu;
+        iArgu = NULL;
+        iArgu = Usif::COpaqueNamedParams::NewL();
+        iArgu->AddIntL( Usif::KSifInParam_InstallSilently, 1 );
+
+        delete iResults;
+        iResults = NULL;
+        iResults = Usif::COpaqueNamedParams::NewL();
+        TRAP( err ,iInstaller.Uninstall( aComponent.GetComponentId(), *iArgu, *iResults, aStatus ));
+
+        RDEBUG_2( "CApplicationManagementServer::UninstallL: UninstallL result '0x%X'", err );
+        User::LeaveIfError(err);
+        iInstallInProgress = ETrue;
+        }
+    else
+        {
+        RDEBUG( "CApplicationManagementServer::UninstallL: previous uninstall still in progress...bailing out" );
+        TRequestStatus * status = &aStatus;
+        User::RequestComplete(status, KErrInUse);
+        }
+
+    RDEBUG( "CApplicationManagementServer::UninstallL: end" );
+    }
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::PerformRFSL()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::PerformRFSL()
+    {
+    RDEBUG( "CApplicationManagementServer::PerformRFSL: begin" );
+    const RComponentIdArray &arrt = iStorage->GetComponentIds();
+    TCertInfoPckg *corcert = NULL;
+    for (TInt i(0); i < arrt.Count(); i++)
+        {
+        RDEBUG_3( "CApplicationManagementServer::PerformRFSL processing dc %d of %d", i, arrt.Count() );
+        CDeploymentComponent &c = iStorage->ComponentL(arrt[i]);
+
+        const RCertArray &certs = iStorage->Certificates();
+        TInt index = c.Owner();
+        TCertInfoPckg *certp = NULL;
+        if (index >= 0)
+            {
+            certp = certs[c.Owner()];
+            }
+        if (!corcert && certp)
+            {
+            if (CheckCertL((*certp)()))
+                {
+                corcert = certp;
+                RDEBUG_2( "CApplicationManagementServer::PerformRFSL Found CORP Cert! Removing %d ", i );
+                RemoveInternalL(c);
+                }
+            else
+                {
+                RDEBUG_2( "CApplicationManagementServer::PerformRFSL skipping %d because not corp dc", i );
+                }
+            }
+        else
+            {
+            if (corcert == certp)
+                {
+                RDEBUG_2( "CApplicationManagementServer::PerformRFSL Removing %d ", i );
+                RemoveInternalL(c);
+                }
+            else
+                {
+                RDEBUG_2( "CApplicationManagementServer::PerformRFSL skipping %d because not corp dc", i );
+                }
+            }
+        }
+    RDEBUG( "CApplicationManagementServer::PerformRFSL: end" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::RemoveInternalL()
+// ------------------------------------------------------------------------------------------------
+
+
+void CApplicationManagementServer::RemoveInternalL(
+        const CDeploymentComponent &aCompo, TBool aDoUninstall /* = ETrue */)
+    {
+    RDEBUG_2("CApplicationManagementServer: RemoveInternalL - Remove id: (%d)", aCompo.InternalId() );
+    TInt err(KErrNone);
+    TDeploymentComponentName name = aCompo.ComponentName();
+    TBuf<KDeploymentComponentNameMaxLength> ne;
+    ne.Copy(name);
+    m_appName = QString::fromUtf16(ne.Ptr(), ne.Length());
+
+    RDEBUG("CApplicationManagementServer: RemoveInternalL - step1");
+
+    TInt err1 = KErrNone;
+    if (!err1)
+        {
+        RDEBUG("CApplicationManagementServer: RemoveInternalL - step2");
+
+        aCompo.SetStatusNode(EDelivered_RemoveProgress);
+
+        TDeploymentComponentState st(aCompo.State());
+        if (st == EDCSDelivered || st == EDCSDownload)
+            {
+            RDEBUG("CApplicationManagementServer: RemoveInternalL - step3 start");
+            TRAP(err,iStorage->RemoveL( aCompo.InternalId() ));
+            RDEBUG("CApplicationManagementServer: RemoveInternalL - step4 start");
+            }
+        else if (st == EDCSActive || st == EDCSInactive)
+            {
+            RDEBUG("CApplicationManagementServer: RemoveInternalL - step5 start");
+            if (aDoUninstall)
+                {
+                if (aCompo.Uid() != TUid::Null())
+                    {
+                    TInt nonSilentOperation = KErrNotFound;
+                    iOMASCOMOEnabled = IsOMASCOMOEnabledL();
+                    if (!iOMASCOMOEnabled)
+                        nonSilentOperation = 0;
+                    RDEBUG("CApplicationManagementServer: RemoveInternalL - step5 start 1");
+
+                    TInt silentsession = 0;
+                    RProperty::Get(KPSUidNSmlSOSServerKey, KNSmlDMSilentJob,
+                            silentsession);
+
+                    CApplicationManagementUtility::iSilentSession
+                            = silentsession;
+                    TRequestStatus s1 = KRequestPending;
+                    AppMgmtNotifier* note = new AppMgmtNotifier(m_appName);
+                    
+                    // displaying uninstall confirm notes
+                    if (!CApplicationManagementUtility::iSilentSession)
+                        {
+                        CDialogWait* wait = CDialogWait::NewL(); 
+                        note->showUninstallDialog(aCompo, wait->iStatus);     
+                        m_Window->raise();   
+                        wait->StartWait();
+                        s1=wait->iStatus;
+                        delete wait;
+                        }
+                    if (s1 != KStatusUserCancelled)
+                        {
+                        TInt type = EUninstallWaitDlg;
+                        TRequestStatus s;
+                        if (!CApplicationManagementUtility::iSilentSession)
+                            {
+                            m_Dlg = new AMWaitProgDialog(m_appName, *this);
+                            m_Dlg->createWaitDialog(type);
+                            m_Window->raise();
+                            CApplicationManagementUtility::mCurrDlg->setVisible(
+                                        true);
+                                
+                            }
+                        CDialogWait* wait1 = CDialogWait::NewL();           
+                     
+                        TRAP(err,UninstallL( aCompo, wait1->iStatus ));
+                        //wait till uninstall completes
+                        wait1->StartWait();
+                        if (!CApplicationManagementUtility::iSilentSession)
+                            m_Dlg->closeAMWaitDialog();
+                        m_Window->lower();
+                        s = wait1->iStatus;
+                        delete wait1;
+                        iInstallInProgress = EFalse;
+                        // Capturing Installer errors,if any
+                        err = s.Int();
+                        if (s.Int() == KErrNone)
+                            {
+                            note->showUnInstallSuccessNote();
+                            RDEBUG("CApplicationManagementServer::RemoveInternalL Uninstalled");
+                            }
+                        else
+                            {
+                            note->showUnInstallFailedNote();
+                            if (s.Int() == KErrNotFound)
+                                {
+                                RDEBUG( "CApplicationManagementServer: RemoveInternalL WARNING component was not found by uninstaller" );
+                                }
+                            else
+                                {
+                                RDEBUG_2("CApplicationManagementServer: RemoveInternalL ERROR uninstall failed %d", s.Int() );
+                                }
+                            }
+                        }
+                    else
+                        {
+                        err = SwiUI::KSWInstErrUserCancel;
+                        aCompo.SetStatusNode(EDelivered_RemoveFailed);
+                        RDEBUG( "CApplicationManagementServer: RemoveInternalL User cancelled" );
+                        }
+                    delete note;
+                    }
+                else
+                    {
+                    RDEBUG( "CApplicationManagementServer: RemoveInternalL ERROR component is deployed but has null uid - it cannot be uninstalled!" );
+                    }
+                }
+            else
+                {
+                RDEBUG_2("CApplicationManagementServer: RemoveInternalL - Skipped uninstall of %d", aCompo.InternalId() );
+                }
+            /*
+             *   if (unstall is sucesss) then remove component from storage
+             *   
+             */
+            if (err == KErrNone)
+                {
+                iStorage->RemoveL(aCompo.InternalId());
+                }
+            }
+        else
+            {
+            RDEBUG_2("CApplicationManagementServer: RemoveInternalL ERROR called with illegal state component id %d", aCompo.State() );
+            User::Leave(KErrArgument);
+            }
+        /*  
+         * if error set state to remove failed
+         * Finally call userleaveiferror()
+         * */
+        if (err != KErrNone)
+            {
+            aCompo.SetStatusNode(EDelivered_RemoveFailed);
+            }
+        }
+    else
+        {
+        err = SwiUI::KSWInstErrUserCancel;
+        aCompo.SetStatusNode(EDelivered_RemoveFailed);
+        }
+
+    User::LeaveIfError(err);
+    }
+    
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::CheckCertL()
+// ------------------------------------------------------------------------------------------------
+
+TBool CApplicationManagementServer::CheckCertL(const TCertInfo &aInfo) const
+    {
+    TBool go(EFalse);
+
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        //	#ifdef __SAP_POLICY_MANAGEMENT
+        RPolicyEngine peng;
+
+        // The management session
+        //
+        TInt err(peng.Connect());
+
+        if (err == KErrNone)
+            {
+            CleanupClosePushL(peng);
+            RPolicyRequest rq;
+            err = rq.Open(peng);
+            if (err == KErrNone)
+                {
+                CleanupClosePushL(rq);
+
+                TRequestContext rc;
+
+                using namespace PolicyEngineXACML;
+                using namespace NPolicyConstants;
+
+                rc.AddSubjectAttributeL(KTrustedSubject, aInfo);
+                rc.AddResourceAttributeL(KResourceId, KApplicationManagement,
+                        KStringDataType);
+
+                TResponse resp;
+                err = rq.MakeRequest(rc, resp);
+                if (err == KErrNone)
+                    {
+                    if (resp.GetResponseValue() == EResponsePermit
+#ifdef _DEBUG
+                            || resp.GetResponseValue()
+                                    == EResponseNotApplicable
+#endif 
+                    )
+                        {
+                        go = ETrue;
+                        }
+                    else
+                        {
+                        RDEBUG_2( "CApplicationManagementSession::CheckCertL; Policy response denies access! %d", resp.GetResponseValue());
+                        }
+                    }
+                else
+                    {
+                    RDEBUG_2( "CApplicationManagementSession::CheckCertL; ERROR making policy request! %d", err);
+                    }
+                CleanupStack::PopAndDestroy(&rq);
+                }
+            else
+                {
+                RDEBUG_2( "CApplicationManagementSession::CheckCertL; ERROR Failed to open policy engine session! %d", err);
+                }
+            CleanupStack::PopAndDestroy(&peng);
+            }
+        else
+            {
+            RDEBUG_2( "CApplicationManagementSession::CheckCertL; ERROR Failed to connect policy engine! %d", err);
+            }
+        User::LeaveIfError(err);
+        }
+    else
+        {
+        RDEBUG( "CApplicationManagementSession::CheckCertL; No PolicyManagement by featmgr-> cert ok!" );
+        go = ETrue;
+        }
+    return go;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::HasUidL()
+// ------------------------------------------------------------------------------------------------	
+
+TBool CApplicationManagementServer::HasUidL(const TUid &aUid,
+        CDeploymentComponent *& aCompo, CDeploymentComponent *aIgnored /* = NULL */)
+    {
+    TBool found(EFalse);
+    const RComponentIdArray &arrt = iStorage->GetComponentIds();
+    TInt count(arrt.Count());
+    for (TInt i(0); i < count; i++)
+        {
+        CDeploymentComponent &compo = iStorage->ComponentL(arrt[i]);
+        if (compo.Uid() == aUid)
+            {
+            if (&compo != aIgnored)
+                {
+                aCompo = &compo;
+                found = ETrue;
+                RDEBUG_3( "ApplicationManagementServer: UidExistsL 0x%X - Found NOT ignored %d", aUid.iUid, compo.InternalId() );
+                }
+            else
+                {
+                RDEBUG( "ApplicationManagementServer: UidExistsL - Found ignored " );
+                }
+            }
+        }
+    if (!found)
+        {
+        found = FindInstalledSisUidL(aUid);
+        if (!found)
+            {
+            found = FindInstalledJavaUidL(aUid);
+            }
+        }
+    return found;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::FindInstalledSisUidL()
+// ------------------------------------------------------------------------------------------------	
+
+TBool CApplicationManagementServer::FindInstalledSisUidL(const TUid &aUid) const
+    {
+    TBool found(EFalse);
+    Swi::RSisRegistrySession sisses;
+    TInt r(sisses.Connect());
+    User::LeaveIfError(r);
+    CleanupClosePushL(sisses);
+
+    RArray<TUid> uids;
+    sisses.InstalledUidsL(uids);
+    CleanupClosePushL(uids);
+
+    TInt uidc(uids.Count());
+    for (TInt j(0); found == EFalse && j < uidc; j++)
+        {
+        if (uids[j] == aUid)
+            {
+            found = ETrue;
+            }
+        }
+    CleanupStack::PopAndDestroy(&uids);
+    CleanupStack::PopAndDestroy(&sisses);
+
+    return found;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::FindInstalledJavaUidL()
+// ------------------------------------------------------------------------------------------------	
+
+TBool CApplicationManagementServer::FindInstalledJavaUidL(const TUid &aUid) const
+    {
+    TBool found(EFalse);
+    iUtility->RefreshJavaRegistryL();
+    found = iUtility->FindInstalledJavaUidL(aUid);
+    return found;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::FindNewUid()
+// ------------------------------------------------------------------------------------------------	
+
+TUid CApplicationManagementServer::FindNewUid(const RArray<TUid> &aUidsOrig,
+        const RArray<TUid> &aUidsNew) const
+    {
+    TUid ret(TUid::Null());
+    TInt c1(aUidsOrig.Count());
+    TInt c2(aUidsNew.Count());
+    if (c2 >= c1)
+        {
+        for (TInt i(c2 - 1); i >= 0 && !ret.iUid; i--)
+            {
+            if (aUidsOrig.Find(aUidsNew[i]) == KErrNotFound)
+                {
+                ret = aUidsNew[i];
+                }
+            }
+        }
+    return ret;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::JavaUidsL()
+// ------------------------------------------------------------------------------------------------	
+
+void CApplicationManagementServer::JavaUidsL(RArray<TUid> &aUids) const
+    {
+    iUtility->RefreshJavaRegistryL();
+    iUtility->JavaUidsL(aUids);
+    }
+
+void CApplicationManagementServer::CheckforDuplicateMidletsL(
+        TMidletParameters& amidletParameters)
+    {
+    RDEBUG( "CApplicationManagementServer::CheckforDuplicateMidletsL: Start");
+    const RComponentIdArray &arrt = iStorage->GetComponentIds();
+    TInt cont(arrt.Count());
+    for (TInt i( 0); i < cont; i++)
+     {
+     CDeploymentComponent &compo = iStorage->ComponentL(arrt[i]);
+     if (((compo.State() == EDCSActive) || (compo.State() == EDCSInactive ))
+     && (compo.MidletName()== amidletParameters.iMidletName)
+     && (compo.MidletVendor()== amidletParameters.iMidletVenorName))
+     {
+     //remove old one
+     iStorage->RemoveL(compo.InternalId() );
+     }
+     }
+
+    RDEBUG( "CApplicationManagementServer::CheckforDuplicateMidletsL: End");
+    }
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::JavaInstallL()
+// ------------------------------------------------------------------------------------------------	
+
+void CApplicationManagementServer::JavaInstallL(CDeploymentComponent &aCompo)
+    {
+    RDEBUG( "CApplicationManagementServer::JavaInstallL: Start");
+
+    //TRequestStatus s;
+    TInt err(KErrNone);
+    // set state to install progressf
+    CDialogWait* wait = CDialogWait::NewL();
+    aCompo.SetStatusNode(EDelivered_InstallProgress);
+    TRAP(err,InstallL( aCompo,wait->iStatus ));
+    if (err != KErrNone)
+        {
+        aCompo.SetStatusNode(EDelivered_InstalledFailedWithData);
+        User::Leave(err);
+        }
+    wait->StartWait();
+    if (!CApplicationManagementUtility::iSilentSession && CApplicationManagementUtility::mCurrDlg)
+        m_Dlg->closeAMWaitDialog();
+    m_Window->lower();
+    TRequestStatus s1 = wait->iStatus;
+    delete wait;
+    RDEBUG_2( "ApplicationManagementSession: JavaInstallL 1 failed with code %d",
+                s1.Int() );
+
+    TInt usifdeplid = -1;
+        if (iResults && wait->iStatus.Int()!=KErrCancel)
+	  {
+            iResults->GetIntByNameL(Usif::KSifOutParam_ComponentId, usifdeplid);
+    		RDEBUG_2( "ApplicationManagementSession: JavaInstallL usifdeplid %d",
+                usifdeplid);
+
+	  }
+      RDEBUG( "wait->StartWait() CApplicationManagementServer::javainstallL Step3");
+
+        aCompo.SetComponentId(usifdeplid);
+
+         s1 = wait->iStatus;
+        delete wait;
+        RDEBUG_2("ApplicationManagementSession: javainstallL with code %d",
+                        s1.Int() );
+    if (s1 == KErrCancel)
+        {
+        RDEBUG_2( "ApplicationManagementSession: JavaInstallL failed with code %d",
+                s1.Int() );
+        // set state to install failed with data
+        aCompo.SetStatusNode(EDelivered_InstalledFailedWithData);
+        User::Leave(s1.Int());
+        }
+    else
+        {
+        TMidletParameters midletParameters;
+        iUtility->RefreshJavaRegistryL();
+        //Ignore if any error comes
+        TRAPD(err,iUtility->GetInstalledMidletParametersL(midletParameters));
+        TRAP(err,CheckforDuplicateMidletsL(midletParameters));
+
+        if (err != KErrNone)
+            {
+            aCompo.SetStatusNode(EDelivered_InstalledFailedWithData);
+            User::Leave(err);
+            }
+        else
+            {
+            aCompo.SetStatusNode(EIdle);
+            }
+        aCompo.SetUid(midletParameters.iMidletUid);
+
+        RDEBUG( "CApplicationManagementServer::JavaInstallL: Step1");
+        if (aCompo.ComponentVersion() == KNullDesC8)
+            {
+            aCompo.SetVersionL(midletParameters.bufVersion);
+
+            }
+
+        TBool status = EFalse;
+
+        //Since "C" drive is not removable
+
+        if (midletParameters.iDrive != EDriveC)
+            {
+            status = IsInstalledAppRemovableL(midletParameters.iDrive);
+            }
+        if (status)
+            {
+            RDEBUG( "IsInstalledAppRemovableL(midletParameters.iDrive); True");
+            }
+        else
+            {
+            RDEBUG( "IsInstalledAppRemovableL(midletParameters.iDrive); False");
+            }
+
+        //check for status drive
+        aCompo.SetAppRemovableStatus(status);
+        }
+
+    RDEBUG( "CApplicationManagementServer::JavaInstallL: End");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::SisInstallL()
+// ------------------------------------------------------------------------------------------------	
+
+void CApplicationManagementServer::SisInstallL(
+        const CDeploymentComponent &aCompo)
+    {
+    TRequestStatus s;
+    CDialogWait* wait = CDialogWait::NewL();
+    // set state to install progress
+    aCompo.SetStatusNode(EDelivered_InstallProgress);
+    TInt err(KErrNone);
+    TRAP(err,InstallL( aCompo,wait->iStatus ));
+    if (err != KErrNone)
+        {
+        aCompo.SetStatusNode(EDelivered_InstalledFailedWithData);
+        User::Leave(err);
+        }
+    RDEBUG_2("ApplicationManagementSession: SisInstallL failed with code before startwait %d",
+            wait->iStatus.Int() );
+    wait->StartWait();
+    RDEBUG_2("ApplicationManagementSession: SisInstallL failed with code after startwait %d",
+                wait->iStatus.Int() );
+    RDEBUG( "wait->StartWait() CApplicationManagementServer::SisInstallL Step1");
+    if (!CApplicationManagementUtility::iSilentSession && CApplicationManagementUtility::mCurrDlg)
+        m_Dlg->closeAMWaitDialog();
+    delete m_Dlg;
+    m_Dlg=NULL;
+    RDEBUG( "wait->StartWait() CApplicationManagementServer::SisInstallL Step2");
+    
+    m_Window->lower();
+    
+    TInt usifdeplid = -1;
+    if (iResults && wait->iStatus.Int()!=KErrCancel)
+        iResults->GetIntByNameL(Usif::KSifOutParam_ComponentId, usifdeplid);
+    
+    RDEBUG( "wait->StartWait() CApplicationManagementServer::SisInstallL Step3");
+
+    iComp->SetComponentId(usifdeplid);
+
+    TRequestStatus s1 = wait->iStatus;
+    delete wait;
+    RDEBUG_2("ApplicationManagementSession: SisInstallL with code %d",
+                    s1.Int() );
+    
+    if(s1 == KErrCancel)
+        {
+        s1 = KStatusUserCancelled;
+        RDEBUG( "KErrCancel visited operation cancelled");
+        mUserCancelled=1;
+        }
+    if (s1 != KErrNone)
+        {
+        RDEBUG_2("ApplicationManagementSession: SisInstallL failed with code %d",
+                s1.Int() );
+        // set state to install failed with data
+        aCompo.SetStatusNode(EDelivered_InstalledFailedWithData);
+        User::Leave(s1.Int());
+        }
+    else
+        {
+        // set state to install sucessful
+        aCompo.SetStatusNode(EIdle);
+        RDEBUG("ApplicationManagementSession: SisInstallL successfull" );
+        }
+    RDEBUG( "CApplicationManagementServer::SisInstallL: End");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::DoTheInstallL()
+// ---------------------------------------------------- --------------------------------------------	
+
+void CApplicationManagementServer::DoTheInstallL(CDeploymentComponent &aCompo)
+    {
+    RDEBUG( "CApplicationManagementServer::DoTheInstallL: Start");
+    TInt error(KErrNone);
+    iComp = &aCompo;
+    
+    TDeploymentComponentName name = aCompo.ComponentName();
+    if(name.Compare(KNullDesC8())==0)
+        {
+        name = aCompo.UserId();
+        }
+    TBuf<KDeploymentComponentNameMaxLength> nameBuf;
+    nameBuf.Copy(name);
+    m_appName = QString::fromUtf16(nameBuf.Ptr(), nameBuf.Length());
+
+    TRequestStatus stat = KErrCompletion;
+    if (!aCompo.DriveSelected()
+            && !CApplicationManagementUtility::iSilentSession)
+        {
+        // displaying install confirm notes
+        CDialogWait* ao = CDialogWait::NewL();
+        AppMgmtNotifier* note = new AppMgmtNotifier();
+        int err = KErrNone;
+        TRAP( err, QT_TRYCATCH_LEAVING(note->showInstallDialog(iComp, ao->iStatus)));
+        ao->StartWait();
+        stat = ao->iStatus;
+        delete ao;
+        m_Window->lower();
+        delete note;
+        }
+    aCompo.SetDriveSelectionStatus(false);
+    if (stat == KErrCompletion)
+        {
+        if (CDeploymentComponent::IsJavaMimeL(aCompo.Data().MimeType())
+                || CDeploymentComponent::IsJavaMimeL(
+                        aCompo.MetaData().MimeType()))
+            {
+            TRAP( error, JavaInstallL( aCompo ) );
+            }
+        else
+            {
+            TRAP( error, SisInstallL( aCompo ) );
+            if(error==KErrNone)
+                {
+                SetSisAppVersionAndDriveL(aCompo);
+                }
+            }
+      
+
+
+        if (error == KErrNone)
+            {
+            InstallCompleteL(aCompo, ETrue);
+            CDeploymentComponent *old = DoDataUpdateCheckL(aCompo);
+            if (old)
+                {
+                if (aCompo.State() == EDCSDelivered)
+                    {
+                    if (old->State() == EDCSActive || old->State()
+                            == EDCSInactive)
+                        {
+                        RDEBUG("AMSession: DoTheInstallL ** deleting old node **" );
+                        iStorage->RemoveL(old->InternalId());
+                        }
+                    }
+                }
+            iStorage->InstalledL(aCompo);
+            }
+        else
+            {
+            InstallCompleteL(aCompo, EFalse);
+            User::Leave(error);
+            }
+        }
+    else
+        {
+        aCompo.SetStatusNode(EDelivered_InstallFailedwithOutData);
+        }
+    
+    RDEBUG( "CApplicationManagementServer::DoTheInstallL: End");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::DoDataUpdateCheckL()
+// ------------------------------------------------------------------------------------------------	
+
+CDeploymentComponent *CApplicationManagementServer::DoDataUpdateCheckL(
+        CDeploymentComponent &aCompo)
+    {
+    CDeploymentComponent *old = NULL;
+    if (aCompo.Uid() != TUid::Null() && HasUidL(aCompo.Uid(), old, &aCompo))
+        {
+        // check for Uid component.. Legacy code removed.
+        }
+    return old;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::SetDataL()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::SetDataL(CDeploymentComponent &aCompo,
+        const TDesC8 &aData, const TDesC8 &aMime)
+    {
+    aCompo.SetDataL(aData, aMime);
+    DoDataUpdateCheckL(aCompo);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::FullUpdateL()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::FullUpdateL(const TUint32 sid,
+        const TUint32 tid)
+    {
+    CDeploymentComponent &scompo = iStorage->ComponentL(sid);
+    CDeploymentComponent &tcompo = iStorage->ComponentL(tid);
+    FullUpdateL(scompo, tcompo);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::FullUpdateL()
+// ------------------------------------------------------------------------------------------------
+
+void CApplicationManagementServer::FullUpdateL(CDeploymentComponent &scompo,
+        const CDeploymentComponent &tcompo)
+    {
+    if (scompo.State() == EDCSDelivered)
+        {
+        if (tcompo.State() == EDCSActive || tcompo.State() == EDCSInactive)
+            {
+            TRequestStatus s2;
+            InstallL(scompo, s2);
+            User::WaitForRequest(s2);
+            if (s2 != KErrNone)
+                {
+                RDEBUG_2( "ApplicationManagementSession: FullUpdateL failed with code %d", s2.Int() );
+                User::Leave(s2.Int());
+                }
+            else
+                {
+                InstallCompleteL(scompo);
+                // Before deleting old node ,copy node values which are not set in new node from old node
+                if (scompo.ComponentId() == KNullDesC8)
+                    scompo.SetIdL(tcompo.ComponentId());
+
+                if (scompo.ComponentName() == KNullDesC8)
+                    scompo.SetNameL(tcompo.ComponentName());
+
+                if (scompo.ComponentVersion() == KNullDesC8)
+                    scompo.SetVersionL(tcompo.ComponentVersion());
+
+                //Tag tcompo state for deletion. Cant delete now, since nsmldmtree woudnt be updated
+                //Remove the const'ness since state needs to be updated.
+
+                iStorage->SetDeploymentComponentState(
+                        const_cast<CDeploymentComponent &> (tcompo),
+                        EDCSDelete);
+
+                iStorage->InstalledL(scompo);
+                RDEBUG( "ApplicationManagementSession: FullUpdateL ok" );
+                }
+            }
+        else
+            {
+            RDEBUG_2( "ApplicationManagementSession: ERROR FullUpdateL called for illegal state component: %d!", scompo.State() );
+            User::Leave(KErrArgument);
+            }
+        }
+    else
+        {
+        RDEBUG( "ApplicationManagementSession: ERROR FullUpdateL called for illegal state message!" );
+        User::Leave(KErrArgument);
+        }
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::IsDataFileB64EncodedL()
+// -------------------------------------------------------------------------------------------------------------------
+TBool CApplicationManagementServer::IsDataFileB64EncodedL(RFile &aFile,
+        TInt& aLength)
+    {
+    RDEBUG("CApplicationManagementServer::IsDataFileB64EncodedL()  : start");
+    TBool encoded = ETrue; // assume b64 encoded
+    TInt bufSize(KBase64BufSize);
+    TInt offset(0);
+    HBufC8 *dataBuf = HBufC8::NewLC(bufSize);
+    TPtr8 dataPtr = dataBuf->Des();
+    aFile.Size(aLength);
+    aFile.Seek(ESeekStart, offset);
+
+    while (encoded)
+        {
+        aFile.Read(dataPtr);
+        if (!dataPtr.Length())
+            {
+            break;
+            }
+        offset = 0;
+        aFile.Seek(ESeekCurrent, offset);
+        RDEBUG_2("OFFSET: %d", offset);
+        encoded = CheckB64Encode(dataPtr);
+        }
+    RDEBUG_2("Encoded: %d", encoded);
+    CleanupStack::PopAndDestroy(dataBuf);
+    offset = 0;
+    aFile.Seek(ESeekStart, offset);
+
+    RDEBUG("CApplicationManagementServer::IsDataFileB64EncodedL()  : end");
+    return encoded;
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::CheckB64Encode( const TDesC8& aData )
+// -------------------------------------------------------------------------------------------------------------------
+TBool CApplicationManagementServer::CheckB64Encode(const TDesC8& aData)
+    {
+    TInt inputIndex = 0;
+    TInt inputLen = aData.Length();
+
+    while (inputIndex < inputLen)
+        {
+        const TUint8& p = aData[inputIndex];
+
+        if ((p >= 48 && p <= 57) || (p >= 65 && p <= 90) || (p >= 97 && p
+                <= 122) || p == 43 || p == 47 || p == 61 || p == 10 || p
+                == 13)
+            {
+            }
+        else
+            {
+            return EFalse;
+            }
+
+        inputIndex++;
+
+        }
+
+    return ETrue;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::GetAMServerDownloadDBL()
+// ------------------------------------------------------------------------------------------------	
+
+void CApplicationManagementServer::GetAMServerDownloadDBL(TUint32 internalid,
+        TInt& finalresult, TDes8& aTargetURI)
+    {
+    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step1" );
+
+    TBuf<50> internalidbuf;
+
+    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step2" );
+    internalidbuf.Num(internalid);
+
+    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step3" );
+
+    RPointerArray<CAMDbItem> aItemArray;
+
+    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step4" );
+
+    iAMServerDB->GetEntryForLUIDL(aItemArray, internalidbuf);
+
+    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step5" );
+
+    if (aItemArray.Count() != 0)
+        {
+        RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step6" );
+
+        finalresult = aItemArray[0]->iResult;
+
+        RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step7" );
+
+        if (finalresult < KErrNone)
+            User::Leave(KErrGeneral);
+
+        RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step8" );
+
+        if (*aItemArray[0]->iTargetURI == KNullDesC8())
+            User::Leave(KErrGeneral);
+
+        RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step9" );
+        aTargetURI.Copy(*aItemArray[0]->iTargetURI);
+
+        }
+    RDEBUG( "CApplicationManagementServer::GetAMServerDownloadDBL(): Step10" );
+    aItemArray.ResetAndDestroy();
+
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::DeleteGenericAlertForIDL()
+// ------------------------------------------------------------------------------------------------	
+
+void CApplicationManagementServer::DeleteGenericAlertForIDL(
+        TUint32 internalid)
+    {
+    iAMServerDB->DeleteFromDatabaseL(internalid);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::DecodeB64DataFileL( RFile& aDataFile, RFile& aDestinationFile )
+// -------------------------------------------------------------------------------------------------------------------
+void CApplicationManagementServer::DecodeB64DataFileL(RFile& aSourceFile,
+        RFile& aDestinationFile)
+    {
+    RDEBUG( "CApplicationManagementServer::DecodeB64DataFileL(): Start" );
+    // Create buffers
+    //TInt b64bufferSize = 131072;
+    TInt decodedBufferSize = ((KBase64BufSize * 3) / 4 + 16);
+    HBufC8 *dataBuf = HBufC8::NewLC(KBase64BufSize);
+    TPtr8 dataPtr = dataBuf->Des();
+    HBufC8* targetBuf = HBufC8::NewLC(decodedBufferSize);
+    TPtr8 targetPtr(targetBuf->Des());
+
+    TInt offset(0);
+    TInt length(0);
+    TBool reading(ETrue);
+    aSourceFile.Size(length);
+    RDEBUG_2( "CApplicationManagementServer::DecodeB64DataFileL(): b64 file total size: (%d)", length );
+    aSourceFile.Seek(ESeekStart, offset);
+
+    // Initialize decoder
+    TImCodecB64 B64Coder;
+    B64Coder.Initialise();
+
+    while (reading)
+        {
+        aSourceFile.Read(dataPtr);
+        if (!dataPtr.Length())
+            {
+            // EOF
+            break;
+            }
+        offset = 0;
+        aSourceFile.Seek(ESeekCurrent, offset);
+        RDEBUG_2("OFFSET: %d", offset);
+
+        // decode data
+        B64Coder.Decode(dataPtr, targetPtr);
+        // write decoded data to temporary file
+        aDestinationFile.Write(targetPtr);
+        }
+    CleanupStack::PopAndDestroy(targetBuf);
+    CleanupStack::PopAndDestroy(dataBuf);
+
+    offset = 0;
+    aDestinationFile.Seek(ESeekStart, offset);
+    RDEBUG( "CApplicationManagementServer::DecodeB64DataFileL(): end" );
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementServer::DecodeB64DataLC( const TDesC8& aData )
+// -------------------------------------------------------------------------------------------------------------------
+HBufC8* CApplicationManagementServer::DecodeB64DataLC(const TDesC8 &aData)
+    {
+    RDEBUG( "CApplicationManagementServer::DecodeB64DataLC(): Start" );
+    TImCodecB64 B64Coder;
+    B64Coder.Initialise();
+    HBufC8 *target = HBufC8::NewLC((aData.Length() * 3) / 4 + 16);
+    TPtr8 targetPtr(target->Des());
+    B64Coder.Decode(aData, targetPtr);
+    RDEBUG( "CApplicationManagementServer::DecodeB64DataLC(): End" );
+    return target;
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+//  CApplicationManagementServer::EncodeDataL( const TDesC8& aData, CBufBase &aTarget )
+// -------------------------------------------------------------------------------------------------------------------
+void CApplicationManagementServer::EncodeDataL(const TDesC8& aData,
+        CBufBase &aTarget)
+    {
+    TInt outLen(aData.Length() * 2);
+    aTarget.ExpandL(0, outLen);
+    TImCodecB64 B64Coder;
+    B64Coder.Initialise();
+    TPtr8 target(aTarget.Ptr(0));
+    TInt decoded(B64Coder.Encode(aData, target));
+    TInt s(target.Length());
+    aTarget.ResizeL(s);
+    aTarget.Compress();
+    if (!decoded)
+        {
+        RDEBUG( "CApplicationManagementServer::EncodeDataL(): Encoding b64 failed?" );
+        }
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::CApplicationManagementSession
+// -------------------------------------------------------------------------------------------------------------------
+inline CApplicationManagementSession::CApplicationManagementSession()
+    {
+    RDEBUG_2( "CApplicationManagementSession::CApplicationManagementSession 0x%x", this);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::CApplicationManagementSession
+// -------------------------------------------------------------------------------------------------------------------
+
+inline CApplicationManagementSession::CApplicationManagementSession(
+        const TCertInfo &aInfo) :
+    iCertInfo(aInfo)
+    {
+    RDEBUG( "CApplicationManagementSession::CApplicationManagementSession (cert) " );
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::Server()
+// -------------------------------------------------------------------------------------------------------------------
+
+inline CApplicationManagementServer& CApplicationManagementSession::Server() const
+    {
+    return *static_cast<CApplicationManagementServer*> (const_cast<CServer2*> (CSession2::Server()));
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::CreateL()
+// -------------------------------------------------------------------------------------------------------------------
+// 2nd phase construct for sessions - called by the CServer framework
+
+void CApplicationManagementSession::CreateL()
+    {
+    RDEBUG_2( "ApplicationManagementSession: CApplicationManagementSession::CreateL: 0x%x", this );
+
+    Server().AddSession();
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::~CApplicationManagementSession()
+// -------------------------------------------------------------------------------------------------------------------
+
+CApplicationManagementSession::~CApplicationManagementSession()
+    {
+    RDEBUG_3("CApplicationManagementSession::~CApplicationManagementSession 0x%X - 0x%X", reinterpret_cast<TUint>(this),
+            reinterpret_cast<TUint>(this)+sizeof( CApplicationManagementSession ) );
+    RDEBUG_2("CApplicationManagementSession::~CApplicationManagementSession iCertInfo offs 0x%X",
+            reinterpret_cast<TUint>(&this->iCertInfo) - reinterpret_cast<TUint>(this) );
+
+    Server().DropSession();
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::ServiceL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::ServiceL(const RMessage2& aMessage)
+    {
+    if (aMessage.Function() == EPerformRfs)
+        {
+        TRAPD( err, Server().PerformRFSL() );
+        aMessage.Complete(err);
+        }
+    else
+        {
+        TBool handled(EFalse);
+        TInt err(KErrNone);
+        TRAP( err, handled = PreDispatchMessageL( aMessage ) );
+        if (!handled)
+            {
+            TRAP(err,DispatchMessageL(aMessage));
+            }
+
+        // Some of the functions contains operations that already complete message
+        // doing Complete() twice will cause panic
+        if (aMessage.Handle())
+            {
+            aMessage.Complete(err);
+            }
+        }
+    }
+
+// CApplicationManagementSession::PreDispatchMessageL()
+// -------------------------------------------------------------------------------------------------------------------
+
+TBool CApplicationManagementSession::PreDispatchMessageL(
+        const RMessage2 &aMessage)
+    {
+    TBool ret(EFalse);
+    // These succeed regardless of certificate....
+    switch (aMessage.Function())
+        {
+        case EGetStateChangingIdsCountOperation:
+            {
+            // gets count of items list of ids that are potentially changing state
+            StateChangeComponentIdsCountL(aMessage);
+            ret = ETrue;
+            break;
+            }
+        case EGetStateChangingIdsOperation:
+            {
+            // gets list of ids that are potentially changing state
+            StateChangeComponentIdsL(aMessage);
+            ret = ETrue;
+            break;
+            }
+        case ECompleteStateChangeOperation: // completes change of state
+            {
+            StateChangeCompleteL(aMessage);
+            ret = ETrue;
+            break;
+            }
+        default:
+            {
+            break;
+            }
+        }
+    return ret;
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::DispatchMessageL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::DispatchMessageL(
+        const RMessage2& aMessage)
+    {
+    RDEBUG_2( "CApplicationManagementSession::DispatchMessageL; %d" ,
+            aMessage.Function() );
+
+    TBool go(EFalse);
+    if (iTrustAdded)
+        {
+        go = Server().CheckCertL(iCertInfo);
+        }
+    else
+        {
+        go = ETrue;
+        }
+
+    if (go)
+        {
+        switch (aMessage.Function())
+            {
+            case EAddTrust:
+                {
+                RDEBUG_2( "CApplicationManagementSession::DispatchMessageL; EAddTrust this=0x%x", this );
+                AddTrustL(aMessage);
+                break;
+                }
+            case EDeplCompCountOperation:
+                {
+                ComponentCountL(aMessage);
+                return;
+                }
+            case EDeplCompIdsOperation:
+                {
+                ComponentIdsL(aMessage);
+                return;
+                }
+            case EDeplCompDeliverCompleteOperation:
+                {
+                DeliverCompleteL(aMessage);
+                break;
+                }
+            case EDeplCompGetOperation:
+                {
+                GetComponentL(aMessage);
+                break;
+                }
+            case EInstallOperation:
+                {
+                InstallL(aMessage);
+                break;
+                }
+            case EDeplCompAttrUpdateOperation:
+                {
+                UpdateL(aMessage);
+                break;
+                }
+            case EDeplCompGetDataOperation:
+                {
+                GetDataL(aMessage);
+                break;
+                }
+            case EDeplCompGetDataLengthOperation:
+                {
+                GetDataLengthL(aMessage);
+                break;
+                }
+            case EDeplCompRemoveOperation:
+                {
+                RemoveL(aMessage);
+                break;
+                }
+            case EDeplCompDeliverStartOperation2:
+                {
+                Deliver2L(aMessage);
+                break;
+                }
+            case EDeplCompUpdateDataOperation:
+                {
+                UpdateDataL(aMessage);
+                break;
+                }
+            case EDeplCompUpdateStreamedDataOperation:
+                {
+                UpdateStreamedDataL(aMessage);
+                break;
+                }
+            case EDeplCompDownloadOperation:
+                {
+                DownloadL(aMessage);
+                break;
+                }
+            case EDeplCompUpdateOperation:
+                {
+                FullUpdateL(aMessage);
+                break;
+                }
+            case EDeplCompGetUserIdOperation:
+                {
+                GetUserIdL(aMessage);
+                break;
+                }
+            case EDeplCompStartDownloadOperation:
+                {
+                StartDownloadL(aMessage);
+                break;
+                }
+            case EDeplCompDeactivateOperation:
+                {
+                DeactivateL(aMessage);
+                break;
+                }
+            case EDeplCompActivateOperation:
+                {
+                ActivateL(aMessage);
+                break;
+                }
+            case EDeplCompGetTemporaryInstFile:
+                {
+                GetTemporaryInstFileL(aMessage);
+                break;
+                }
+
+            case EDeplCompGetFinalResultForGA:
+                {
+                GetFinalResultForGAL(aMessage);
+                break;
+
+                }
+            case EDeplCompGenericAlertSent:
+                {
+                GenericAlertSentForIdL(aMessage);
+                break;
+                }
+            case ECheckStatusNodes:
+                {
+                CheckStatusNodesValuesL();
+                break;
+                }
+
+            default:
+                {
+                User::Leave(KErrNotSupported);
+                break;
+                }
+            }
+        }
+    else
+        {
+        RDEBUG_2( "CApplicationManagementSession::DispatchMessageL; Policy prevented action this=0x%x", this );
+        User::Leave(KErrAccessDenied);
+        }
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::GenericAlertSentForIdL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::GenericAlertSentForIdL(
+        const RMessage2& aMessage) const
+    {
+    TUint32 luid;
+    TPckg<TUint32> pk(luid);
+    TInt read(aMessage.Read(0, pk));
+
+    Server().DeleteGenericAlertForIDL(luid);
+
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::GetFinalResultForGAL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::GetFinalResultForGAL(
+        const RMessage2& aMessage)
+    {
+
+    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 1" );
+    TUint32 luid;
+    TPckg<TUint32> pk(luid);
+
+    TInt finalresult = KErrNone;
+
+    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 2" );
+
+    HBufC8 *targetURI = HBufC8::NewL(512);
+    TPtr8 ptr = targetURI->Des();
+
+    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 3" );
+
+    TInt read(aMessage.Read(0, pk));
+
+    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 4" );
+
+    Server().GetAMServerDownloadDBL(luid, finalresult, ptr);
+
+    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 5" );
+
+    RDEBUG_2( "ApplicationManagementServer: GetFinalResultForGAL Count is %d", finalresult );
+    TPckg<TInt> p1(finalresult);
+    aMessage.WriteL(1, p1);
+
+    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 6" );
+    aMessage.WriteL(2, ptr);
+
+    RDEBUG( "CApplicationManagementSession: GetFinalResultForGAL Step 7" );
+    if (targetURI)
+        delete targetURI;
+
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::ComponentCountL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::ComponentCountL(const RMessage2& aMessage)
+    {
+    RDEBUG( "CApplicationManagementSession: ComponentCountL" );
+    TDeploymentComponentState st;
+    TPckg<TDeploymentComponentState> pk(st);
+
+    TInt read(aMessage.Read(1, pk));
+    RDEBUG_3( "CApplicationManagementSession: ComponentCountL State is %d, read %d", st, read);
+
+    const RComponentIdArray &arrt = Server().Storage()->GetComponentIds();
+    RComponentIdArray arr;
+    CleanupClosePushL(arr);
+    if ((st == EDCSActive) || (st == EDCSInactive))
+        {
+        ActiveComponentsL(arrt, arr, st);
+        }
+    else
+        {
+        TInt count(arrt.Count());
+        for (TInt i(0); i < count; i++)
+            {
+            CDeploymentComponent &compo = Server().Storage()->ComponentL(
+                    arrt[i]);
+            if (st == EDCSNone || compo.State() == st)
+                {
+                arr.Append(arrt[i]);
+                }
+            }
+        }
+    TInt n(arr.Count());
+    CleanupStack::PopAndDestroy(&arr);
+
+    RDEBUG_2( "ApplicationManagementServer: ComponentCountL Count is %d", n );
+    TPckg<TInt> p(n);
+
+    aMessage.WriteL(0, p);
+
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::ActiveComponentsL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::ActiveComponentsL(
+        const RComponentIdArray &aArrt, RComponentIdArray &aArr,
+        TDeploymentComponentState &aState) const
+    {
+    Swi::RSisRegistrySession sisses;
+    TInt r(sisses.Connect());
+    User::LeaveIfError(r);
+    CleanupClosePushL(sisses);
+
+    RArray<TUid> uids;
+    sisses.InstalledUidsL(uids);
+    CleanupClosePushL(uids);
+    TInt cont(aArrt.Count());
+    TInt uidc(uids.Count());
+    RArray<TUid> juids;
+    Server().JavaUidsL(juids);
+    CleanupClosePushL(juids);
+    TInt juidc(juids.Count());
+    RComponentIdArray rem;
+    CleanupClosePushL(rem);
+    for (TInt i(0); i < cont; i++)
+        {
+        CDeploymentComponent &compo =
+                Server().Storage()->ComponentL(aArrt[i]);
+        TDeploymentComponentState state = compo.State();
+        if (state == aState)
+            {
+            TBool add(EFalse);
+            const TUid &uid(compo.Uid());
+            for (TInt j(0); add == EFalse && j < uidc; j++)
+                {
+
+                if (uids[j] == uid)
+                    {
+                    RDEBUG( "CApplicationManagementSession::ActiveComponentsL Entered" );
+
+                    // Check if this registry entry is present
+                    Swi::RSisRegistrySession sisSession;
+                    User::LeaveIfError(sisSession.Connect());
+                    CleanupClosePushL(sisSession);
+
+                    Swi::RSisRegistryEntry sisEntry;
+
+                    //Opens the base package entry by specifying a UID. 
+                    User::LeaveIfError(sisEntry.Open(sisSession, compo.Uid()));
+                    CleanupClosePushL(sisEntry);
+
+                    add = sisEntry.IsPresentL();
+
+                    if (add)
+                        {
+                        // If Present update the Version, name and other info to that deployement component. Since application would have got an update
+                        // by some other means
+                        TVersion version = sisEntry.VersionL();
+                        TBuf8<KVersionLength> pkgDes;
+                        pkgDes.AppendNum(version.iMajor);
+                        pkgDes.Append(KLiteralPeriod);
+                        pkgDes.AppendNum(version.iMinor);
+
+                        HBufC *packagename = sisEntry.PackageNameL();
+                        TBuf8<512> packagename8;
+                        packagename8.Copy(*packagename);
+                        delete packagename;
+
+                        compo.SetNameL(packagename8);
+                        compo.SetVersionL(pkgDes);
+
+                        Server().Storage()->UpdateL(compo);
+
+                        RDEBUG( "CApplicationManagementSession::ActiveComponentsL ETrue" );
+
+                        }
+                    else
+                        RDEBUG( "CApplicationManagementSession::ActiveComponentsL EFalse" );
+                    CleanupStack::PopAndDestroy(2, &sisSession);
+                    }
+                }
+            if (!add) // go throug java suites
+                {
+                for (TInt k(0); add == EFalse && k < juidc; k++)
+                    {
+                    if (juids[k] == uid)
+                        {
+                        add = ETrue;
+                        }
+                    }
+                }
+            if (add)
+                {
+                aArr.Append(aArrt[i]);
+                }
+            else
+                {
+                RDEBUG8_3( "ApplicationManagementServer: ActiveComponentCountL skipping 0x%x, %S",
+                        compo.Uid() ,&compo.ComponentId() );
+                rem.Append(aArrt[i]);
+                }
+            }
+        }
+    TInt rc(rem.Count());
+    for (TInt t(0); t < rc; t++)
+        {
+        RDEBUG_2( "ApplicationManagementServer: ActiveComponentCountL removing non existing %d", rem[t] );
+        CDeploymentComponent &compo = Server().Storage()->ComponentL(rem[t]);
+        if (!compo.AppRemovable())
+            Server().RemoveInternalL(compo, EFalse);
+        }
+    CleanupStack::PopAndDestroy(&rem);
+    CleanupStack::PopAndDestroy(&juids);
+    CleanupStack::PopAndDestroy(&uids);
+    CleanupStack::PopAndDestroy(&sisses);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::ComponentIdsL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::ComponentIdsL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "CApplicationManagementSession: ComponentIdsL" );
+    TDeploymentComponentState st;
+    TPckg<TDeploymentComponentState> pk(st);
+
+    TInt read(aMessage.Read(1, pk));
+    RDEBUG_3( "CApplicationManagementSession: ComponentIdsL State is %d, read %d", st, read);
+
+    const RComponentIdArray &arrt = Server().Storage()->GetComponentIds();
+    TInt buflen(0);
+    TUint32* buf = NULL;
+    if (st == EDCSNone)
+        {
+        buflen = arrt.Count();
+        buf = new (ELeave) TUint32[buflen];
+        CleanupArrayDeletePushL(buf);
+        for (TInt i(0); i < buflen; i++)
+            {
+            RDEBUG_2("ApplicationManagementSession: ComponentIdsL Adding %d!!", arrt[i]);
+            buf[i] = arrt[i];
+            }
+        }
+    else
+        {
+        RComponentIdArray arr;
+        if (st == EDCSActive)
+            {
+            ActiveComponentsL(arrt, arr, st);
+            }
+        else
+            {
+            TInt artc(arrt.Count());
+            for (TInt i(0); i < artc; i++)
+                {
+                CDeploymentComponent &compo = Server().Storage()->ComponentL(
+                        arrt[i]);
+                if (compo.State() == st)
+                    {
+                    arr.Append(arrt[i]);
+                    }
+                }
+            }
+        buflen = arr.Count();
+        buf = new (ELeave) TUint32[buflen];
+        CleanupArrayDeletePushL(buf);
+
+        TUint32 len(aMessage.GetDesMaxLength(0) / 4);
+        if (buflen == len)
+            {
+            RDEBUG( "CApplicationManagementSession: ComponentIdsL Right count!!" );
+            }
+        else
+            {
+            RDEBUG_3( "CApplicationManagementSession: ComponentIdsL Wrong count (is %d, should be %d)!!", len, buflen);
+            if (len < buflen)
+                {
+                buflen = len;
+                }
+            }
+        for (TInt i(0); i < buflen; i++)
+            {
+            RDEBUG_2( "CApplicationManagementSession: ComponentIdsL Adding %d!!",
+                    arr[i] );
+            buf[i] = arr[i];
+            }
+        arr.Close();
+        }
+
+    TPtrC8 p((TUint8*) buf, buflen * sizeof(TUint32));
+    aMessage.WriteL(0, p);
+
+    CleanupStack::PopAndDestroy(buf);
+    }
+
+#ifdef _DEBUG
+HBufC* Des8to16LC(const TDesC8 &aDes)
+    {
+    HBufC *b = HBufC::NewLC(aDes.Length());
+    TPtr p(b->Des());
+    p.Copy(aDes);
+    return b;
+    }
+
+HBufC* ToStringLC(TDeploymentComponent &aComp)
+    {
+    HBufC *b = HBufC::NewLC(aComp.iId.Length() + aComp.iName.Length()
+            + aComp.iVersion.Length() + 10 + 50);
+    TPtr p(b->Des());
+    _LIT( KFormat, "Id: '%S', Name: '%S', Version: '%S', State: %d, OldState: %d");
+    p.Format(KFormat, &*Des8to16LC(aComp.iId), &*Des8to16LC(aComp.iName),
+            &*Des8to16LC(aComp.iVersion), aComp.iState, aComp.iOldState);
+    CleanupStack::PopAndDestroy(3);
+    return b;
+    }
+#endif
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::Deliver2L()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::Deliver2L(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: Deliver2L" );
+
+    TDeploymentComponentIPC comp;
+    TPckg<TDeploymentComponentIPC> pcomp(comp);
+    TInt read2(aMessage.Read(0, pcomp));
+
+    HBufC8 *data = HBufC8::NewLC(aMessage.GetDesLength(1));
+    TPtr8 pbuf(data->Des());
+    TInt read(aMessage.Read(1, pbuf));
+
+    CDeploymentComponent *compo = NULL;
+    if (iTrustAdded)
+        {
+        compo = Server().Storage()->NewComponentL(EDCSDelivered,
+                comp.iUserId, &iCertInfo);
+        }
+    else
+        {
+        compo
+                = Server().Storage()->NewComponentL(EDCSDelivered,
+                        comp.iUserId);
+        }
+
+    compo->Set(comp.iComponent);
+    compo->Data().SetDataL(pbuf, comp.iMimeType);
+    Server().Storage()->UpdateL(*compo);
+    compo->CopyStateTo(comp.iComponent);
+
+#ifdef _DEBUG
+    RDEBUG_2( "Deliver2L: TDeploymentComponent is '%S'",
+            ToStringLC( comp.iComponent ) );
+    CleanupStack::PopAndDestroy();
+#endif
+
+    TPckg<TDeploymentComponent> pcomp2(comp.iComponent);
+    aMessage.Write(0, pcomp2);
+    CleanupStack::PopAndDestroy(data);
+    TInt n(compo->InternalId());
+    TPckg<TUint32> p(n);
+    aMessage.WriteL(2, p);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::DeliverCompleteL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::DeliverCompleteL(
+        const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: DeliverCompleteL" );
+    TUint32 id;
+    TPckg<TUint32> pid(id);
+
+    TInt read(aMessage.Read(0, pid));
+    RDEBUG_2( "ApplicationManagementSession: DeliverCompleteL id is %d", id );
+
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
+
+    HBufC8 *opts = HBufC8::NewLC(aMessage.GetDesLength(1));
+    TPtr8 popts(opts->Des());
+    TInt read1(aMessage.Read(1, popts));
+    compo.SetInstallOptsL(*opts);
+
+    HBufC8 *meta = HBufC8::NewLC(aMessage.GetDesLength(2));
+    TPtr8 pmeta(meta->Des());
+    TInt read2(aMessage.Read(2, pmeta));
+    compo.SetMetaDataL(*meta, KNullDesC8);
+
+    CleanupStack::PopAndDestroy(meta);
+    CleanupStack::PopAndDestroy(opts);
+    Server().Storage()->UpdateL(compo);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::GetComponentL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::GetComponentL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: GetComponentL" );
+    TUint32 id;
+    TPckg<TUint32> pid(id);
+    TInt read(aMessage.Read(0, pid));
+
+    RDEBUG_2( "ApplicationManagementSession: GetComponentL id is %d", id );
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
+
+    TDeploymentComponent comp;
+    compo.CopyStateTo(comp);
+
+    TPckg<TDeploymentComponent> pcomp(comp);
+    aMessage.Write(1, pcomp);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::StartDownloadL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::StartDownloadL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: StartDownloadL" );
+    TUint32 id = 0;
+    TPckg<TUint32> pid(id);
+    TInt read(aMessage.Read(0, pid));
+
+    TPckgBuf<TDownloadTarget> target;
+    read = aMessage.Read(1, target);
+    RDEBUG_2( "ApplicationManagementSession: StartDownloadL id is %d", id );
+
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
+    compo.SetDownloadTarget(target());
+    Server().AddDownloadL(&compo);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::DeactivateL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::DeactivateL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: DeactivateL" );
+    TUint32 id = 0;
+    TPckg<TUint32> pid(id);
+    TInt read(aMessage.Read(0, pid));
+
+    RDEBUG_2( "ApplicationManagementSession: DeactivateL id is %d", id );
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
+    Server().Storage()->DeactivateL(compo);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::ActivateL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::ActivateL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: ActivateL" );
+    TUint32 id;
+    TPckg<TUint32> pid(id);
+    TInt read(aMessage.Read(0, pid));
+
+    RDEBUG_2( "ApplicationManagementSession: ActivateL id is %d", id );
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
+    Server().Storage()->ActivateL(compo);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::GetUserIdL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::GetUserIdL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: GetUserIdL" );
+    TUint32 id = 0;
+    TPckg<TUint32> pid(id);
+    TInt read(aMessage.Read(0, pid));
+
+    RDEBUG_2( "ApplicationManagementSession: GetUserIdL id is %d", id );
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
+
+    aMessage.Write(1, compo.UserId());
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::GetTemporaryInstFileL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::GetTemporaryInstFileL(
+        const RMessage2& aMessage) const
+    {
+    // TIpcArgs( &id, &itemid, &filehandle )
+    RDEBUG( "ApplicationManagementSession: GetTemporaryInstFileL" );
+    TUint32 id;
+    TPckg<TUint32> pid(id);
+    TInt read(aMessage.Read(0, pid));
+
+    TDeplCompAttrType item;
+    TPckg<TDeplCompAttrType> itemid(item);
+    read = aMessage.Read(1, itemid);
+
+    RDEBUG_2( "ApplicationManagementSession: GetTemporaryInstFileL id is %d", id );
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
+
+    TFileName fileName;
+
+    if (item == EDCData)
+        {
+        fileName.Copy(compo.Data().DataFileName());
+        }
+    else if (item == EDCMetaData)
+        {
+        fileName.Copy(compo.MetaData().DataFileName());
+        }
+    else
+        {
+        RDEBUG_2( "ApplicationManagementSession: GetTemporaryInstFileL: Not supported type: (%d)", item);
+        User::Leave(KErrNotSupported);
+        }
+
+    RDEBUG_2( "ApplicationManagementSession: GetTemporaryInstFileL: (%S)", &fileName);
+
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    User::LeaveIfError(fs.ShareProtected());
+    CleanupClosePushL(fs);
+    RFile file;
+    User::LeaveIfError(file.Open(fs, fileName, EFileWrite));
+    CleanupClosePushL(file);
+
+    // Takes care of completing with session (RFs), 
+    // SendReceieve returns session handle at client side
+    User::LeaveIfError(file.TransferToClient(aMessage, 2));
+    CleanupStack::PopAndDestroy(2, &fs); // fs , file	
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::PackageSizeL()
+// -------------------------------------------------------------------------------------------------------------------
+
+TInt CApplicationManagementSession::PackageSizeL(
+        Swi::RSisRegistrySession& aSession, Swi::RSisRegistryEntry& aEntry)
+    {
+    RPointerArray<Swi::CSisRegistryPackage> listPackages;
+    TInt size(0);
+    TInt err(0);
+    CleanupClosePushL(listPackages);
+
+    aEntry.AugmentationsL(listPackages);
+
+    for (TInt index(0); index < listPackages.Count(); index++)
+        {
+        TRAP(err, AugmentationSizeL( aSession, *listPackages[index]))
+        if (err != KErrNone)
+            {
+            break;
+            }
+        }
+
+    if (err != KErrNone)
+        {
+        size = 0;
+        }
+    else
+        {
+        TRAP(err, size += aEntry.SizeL() );
+        }
+
+    listPackages.ResetAndDestroy();
+    CleanupStack::PopAndDestroy(&listPackages);
+
+    if (err != KErrNone)
+        {
+        //We leave if there was an error, 
+        // but we have to clean up the listPackages before the leave.
+        User::Leave(err);
+        }
+
+    return size;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CAppMngrSisxInfo::AugmentationSizeL()
+// Returns the Size of the package
+// (other items were commented in a header).
+// ------------------------------------------------------------------------------------------------
+//  
+TInt CApplicationManagementSession::AugmentationSizeL(
+        Swi::RSisRegistrySession& aSession,
+        const Swi::CSisRegistryPackage& aPackage)
+    {
+    TInt size(0);
+    Swi::RSisRegistryEntry regEntry;
+    CleanupClosePushL(regEntry);
+
+    regEntry.OpenL(aSession, aPackage);
+    size += PackageSizeL(aSession, regEntry);
+
+    CleanupStack::PopAndDestroy(&regEntry);
+
+    return size;
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::LookupSisRegistryL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::LookupSisRegistryL()
+    {
+    Swi::RSisRegistrySession sisses;
+    TInt r(sisses.Connect());
+    RPointerArray<Swi::CSisRegistryPackage> pkgs(12);
+    sisses.InstalledPackagesL(pkgs);
+
+    TInt count(pkgs.Count());
+    for (TInt i(0); i < count; i++)
+        {
+        Swi::CSisRegistryPackage* p = pkgs[i];
+
+        RDEBUG_5(" Found package: %d, '%S', uid: 0x%X, size: %d" ,
+                i, &p->Name(), p->Uid().iUid, AugmentationSizeL( sisses, *p ) );
+        }
+
+    sisses.Close();
+    pkgs.ResetAndDestroy();
+
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::InstallL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::InstallL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: InstallL" );
+    TUint32 id;
+    TPckg<TUint32> pid(id);
+    TInt read(aMessage.Read(0, pid));
+
+    TDeploymentComponentState targetst;
+    TPckg<TDeploymentComponentState> pk(targetst);
+
+    read = aMessage.Read(1, pk);
+
+    RDEBUG_3( "ApplicationManagementSession: InstallL id is %d, targetstate %d",
+            id, targetst );
+
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
+    if (compo.State() == EDCSDelivered)
+        {
+        Server().DoTheInstallL(compo);
+        }
+    else
+        {
+        User::Leave(KErrArgument);
+        }
+    RDEBUG_2( "ApplicationManagementSession: InstallL success. New compo state (%d)", compo.State());
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::UpdateDataL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::UpdateDataL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: UpdateDataL" );
+
+    TDeplCompDataIPC ipc;
+    TPckg<TDeplCompDataIPC> pipc(ipc);
+    TInt read(aMessage.Read(0, pipc));
+    RDEBUG_2( "ApplicationManagementSession: UpdateDataL id is %d", ipc.iInternalId );
+
+    HBufC8 *buf = HBufC8::NewLC(aMessage.GetDesLength(1));
+    TPtr8 pbuf(buf->Des());
+    TInt read2(aMessage.Read(1, pbuf));
+
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(
+            ipc.iInternalId);
+
+    if (Server().CheckB64Encode(pbuf))
+        {
+        RDEBUG( "ApplicationManagementSession: UpdateDataL data is base64 encoded");
+        // b64 encoded data, decode it 
+        HBufC8* tmp;
+        tmp = Server().DecodeB64DataLC(pbuf);
+        pbuf.Copy(*tmp);
+        pbuf = buf->Des();
+        CleanupStack::PopAndDestroy(tmp);
+        }
+
+    if (compo.State() == EDCSDelivered)
+        {
+        if (ipc.iAttrType == EDCData)
+            {
+            compo.SetDataL(pbuf, ipc.iDataMime);
+            }
+        else if (ipc.iAttrType == EDCMetaData)
+            {
+            compo.SetMetaDataL(pbuf, ipc.iDataMime);
+            }
+        else
+            {
+            RDEBUG_2( "ApplicationManagementSession::UpdateDataL -  ERROR UpdateDataL called for illegal item: %d!", ipc.iAttrType );
+            User::Leave(KErrArgument);
+            }
+
+        Server().Storage()->UpdateL(compo);
+        }
+    else
+        {
+        RDEBUG( "ApplicationManagementSession::UpdateDataL -  ERROR UpdateDataL called for illegal state message!" );
+        User::Leave(KErrArgument);
+        }
+    CleanupStack::PopAndDestroy(buf);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::UpdateStreamedDataL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::UpdateStreamedDataL(
+        const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: UpdateStreamedDataL() Start");
+    TDeplCompDataIPC ipc;
+    TPckg<TDeplCompDataIPC> pipc(ipc);
+    TInt read(aMessage.Read(0, pipc));
+    RDEBUG_2( "ApplicationManagementSession: UpdateStreamedDataL id is %d", ipc.iInternalId );
+
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(
+            ipc.iInternalId);
+
+    if (compo.State() == EDCSDelivered)
+        {
+        RFs fs;
+        User::LeaveIfError(fs.Connect());
+        CleanupClosePushL(fs);
+        RFile file;
+        TFileName dataFileName;
+        TInt length(0);
+
+        if (ipc.iAttrType == EDCData)
+            {
+            dataFileName.Copy(compo.Data().DataFileName());
+            }
+        else if (ipc.iAttrType == EDCMetaData)
+            {
+            dataFileName.Copy(compo.MetaData().DataFileName());
+            }
+        else
+            {
+            RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL -  ERROR called for illegal item: %d!", ipc.iAttrType );
+            User::Leave(KErrArgument);
+            }
+
+        RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL(): using dataFile: (%S)", &dataFileName );
+
+        // EFileWrite So we can delete the original decoded data file
+        User::LeaveIfError(file.Open(fs, dataFileName, EFileWrite));
+        CleanupClosePushL(file);
+        if (Server().IsDataFileB64EncodedL(file, length))
+            {
+            RDEBUG( "CApplicationManagementServer::UpdateStreamedDataL(): data is decoded" );
+
+            TFileName tempFileName;
+            TBuf<30> privatePath;
+            fs.PrivatePath(privatePath);
+            RFile tempFile;
+            TInt err(KErrNone);
+            err = tempFile.Temp(fs, privatePath, tempFileName, EFileWrite);
+            if (err == KErrNone)
+                {
+                RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL(): created tempFile: (%S)", &tempFileName );
+                }
+            else
+                {
+                User::Leave(err);
+                }
+            CleanupClosePushL(tempFile);
+
+            TRAP( err, Server().DecodeB64DataFileL( file, tempFile ) );
+            if (err != KErrNone)
+                {
+                RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL -  failed to decode datafile: %d", err );
+                CleanupStack::PopAndDestroy(2, &file);
+                compo.ResetDataL(fs); // Remove both files if exists
+                User::Leave(err);
+                }
+            else
+                {
+                // close both files, delete decode file and rename temp file to correct one
+                CleanupStack::PopAndDestroy(2, &file);
+                fs.Delete(dataFileName);
+                err = fs.Rename(tempFileName, dataFileName);
+                RDEBUG_2( "ApplicationManagementSession::UpdateStreamedDataL -  successfully decoded datafile: %d", err );
+                }
+            CleanupStack::PopAndDestroy(&fs);
+            }
+        else
+            {
+            RDEBUG( "ApplicationManagementSession::UpdateStreamedDataL(): data is NOT decoded" );
+            CleanupStack::PopAndDestroy(2, &fs);
+            }
+
+        if (ipc.iAttrType == EDCData)
+            {
+            compo.SetDataL(ipc.iDataMime);
+            }
+        else
+            {
+            compo.SetMetaDataL(ipc.iDataMime);
+            }
+
+        Server().Storage()->UpdateL(compo);
+        }
+    else
+        {
+        RDEBUG( "ApplicationManagementSession::UpdateStreamedDataL -  ERROR called for illegal state message!" );
+        User::Leave(KErrArgument);
+        }
+    RDEBUG( "ApplicationManagementSession: UpdateStreamedDataL() End");
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::UpdateL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::UpdateL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: UpdateL" );
+
+    TUint32 id;
+    TPckg<TUint32> pid(id);
+    TInt read(aMessage.Read(0, pid));
+    RDEBUG_2("ApplicationManagementSession: UpdateL id is %d", id );
+
+    TDeplCompAttrType item;
+    TPckg<TDeplCompAttrType> itemid(item);
+    TInt read1(aMessage.Read(1, itemid));
+    HBufC8 *buf = HBufC8::NewLC(aMessage.GetDesLength(2));
+    TPtr8 pbuf(buf->Des());
+    TInt read2(aMessage.Read(2, pbuf));
+
+    CDeploymentComponent &c = Server().Storage()->ComponentL(id);
+    TDeploymentComponentState st(c.State());
+    if (st == EDCSDelivered || st == EDCSDownload)
+        {
+        switch (item)
+            {
+            case EDCId:
+                {
+                c.SetIdL(pbuf);
+                break;
+                }
+            case EDCName:
+                {
+                c.SetNameL(pbuf);
+                break;
+                }
+            case EDCVersion:
+                {
+                c.SetVersionL(pbuf);
+                break;
+                }
+            case EDCDescriptionRef:
+                {
+                c.SetDescriptionL(pbuf);
+                break;
+                }
+            case EDCInstallOptions:
+                {
+                c.SetInstallOptsL(pbuf);
+                break;
+                }
+            case EDCMetaData:
+                {
+                c.SetMetaDataL(pbuf, KNullDesC8);
+                break;
+                }
+            case EDCPkgID:
+                {
+                c.SetPkgIDL(pbuf);
+                break;
+                }
+            case EDCPkgType:
+                {
+                c.SetPkgTypeL(pbuf);
+                break;
+                }
+
+            default:
+                {
+                if (st == EDCSDelivered)
+                    {
+                    switch (item)
+                        {
+                        case EDCData:
+                            {
+                            c.SetDataL(pbuf, KNullDesC8);
+                            if (c.State() == EDCSDownload)
+                                {
+                                //	Server().StartDownload( *compo );
+                                }
+                            break;
+                            }
+                        default:
+                            {
+                            RDEBUG_2("ApplicationManagementSession: ERROR UpdateL called for illegal item type!!!! %d", item );
+                            User::Leave(KErrArgument);
+                            }
+                        }
+                    }
+                else if (st == EDCSDownload)
+                    {
+                    switch (item)
+                        {
+                        case EDCId:
+                            {
+                            c.SetIdL(pbuf);
+                            break;
+                            }
+                        case EDCName:
+                            {
+                            c.SetNameL(pbuf);
+                            break;
+                            }
+                        case EDCVersion:
+                            {
+                            c.SetVersionL(pbuf);
+                            break;
+                            }
+                        case EDCDownloadURI:
+                            {
+                            c.SetDownloadURIL(pbuf);
+                            break;
+                            }
+                        case EDCConRef:
+                            {
+                            TPckgBuf<TInt> aInt;
+                            aInt.Copy(pbuf);
+                            c.SetIAPL(aInt());
+                            break;
+                            }
+                        default:
+                            {
+                            RDEBUG_2( "ApplicationManagementSession: ERROR UpdateL called for illegal item type!!!! %d", item );
+                            User::Leave(KErrArgument);
+                            break;
+                            }
+                        }
+                    }
+                break;
+                }
+            }
+        Server().Storage()->UpdateL(c);
+        }
+    else if (st == EDCSActive || st == EDCSInactive)
+        {
+        switch (item)
+            {
+            case EDCName:
+                {
+                c.SetNameL(pbuf);
+                break;
+                }
+            case EDCVersion:
+                {
+                c.SetVersionL(pbuf);
+                break;
+                }
+            case EDCDescriptionRef:
+                {
+                c.SetDescriptionL(pbuf);
+                break;
+                }
+            default:
+                {
+                RDEBUG_2( "ApplicationManagementSession: ERROR UpdateL called for illegal item type!!!! %d", item );
+                User::Leave(KErrArgument);
+                break;
+                }
+            }
+        Server().Storage()->UpdateL(c);
+        }
+    else
+        {
+        RDEBUG( "ApplicationManagementSession: ERROR UpdateL called for illegal state message!" );
+        User::Leave(KErrArgument);
+        }
+    CleanupStack::PopAndDestroy(buf);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::GetDataLengthL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::GetDataLengthL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: GetDataLengthL" );
+    TUint32 id;
+    TPckg<TUint32> pid(id);
+
+    TInt read(aMessage.Read(0, pid));
+
+    TInt length(0);
+
+    TDeplCompAttrType dt;
+    TPckg<TDeplCompAttrType> pdt(dt);
+    read = aMessage.Read(1, pdt);
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
+    if (compo.State() == EDCSDelivered)
+        {
+        if (dt == EDCInstallOptions)
+            {
+            if (compo.InstallOptsSet())
+                {
+                length = sizeof(TAMInstallOptions);
+                }
+            }
+        else if (dt == EDCData)
+            {
+            length = compo.Data().DataLengthL();
+            }
+        else if (dt == EDCDataMime)
+            {
+            length = compo.Data().MimeType().Length();
+            }
+        else if (dt == EDCMetaData)
+            {
+            length = compo.MetaData().DataLengthL();
+            }
+        else if (dt == EDCMetaDataMime)
+            {
+            length = compo.MetaData().MimeType().Length();
+            }
+        else
+            {
+            RDEBUG_2( "ApplicationManagementSession: GetDataLengthL ERROR called with illegal type %d", dt );
+            User::Leave(KErrArgument);
+            }
+        }
+    else if (compo.State() == EDCSDownload)
+        {
+        if (dt == EDCDownloadURI)
+            {
+            length = compo.DownloadURI().Length();
+            }
+        else if (dt == EDCInstallOptions)
+            {
+            if (compo.InstallOptsSet())
+                {
+                length = sizeof(TAMInstallOptions);
+                }
+            }
+        else
+            {
+            RDEBUG_2( "ApplicationManagementSession: GetDataLengthL ERROR Download / called with illegal state component id %d",
+                    compo.State() );
+            User::Leave(KErrArgument);
+            }
+        }
+    else
+        {
+        RDEBUG_2( "ApplicationManagementSession: GetDataLengthL ERROR called with illegal state component id %d",
+                compo.State() );
+        User::Leave(KErrArgument);
+        }
+
+    TPckg<TInt> pcomp(length);
+    aMessage.Write(2, pcomp);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::GetDataL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::GetDataL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: GetDataL" );
+    TUint32 id;
+    TPckg<TUint32> pid(id);
+
+    TInt read(aMessage.Read(0, pid));
+
+    TDeplCompAttrType dt;
+    TPckg<TDeplCompAttrType> pdt(dt);
+    read = aMessage.Read(1, pdt);
+
+    RDEBUG_3( "ApplicationManagementSession: GetDataL id is %d, and attribute %d", id, dt );
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(id);
+    if (dt == EDCStatus)
+        {
+        TPckg<TInt> p(compo.Status());
+        aMessage.Write(2, p);
+        }
+    else if (compo.State() == EDCSDelivered)
+        {
+        if (dt == EDCInstallOptions)
+            {
+            if (compo.InstallOptsSet())
+                {
+                TAMInstallOptionsPckgBuf pckg(compo.InstallOpts());
+                aMessage.Write(2, pckg);
+                }
+            else
+                {
+                aMessage.Write(2, KNullDesC8);
+                }
+            }
+        else if (dt == EDCData)
+            {
+            aMessage.Write(2, compo.Data().Data());
+            }
+        else if (dt == EDCDataMime)
+            {
+            aMessage.Write(2, compo.Data().MimeType());
+            }
+        else if (dt == EDCMetaData)
+            {
+            aMessage.Write(2, compo.MetaData().Data());
+            }
+        else if (dt == EDCMetaDataMime)
+            {
+            aMessage.Write(2, compo.MetaData().MimeType());
+            }
+        else
+            {
+            RDEBUG_2( "ApplicationManagementSession: GetDataL ERROR called with illegal type %d", dt );
+            User::Leave(KErrArgument);
+            }
+        }
+    else if (compo.State() == EDCSDownload)
+        {
+
+        if (dt == EDCDownloadURI)
+            {
+            aMessage.Write(2, compo.DownloadURI());
+            }
+
+        else if (dt == EDCInstallOptions)
+            {
+            if (compo.InstallOptsSet())
+                {
+                TAMInstallOptionsPckgBuf pckg(compo.InstallOpts());
+                aMessage.Write(2, pckg);
+                }
+            else
+                {
+                aMessage.Write(2, KNullDesC8);
+                }
+            }
+        else if (dt == EDCConRef)
+            {
+            TPckg<TInt> p(compo.GetIAP());
+            aMessage.Write(2, p);
+            }
+        else
+            {
+            RDEBUG_2( "ApplicationManagementSession:GetDataL ERROR called with illegal type %d", dt );
+            User::Leave(KErrArgument);
+            }
+        }
+    else
+        {
+        RDEBUG_2("ApplicationManagementSession: GetDataL ERROR called with illegal state component id %d", compo.State() );
+        User::Leave(KErrArgument);
+        }
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::RemoveL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::RemoveL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: RemoveL" );
+    TUint32 id;
+    TPckg<TUint32> pid(id);
+    TInt read(aMessage.Read(0, pid));
+    RDEBUG_2( "ApplicationManagementSession: RemoveL id is %d", id );
+    RemoveInternalL(id);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::RemoveInternalL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::RemoveInternalL(const TUint32 &aId) const
+    {
+    CDeploymentComponent &compo = Server().Storage()->ComponentL(aId);
+
+    Server().RemoveInternalL(compo);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::DownloadL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::DownloadL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: DownloadL" );
+
+    TDCUserId userId;
+    aMessage.ReadL(1, userId);
+    CDeploymentComponent *compo = NULL;
+
+    if (iTrustAdded)
+        {
+        compo = Server().Storage()->NewComponentL(EDCSDownload, userId,
+                &iCertInfo);
+        }
+    else
+        {
+        compo = Server().Storage()->NewComponentL(EDCSDownload, userId);
+        }
+    TUint32 i(compo->InternalId());
+    TPckg<TUint32> p(i);
+    aMessage.WriteL(0, p);
+    RDEBUG( "ApplicationManagementSession: DownloadL end" );
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::FullUpdateL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::FullUpdateL(const RMessage2& aMessage) const
+    {
+    RDEBUG( "ApplicationManagementSession: FullUpdateL" );
+
+    TUint32 sid;
+
+    TPckg<TUint32> psid(sid);
+    TInt read(aMessage.Read(0, psid));
+    TUint32 tid;
+    TPckg<TUint32> ptid(tid);
+    TInt read2(aMessage.Read(1, ptid));
+
+    RDEBUG_3( "ApplicationManagementSession: FullUpdateL sid is %d, tid is %d", sid, tid );
+    CApplicationManagementServer &server = Server();
+    server.FullUpdateL(sid, tid);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::ServiceError()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::ServiceError(const RMessage2& aMessage,
+        TInt aError)
+    {
+    RDEBUG_2( "ApplicationManagementSession: CApplicationManagementSession::ServiceError %d", aError);
+    CSession2::ServiceError(aMessage, aError);
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::AddTrustL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::AddTrustL(const RMessage2 &aMessage)
+    {
+    TPckg<TCertInfo> pkg(iCertInfo);
+    aMessage.ReadL(0, pkg);
+    iTrustAdded = ETrue;
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::StateChangeComponentIdsL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::StateChangeComponentIdsL(
+        const RMessage2& aMessage) const
+    {
+    RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsL" );
+    RComponentIdArray arr;
+    Server().Storage()->GetStateChangeComponentIdsL(arr);
+    TInt buflen(arr.Count());
+    TUint32* buf = new (ELeave) TUint32[buflen];
+    CleanupArrayDeletePushL(buf);
+    for (TInt i(0); i < buflen; i++)
+        {
+        RDEBUG_2( "ApplicationManagementSession:ComponentIdsL Adding %d!!", arr[i]);
+        buf[i] = arr[i];
+        }
+    TPtrC8 p((TUint8*) buf, buflen * sizeof(TUint32));
+    aMessage.WriteL(0, p);
+    arr.Close();
+    CleanupStack::PopAndDestroy(buf);
+    RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsL end" );
+
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::StateChangeComponentIdsCountL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::StateChangeComponentIdsCountL(
+        const RMessage2& aMessage) const
+    {
+    RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsCountL" );
+    RPointerArray<TPreInstalledAppParams> preInstalledAppParams;
+    CAMPreInstallApp* preInstallApp = CAMPreInstallApp::NewL();
+    preInstallApp->GetPreInstalledAppsL(preInstalledAppParams);
+    TInt count = 0;
+    for (count = 0; count < preInstalledAppParams.Count(); count++)
+        {
+        RDEBUG8_2("CApplicationManagementSession::DownloadL: Installed App Name is: %S",&(preInstalledAppParams[count]->iPreInstalledAppame));
+        RDEBUG8_2("CApplicationManagementSession::DownloadL: Installed App Vendor is: %S",&(preInstalledAppParams[count]->iPreInstalledAppVendorName));
+        RDEBUG_2("CApplicationManagementSession::DownloadL: Installed App UID is : '0x%X'",preInstalledAppParams[count]->iPreInstalledAppUid);
+
+        TBool found = EFalse;
+        const RComponentIdArray &arrt = Server().Storage()->GetComponentIds();
+        TInt countval(arrt.Count());
+        for (TInt i(0); i < countval; i++)
+            {
+            CDeploymentComponent &compo = Server().Storage()->ComponentL(
+                    arrt[i]);
+            if (compo.Uid()
+                    == preInstalledAppParams[count]->iPreInstalledAppUid)
+                {
+                RDEBUG( "CApplicationManagementSession: ActiveComponentsL found= TRUE" );
+                found = ETrue;
+                }
+            }
+        if (!found)
+            {
+            RDEBUG( "CApplicationManagementSession: Adding Pre-installed app" );
+            TDCUserId preInstalledAppName;
+            preInstalledAppName.Copy(
+                    preInstalledAppParams[count]->iPreInstalledAppame);
+            CDeploymentComponent *preInstallCompo = NULL;
+            RDEBUG8_2("CApplicationManagementSession: Installed App Name is: %S",&preInstalledAppName);
+            preInstallCompo = Server().Storage()->NewComponentL(EDCSActive,
+                    preInstalledAppName);
+            preInstallCompo->SetUid(
+                    preInstalledAppParams[count]->iPreInstalledAppUid);
+            preInstallCompo->SetNameL(preInstalledAppName);
+            preInstallCompo->SetVersionL(
+                    preInstalledAppParams[count]->iVersion);
+            preInstallCompo->SetMimeTypeL(
+                    preInstalledAppParams[count]->iMimeType);
+            preInstallCompo->SetAppRemovableStatus(ETrue);
+
+            Server().Storage()->UpdateL(*preInstallCompo);
+            Server().Storage()->CheckForDuplicateNodesInDeployedL(
+                    *preInstallCompo);
+            }
+        }
+    delete preInstallApp;
+    RComponentIdArray arr;
+    Server().Storage()->GetStateChangeComponentIdsL(arr);
+    TPckgBuf<TInt> buflen(arr.Count());
+    aMessage.WriteL(0, buflen);
+    arr.Close();
+    RDEBUG( "CApplicationManagementSession: StateChangeComponentIdsCountL end" );
+    }
+
+// -------------------------------------------------------------------------------------------------------------------
+// CApplicationManagementSession::StateChangeCompleteL()
+// -------------------------------------------------------------------------------------------------------------------
+
+void CApplicationManagementSession::StateChangeCompleteL(
+        const RMessage2& aMessage) const
+    {
+    RDEBUG( "CApplicationManagementSession: StateChangeCompleteL" );
+    TUint32 tid;
+    TPckg<TUint32> ptid(tid);
+    TInt read2(aMessage.Read(0, ptid));
+    Server().Storage()->StateChangedL(tid);
+    }
+void CApplicationManagementSession::CheckStatusNodesValuesL()
+    {
+    const RComponentIdArray &arrt = Server().Storage()->GetComponentIds();
+    TInt cont(arrt.Count());
+    TBool isUpdateRequired = ETrue;
+    for (TInt i(0); i < cont; i++)
+        {
+        CDeploymentComponent &compo = Server().Storage()->ComponentL(arrt[i]);
+        isUpdateRequired = EFalse;
+        if (compo.Status() == EDownload_DownloadProgress)
+            {
+            compo.SetStatusNode(EDownload_DownloadFailed);
+            isUpdateRequired = ETrue;
+            }
+        else if (compo.Status() == EDelivered_InstallProgress)
+            {
+            compo.SetStatusNode(EDelivered_InstalledFailedWithData);
+            isUpdateRequired = ETrue;
+            }
+        else if (compo.Status() == EDelivered_RemoveProgress)
+            {
+            compo.SetStatusNode(EDelivered_RemoveFailed);
+            isUpdateRequired = ETrue;
+            }
+        else if (compo.Status() == EDeployed_RemoveProgress)
+            {
+            compo.SetStatusNode(EDeployed_RemoveFailed);
+            isUpdateRequired = ETrue;
+            }
+        else if (compo.Status() == EDeployed_ActivateProgress)
+            {
+            compo.SetStatusNode(EDeployed_ActivateFailed);
+            isUpdateRequired = ETrue;
+            }
+        else if (compo.Status() == EDeployed_DeactivateProgress)
+            {
+            compo.SetStatusNode(EDeployed_DeactivateFailed);
+            isUpdateRequired = ETrue;
+            }
+        if (isUpdateRequired)
+            Server().Storage()->UpdateL(compo);
+        }
+
+    }
+
+void CApplicationManagementServer::SetSisAppVersionAndDriveL(
+        CDeploymentComponent &aCompo)
+    {
+    RDEBUG( "CApplicationManagementSession: SetSisAppVersionAndDriveL: Begin" );
+
+    Swi::RSisRegistrySession sisSession;
+    User::LeaveIfError(sisSession.Connect());
+    CleanupClosePushL(sisSession);
+
+    Swi::RSisRegistryEntry sisEntry;
+
+    //Opens the base package entry by specifying a UID. 
+    User::LeaveIfError(sisEntry.Open(sisSession, aCompo.Uid()));
+    CleanupClosePushL(sisEntry);
+
+    TUint drivesMask = sisEntry.InstalledDrivesL();
+
+    TInt drive = EDriveA;
+    TDriveNumber installedDrive = EDriveC;
+
+    if (drivesMask)
+        {
+        // Select the highest drive as location drive. That's the case when 
+        // all installation is not in same drive
+
+        while (drivesMask >>= 1)
+            {
+            drive++;
+            }
+
+        RDEBUG_2( "drive -> SetSisAppVersionAndDriveL %d", drive);
+
+        installedDrive = (TDriveNumber) drive;
+        }
+
+    TBool status = EFalse;
+
+    //Since "C" drive is not removable
+
+    if (installedDrive != EDriveC)
+        {
+        status = IsInstalledAppRemovableL(installedDrive);
+        }
+    if (status)
+        {
+        RDEBUG( "IsInstalledAppRemovableL(SetSisAppVersionAndDriveL); True");
+        }
+    else
+        {
+        RDEBUG( "IsInstalledAppRemovableL(SetSisAppVersionAndDriveL); False");
+        }
+
+    //check for status drive
+    aCompo.SetAppRemovableStatus(status);
+
+    TVersion version = sisEntry.VersionL();
+
+    if (aCompo.ComponentVersion() == KNullDesC8)
+        {
+        TBuf8<KVersionLength> pkgDes;
+        pkgDes.AppendNum(version.iMajor);
+        pkgDes.Append(KLiteralPeriod);
+        pkgDes.AppendNum(version.iMinor);
+        aCompo.SetVersionL(pkgDes);
+
+        }
+    CleanupStack::PopAndDestroy(2, &sisSession);
+
+    RDEBUG( "CApplicationManagementSession: SetSisAppVersionAndDriveL: End" );
+    }
+
+TBool CApplicationManagementServer::IsInstalledAppRemovableL(
+        TDriveNumber &iDrive)
+    {
+    RDEBUG( "IsInstalledAppRemovableL: Step1" );
+    TBool removable = EFalse;
+    RFs rfs;
+    User::LeaveIfError(rfs.Connect());
+    CleanupClosePushL(rfs);
+    TDriveList driveList;
+    TInt driveCount;
+
+    //Get all removeable drive, both physically and logically
+    User::LeaveIfError(DriveInfo::GetUserVisibleDrives(rfs, driveList,
+            driveCount, KDriveAttRemovable));
+
+    TInt max(driveList.Length());
+
+    RDEBUG_2( "driveList.Length() %d", max);
+
+    RDEBUG_2( "driveCount %d", driveCount);
+
+    TBuf<26> buf;
+    buf.Copy(driveList);
+    RDEBUG_2( "Drive Info (%S)", &buf);
+
+    for (TInt i = 0; i < max; ++i)
+        {
+        if (driveList[i])
+            {
+            TUint status;
+            RDEBUG( "IsInstalledAppRemovableL: Step3" );
+            DriveInfo::GetDriveStatus(rfs, i, status);
+
+            RDEBUG( "IsInstalledAppRemovableL: Step4" );
+            //To make sure the drive is physically removeable not logically removeable  
+            if (status & DriveInfo::EDriveRemovable)
+                {
+                RDEBUG( "IsInstalledAppRemovableL: Drive removable" );
+                RDEBUG_2( "IsInstalledAppRemovableL: Drive removable Drive ID %d", i);
+                if (i == iDrive)
+                    {
+                    RDEBUG( "IsInstalledAppRemovableL: Step5" );
+                    removable = ETrue;
+                    break;
+                    }
+                }
+            }
+        }
+
+    CleanupStack::PopAndDestroy(&rfs);
+
+    return removable;
+    }
+
+// -----------------------------------------------------------------------------
+// CShutDown::CShutdown()
+// ------------------------------------------------------------------------------------------------
+
+inline CShutdown::CShutdown() :
+    CTimer(-1)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CShutDown::ConstructL()
+// ------------------------------------------------------------------------------------------------
+
+inline void CShutdown::ConstructL()
+    {
+    CTimer::ConstructL();
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CShutDown::Start()
+// ------------------------------------------------------------------------------------------------
+
+inline void CShutdown::Start()
+    {
+    RDEBUG( "ApplicationManagementServer: starting shutdown timeout" );
+    After(KApplicationManagementShutdownDelay);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CShutDown::RunL()
+// ------------------------------------------------------------------------------------------------
+
+void CShutdown::RunL()
+    {
+    RDEBUG( "ApplicationManagementServer timeout ... closing" );
+    HbApplication::exit(0);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// CShutDown::Start()
+// ------------------------------------------------------------------------------------------------
+inline void CShutdown::Stop()
+    {
+    RDEBUG( "ApplicationManagementServer: Stop" );
+    HbApplication::exit(0);
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/ApplicationManagementUtility.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+ *
+* Description:  Implementation of applicationmanagement components
+ *
+*/
+
+
+//	CLASS HEADER
+#include "ApplicationManagementUtility.h"
+#include "debug.h"
+using namespace NApplicationManagement;
+
+// CONSTRUCTION
+CApplicationManagementUtility* CApplicationManagementUtility::NewL()
+    {
+    CApplicationManagementUtility* self =
+            CApplicationManagementUtility::NewLC();
+    CleanupStack::Pop();
+
+    return self;
+    }
+TInt CApplicationManagementUtility::mHidden=0;
+HbDialog* CApplicationManagementUtility::mCurrDlg=0;
+TInt CApplicationManagementUtility::iSilentSession = 0;
+TFileName CApplicationManagementUtility::iFileName(KNullDesC);
+
+CApplicationManagementUtility* CApplicationManagementUtility::NewLC()
+    {
+    CApplicationManagementUtility* self = new( ELeave ) CApplicationManagementUtility();
+    CleanupStack::PushL(self);
+
+    self->ConstructL();
+    return self;
+    }
+
+// Destructor (virtual by CBase)
+CApplicationManagementUtility::~CApplicationManagementUtility()
+    {
+    }
+
+// Default constructor
+CApplicationManagementUtility::CApplicationManagementUtility()
+    {
+    }
+
+// Second phase construct
+void CApplicationManagementUtility::ConstructL()
+    {
+    }
+
+TBool CApplicationManagementUtility::FindInstalledJavaUidL(const TUid& /*aUid*/) const
+    {
+    return EFalse;
+    }
+
+void CApplicationManagementUtility::InstalledSuiteUidsL(RArray <TUid>)
+    {
+    // do nothing
+    }
+
+void CApplicationManagementUtility::JavaUidsL(RArray<TUid>& /*aUids*/)
+    {
+    // do nothing
+    }
+
+void CApplicationManagementUtility::RefreshJavaRegistryL()
+    {
+    // do nothing
+    }
+void CApplicationManagementUtility::GetInstalledMidletParametersL(
+        TMidletParameters& /*aMidletParameters*/)
+    {
+    RDEBUG( "CApplicationManagementUtility::GetInstalledMidletParametersL: Start");
+    //do nothng
+    RDEBUG( "CApplicationManagementUtility::GetInstalledMidletParametersL: end");
+    }
+void CApplicationManagementUtility::SetFileName(const TFileName& aFileName)
+    {
+	iFileName = aFileName;
+    }
+void CApplicationManagementUtility::GetFileName(TFileName& aFileName)
+   {
+	aFileName = iFileName;
+   }
+	
+//  END OF FILE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/ApplicationManagementUtilityFactory.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -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: Implementation of applicationmanagement components
+ *
+ */
+
+//	CLASS HEADER
+#include "ApplicationManagementUtilityFactory.h"
+
+using namespace NApplicationManagement;
+
+//  METHODS
+CApplicationManagementUtility* ApplicationManagementUtilityFactory::CreateManagementUtilityL()
+    {
+    return CApplicationManagementUtility::NewL();
+    }
+
+//  END OF FILE
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/amstorage.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,643 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+
+#include <centralrepository.h>
+#include <s32mem.h>
+#include <s32file.h>
+#include <e32des8.h>
+#ifndef __SERIES60_30__
+#include "AMAppHideUtil.h"
+#endif
+#include "debug.h"
+#include "amprivateCRKeys.h"
+#include "amstorage.h"
+#include "AMDeploymentComponent.h"
+
+using namespace NApplicationManagement;
+
+// CONSTANTS
+
+
+/***************************************************
+ // RComponentIdArray
+ ***************************************************/
+
+void RComponentIdArray::SetListL(const TDesC8& aChilds)
+    {
+#ifdef _DEBUG
+    HBufC *b = HBufC::NewLC(aChilds.Length() );
+    TPtr p(b->Des() );
+    p.Copy(aChilds);
+    RDEBUG_2( "RComponentIdArray::SetListL: Setting list from: '%S'", &p);
+    CleanupStack::PopAndDestroy(b);
+#endif
+
+    RDesReadStream buf(aChilds);
+    //TInt size( buf.Source()->TellL( MStreamBuf::ERead ).SizeL() );
+    TInt left(aChilds.Length() );
+    const TInt KSize(sizeof(TUint32));
+    while (left > 0)
+        {
+        TUint32 val(buf.ReadUint32L() );
+#ifdef _DEBUG
+        RDEBUG_2( "RComponentIdArray::SetListL: Appending id: '%d'", val);
+#endif
+        Append(val);
+        left -= KSize;
+        }
+    buf.Close();
+    }
+
+void RComponentIdArray::RemoveByValue(TUint32 aValue)
+    {
+    TInt ind(Find(aValue) );
+    Remove(ind);
+    }
+
+void RComponentIdArray::GetListLC(HBufC8 *&aChilds, TInt &aLength)
+    {
+    ASSERT( aChilds == NULL );
+    TInt c(Count() );
+    if (c > 0)
+        {
+        aLength = c * sizeof(TUint32);
+        aChilds = HBufC8::NewLC(aLength);
+        TPtr8 p(aChilds->Des() );
+        RDesWriteStream stream(p);
+        CleanupClosePushL(stream);
+        TInt i( 0);
+        do
+            {
+            stream.WriteUint32L(operator[](i) );
+            }
+        while ( ++i < c);
+        stream.CommitL();
+        CleanupStack::PopAndDestroy( &stream);
+        }
+    else
+        {
+        aChilds = KNullDesC8().AllocLC();
+        aLength = 0;
+        }
+    }
+
+/*	
+ void TCertInfoPckg::ExternalizeL(RWriteStream& aStream) const
+ {
+ aStream << iId;
+ TPckgBuf<TCertInfo>::ExternalizeL( aStream );
+ }
+
+ void TCertInfoPckg::InternalizeL(RReadStream& aStream)
+ {
+ 
+ }
+ */
+
+void RCertArray::ExternalizeL(RWriteStream& aStream) const
+    {
+    TInt c(Count() );
+    aStream.WriteInt32L(c);
+    for (TInt i( 0); i < c; i++)
+        {
+        aStream.WriteInt32L(i);
+        aStream << (*(operator[](i)));
+        }
+    }
+
+void RCertArray::InternalizeL(RReadStream& aStream)
+    {
+    TInt c(aStream.ReadInt32L() );
+    for (TInt i( 0); i < c; i++)
+        {
+        TCertInfoPckg *pkg = new ( ELeave ) TCertInfoPckg;
+        RDEBUG_2( "RCertArray::InternalizeL - allocated TCertInfoPckg 0x%X", reinterpret_cast<TUint>( pkg ) );
+        CleanupStack::PushL(pkg);
+        TInt idx(aStream.ReadInt32L() );
+        aStream >> (*pkg);
+        Append(pkg);
+        CleanupStack::Pop(pkg);
+        }
+    }
+
+TInt RCertArray::FindByValue(const TCertInfoPckg &aPckg)
+    {
+    TInt c(Count() );
+    for (TInt i( 0); i < c; i++)
+        {
+        if (operator[](i)->Compare(aPckg) == 0)
+            {
+            return i;
+            }
+        }
+    return KErrNotFound;
+    }
+
+/***************************************************
+ // CDeliveryComponentStorage
+ ***************************************************/
+
+CDeliveryComponentStorage::CDeliveryComponentStorage()
+    {
+
+    }
+
+void CDeliveryComponentStorage::ConstructL()
+    {
+#ifndef __SERIES60_30__
+    iHidder = CAMAppHideUtil::NewL();
+#endif
+    LoadCertsL();
+    TRAPD( erx, iRepository = CRepository::NewL ( KCRUidPrivateApplicationManagementKeys ) )
+    ;
+    if (erx != KErrNone)
+        {
+        RDEBUG_2( "CDeliveryComponentStorage::ConstructL() ERROR CentRep not initialized: Check deployment! %d", erx );
+        User::Leave(erx);
+        }
+    TInt err(iRepository->Get(KNextIdKey, iNextId) );
+    if (err == KErrNotFound)
+        {
+        iNextId = KMinIdValue;
+        User::LeaveIfError(iRepository->Create(KNextIdKey, iNextId) );
+        }
+    else
+        {
+        User::LeaveIfError(err);
+        }
+    LoadComponentsL();
+    }
+
+void CDeliveryComponentStorage::LoadCertsL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect() );
+    CleanupClosePushL(fs);
+    TInt e(fs.CreatePrivatePath(KDefaultDrive) );
+
+    User::LeaveIfError(e);
+    TBuf<64> privatePath;
+    User::LeaveIfError(fs.PrivatePath(privatePath) );
+
+    TInt privPathLength(privatePath.Length() );
+    _LIT( KCertFile, "amcerts.dat");
+    HBufC *afile = HBufC::NewLC(privPathLength + KCertFile().Length());
+    *afile = privatePath;
+    afile->Des().Append(KCertFile);
+    RFileReadStream certFile;
+    TInt err(certFile.Open(fs, *afile, EFileRead) );
+    if (err == KErrNone)
+        {
+        CleanupClosePushL(certFile);
+        iCertificates.InternalizeL(certFile);
+        CleanupStack::PopAndDestroy( &certFile);
+        }
+    else
+        if (err == KErrNotFound)
+            {
+
+            }
+        else
+            {
+            User::Leave(err);
+            }
+    CleanupStack::PopAndDestroy(afile);
+    CleanupStack::PopAndDestroy( &fs);
+    }
+
+CDeliveryComponentStorage* CDeliveryComponentStorage::NewLC()
+    {
+    CDeliveryComponentStorage *self = new ( ELeave ) CDeliveryComponentStorage( );
+    CleanupStack::PushL(self) ;
+    self->ConstructL() ;
+    return self;
+    }
+
+CDeliveryComponentStorage* CDeliveryComponentStorage::NewL()
+    {
+    CDeliveryComponentStorage *self = NewLC();
+    CleanupStack::Pop(self) ;
+    return self;
+    }
+
+TInt CDeliveryComponentStorage::NextKey()
+    {
+    TInt oldNext(iNextId++);
+    iRepository->Set(KNextIdKey, iNextId);
+    return oldNext;
+    }
+
+CDeliveryComponentStorage::~CDeliveryComponentStorage()
+    {
+    RDEBUG_3( "CDeliveryComponentStorage::~CDeliveryComponentStorage 0x%X - 0x%X", reinterpret_cast<TUint>(this),
+            reinterpret_cast<TUint>(this)+sizeof( CDeliveryComponentStorage ) );
+    delete iRepository;
+    iRepository = NULL;
+    iComponents.ResetAndDestroy();
+    iComponentIds.Close();
+    TRAPD( err,CloseCertificatesL() )
+    ;
+    if (err != KErrNone)
+        {
+        RDEBUG_2( "CDeliveryComponentStorage::~CDeliveryComponentStorage: ERROR Failed to close certificate storage properly: %d", err);
+        }
+#ifndef __SERIES60_30__
+    delete iHidder;
+    iHidder = NULL;
+#endif
+    }
+
+void CDeliveryComponentStorage::CloseCertificatesL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect() );
+    CleanupClosePushL(fs);
+    TInt e(fs.CreatePrivatePath(KDefaultDrive) );
+
+    User::LeaveIfError(e);
+    TBuf<64> privatePath;
+    User::LeaveIfError(fs.PrivatePath(privatePath) );
+
+    TInt privPathLength(privatePath.Length() );
+    _LIT( KCertFile, "amcerts.dat");
+    HBufC *afile = HBufC::NewLC(privPathLength + KCertFile().Length());
+    *afile = privatePath;
+    afile->Des().Append(KCertFile);
+    RFileWriteStream certFile;
+
+    TInt err(certFile.Replace(fs, *afile, EFileWrite) );
+    if (err == KErrNone)
+        {
+        CleanupClosePushL(certFile);
+        iCertificates.ExternalizeL(certFile);
+        CleanupStack::PopAndDestroy( &certFile);
+        }
+    else
+        if (err == KErrNotFound)
+            {
+
+            }
+        else
+            {
+            User::Leave(err);
+            }
+    CleanupStack::PopAndDestroy(afile);
+    CleanupStack::PopAndDestroy( &fs);
+    iCertificates.ResetAndDestroy();
+    }
+
+const RComponentIdArray &CDeliveryComponentStorage::GetComponentIds() const
+    {
+    return iComponentIds;
+    }
+
+void CDeliveryComponentStorage::GetStateChangeComponentIdsL(
+        RComponentIdArray &aArray)
+    {
+    RDEBUG_2( "CDeliveryComponentStorage::GetStateChangeComponentIdsL %d dcs", iComponentIds.Count());
+    aArray.Reset();
+    TInt c(iComponentIds.Count() );
+    for (TInt i( 0); i < c; i++)
+        {
+        CDeploymentComponent &compo = ComponentL(iComponentIds[i]);
+        if (compo.OldState() != EDCSNone)
+            {
+            aArray.Append(iComponentIds[i]);
+            }
+        }
+    RDEBUG( "CDeliveryComponentStorage::GetStateChangeComponentIdsL end");
+    }
+
+void CDeliveryComponentStorage::StateChangedL(TUint32 aInternalId)
+    {
+    RDEBUG_2( "CDeliveryComponentStorage::StateChangedL id %d", aInternalId);
+    CDeploymentComponent &compo = ComponentL(aInternalId);
+    compo.StateChangeComplete();
+    UpdateL(compo);
+    }
+
+void CDeliveryComponentStorage::LoadComponentsL()
+    {
+    TInt length( 0);
+    TInt err(iRepository->Get(KIdListLengthKey, length) );
+    if (err == KErrNotFound)
+        {
+        length = 0;
+        User::LeaveIfError(iRepository->Create(KIdListLengthKey, length) );
+        }
+    else
+        {
+        User::LeaveIfError(err);
+        }
+    HBufC8 *listbuf = HBufC8::NewLC(length) ;
+    TPtr8 ptr(listbuf->Des() );
+    err = iRepository->Get(KIdListKey, ptr) ;
+    if (err == KErrNotFound)
+        {
+        err = iRepository->Create(KIdListKey, KNullDesC8);
+        }
+    else
+        {
+
+        }
+    User::LeaveIfError(err);
+    TRAPD(code, iComponentIds.SetListL( ptr ))
+    ;
+    if (code != KErrEof)
+        {
+        User::LeaveIfError(code);
+        }
+
+    CleanupStack::PopAndDestroy(listbuf);
+#ifndef __SERIES60_30__
+    TInt i(iComponentIds.Count() );
+    //iHidder->Reset();
+    while ( --i >= 0)
+        {
+        CDeploymentComponent &comp = ComponentL(iComponentIds[i]);
+        if (comp.State() == EDCSInactive)
+            {
+            iHidder->AddUidL(comp.Uid());
+            }
+        else
+            if (comp.State() == EDCSActive)
+                {
+                iHidder->RemoveUidL(comp.Uid() );
+                }
+        }
+    iHidder->PersistUidsL();
+#endif
+
+    }
+
+CDeploymentComponent *CDeliveryComponentStorage::NewComponentL(
+        const TDeploymentComponentState &aState, const TDCUserId &aUserId,
+        const TCertInfo *aCertInfo/* = NULL */)
+    {
+    CDeploymentComponent *newc = CDeploymentComponent::NewLC(NextKey(),
+            aUserId);
+    if (aCertInfo != NULL)
+        {
+        TCertInfoPckg *p = new( ELeave ) TCertInfoPckg(*aCertInfo);
+        RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - allocated TCertInfoPckg 0x%X", reinterpret_cast<TUint>( p ) );
+
+        TInt idx(iCertificates.FindByValue(*p) );
+        if (idx == KErrNotFound)
+            {
+            RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - TCertInfoPckg NOT found 0x%X", reinterpret_cast<TUint>( p ) );
+            iCertificates.Append(p);
+            idx = iCertificates.Count() - 1;
+            }
+        else
+            {
+            RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - TCertInfoPckg found at %d, deleting temporary", idx );
+            delete p;
+            p = NULL;
+            }
+        if (idx >= 0)
+            {
+            RDEBUG_2( "CDeliveryComponentStorage::NewComponentL - TCertInfoPckg found 0x%X", reinterpret_cast<TUint>( p ) );
+            newc->SetOwner(idx);
+            }
+        else
+            {
+            RDEBUG_3( "CDeliveryComponentStorage::NewComponentL - WARNING Could not add certificate 0x%X: %d", reinterpret_cast<TUint>( p ), idx );
+
+            }
+        }
+    newc->SetState(aState);
+    newc->SetStatusNode(EIdle);
+    UpdateL( *newc);
+    iComponents.Append(newc);
+    iComponentIds.Append(newc->InternalId() );
+RDEBUG_2( "CDeliveryComponentStorage::NewComponentL -Internal ID is  %d, ", newc->InternalId() );
+    PersistStateL();
+    CleanupStack::Pop(newc);
+    return newc;
+    }
+
+void CDeliveryComponentStorage::UpdateL(
+        const CDeploymentComponent &aComponent)
+    {
+    aComponent.PersistL( *iRepository) ;
+
+#ifndef __SERIES60_30__
+    if (aComponent.State() == EDCSInactive)
+        {
+        iHidder->AddUidL(aComponent.Uid(), ETrue);
+        }
+    else
+        {
+        iHidder->RemoveUidL(aComponent.Uid(), ETrue);
+        }
+#endif
+    }
+
+void CDeliveryComponentStorage::PersistStateL()
+    {
+    TInt length( 0);
+    HBufC8 *buf= NULL;
+    iComponentIds.GetListLC(buf, length);
+    User::LeaveIfError(iRepository->Set(KIdListLengthKey, length) );
+    User::LeaveIfError(iRepository->Set(KIdListKey, *buf) );
+    CleanupStack::PopAndDestroy(buf);
+    }
+
+void CDeliveryComponentStorage::RemoveL(TUint32 aInternalId)
+    {
+    RDEBUG_2("CDeliveryComponentStorage::RemoveL - Remove id: (%d)", aInternalId );
+    TInt count(iComponents.Count() );
+    for (TInt i( 0); i < count; i++)
+        {
+        CDeploymentComponent *el = iComponents[i];
+        if (aInternalId == el->iInternalId)
+            {
+#ifndef __SERIES60_30__
+            iHidder->RemoveUidL(el->Uid(), ETrue);
+#endif
+            iComponents.Remove(i);
+            iComponentIds.RemoveByValue(aInternalId);
+            el->DestroyL( *iRepository);
+            delete el;
+            RDEBUG_2("CDeliveryComponentStorage::RemoveL - Removed id: (%d)", aInternalId );
+            PersistStateL();
+            break;
+            }
+        }
+    }
+
+CDeploymentComponent &CDeliveryComponentStorage::ComponentL(
+        TUint32 aInternalId)
+    {
+    CDeploymentComponent *resp= NULL;
+    TInt count(iComponents.Count() );
+    for (TInt i( 0); i < count; i++)
+        {
+        CDeploymentComponent *el = iComponents[i];
+        if (aInternalId == el->iInternalId)
+            {
+            resp = el;
+            break;
+            }
+        }
+    if (resp == NULL)
+        {
+        TBuf8< NCentralRepositoryConstants::KMaxBinaryLength> buf;
+        TInt err(iRepository->Get(aInternalId, buf) );
+        User::LeaveIfError(err) ;
+        resp = LoadComponentL(aInternalId, buf) ;
+        iComponents.Append(resp);
+        }
+    if (resp == NULL)
+        {
+        User::Leave(KErrNotFound);
+        }
+    return *resp;
+    }
+
+CDeploymentComponent *CDeliveryComponentStorage::LoadComponentL(
+        TInt aInternalId, const TDesC8 &aBuffer) const
+    {
+    CDeploymentComponent *res = CDeploymentComponent::LoadL(aInternalId,
+            aBuffer);
+#ifdef _DEBUG
+    if (res)
+        {
+        RDEBUG8_4( "CDeliveryComponentStorage::LoadComponentL - loaded component state %d, internalid %d, and userid: %S", res->State(), res->InternalId(),&res->UserId() );
+        }
+    else
+        {
+        RDEBUG( "CDeliveryComponentStorage::LoadComponentL - WARNING failed to load component" );
+        }
+#endif
+    return res;
+    }
+void CDeliveryComponentStorage::CheckForDuplicateNodesInDeployedL(
+        CDeploymentComponent &aComponent)
+    {
+    TInt CompIdsCount(iComponentIds.Count() );
+    RDEBUG8_2("CheckForDuplicateNodesInDeployedL: CompIdsCount-> (%d)", CompIdsCount );
+    RDEBUG8_2("CheckForDuplicateNodesInDeployedL: aComponent UserID is %S", &(aComponent.UserId()));
+    for (TInt i( 0); i < CompIdsCount; i++)
+        {
+        CDeploymentComponent &compo = ComponentL(iComponentIds[i]);
+        RDEBUG8_2("CheckForDuplicateNodesInDeployedL: compo UserID is %S", &(compo.UserId()));
+        if (&aComponent != &compo)
+        {
+        if (((compo.State()== EDCSActive) || (compo.State()== EDCSInactive))
+                &&(compo.UserId() == aComponent.UserId()))
+            {
+            (aComponent.iUserId).Append(*IntToDes8LC(aComponent.iInternalId));
+            CleanupStack::PopAndDestroy();
+            break;
+            }
+          }
+        }
+    }
+
+HBufC8* CDeliveryComponentStorage::IntToDes8LC(const TInt aLuid)
+    {
+    HBufC8* buf = HBufC8::NewLC( 10); //10 = max length of 32bit integer
+    TPtr8 ptrBuf = buf->Des();
+    ptrBuf.Num(aLuid);
+    return buf;
+    }
+
+void CDeliveryComponentStorage::InstalledL(CDeploymentComponent &aComponent)
+    {
+    CheckForDuplicateNodesInDeployedL(aComponent);
+    aComponent.SetState(EDCSActive);
+    // set state to IDLE 
+    aComponent.SetStatusNode(EIdle);
+    UpdateL(aComponent);
+    }
+
+void CDeliveryComponentStorage::DeactivateL(CDeploymentComponent &aComponent)
+    {
+    /* :
+     * set state to InActivate in progress
+     * use TRAP instead of leaving.
+     */
+    aComponent.SetStatusNode(EDeployed_DeactivateProgress);
+    //User::LeaveIfError(aComponent.SetState(EDCSInactive) );
+    TInt err = aComponent.SetState(EDCSInactive);
+    if (err == KErrNone)
+        {
+        TRAP(err,UpdateL(aComponent));
+        }
+    //UpdateL(aComponent);
+    /*:
+     * if error set state to InActivate failed or else set to Idle
+     * call userleaveiferror()
+     */
+    if (err == KErrNone)
+        {
+        aComponent.SetStatusNode(EIdle);
+        }
+    else
+        {
+        aComponent.SetStatusNode(EDeployed_DeactivateFailed);
+        }
+    User::LeaveIfError(err);
+    }
+
+void CDeliveryComponentStorage::SetDeploymentComponentState(CDeploymentComponent &aComponent,TDeploymentComponentState aState)
+    {
+    aComponent.SetState( aState );
+    TRAP_IGNORE(UpdateL( aComponent ));    
+    }
+
+void CDeliveryComponentStorage::ActivateL(CDeploymentComponent &aComponent)
+    {
+    /* :
+     * set state to Activate in progress
+     * use TRAP instead of leaving.
+     */
+    aComponent.SetStatusNode(EDeployed_ActivateProgress);
+    TInt err = aComponent.SetState(EDCSActive);
+    //UpdateL( aComponent );
+    if (err == KErrNone)
+        {
+        TRAP(err,UpdateL(aComponent));
+        }
+    /*:
+     * if error set state to InActivate failed or else set to Idle
+     * call userleaveiferror()
+     */
+    if (err == KErrNone)
+        {
+        aComponent.SetStatusNode(EIdle);
+        }
+    else
+        {
+        aComponent.SetStatusNode(EDeployed_ActivateFailed);
+        }
+    User::LeaveIfError(err);
+    }
+
+/*void CDeliveryComponentStorage::UninstalledL( CDeploymentComponent &aComponent )
+ {
+ aComponent.SetState( EDCSInactive );
+ UpdateL( aComponent );
+ }
+ 
+ void CDeliveryComponentStorage::ResetL()
+ {
+ }
+ */
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/amview.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#include "amview.h"
+#include "debug.h"
+using namespace NApplicationManagement;
+
+// ------------------------------------------------------------------------------------------------
+// AMView::AMView()
+// ------------------------------------------------------------------------------------------------
+AMView::AMView()
+    {
+    
+    }
+// ------------------------------------------------------------------------------------------------
+// AMView::~AMView()
+// ------------------------------------------------------------------------------------------------
+AMView::~AMView()
+    {
+    
+    }
+// ------------------------------------------------------------------------------------------------
+// AMView::eventFilter()
+// ------------------------------------------------------------------------------------------------
+bool AMView::eventFilter(QObject *object, QEvent *event)
+{   
+    switch (event->type())
+        {
+        case QEvent::ApplicationActivate:
+            {
+            RDEBUG( "eventFilter: QEvent::ApplicationActivate start" );
+            CApplicationManagementUtility::mHidden=0;
+            if(CApplicationManagementUtility::mCurrDlg)
+                CApplicationManagementUtility::mCurrDlg->setVisible(true);
+            RDEBUG( "eventFilter: end" );
+            break;
+            }
+        default:
+            break;
+        }
+return HbView::eventFilter(object, event); 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/amwaitprogdialog.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+
+#include <apgtask.h>
+#include <hbaction.h>
+#include <eikenv.h>
+#include <hblabel.h>
+#include <dmindicatorconsts.h>
+#include "amwaitprogdialog.h"
+#include "ApplicationManagementServer.h"
+
+using namespace NApplicationManagement;
+
+// ------------------------------------------------------------------------------------------------
+// AMWaitProgDialog::AMWaitProgDialog()
+// ------------------------------------------------------------------------------------------------
+AMWaitProgDialog::AMWaitProgDialog(QString aAppName, MInstallerCallBack& aCallback)
+:mDlg(0),m_callback(aCallback)
+    {
+    mIndi = 0;
+    m_appname = aAppName;
+    }
+// ------------------------------------------------------------------------------------------------
+// AMWaitProgDialog::~AMWaitProgDialog
+// ------------------------------------------------------------------------------------------------
+AMWaitProgDialog::~AMWaitProgDialog()
+    {
+    if(mDlg)
+        {
+        delete mDlg;
+        mDlg=NULL;
+        }
+    if(mIndi)
+        {
+        delete mIndi;
+        mIndi = NULL;
+        }
+    }
+// ------------------------------------------------------------------------------------------------
+// AMWaitProgDialog::createWaitDialog
+// ------------------------------------------------------------------------------------------------
+void AMWaitProgDialog::createWaitDialog(TInt aType)
+    {
+    mType = aType;
+    if(mDlg==NULL)
+        {
+        mDlg = new HbProgressDialog(HbProgressDialog::WaitDialog);
+        CApplicationManagementUtility::mCurrDlg=mDlg;
+        }
+    if (aType == EInstallWaitDlg)
+        {
+        //installing wait dialog
+        mDlg->setHeadingWidget(new HbLabel(hbTrId(
+                "txt_device_update_title_installing")));
+        mDlg->setText(hbTrId("txt_deviceupdate_info_file_1_2").arg(m_appname));
+        QString val = hbTrId("txt_common_button_hide");
+        HbAction* hide = new HbAction(mDlg);
+        hide->setText(val);
+        mDlg->clearActions();
+        mDlg->addAction(hide);
+        val = hbTrId("txt_common_button_cancel");
+        HbAction* cancel = new HbAction(mDlg);
+        cancel->setText(val);
+        mDlg->addAction(cancel);
+        QObject::connect(hide, SIGNAL(triggered()), this,
+                SLOT(hideAMWaitDialog()));
+        QObject::connect(cancel, SIGNAL(triggered()), this,
+                SLOT(cancelWaitDialog()));
+        
+        mDlg->show();
+        }
+    else
+        {
+        //uninstalling wait dialog
+    mDlg->setHeadingWidget(new HbLabel(hbTrId(
+                "txt_device_update_title_removing")));
+    mDlg->setText(hbTrId("txt_deviceupdate_info_application_1").arg(m_appname));
+        QString val = hbTrId("txt_common_button_hide");
+        HbAction* hide = new HbAction();
+        hide->setText(val);
+        mDlg->clearActions();
+        mDlg->addAction(hide);
+        val = hbTrId("txt_common_button_cancel");
+        QObject::connect(hide, SIGNAL(triggered()), this,
+                SLOT(hideAMWaitDialog()));
+        mDlg->setAttribute(Qt::WA_DeleteOnClose, true);
+        mDlg->show();
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AMWaitProgDialog::startIndicator()
+// ------------------------------------------------------------------------------------------------
+void AMWaitProgDialog::startIndicator()
+        {
+    CApplicationManagementUtility::mHidden = 1;
+    mIndi = new HbIndicator();
+    if (mType == EInstallWaitDlg)
+        {
+        QString str(hbTrId("txt_device_update_title_installing"));
+        mIndi->activate(KScomoProgressIndicatorType, str);
+        }
+    else
+        {
+        QString str(hbTrId("txt_device_update_title_removing"));
+        mIndi->activate(KScomoProgressIndicatorType, str);
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AMWaitProgDialog::closeAMWaitDialog()
+// ------------------------------------------------------------------------------------------------
+void AMWaitProgDialog::closeAMWaitDialog()
+    {
+    CApplicationManagementUtility::mCurrDlg=0;
+    if(mDlg)
+        {
+    mDlg->close();       
+        }
+    if(mIndi)
+        {
+        mIndi->deactivate(KScomoProgressIndicatorType);
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AMWaitProgDialog::hideAMWaitDialog()
+// ------------------------------------------------------------------------------------------------
+void AMWaitProgDialog::hideAMWaitDialog()
+    {
+    CCoeEnv* coe = CCoeEnv::Static();
+    TApaTaskList taskList(coe->WsSession());
+        TApaTask task=taskList.FindApp(TUid::Uid(KAppMgmtServerUid));
+        if(task.Exists())
+            {
+            task.SendToBackground();
+            }
+        startIndicator();
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AMWaitProgDialog::cancelDialog()
+// ------------------------------------------------------------------------------------------------
+void AMWaitProgDialog::cancelWaitDialog()
+    {
+    //mInstaller.CancelOperation();
+    m_callback.InstallationCancelled();
+    closeAMWaitDialog();
+    CCoeEnv* coe = CCoeEnv::Static();
+    TApaTaskList taskList(coe->WsSession());
+    TApaTask task=taskList.FindApp(TUid::Uid(KAppMgmtServerUid));  
+    if(task.Exists())
+        {
+        task.SendToBackground();
+        }
+    CApplicationManagementUtility::mCurrDlg=0;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AMWaitProgDialog::registerInstallRequest
+// ------------------------------------------------------------------------------------------------
+void AMWaitProgDialog::registerInstallRequest(TRequestStatus &stat)
+    {
+    //mInstaller = aInstaller;
+    m_Stat = &stat;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/appmgmtdownloadmgr.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,933 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+#include <nsmldmconst.h>
+#include <downloadmanager.h>
+#include <download.h>
+#include <e32Property.h>
+#include <serviceipc.h>
+#include <hbdialog.h>
+#include <hblabel.h>
+#include <HbMessageBox.h>
+#include <hbapplication.h>
+#include <hbdevicenotificationdialog.h>
+#include <hbaction.h>
+#include <apgtask.h>
+#include <coemain.h>
+#include <e32base.h>
+#include <eikenv.h>
+#include <Driveinfo.h>
+#include <e32property.h>
+#include "ApplicationManagementUtility.h"
+#include "debug.h"
+#include "dmcommon.h"
+#include "amstorage.h"
+#include "appmgmtnotifier.h"
+#include "appmgmtdownloadmgr.h"
+#include "ServicePluginLogger.h"
+using namespace NApplicationManagement;
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::appmgmtdownloadmgr
+// ------------------------------------------------------------------------------------------------ 
+appmgmtdownloadmgr::appmgmtdownloadmgr(QWidget* parent,
+        MDownloadMgrQTCallback& callback,TRequestStatus& aStatus) :
+    QWidget(parent), m_callback(callback), iStatus(aStatus)
+    {
+    iProgressNote = NULL;
+    iSetFinalValue = 0;
+    iProgressCancelled = 0;
+    iDialogAccepted = 0;
+    mEndReported = 0;
+    mNetworkLoss = 0;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::~appmgmtdownloadmgr
+// ------------------------------------------------------------------------------------------------ 
+appmgmtdownloadmgr::~appmgmtdownloadmgr()
+    {
+    if (iProgressNote)
+        {
+        iProgressNote->closeAMProgDialog();
+        delete iProgressNote;
+        iProgressNote = 0;
+        }
+    if(mNote)
+        {
+        delete mNote;
+        mNote=0;
+        }
+    
+    delete iFileName;
+    
+    delete iContentType;
+
+    delete iURI;
+    delete iComp;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::startDownload
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::startDownload(CDeploymentComponent *aComponent)
+    {
+
+    RDEBUG( "appmgmtdownloadmgr::startDownload Start" );
+
+    QString m_appName = "ApplicationManagementServer";
+
+    iComp = aComponent;
+    iDownloadManager = new DownloadManager(m_appName);
+    // initialise the downloads of the last session
+
+    connect(iDownloadManager,
+            SIGNAL(downloadManagerEvent(DownloadManagerEvent *)), this,
+            SLOT(downloadMgrEventRecieved(DownloadManagerEvent *)));
+
+    iDownloadManager->initialize();
+
+    DownloadType m_type = Parallel;
+
+    DownloadPriority m_priority = High;
+    #ifdef __WINS__
+        iDownloadManager->setProxy("bswebproxy01.americas.nokia.com", 8080);
+    #endif
+    TBuf<KMaxUrlLength> buf;
+    buf.Copy(aComponent->DownloadURI());
+
+    QString url((QChar*) buf.Ptr(), buf.Length());
+    
+    TInt silentsession = 0;
+    RProperty::Get(KPSUidNSmlSOSServerKey,KNSmlDMSilentJob,silentsession);
+    
+    CApplicationManagementUtility::iSilentSession = silentsession;
+
+    iDl = iDownloadManager->createDownload(url, m_type);
+
+    bool t = connect(iDl, SIGNAL(downloadEvent(DownloadEvent *)), this,
+            SLOT(downloadEventRecieved(DownloadEvent *)));
+
+    if (!iDl)
+        return;
+
+    QString path("c:\\system\\appmgr\\");
+
+    iDl->setAttribute(Priority, m_priority);
+    iDl->setAttribute(DestinationPath, path);
+    iDl->start();
+
+    iOperationType = aComponent->DownloadTarget();
+
+    RDEBUG( "appmgmtdownloadmgr::startDownload End" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::convertSize
+// ------------------------------------------------------------------------------------------------ 
+QString appmgmtdownloadmgr::convertSize()
+    {
+    RDEBUG( "appmgmtdownloadmgr::convertSize Start" );
+    TBuf<64> size;
+    TReal filesize;
+    TRealFormat realFormat;
+    TInt64 fileKBytes;
+    realFormat.iWidth = 6;
+    
+    //converting size to Kb
+    fileKBytes = m_totalSize / KSizeDivisor;
+    filesize = (TReal) m_totalSize / (KSizeDivisor);
+    size.Num(fileKBytes);
+    
+    //get the length of the value in Kb before the decimal point.
+    //Accordingly convert it further.
+    int len = size.Length();
+    QString text;
+    if (len >= 7)
+        {
+        //in gb
+        TReal mul = (KSizeDivisor * KSizeDivisor);
+        TReal temp = filesize / mul;
+        size.Num(temp, realFormat);
+        mSize = QString::fromUtf16(size.Ptr(), size.Length());
+        text = hbTrId("txt_deviceupdate_info_size_1_Gb").arg(mSize);
+        mSizeFormat = "gb";
+        }
+    else if (len >= 4)
+        {
+        //in mb
+        TReal temp = filesize / KSizeDivisor;
+        size.Num(temp, realFormat);
+        mSize = QString::fromUtf16(size.Ptr(), size.Length());
+        text = hbTrId("txt_deviceupdate_info_size_1_mb").arg(mSize);
+        mSizeFormat = "mb";
+        }
+    else
+        {
+        mSize = QString::fromUtf16(size.Ptr(), size.Length());
+        text = hbTrId("txt_deviceupdate_info_size_1_kb").arg(mSize);
+        mSizeFormat = "kb";
+        }
+    RDEBUG( "appmgmtdownloadmgr::convertSize End" );
+    return text;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::getAvailableDrives()
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::getAvailableDrives()
+    {
+    RDEBUG( "appmgmtdownloadmgr::getAvailableDrives start" );
+    RFs iFs;
+    qt_symbian_throwIfError(iFs.Connect());
+    TDriveList driveList;
+    TInt driveCount = 0;
+    TBuf<20> buf;
+    int i = 0;
+    QString val;
+    QStringList list;
+    TDriveInfo info;
+    TVolumeInfo volumeInfo;
+    qt_symbian_throwIfError(DriveInfo::GetUserVisibleDrives(iFs, driveList,
+            driveCount));
+    TUint driveStatus = 0;
+    for (TInt index(0); index < KMaxDrives; index++)
+        {
+        if (driveList[index])
+            {
+            TRealFormat realFormat;
+            qt_symbian_throwIfError(DriveInfo::GetDriveStatus(iFs, index,
+                    driveStatus));
+            TFileName path;
+            TDriveUnit driveUnit(index);
+            if (!(driveStatus & DriveInfo::EDriveRemote))
+                {
+                TBuf<64> freeSpace;
+                TReal free;
+                TInt64 freeKBytes;
+                realFormat.iWidth = 6;
+                iFs.Drive(info, index);
+                if(iFs.Volume(volumeInfo, index)==KErrNone)
+                    {
+                RDEBUG_2("free space: (%d)", volumeInfo.iFree  );
+                freeKBytes = 0;
+                freeKBytes = volumeInfo.iFree / KSizeDivisor;
+                free = volumeInfo.iFree / KSizeDivisor;
+                freeSpace.Num(freeKBytes);
+                TInt sizeUnit = EKb;
+
+                //converting the drive freespace
+                int len = freeSpace.Length();
+                if (len >= 7)
+                    {
+                    TReal nul = (KSizeDivisor * KSizeDivisor);
+                    TReal temp = free / nul;
+                    freeSpace.Num(temp, realFormat);
+                    sizeUnit = EGb;
+                    }
+                else
+                    {
+                    TReal temp = free / KSizeDivisor;
+                    freeSpace.Num(temp, realFormat);
+                    sizeUnit = EMb;
+                    }
+                //Getting the drive name in QString
+                path.Zero();
+                path.Append(driveUnit.Name());
+                val = QString::fromUtf16(path.Ptr(), path.Length());
+                drilist.Append(path);
+                //Getting the drive free space in QString
+                path.Zero();
+                path.Append(freeSpace);
+                QString str1 = QString::fromUtf16(path.Ptr(), path.Length());
+                QString driv;
+                if (sizeUnit == EKb)
+                    {
+                    driv
+                            = hbTrId(
+                                    "txt_deviceupdate_setlabel_install_to_val_1_2_kb").arg(
+                                    val, str1);
+                    }
+                else if (sizeUnit == EMb)
+                    {
+                    driv
+                            = hbTrId(
+                                    "txt_deviceupdate_setlabel_install_to_val_1_2_Mb").arg(
+                                    val, str1);
+                    }
+                else
+                    {
+                    driv
+                            = hbTrId(
+                                    "txt_deviceupdate_setlabel_install_to_val_1_2_Gb").arg(
+                                    val, str1);
+                    }
+                    mDriveBox->insertItem(i++, driv);
+                    }
+                }
+            }
+        }
+    RDEBUG( "appmgmtdownloadmgr::getAvailableDrives End" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::showInstalltoDialog()
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::showInstalltoDialog()
+    {
+    RDEBUG( "appmgmtdownloadmgr::showIntalltoDialog start" );
+    HbDocumentLoader loader;
+    QString val;
+    bool ok = false;
+    HbLabel* label;
+        
+    loader.load(":/xml/sample.docml", &ok);
+    if (!ok)
+        {
+        return;
+        }
+    Q_ASSERT_X(ok, "Device Manager", "Invalid docml file");
+    mDialog = qobject_cast<HbDialog*> (loader.findWidget("dialog"));
+
+    //set title for the dialog
+    label = qobject_cast<HbLabel*> (loader.findWidget(
+            "qtl_dialog_pri_heading"));
+    if (iOperationType == EInstallAndActivate)
+        {
+        val = hbTrId("txt_device_update_title_download_and_install");
+        label->setPlainText(val);
+        }
+    else
+        {
+        val = hbTrId("txt_device_update_title_install");
+        label->setPlainText(val);
+        }
+
+    //set the app name
+    label = qobject_cast<HbLabel*> (loader.findWidget("label"));
+    val = hbTrId("txt_deviceupdate_info_file_1_2").arg(m_appName);
+    label->setPlainText(val);
+
+    //size
+    label = qobject_cast<HbLabel*> (loader.findWidget("label_1"));
+    if (m_totalSize != 0)
+        {
+        m_sizeStr = convertSize();
+        label->setPlainText(m_sizeStr);
+        }
+    else
+        {
+        val = hbTrId("txt_device_update_info_details_not_available");
+        label->setPlainText(val);
+        }
+
+    //icon
+    label = qobject_cast<HbLabel*> (loader.findWidget("icon"));
+    HbIcon* icon = new HbIcon(":/icon/qgn_prop_sml_http.svg");
+    label->setIcon(*icon);
+
+    //"install to" label
+    label = qobject_cast<HbLabel*> (loader.findWidget("qtl_dialog_pri5"));
+    val = hbTrId("txt_device_update_setlabel_install_to");
+    label->setPlainText(val);
+
+    //getting the available free space in all drives and adding to combobox
+
+    mDriveBox = qobject_cast<HbComboBox*> (loader.findWidget("combobox"));
+    int err(KErrNone);
+    TRAP(err,QT_TRYCATCH_LEAVING(getAvailableDrives()));
+    
+    if(err!=KErrNone)
+        {
+        mDriveBox->setVisible(false);
+        }
+    iComp->SetDriveSelectionStatus(true);
+    CDeliveryComponentStorage* iStorage;
+    QT_TRAP_THROWING(iStorage = CDeliveryComponentStorage::NewL());
+    TRAP( err, QT_TRYCATCH_LEAVING(iStorage->UpdateL(*iComp)));
+    delete iStorage;
+    iStorage = NULL;
+    
+    connect(mDriveBox, SIGNAL(currentIndexChanged(int)), this,
+            SLOT(defaultDriveChanged(int )));
+    //setting the actions
+    mOkButton = qobject_cast<HbAction*> (loader.findObject(
+            "qtl_dialog_softkey_2_left"));
+    mCancel = qobject_cast<HbAction*> (loader.findObject(
+            "qtl_dialog_softkey_2_right"));
+    val = hbTrId("txt_common_button_ok");
+    mOkButton->setText(val);
+    val = hbTrId("txt_common_button_cancel");
+    mCancel->setText(val);
+    RDEBUG( "appmgmtdownloadmgr::showIntalltoDialog End" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::showDownloadDialog()
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::showDownloadDialog()
+    {
+    RDEBUG( "appmgmtdownloadmgr::showDownloadDialog start" );
+    HbDocumentLoader loader;
+    QString val;
+    bool ok = false;
+    HbLabel* label;
+
+    loader.load(":/xml/downloaddialog.docml", &ok);
+
+    Q_ASSERT_X(ok, "Device Manager", "Invalid docml file");
+    mDialog = qobject_cast<HbDialog*> (loader.findWidget("dialog"));
+
+    //set title for the dialog
+    label = qobject_cast<HbLabel*> (loader.findWidget(
+            "qtl_dialog_pri_heading"));
+    val = hbTrId("txt_device_update_title_download");
+    label->setPlainText(val);
+
+    //set icon
+    label = qobject_cast<HbLabel*> (loader.findWidget("icon"));
+    HbIcon* icon = new HbIcon(":/icon/qgn_prop_sml_http.svg");
+    label->setIcon(*icon);
+
+    label = qobject_cast<HbLabel*> (loader.findWidget("qtl_dialog_pri5"));
+
+    //set appname
+    val = hbTrId("txt_deviceupdate_info_file_1_2").arg(m_appName);
+    label->setPlainText(val);
+
+    //size
+    label = qobject_cast<HbLabel*> (loader.findWidget("qtl_dialog_pri5_1"));
+
+    //size
+    if (m_totalSize != 0)
+        {
+        m_sizeStr = convertSize();
+        label->setPlainText(m_sizeStr);
+        }
+    else
+        {
+        val = hbTrId("txt_device_update_info_details_not_available");
+        label->setPlainText(val);
+        }
+    //setting the actions
+    mOkButton = qobject_cast<HbAction*> (loader.findObject(
+            "qtl_dialog_softkey_2_left"));
+    mCancel = qobject_cast<HbAction*> (loader.findObject(
+            "qtl_dialog_softkey_2_right"));
+    val = hbTrId("txt_common_button_ok");
+    mOkButton->setText(val);
+    val = hbTrId("txt_common_button_cancel");
+    mCancel->setText(val);
+    RDEBUG( "appmgmtdownloadmgr::showDownloadDialog End" );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::showDialog
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::showDialog(CDeploymentComponent *aComponent)
+    {
+    CCoeEnv* coe = CCoeEnv::Static();
+    TApaTaskList taskList(coe->WsSession());
+    TApaTask task1(taskList.FindApp(TUid::Uid(KAppMgmtServerUid)));
+    if (task1.Exists())
+        {
+        task1.BringToForeground();
+        }
+
+    
+
+    //get the Size of the install package
+    m_totalSize = iDl->attribute(TotalSize).toInt();
+
+    //get the name of the install package
+    TDeploymentComponentName name = aComponent->ComponentName();
+    TBuf<KDeploymentComponentNameMaxLength> nameBuf;
+    nameBuf.Copy(name);
+    m_appName = QString::fromUtf16(nameBuf.Ptr(), nameBuf.Length());
+
+    (iOperationType == EInstallAndActivate)?showInstalltoDialog():showDownloadDialog();
+
+    mDialog->setTimeout(20000);
+    mNotifierdata = m_appName;
+    QString comma(",");
+    mNotifierdata.append(comma);
+    mNotifierdata.append(mSize);
+    mNotifierdata.append(comma);
+    mNotifierdata.append(mSizeFormat);
+    
+    mDialogData = m_appName;
+    mDialogData.append(comma);
+    mDialogData.append(m_sizeStr);
+    
+    CApplicationManagementUtility::mCurrDlg = mDialog;
+    mDialog->setAttribute(Qt::WA_DeleteOnClose);
+    mDialog->open(this,SLOT(dialogSlot(HbAction*)));
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::defaultDriveChanged
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::defaultDriveChanged(int i)
+    {
+    TAMInstallOptions opts = iComp->InstallOpts();
+    int err = KErrNone;
+    TChar drive = drilist[i*2];
+    drive.LowerCase();
+    opts.iOptions.iDrive = drive;
+    TPtrC8 buf;
+    TAMInstallOptionsPckg optsb(opts);
+    buf.Set(optsb);
+    TRAP( err, QT_TRYCATCH_LEAVING(iComp->SetInstallOptsL(buf)));
+    CDeliveryComponentStorage* iStorage;
+    TRAP( err, QT_TRYCATCH_LEAVING(iStorage = CDeliveryComponentStorage::NewL()));
+    TRAP( err, QT_TRYCATCH_LEAVING(iStorage->UpdateL(*iComp)));
+    delete iStorage;
+    iStorage = NULL;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::dialogSlot
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::dialogSlot(HbAction* recAction)
+    {
+    RDEBUG("dialogslot");
+    TRequestStatus* stat = &iWait->iStatus;
+    User::RequestComplete(stat,KErrNone);
+    if(recAction == mCancel)
+        {
+    mEndReported = 1;
+        sendSrvToBg();
+        iWait->Stop();
+        iDl->cancel();
+        }
+    else
+        {
+        //visited if ok is selected or after timeout
+        iDialogAccepted = 1;      
+        int err = RProperty::Set(TUid::Uid(KOmaDMAppUid), KDownloadActive, iDialogAccepted);
+        RDEBUG_2("RProperty set (%d)", err  );
+        }  
+    CApplicationManagementUtility::mCurrDlg = 0;
+    mOkButton=0;
+    mCancel = 0;
+    RDEBUG("dialogslot end");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::downloadMgrEventRecieved(
+// ------------------------------------------------------------------------------------------------ 
+bool appmgmtdownloadmgr::downloadMgrEventRecieved(DownloadManagerEvent *event)
+    {
+    //DEventType type = (DEventType)event->type();
+    //bool eventHandled = false;
+    switch (event->type())
+
+        {
+        case DownloadManagerEvent::Created:
+            {
+            RDEBUG("DownloadCreated");
+            return true;
+            }
+        case DownloadManagerEvent::Removed:
+            {
+            RDEBUG("Removed");
+            return true;
+            }
+
+        default:
+            {
+            //QWidget::event(event);
+            return false;
+            }
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::FileName
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::FileName(QString& filename)
+    {
+    if (iDl)
+        filename = iDl->attribute(WRT::FileName).toString();
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::MimeType
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::MimeType(QString& mimetype)
+    {
+    	mimetype=m_mimetype;
+    	TBuf<1024> buffer(mimetype.utf16());
+	RDEBUG_2( "appmgmtdownloadmgr::MimeType '%S'", &buffer );
+    }
+void appmgmtdownloadmgr::SetMimeType()
+   {
+    if (iDl)
+      m_mimetype  = iDl->attribute(ContentType).toString();
+	TBuf<1024> buffer(m_mimetype.utf16());
+	RDEBUG_2( "appmgmtdownloadmgr::MimeType SetMimeType '%S'", &buffer );
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::downloadEventRecieved
+// ------------------------------------------------------------------------------------------------ 
+bool appmgmtdownloadmgr::downloadEventRecieved(DownloadEvent *event)
+    {
+    //DEventType type = (DEventType)event->type();
+    bool eventHandled = true;
+    switch (event->type())
+        {
+        case DownloadEvent::Started:
+            {
+            RDEBUG("Started");
+            m_inProgress = false;
+            break;
+            }
+
+        case DownloadEvent::HeadersReceived:
+            {
+            RDEBUG("HeaderReceived");
+            m_inProgress = false;
+		SetMimeType();
+            break;
+            }
+
+        case DownloadEvent::InProgress:
+            {
+            RDEBUG("Progress");
+
+            //HandleAlreadyRunningL(downloadedsize, contentsize, *download, aEvent.iProgressState);
+            if (!iDialogAccepted)
+                {
+                if (!CApplicationManagementUtility::iSilentSession)
+                    {
+                    showDialog(iComp);
+                    int err = KErrNone;
+                    TRAP( err, QT_TRYCATCH_LEAVING(iWait = CDialogWait::NewL()));
+                    iWait->StartWait();                  
+                    }
+                }
+            else
+                {
+                m_totalSize = iDl->attribute(TotalSize).toInt();
+                RDEBUG_2("total size = %d",m_totalSize );
+                m_currentDownloadedSize
+                        = iDl->attribute(DownloadedSize).toInt();
+                RDEBUG_2("m_currentDownloadedSize = %d",m_currentDownloadedSize );
+                if (!CApplicationManagementUtility::iSilentSession)
+                    updateProgress(m_currentDownloadedSize, m_totalSize);
+                }
+            break;
+            }
+        case DownloadEvent::Paused:
+            {
+            RDEBUG("Paused");
+            break;
+            }
+        case DownloadEvent::Completed:
+            {
+            RDEBUG("Completed");
+            m_inProgress = false;
+            closeProgress();
+            QApplication::processEvents();
+            if (iOperationType == EDeliver && !CApplicationManagementUtility::iSilentSession)
+                {
+                mNote = new AppMgmtNotifier(m_appName);
+				if(mNote)
+				    mNote->showDownloadSuccessNote();
+                delete mNote;
+                mNote=NULL;
+                }
+            m_callback.DownloadCompleted();
+            iStatus = KErrNone;
+            break;
+            }
+
+        case DownloadEvent::Failed:
+            {
+            RDEBUG("Failed");
+            m_inProgress = false;
+            closeProgress();
+            if(!CApplicationManagementUtility::iSilentSession)
+                {
+            mNote = new AppMgmtNotifier(m_appName);
+			if(mNote)
+			{
+            bool ret = mNote->showDownloadFailedNote(mNotifierdata);
+            RDEBUG_2( "device dialog : %d", ret );
+            delete mNote;
+            mNote=NULL;
+                    }
+			}
+
+            break;
+            }
+        case DownloadEvent::Cancelled:
+            {
+            RDEBUG("Cancelled");
+            m_inProgress = false;
+
+            closeProgress();
+            if(!mNetworkLoss)
+                {
+                m_callback.DownloadFailed(KStatusUserCancelled);
+                }
+            else
+                {
+                m_callback.DownloadFailed(KStatusDownloadFailed);
+                }
+            iStatus = KErrNone;
+            break;
+            }
+        case DownloadEvent::ConnectionNeeded:
+        case DownloadEvent::ConnectionDisconnected:
+        case DownloadEvent::NetworkLoss:
+            {
+            RDEBUG("NetworkLoss");
+            m_inProgress = false;
+            int errornum;
+            int statusdwnld;
+			closeProgress();
+            if(!mEndReported)
+                {
+                mNetworkLoss = 1;
+                mEndReported = 1;
+                if (!CApplicationManagementUtility::iSilentSession)
+                    {
+                mNote = new AppMgmtNotifier(m_appName);
+                if(mNote)
+                    mNote->showDownloadFailedNote(mNotifierdata);
+                delete mNote;
+                mNote=NULL;
+                    }
+                iDl->cancel();
+                }
+            break;
+            }
+
+        case DownloadEvent::Error:
+            {
+            RDEBUG("Error");
+            m_inProgress = false;
+
+            int errornum;
+            int statusdwnld;
+            
+            Download::State state =
+                    (Download::State) iDl->attribute(State).toInt();
+
+            errornum = iDl->attribute(LastError).toInt();
+            
+            statusdwnld = currDwnldStatForGenericAlert(errornum);
+			closeProgress();
+            if(!mEndReported)
+                {
+                if (!CApplicationManagementUtility::iSilentSession)
+                    {
+                mNote = new AppMgmtNotifier(m_appName);
+                if(mNote)
+                   mNote->showDownloadFailedNote(mNotifierdata);
+                delete mNote;
+                mNote=NULL;
+                    }
+                m_callback.DownloadFailed(statusdwnld);
+                mEndReported = 1;
+                }
+            iStatus = KErrNone;
+            break;
+            }
+
+        default:
+            {
+            eventHandled = false;
+            }
+        }
+    return eventHandled;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::updateProgress
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::updateProgress(TInt32 aDownloadedSize,
+        TInt32 aContentSize)
+    {       
+    if (!iProgressNote)
+        {
+        iProgressNote = new AppMgmtProgDialog(mDialogData,*iDl,mEndReported); 
+        iProgressNote->startDialog(aContentSize, aDownloadedSize);
+        }
+
+    //handles the progress dialog
+    //creating progress dialog and set final val and update
+    if (aContentSize >= 0)
+        {
+        iProgressNote->updateProgress(aDownloadedSize);
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::currDwnldStatForGenericAlert
+// ------------------------------------------------------------------------------------------------ 
+int appmgmtdownloadmgr::currDwnldStatForGenericAlert(int dwnldstatus)
+    {
+     int status;
+        if(dwnldstatus == DiskFull )
+            status = KStatusDowloadFailedOOM;
+        else if(dwnldstatus == TransactionFailed ||dwnldstatus== HostNotFoundError || dwnldstatus== TimeoutError || dwnldstatus== OperationCanceledError)
+            status = KStatusAltDowldUnavailable;
+        else if (dwnldstatus == AuthenticationRequiredError )
+            status = KStatusAlternateDownldAuthFail;
+        else
+            status = KStatusDownloadFailed;
+        
+        return status;
+            
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::closeProgress
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::closeProgress()
+    {
+    if(iProgressNote)
+        {
+        iProgressNote->closeAMProgDialog();
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// appmgmtdownloadmgr::sendSrvToBg
+// ------------------------------------------------------------------------------------------------ 
+void appmgmtdownloadmgr::sendSrvToBg()
+{
+    {
+    CCoeEnv* coe = CCoeEnv::Static();
+    TApaTaskList taskList(coe->WsSession());
+    TApaTask task=taskList.FindApp(TUid::Uid(KAppMgmtServerUid));
+    if(task.Exists())
+        {
+        task.SendToBackground();
+        }
+    }
+}
+
+
+
+//---------------------------------------------------------------------------------
+// CDialogWait::CDialogWait
+//---------------------------------------------------------------------------------
+CDialogWait::CDialogWait()
+: CActive(0)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+//---------------------------------------------------------------------------------
+// CDialogWait::ConstructL
+//---------------------------------------------------------------------------------
+void CDialogWait::ConstructL()
+    {
+    iWait = new( ELeave ) CActiveSchedulerWait;
+    }
+
+//---------------------------------------------------------------------------------
+// CDialogWait::NewL
+//---------------------------------------------------------------------------------
+CDialogWait* CDialogWait::NewL()
+    {
+    CDialogWait* self = new( ELeave ) CDialogWait();                                                       
+        CleanupStack::PushL( self );
+        self->ConstructL();
+        CleanupStack::Pop();
+        return self;
+    }
+
+//---------------------------------------------------------------------------------
+// CDialogWait::~CDialogWait
+// Destructor
+//---------------------------------------------------------------------------------
+CDialogWait::~CDialogWait()
+    {
+    Cancel();
+    delete iWait;
+    }
+
+//---------------------------------------------------------------------------------
+// CDialogWait::Stop
+//---------------------------------------------------------------------------------
+void CDialogWait::Stop()
+    {
+    if (iWait && iWait->IsStarted() && iWait->CanStopNow())
+        {
+        iWait->AsyncStop();
+        }
+    }
+
+//---------------------------------------------------------------------------------
+// CDialogWait::WaitOnDialog
+//---------------------------------------------------------------------------------
+void CDialogWait::StartWait()
+    {    
+    RDEBUG("startwait start");
+    if (!IsActive() )
+	{
+		if(iWait)
+		{
+		  if(!iWait->IsStarted())
+		      {
+              iStatus = KRequestPending;
+              SetActive();
+              iWait->Start();
+		      }
+		}
+	}
+    RDEBUG("startwait end");
+    }
+
+// --------------------------------------------------------------------------
+// CDialogWait::DoCancel()
+// --------------------------------------------------------------------------
+//
+void CDialogWait::DoCancel()
+    {
+     if (iWait && iWait->IsStarted() && iWait->CanStopNow())
+         {
+         iWait->AsyncStop();
+         }
+    }    
+
+// --------------------------------------------------------------------------
+// CDialogWait::RunL()
+// --------------------------------------------------------------------------
+//
+void CDialogWait::RunL()
+    {
+    if (iWait && iWait->IsStarted() && iWait->CanStopNow())
+        {
+        iWait->AsyncStop();
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CDialogWait::RunError()
+// --------------------------------------------------------------------------
+//
+TInt CDialogWait::RunError(TInt aError)
+    {
+    RDEBUG_2("CDialogWait::RunError %d",aError );
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/appmgmtnotifier.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,601 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+
+#include <HbDeviceDialog.h>
+#include <apgtask.h>
+#include <eikenv.h>
+#include <Driveinfo.h>
+#include "amstorage.h"
+#include "appmgmtnotifier.h"
+#include "appmgmtdownloadmgr.h"
+#include "applicationmanagementutility.h"
+#include "debug.h"
+#include <hbapplication.h>
+#include <hbmessagebox.h>
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::AppMgmtNotifier
+// ------------------------------------------------------------------------------------------------ 
+AppMgmtNotifier::AppMgmtNotifier(QString aAppName)
+    {
+    m_appname = aAppName;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::~AppMgmtNotifier
+// ------------------------------------------------------------------------------------------------ 
+AppMgmtNotifier::~AppMgmtNotifier()
+    {
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::getAvailableDrives
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::getAvailableDrives()
+    {
+    RFs iFs;
+    int err;
+    qt_symbian_throwIfError(iFs.Connect());
+    TDriveList driveList;
+    TInt driveCount = 0;
+    TBuf<20> buf;
+    int i = 0;
+    QString val;
+    QStringList list;
+    TDriveInfo info;
+    TVolumeInfo volumeInfo;
+    qt_symbian_throwIfError(DriveInfo::GetUserVisibleDrives(iFs, driveList,
+            driveCount));
+    TUint driveStatus = 0;
+    for (TInt index(0); index < KMaxDrives; index++)
+        {
+        if (driveList[index])
+            {
+            TRealFormat realFormat;
+            qt_symbian_throwIfError(DriveInfo::GetDriveStatus(iFs, index,
+                    driveStatus));
+            TFileName path;
+            TDriveUnit driveUnit(index);
+            if (!(driveStatus & DriveInfo::EDriveRemote))
+                {
+                TBuf<64> freeSpace;
+                TReal free;
+                TInt64 freeKBytes;
+                realFormat.iWidth = 6;
+                iFs.Drive(info, index);
+                if(iFs.Volume(volumeInfo, index)==KErrNone)
+                    {
+                freeKBytes = 0;
+                freeKBytes = volumeInfo.iFree / 1024;
+                RDEBUG_2("free space: (%d)", volumeInfo.iFree  );
+                free = volumeInfo.iFree / 1024;
+                freeSpace.Num(freeKBytes);
+                TInt sizeUnit = -1;
+
+                //converting the drive freespace
+                int len = freeSpace.Length();
+                if (len >= 7)
+                    {
+                    TReal nul = (1024 * 1024);
+                    TReal temp = free / nul;
+                    freeSpace.Num(temp, realFormat);
+                    sizeUnit = 1;
+                    }
+                else
+                    {
+                    TReal temp = free / 1024;
+                    freeSpace.Num(temp, realFormat);
+                    sizeUnit = 0;
+                    }
+                //Getting the drive name in QString
+                path.Zero();
+                path.Append(driveUnit.Name());
+                val = QString::fromUtf16(path.Ptr(), path.Length());
+                m_Drilist.Append(path);
+                //Getting the drive free space in QString
+                path.Zero();
+                path.Append(freeSpace);
+                QString str1 = QString::fromUtf16(path.Ptr(), path.Length());
+                QString driv;
+                if (sizeUnit == -1)
+                    {
+                    driv
+                            = hbTrId(
+                                    "txt_deviceupdate_setlabel_install_to_val_1_2_kb").arg(
+                                    val, str1);
+                    }
+                else if (sizeUnit == 0)
+                    {
+                    driv
+                            = hbTrId(
+                                    "txt_deviceupdate_setlabel_install_to_val_1_2_Mb").arg(
+                                    val, str1);
+                    }
+                else
+                    {
+                    driv
+                            = hbTrId(
+                                    "txt_deviceupdate_setlabel_install_to_val_1_2_Gb").arg(
+                                    val, str1);
+                    }
+                    m_DriveBox->insertItem(i++, driv);
+                    }
+                }
+            }
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::showInstallDialog
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::showInstallDialog(CDeploymentComponent *aCompo, TRequestStatus &s)
+    {
+    bringServerToForeground();
+    iStat = &s;
+    iComp = aCompo;
+    HbDocumentLoader loader;
+    QString val;
+    bool ok = false;
+    HbLabel* label;
+    int err;    
+    iComp->SetDriveSelectionStatus(true);
+    CDeliveryComponentStorage* iStorage ;
+    QT_TRAP_THROWING(iStorage= CDeliveryComponentStorage::NewL());
+    TRAP( err, QT_TRYCATCH_LEAVING(iStorage->UpdateL(*iComp)));
+    delete iStorage;
+    loader.load(":/xml/sample.docml", &ok);
+    if (!ok)
+        {
+        return;
+        }
+    Q_ASSERT_X(ok, "Device Manager", "Invalid docml file");
+    m_Dialog = qobject_cast<HbDialog*> (loader.findWidget("dialog"));
+
+    //set title for the dialog
+    label = qobject_cast<HbLabel*> (loader.findWidget(
+            "qtl_dialog_pri_heading"));
+
+    val = hbTrId("txt_device_update_title_install");
+    label->setPlainText(val);
+
+    TDeploymentComponentName name = aCompo->ComponentName();
+    TBuf<KDeploymentComponentNameMaxLength> nameBuf;
+    nameBuf.Copy(name);
+    m_appname = QString::fromUtf16(nameBuf.Ptr(), nameBuf.Length());
+    //set the app name
+    label = qobject_cast<HbLabel*> (loader.findWidget("label"));
+    val = hbTrId("txt_deviceupdate_info_file_1_2").arg(m_appname);
+    label->setPlainText(val);
+
+    //size
+    label = qobject_cast<HbLabel*> (loader.findWidget("label_1"));
+	label->setPlainText("");
+    //icon
+    label = qobject_cast<HbLabel*> (loader.findWidget("icon"));
+    label->setIcon(HbIcon(":/icon/qgn_prop_sml_http.svg"));
+
+    //"install to" label
+    label = qobject_cast<HbLabel*> (loader.findWidget("qtl_dialog_pri5"));
+    val = hbTrId("txt_device_update_setlabel_install_to");
+    label->setPlainText(val);
+
+    //getting the available free space in all drives and adding to combobox
+
+    m_DriveBox = qobject_cast<HbComboBox*> (loader.findWidget("combobox"));
+    
+    TRAP(err,getAvailableDrives());
+    if(err==KErrNone)
+        {
+    connect(m_DriveBox, SIGNAL(currentIndexChanged(int)), this,
+            SLOT(defaultDriveChanged(int )));
+        }
+    else
+        m_DriveBox->setVisible(false);
+    //setting the actions
+    m_OkButton = qobject_cast<HbAction*> (loader.findObject(
+            "qtl_dialog_softkey_2_left"));
+    m_Cancel = qobject_cast<HbAction*> (loader.findObject(
+            "qtl_dialog_softkey_2_right"));
+    val = hbTrId("txt_common_button_ok");
+    m_OkButton->setText(val);
+    val = hbTrId("txt_common_button_cancel");
+    m_Cancel->setText(val);
+    m_Dialog->setTimeout(20000);
+    CApplicationManagementUtility::mCurrDlg = m_Dialog;
+    m_Dialog->open(this, SLOT(dlgSlot(HbAction*)));
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::defaultDriveChanged
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::defaultDriveChanged(int i)
+    {
+    TAMInstallOptions opts = iComp->InstallOpts();
+    TChar drive = m_Drilist[i*2];
+    drive.LowerCase();
+    int err;
+    opts.iOptions.iDrive = drive;
+    TPtrC8 buf;
+    TAMInstallOptionsPckg optsb(opts);
+    buf.Set(optsb);
+    TRAP( err, QT_TRYCATCH_LEAVING(iComp->SetInstallOptsL(buf)));
+    CDeliveryComponentStorage* iStorage;
+    TRAP( err, QT_TRYCATCH_LEAVING(iStorage = CDeliveryComponentStorage::NewL()));
+    TRAP( err, QT_TRYCATCH_LEAVING(iStorage->UpdateL(*iComp)));
+    delete iStorage;
+    iStorage = NULL;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::dlgSlot
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::dlgSlot(HbAction* action)
+    {
+    if(action == m_Cancel)
+        {
+        sendServerToBackground();
+        TRequestStatus* status(iStat);
+        User::RequestComplete(status, KStatusUserCancelled);
+        }
+    else
+        {
+        TRequestStatus* status(iStat);
+        User::RequestComplete(status, KErrCompletion );      
+        }
+    CApplicationManagementUtility::mCurrDlg = 0;
+    m_OkButton=0;
+    m_Cancel = 0;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::showInstallFailedNote
+//launching a device dialog to display notefor "install failed" case
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::showInstallFailedNote()
+    {
+    HbDeviceDialog deviceDialog;
+    QVariantMap parameters;
+    //_LIT(KScomoNotifier, "scomonotifier");
+    parameters.insertMulti(QString("scomonotifier"), QVariant(QString("installfailed")));
+    QString data = m_appname;
+    parameters.insertMulti(QString("scomoappname"), QVariant(data));
+    const char *deviceDialogType = "com.nokia.hb.devicemanagementdialog/1.0";
+    bool ret = deviceDialog.show(QString(deviceDialogType), parameters);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::sendServerToBackground
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::sendServerToBackground()
+    {
+    CCoeEnv* coe = CCoeEnv::Static();
+    TApaTaskList taskList(coe->WsSession());
+    TApaTask task=taskList.FindApp(TUid::Uid(KAppMgmtServerUid));  
+    if(task.Exists())
+        {
+        task.SendToBackground();
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::bringServerToForeground
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::bringServerToForeground()
+    {
+    CCoeEnv* coe = CCoeEnv::Static();
+    TApaTaskList taskList(coe->WsSession());
+    TApaTask task = taskList.FindApp(TUid::Uid(KAppMgmtServerUid));
+    if (task.Exists())
+        {
+        task.BringToForeground();
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::operationSuccessSlot
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::successSlot(HbAction* action)
+    {
+    RDEBUG("successslot");
+    if(action == m_OkButton || action == NULL)
+        {
+        sendServerToBackground();
+        RDEBUG("slot entered");
+        TRequestStatus* status(iStat);
+        User::RequestComplete(status, KErrCompletion);
+        }
+    m_OkButton = 0;
+    RDEBUG("successslot end");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::showInstallSuccessNote
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::showInstallSuccessNote()
+    {
+    if (CApplicationManagementUtility::mHidden == 1)
+        {
+        //Display Installation complete dialog
+        HbDeviceNotificationDialog notificationDialog;
+        QString text =
+                hbTrId("txt_device_update_title_installation_complete");
+        notificationDialog.setTitle(text);
+        text
+                = hbTrId("txt_device_update_dblist_product_code_val_installa").arg(
+                        m_appname);
+        notificationDialog.setText(text);
+        notificationDialog.show();
+        }
+    else
+        {
+        bringServerToForeground();
+        HbDocumentLoader loader;
+        bool ok = false;
+        loader.load(":/xml/error_notes.docml", &ok);
+        QString val;
+        // Exit if the file format is invalid
+        Q_ASSERT_X(ok, "Device Manager", "Invalid docml file");
+        m_Dialog = qobject_cast<HbDialog*> (loader.findWidget(
+                "dialog"));
+        HbLabel* label = qobject_cast<HbLabel*> (loader.findWidget(
+                "heading_text"));
+        val = hbTrId("txt_device_update_title_installation_complete");
+        label->setPlainText(val);
+        
+        val = hbTrId("txt_deviceupdate_info_file_1_2").arg(m_appname);
+        label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
+        label->setPlainText(val);
+        m_OkButton = qobject_cast<HbAction*> (loader.findObject(
+                "qtl_dialog_softkey_2_left"));
+        val = hbTrId("txt_common_button_ok");
+        m_OkButton->setText(val);
+        
+        m_Dialog->setTimeout(HbPopup::ContextMenuTimeout);
+        //m_Dialog->setAttribute(Qt::WA_DeleteOnClose);
+        m_Dialog->open(this, SLOT(successSlot(HbAction*)));
+	    CDialogWait* wait = CDialogWait::NewL();
+        registerStatus(wait->iStatus);
+	    RDEBUG_2("AppMgmtNotifier::Start before StartWait (%d)", wait->iStatus.Int());
+        wait->StartWait();
+	    delete wait;
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::dialogUnSlot
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::dialogUnSlot(HbAction* retAction)
+    {
+    sendServerToBackground();
+    if (retAction == m_Cancel)
+        {      
+        TRequestStatus* status(iStat);
+        User::RequestComplete(status, KStatusUserCancelled);    
+        }
+    else
+        {
+        TRequestStatus* status(iStat);
+        User::RequestComplete(status, KErrCompletion);
+        }
+    CApplicationManagementUtility::mCurrDlg = 0;
+    m_OkButton = 0;
+    m_Cancel = 0;
+    }
+
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::showUninstallDialog
+//uninstall beginning confirmation note
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::showUninstallDialog(const CDeploymentComponent &aCompo,
+        TRequestStatus &s)
+    {
+    iStat = &s;
+    bringServerToForeground();
+    
+    HbDocumentLoader loader;
+    bool ok;
+    loader.load(":/xml/downloaddialog.docml", &ok);
+
+    Q_ASSERT_X(ok, "Device Manager", "Invalid docml file");
+    m_Dialog = qobject_cast<HbDialog*> (loader.findWidget("dialog"));
+
+    HbLabel* label = qobject_cast<HbLabel*> (loader.findWidget(
+            "qtl_dialog_pri_heading"));
+    QString val = hbTrId("txt_device_update_title_uninstalling_application");
+    label->setPlainText(val);
+
+    label = qobject_cast<HbLabel*> (loader.findWidget("icon"));
+    label->setIcon(HbIcon(":/icons/qgn_prop_sml_http.svg"));
+
+    label = qobject_cast<HbLabel*> (loader.findWidget("qtl_dialog_pri5"));
+    TDeploymentComponentName name = aCompo.ComponentName();
+    TBuf<255> ne;
+    ne.Copy(name);
+
+    QString str = QString::fromUtf16(ne.Ptr(), ne.Length());
+    val = hbTrId("txt_deviceupdate_info_application_1").arg(str);
+    label->setPlainText(val);
+
+    label = qobject_cast<HbLabel*> (loader.findWidget("qtl_dialog_pri5_1"));
+    label->setPlainText("");
+    
+    m_OkButton = qobject_cast<HbAction*> (loader.findObject(
+            "qtl_dialog_softkey_2_left"));
+    m_Cancel = qobject_cast<HbAction*> (loader.findObject(
+            "qtl_dialog_softkey_2_right"));
+    val = hbTrId("txt_common_button_ok");
+    m_OkButton->setText(val);
+    val = hbTrId("txt_common_button_cancel");
+    m_Cancel->setText(val);
+    CApplicationManagementUtility::mCurrDlg = m_Dialog;
+    m_Dialog->setTimeout(10000);
+    m_Dialog->open(this, SLOT(dialogUnSlot(HbAction*)));
+    }
+
+
+// ------------------------------------------------------------------------------------------------
+//AppMgmtNotifier::showUnInstallFailedNote
+//Displaying uninstall failed note
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::showUnInstallFailedNote()
+    {
+    HbDeviceDialog deviceDialog;
+    QVariantMap parameters;
+    //_LIT(KScomoNotifier, "scomonotifier");
+    parameters.insertMulti(QString("scomonotifier"), QVariant(QString(
+            "uninstallfailed")));
+    QString data = m_appname;
+    parameters.insertMulti(QString("scomoappname"), QVariant(data));
+    const char *deviceDialogType = "com.nokia.hb.devicemanagementdialog/1.0";
+    bool ret = deviceDialog.show(QString(deviceDialogType), parameters);
+    }
+
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::showUnInstallSuccessNote
+//uninstall success notification
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::showUnInstallSuccessNote()
+    {
+    if (CApplicationManagementUtility::mHidden == 1)
+        {
+        //Display Installation complete dialog
+        HbDeviceNotificationDialog notificationDialog;
+        QString text = hbTrId(
+                "txt_device_update_title_uninstallation_complete");
+        notificationDialog.setTitle(text);
+        text
+                = hbTrId(
+                        "txt_device_update_dblist_product_code_val_uninstalla_comple").arg(
+                        m_appname);
+        notificationDialog.setText(text);
+        notificationDialog.show();
+        }
+    else
+        {
+        bringServerToForeground();
+
+        HbDocumentLoader loader;
+        bool ok = false;
+        loader.load(":/xml/error_notes.docml", &ok);
+        QString val;
+        // Exit if the file format is invalid
+        Q_ASSERT_X(ok, "Device Manager", "Invalid docml file");
+        m_Dialog = qobject_cast<HbDialog*> (loader.findWidget(
+                "dialog"));
+        QString blank("");
+        HbLabel* label = qobject_cast<HbLabel*> (loader.findWidget(
+                "heading_text"));
+        val = hbTrId("txt_device_update_title_uninstallation_complete");
+        label->setPlainText(val);
+        val
+                = hbTrId(
+                        "txt_device_update_dblist_product_code_val_uninstalla_comple").arg(
+                        m_appname);
+        label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
+        label->setPlainText(val);
+        m_OkButton = qobject_cast<HbAction*> (loader.findObject(
+                "qtl_dialog_softkey_2_left"));
+        val = hbTrId("txt_common_button_ok");
+        m_OkButton->setText(val);
+        
+        m_Dialog->setTimeout(HbPopup::StandardTimeout);
+        m_Dialog->open(this, SLOT(successSlot(HbAction*)));
+        CDialogWait* wait = CDialogWait::NewL();
+        registerStatus(wait->iStatus);
+        RDEBUG_2("AppMgmtNotifier::Start before StartWait (%d)", wait->iStatus.Int());
+        wait->StartWait();
+        delete wait;
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::showDownloadFailedNote
+// ------------------------------------------------------------------------------------------------ 
+bool AppMgmtNotifier::showDownloadFailedNote(QString aNotifierdata)
+    {
+    HbDeviceDialog deviceDialog;
+    QVariantMap parameters;
+    //_LIT(KScomoNotifier, "scomonotifier");
+    parameters.insertMulti(QString("scomonotifier"), QVariant(QString(
+            "downloadfailed")));
+    parameters.insertMulti(QString("scomoappdata"),QVariant(aNotifierdata));
+    const char *deviceDialogType = "com.nokia.hb.devicemanagementdialog/1.0";
+    bool stat = deviceDialog.show(QString(deviceDialogType), parameters); 
+    return stat;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtNotifier::showDownloadSuccessNote
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtNotifier::showDownloadSuccessNote()
+    {
+    if (CApplicationManagementUtility::mHidden == 1)
+        {
+        HbDeviceNotificationDialog notificationDialog;
+        QString tr = hbTrId("txt_device_update_title_download_complete");
+        notificationDialog.setTitle(tr);
+        tr
+                = hbTrId(
+                        "txt_device_update_dblist_product_code_val_download_comple").arg(
+                        m_appname);
+        notificationDialog.setText(tr);
+        notificationDialog.show();
+        }
+    else
+        {
+        bringServerToForeground();
+        HbDocumentLoader loader;
+        bool ok = false;
+        loader.load(":/xml/error_notes.docml", &ok);
+        QString val;
+        // Exit if the file format is invalid
+        Q_ASSERT_X(ok, "Device Manager", "Invalid docml file");
+        m_Dialog = qobject_cast<HbDialog*> (loader.findWidget(
+                "dialog"));
+        HbLabel* label = qobject_cast<HbLabel*> (loader.findWidget(
+                "heading_text"));
+        val = hbTrId("txt_device_update_title_download_complete");
+        label->setPlainText(val);
+
+        val = hbTrId("txt_device_update_dblist_product_code_val_download_comple").arg(m_appname);
+        label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
+        label->setPlainText(val);
+        m_OkButton = qobject_cast<HbAction*> (loader.findObject(
+                "qtl_dialog_softkey_2_left"));
+        val = hbTrId("txt_common_button_ok");
+        m_OkButton->setText(val);
+        
+        m_Dialog->setTimeout(HbPopup::ContextMenuTimeout);
+
+        m_Dialog->open(this, SLOT(successSlot(HbAction*)));
+        CDialogWait* wait = CDialogWait::NewL();
+        registerStatus(wait->iStatus);
+        RDEBUG_2("AppMgmtNotifier::Start before StartWait (%d)", wait->iStatus.Int());
+        wait->StartWait();
+        delete wait;
+        }
+    }
+void AppMgmtNotifier::registerStatus(TRequestStatus &stat)
+    {
+    RDEBUG("registering request status");
+    iStat = &stat;
+    stat = KRequestPending;
+    RDEBUG_2("stat = %d",stat.Int() );
+    RDEBUG("registering request status end");
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/appmgmtprogdialog.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 downloading progress note
+ *
+ */
+
+#include <hblabel.h>
+#include <hbaction.h>
+#include <e32property.h>
+#include <qapplication.h>
+#include <apgtask.h>
+#include <e32base.h>
+#include <eikenv.h>
+#include <dmindicatorconsts.h>
+#include "appmgmtdownloadmgr.h"
+#include "ApplicationManagementUtility.h"
+
+using namespace NApplicationManagement;
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtProgDialog::AppMgmtProgDialog
+// ------------------------------------------------------------------------------------------------ 
+AppMgmtProgDialog::AppMgmtProgDialog(QString aAppData, Download &mdl,int &aUserCancelled)
+:m_Dlg(0)
+    {   
+    m_Data=aAppData;
+    iDl=&mdl;
+    mUsrCancel = aUserCancelled;
+    m_Indi = 0;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtProgDialog::~AppMgmtProgDialog()
+// ------------------------------------------------------------------------------------------------ 
+AppMgmtProgDialog::~AppMgmtProgDialog()
+    {
+    if(m_Dlg)
+        {
+        delete m_Dlg;
+        m_Dlg=NULL;
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtProgDialog::sendServerToBackground()
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtProgDialog::sendServerToBackground()
+    {
+    CCoeEnv* coe = CCoeEnv::Static();
+    TApaTaskList taskList(coe->WsSession());
+    TApaTask task=taskList.FindApp(TUid::Uid(KAppMgmtServerUid));
+    if(task.Exists())
+        {
+        task.SendToBackground();
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtProgDialog::startDialog
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtProgDialog::startDialog(int aContentSize,int aDownloaded)
+    {
+    if (m_Dlg == NULL)
+        {
+        m_Dlg = new HbProgressDialog(HbProgressDialog::ProgressDialog);
+        CApplicationManagementUtility::mCurrDlg = m_Dlg;
+        QStringList strList = m_Data.split(",");
+        m_Name = strList[0];
+        m_SizeStr = strList[1];
+        }
+    m_Dlg->setMinimum(0);
+    m_Dlg->setMaximum(aContentSize);
+
+    m_Dlg->setAutoClose(true);
+    m_Dlg->setProgressValue(aDownloaded);
+
+    QString val = hbTrId("txt_device_update_title_downloading");
+    m_Dlg->setHeadingWidget(new HbLabel(val));
+
+    val = hbTrId("txt_deviceupdate_info_file_1_2").arg(m_Name);
+    val.append("\n");
+    val.append(m_SizeStr);
+
+    m_Dlg->setText(val);
+    val = hbTrId("txt_common_button_hide");
+    HbAction* hide = new HbAction();
+    hide->setText(val);
+    m_Dlg->clearActions();
+    m_Dlg->addAction(hide);
+    val = hbTrId("txt_common_button_cancel");
+    HbAction* cancel = new HbAction();
+    cancel->setText(val);
+    m_Dlg->addAction(cancel);
+    QObject::connect(hide, SIGNAL(triggered()), this,
+            SLOT(hideAMProgDialog()));
+    QObject::connect(cancel, SIGNAL(triggered()), this, SLOT(cancelDialog()));
+    m_Dlg->show();
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtProgDialog::closeAMProgDialog()
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtProgDialog::closeAMProgDialog()
+    {    
+    CApplicationManagementUtility::mCurrDlg=0;
+    if(m_Dlg)
+        {
+        m_Dlg->close();
+        }
+    if(CApplicationManagementUtility::mHidden==0)
+        {
+        sendServerToBackground();
+        }
+    else
+        {
+        m_Indi->deactivate(KScomoProgressIndicatorType);   
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtProgDialog::cancelDialog()
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtProgDialog::cancelDialog()
+    {
+    mUsrCancel = 1;
+    iDl->cancel();
+    if(m_Dlg)
+        {
+        m_Dlg->close();
+        }
+    sendServerToBackground();
+    CApplicationManagementUtility::mCurrDlg=0;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtProgDialog::hideAMProgDialog()
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtProgDialog::hideAMProgDialog()
+    {
+    sendServerToBackground();
+    
+    QString str = hbTrId("txt_device_update_dblist_product_code_val_download").arg(m_Name);
+    CApplicationManagementUtility::mHidden=1;
+    m_Indi = new HbIndicator();
+    m_Indi->activate(KScomoProgressIndicatorType,str);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// AppMgmtProgDialog::updateProgress
+// ------------------------------------------------------------------------------------------------ 
+void AppMgmtProgDialog::updateProgress(int aProgress)
+    {
+    if(m_Dlg)
+        {
+        m_Dlg->setProgressValue(aProgress);       
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/main.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies 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 applicationmanagement components
+ *
+ */
+
+
+#include <hbapplication.h>
+#include <hbtransparentwindow.h>
+#include <hbstackedlayout.h>
+#include <hbmainwindow.h>
+#include <hbview.h>
+#include <QTranslator>
+#include <QLocale>
+#include <e32property.h>
+#include "ApplicationManagementCommon.h"
+#include "debug.h"
+#include "amview.h"
+#include "ApplicationManagementServer.h"
+
+using namespace NApplicationManagement;
+
+int main(int argc, char *argv[])
+    { 
+    RDEBUG( "ApplicationManagementServer: main" );
+
+    HbApplication app(argc, argv);
+    
+    AMView* view = new AMView();
+    view->hideItems(Hb::AllItems);
+    view->setContentFullScreen();
+    //Defining transparent window
+    HbMainWindow mainWindow(0, Hb::WindowFlagTransparent);
+    HbTransparentWindow *transparentWindow = new HbTransparentWindow;
+    HbStackedLayout *stackedLayout = new HbStackedLayout;
+    stackedLayout->addItem(transparentWindow);
+    view->setLayout(stackedLayout);
+
+    mainWindow.addView(view);
+    mainWindow.setCurrentView(view);
+      
+    app.installEventFilter(view);
+
+    //Installing the translator
+    QTranslator *translator = new QTranslator();
+    QString lang = QLocale::system().name();
+    
+    bool fine = translator->load("deviceupdates_" + lang, path);/*finally required once localisation available*/
+    if (fine)
+        qApp->installTranslator(translator);
+    int err = KErrNone;
+    TRAP( err, QT_TRYCATCH_LEAVING(CApplicationManagementServer::NewL(&mainWindow)));
+    
+    RProcess::Rendezvous(KErrNone);
+
+    //Pushing the server to background
+    mainWindow.lower();
+
+    TInt serverLaunchStatus = 1;
+    err = RProperty::Set(KProperty, KInteger, serverLaunchStatus);
+    
+    mainWindow.show();
+    int err1 = app.exec();
+    int value = 0;
+    err = RProperty::Set(TUid::Uid(KOmaDMAppUid), KDownloadActive, value);
+    RDEBUG_2("RProperty set (%d)", err  );
+    return err1;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/nsmldmiapmatcher.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,202 @@
+/*
+ * 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:  DM Tree module
+ *
+ */
+
+#include <utf.h>
+#include <smldmadapter.h>
+#include "nsmldmiapmatcher.h"
+
+
+// -----------------------------------------------------------------------------
+// CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewL( MSmlDmCallback* aDmCallback )
+// -----------------------------------------------------------------------------
+CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewL(MSmlDmCallback* aDmCallback)
+    {
+    CNSmlDMIAPMatcher* self = CNSmlDMIAPMatcher::NewLC(aDmCallback);
+    CleanupStack::Pop();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewLC( MSmlDmCallback* aDmCallback )
+// -----------------------------------------------------------------------------
+CNSmlDMIAPMatcher* CNSmlDMIAPMatcher::NewLC(MSmlDmCallback* aDmCallback)
+    {
+    CNSmlDMIAPMatcher* self = new( ELeave ) CNSmlDMIAPMatcher;
+    CleanupStack::PushL(self);
+    self->ConstructL(aDmCallback);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// void CNSmlDMIAPMatcher::ConstructL( MSmlDmCallback* aDmCallback )
+// -----------------------------------------------------------------------------
+void CNSmlDMIAPMatcher::ConstructL(MSmlDmCallback* aDmCallback)
+    {
+    iCallback = aDmCallback;
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDMIAPMatcher::~CNSmlDMIAPMatcher()
+// -----------------------------------------------------------------------------
+CNSmlDMIAPMatcher::~CNSmlDMIAPMatcher()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// TInt CNSmlDMIAPMatcher::IAPIdFromURIL( const TDesC8& aURI )
+// -----------------------------------------------------------------------------
+TInt CNSmlDMIAPMatcher::IAPIdFromURIL(const TDesC8& aURI)
+    {
+    TInt iapId(KErrNotFound);
+
+    MSmlDmAdapter::TError status;
+    CBufBase* allIAPs = CBufFlat::NewL(16);
+    CleanupStack::PushL(allIAPs);
+    iCallback->FetchLinkL(KNSmlDMIAPUri, *allIAPs, status);
+    TPtrC8 uri = RemoveDotSlash(aURI);
+
+    if (status == MSmlDmAdapter::EOk && uri.Find(KNSmlDMIAPUri) == 0
+            && allIAPs->Ptr(0).Find(LastURISeg(uri))>=0)
+        {
+        HBufC8* luid = iCallback->GetLuidAllocL(uri);
+
+        if (luid->Length() )
+            {
+            iapId = DesToInt(*luid);
+            }
+        delete luid;
+        }
+
+    CleanupStack::PopAndDestroy(allIAPs);
+
+    return iapId;
+    }
+
+// -----------------------------------------------------------------------------
+// HBufC8* CNSmlDMIAPMatcher::URIFromIAPIdL( TInt aIAPId )
+// -----------------------------------------------------------------------------
+HBufC8* CNSmlDMIAPMatcher::URIFromIAPIdL(TInt aIAPId)
+    {
+    CBufBase *allIAPs = CBufFlat::NewL(16);
+    CleanupStack::PushL(allIAPs);
+    MSmlDmAdapter::TError status;
+
+    iCallback->FetchLinkL(KNSmlDMIAPUri, *allIAPs, status);
+
+    if (status == MSmlDmAdapter::EOk)
+        {
+        TInt index(0);
+        TInt segStart(0);
+
+        while (index != KErrNotFound)
+            {
+            TPtrC8 allIAPsptr = allIAPs->Ptr(segStart).Mid(0);
+            index = allIAPsptr.Locate('/');
+            HBufC8* uriSeg = 0;
+
+            if (index == KErrNotFound)
+                {
+                TPtrC8 uriSeg8Ptr = allIAPs->Ptr(segStart);
+                uriSeg = uriSeg8Ptr.AllocLC();
+                }
+            else
+                {
+                TPtrC8 uriSeg8Ptr = allIAPs->Ptr(segStart).Mid( 0, index);
+                uriSeg = uriSeg8Ptr.AllocLC();
+                }
+
+            HBufC8* uri = HBufC8::NewLC(KNSmlDMIAPUri().Length() + 1 + uriSeg->Length() );
+
+            TPtr8 uriPtr = uri->Des();
+            uriPtr.Format(KNSmlDMIAPUri);
+            uriPtr.Append(KNSmlDMSeparator8);
+            uriPtr.Append( *uriSeg);
+            HBufC8* luid = iCallback->GetLuidAllocL(uriPtr);
+            CleanupStack::PushL(luid);
+
+            if (luid->Length() > 0)
+                {
+                TInt iapId = DesToInt(luid->Des());
+                if (iapId == aIAPId)
+                    {
+                    CleanupStack::PopAndDestroy(); //luid
+                    CleanupStack::Pop(); //uri
+                    CleanupStack::PopAndDestroy(2); //uriSeg, allIAPs
+                    return uri;
+                    }
+                }
+            CleanupStack::PopAndDestroy(3); // luid, uri, uriSeg
+
+            segStart += index + 1;
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); // allIAPs
+
+    return 0;
+    }
+
+// -----------------------------------------------------------------------------
+// TInt CNSmlDMIAPMatcher::DesToInt(const TDesC& aLuid)
+// -----------------------------------------------------------------------------
+TInt CNSmlDMIAPMatcher::DesToInt(const TDesC8& aLuid)
+    {
+    TLex8 lex(aLuid);
+    TInt value = 0;
+    lex.Val(value);
+    return value;
+    }
+
+// -----------------------------------------------------------------------------
+// TPtrC8 CNSmlDMIAPMatcher::RemoveDotSlash(const TDesC8& aURI) const
+// -----------------------------------------------------------------------------
+TPtrC8 CNSmlDMIAPMatcher::RemoveDotSlash(const TDesC8& aURI) const
+    {
+    if (aURI.Find(KNSmlDMIAPUriDotSlash)==0)
+        {
+        return aURI.Right(aURI.Length()-KNSmlDMIAPUriDotSlash().Length() );
+        }
+    else
+        {
+        return aURI;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CNSmlDMIAPMatcher::TPtrC8 LastURISeg(const TDesC8& aURI)
+// Returns only the last uri segemnt
+// -----------------------------------------------------------------------------
+TPtrC8 CNSmlDMIAPMatcher::LastURISeg(const TDesC8& aURI) const
+    {
+    TInt i;
+    for (i=aURI.Length()-1; i>=0; i--)
+        {
+        if (aURI[i]==KNSmlDMSlash)
+            {
+            break;
+            }
+        }
+    if (i==0)
+        {
+        return aURI;
+        }
+    else
+        {
+        return aURI.Mid(i+1);
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/server/src/nsmldmuri.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,207 @@
+/*
+ * 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:  DM tree etc.
+ *
+ */
+
+#include "nsmldmuri.h"
+
+// ------------------------------------------------------------------------------------------------
+//  NSmlDmURI
+// ------------------------------------------------------------------------------------------------
+
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::ParentURI(const TDesC8& aURI)
+// returns parent uri, i.e. removes last uri segment
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::ParentURI(const TDesC8& aURI)
+    {
+    TBool onlyOneSeg = ETrue;
+    TInt i;
+    for (i=aURI.Length()-1; i>=0; i--)
+        {
+        if (aURI[i]==KNSmlDMUriSeparator)
+            {
+            onlyOneSeg = EFalse;
+            break;
+            }
+        }
+    if (onlyOneSeg)
+        {
+        return KNSmlDmRootUri();
+        }
+    else
+        {
+        return aURI.Left(i);
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::LastURISeg(const TDesC8& aURI)
+// Returns only the last uri segemnt
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::LastURISeg(const TDesC8& aURI)
+    {
+    TInt i;
+    for (i=aURI.Length()-1; i>=0; i--)
+        {
+        if (aURI[i]==KNSmlDMUriSeparator)
+            {
+            break;
+            }
+        }
+    if (i==0)
+        {
+        return aURI;
+        }
+    else
+        {
+        return aURI.Mid(i+1);
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::RemoveDotSlash(const TDesC8& aURI)
+// return uri without dot and slash in start
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::RemoveDotSlash(const TDesC8& aURI)
+    {
+
+    TInt offset = 0;
+    TInt endSlash = 0;
+
+    if (aURI.Find(KNSmlDmUriDotSlash)==0)
+        {
+        offset = 2;
+        }
+    else
+        {
+        return aURI;
+        }
+
+    if (aURI.Length()>2&&aURI[aURI.Length()-1]==KNSmlDMUriSeparator)
+        {
+        endSlash = 1;
+        }
+
+    return aURI.Mid(offset, aURI.Length()-endSlash-offset);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::RemoveProp(const TDesC8& aURI)
+// removes property from the uri
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::RemoveProp(const TDesC8& aURI)
+    {
+    TInt offset = aURI.Find(KNSmlDmQuestionMark);
+    if (offset!=KErrNotFound)
+        {
+        return aURI.Left(offset);
+        }
+    return aURI;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::RemoveLastSeg(const TDesC8& aURI)
+// Removes last uri segment
+// ------------------------------------------------------------------------------------------------
+TPtrC8 NSmlDmURI::RemoveLastSeg(const TDesC8& aURI)
+    {
+    TInt i;
+    for (i=aURI.Length()-1; i>=0; i--)
+        {
+        if (aURI[i]==KNSmlDMUriSeparator)
+            {
+            break;
+            }
+        }
+
+    if (i>0)
+        {
+        return aURI.Left(i);
+        }
+    else
+        {
+        return KNullDesC8();
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 NSmlDmURI::URISeg(const TDesC8& aURI,TInt aLocation,TInt aSegCount=1)
+// Returns the aLocation:th URI segment
+// ------------------------------------------------------------------------------------------------
+/*TPtrC8 NSmlDmURI::URISeg(const TDesC8& aURI, TInt aLocation, TInt aSegCount/*=1*///)
+    /*{
+    TInt i, start;
+    if (aLocation < 0)
+        {
+        return aURI.Mid(0, 0);
+        }
+    if (aLocation > 0)
+        {
+        for (start=0, i=0; (start<aURI.Length()) && (i<aLocation); start++)
+            {
+            if (aURI[start]=='/')
+                {
+                i++;
+                }
+            if (i==aLocation)
+                {
+                break;
+                }
+            }
+        }
+    else
+        {
+        start=-1;
+        }
+    // empty segment
+    if (start+1 >= aURI.Length())
+        {
+        return aURI.Mid(0, 0);
+        }
+    // start points to beginning of segment
+    for (i=start+1; i<aURI.Length(); i++)
+        {
+        if (aURI[i]=='/')
+            {
+            aSegCount--;
+            if (aSegCount == 0)
+                {
+                break;
+                }
+            }
+        }
+    // i points to end of segment   
+    return aURI.Mid(start+1, i-start-1);
+    }*/
+
+// ------------------------------------------------------------------------------------------------
+// TInt NSmlDmURI::NumOfURISegs(const TDesC8& aURI)
+// Returns the num of uri segs
+// ------------------------------------------------------------------------------------------------
+TInt NSmlDmURI::NumOfURISegs(const TDesC8& aURI)
+    {
+    TInt numOfURISegs = 1;
+    for (TInt i=0; i<aURI.Length(); i++)
+        {
+        if (aURI[i]==KNSmlDMUriSeparator)
+            {
+            numOfURISegs++;
+            }
+        }
+    return numOfURISegs;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/BWINS/amtestu.def	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,3 @@
+EXPORTS
+	?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * LibEntryL(class CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/conf/amtest.cfg	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,120 @@
+[StifSettings]
+CapsModifier= example.exe
+[EndStifSettings]
+
+[Test]
+title DDF
+create amtest foobar
+foobar DDFStructure
+delete foobar
+[Endtest] 
+
+[Test]
+title List
+create amtest foobar
+foobar List 
+delete foobar
+[Endtest] 
+
+
+[Test]
+title ListAndDetail
+create amtest foobar
+foobar Details 
+delete foobar
+[Endtest] 
+
+[Test]
+title FetchDelivered
+create amtest foobar
+foobar FetchNode SCM/Inventory/Delivered
+delete foobar
+[Endtest] 
+
+[Test]
+title FetchDeployed
+create amtest foobar
+foobar FetchNode SCM/Inventory/Deployed
+delete foobar
+[Endtest]
+
+[Test]
+title Deliver
+create amtest foobar
+foobar Deliver Id1 Nimi Version E:\Testing\Data\testhbuf_S60_3_X_v_1_0_0.SISx E:\Testing\Data\verysilent_c_en.xml
+delete foobar
+[Endtest] 
+
+[Test]
+title AddNode
+create amtest foobar
+foobar AddNode SCM/Inventory/Delivered/AppTestNode
+foobar AddNode SCM/Inventory/Delivered/AppTest123
+delete foobar
+[Endtest]
+
+[Test]
+title FetchLeaf
+create amtest foobar
+foobar FetchLeaf SCM/Inventory/Delivered/AppTestNode/Name E:\Testing\Data\LeafResults.txt
+delete foobar
+[Endtest]
+
+[Test]
+title AddUpdateFetchNode
+create amtest foobar
+foobar AddNode SCM/Download/AMDownloadNode3
+foobar FetchLeafObjectSizeL SCM/Download/AMDownloadNode/ID E:\Testing\Data\LeafResults.txt
+foobar FetchLeafObjectSizeL SCM/Download/AMDownloadNode/Name E:\Testing\Data\LeafResults.txt
+delete foobar
+[Endtest]
+
+
+[Test]
+title DeleteNode
+create amtest foobar
+foobar DeleteNode SCM/Inventory/Delivered/AppTest123
+delete foobar
+[Endtest]
+
+
+[Test]
+title StartAtomic
+create amtest foobar
+foobar StartAtomic
+delete foobar
+[Endtest]
+
+[Test]
+title CommitAtomic
+create amtest foobar
+foobar CommitAtomic
+delete foobar
+[Endtest]
+
+
+#[Test]
+#title Install
+#create amtest foobar
+#foobar Install 20
+#delete foobar
+#[Endtest] 
+
+[Test]
+title BareInstall
+create amtest foobar
+foobar BareInstall E:\Testing\Data\bare.sisx
+delete foobar
+[Endtest] 
+
+[Test]
+title DeliverApp
+create amtest foobar
+foobar AddNode SCM/Inventory/Delivered/TestApp5
+foobar UpdateLeaf SCM/Inventory/Delivered/TestApp5/Name Test
+foobar UpdateLeaf SCM/Inventory/Delivered/TestApp5/Version 1.0
+foobar UpdateLeaf SCM/Inventory/Delivered/TestApp5/InstallOpts E:\Testing\Data\TestFramework\verysilent_c_en.xml text/xml
+foobar UpdateLeaf SCM/Inventory/Delivered/TestApp5/Data E:\Testing\Data\TestFramework\testhbuf_S60_3_X_v_1_0_0.SISx
+foobar Execute SCM/Inventory/Delivered/TestApp5/Operations/InstallAndActivate
+delete foobar
+[Endtest]
\ No newline at end of file
Binary file applicationmanagement/tsrc/tarmappmng/data/dmtestmappings.txt has changed
Binary file applicationmanagement/tsrc/tarmappmng/data/testhbuf_S60_3_X_v_1_0_0.SISx has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/data/verysilent_c_en.xml	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,14 @@
+<InstOpts>
+ <StdOpt name="drive" value="c"/> 
+ <StdOpt name="lang" value="EN" /> 
+ <StdOpt name="upgrade" value="yes"/>
+ <StdOpt name="kill" value="yes"/> 
+ <StdSymOpt name="pkginfo" value="yes"/> 
+ <StdSymOpt name="optionals" value="yes"/>
+ <StdSymOpt name="ocsp" value="yes"/>
+ <StdSymOpt name="capabilities" value="yes"/>  
+ <StdSymOpt name="untrusted" value="yes"/> 
+ <StdSymOpt name="ignoreocspwarn" value="yes"/>
+ <StdSymOpt name="ignorewarn" value="no"/>
+ <StdSymOpt name="fileoverwrite" value="yes"/> 
+</InstOpts>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/eabi/amtestu.def	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,9 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+	_ZTI7Camtest @ 2 NONAME ; #<TI>#
+	_ZTV7Camtest @ 3 NONAME ; #<VT>#
+	_ZTI16CTestDmDDFObject @ 4 NONAME ; #<TI>#
+	_ZTI8Cdmatest @ 5 NONAME ; #<TI>#
+	_ZTV16CTestDmDDFObject @ 6 NONAME ; #<VT>#
+	_ZTV8Cdmatest @ 7 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/group/amtest.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,66 @@
+/*
+* 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: Implementation of applicationmanagement components
+*
+*/
+
+
+// To get the APP_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+
+TARGET          amtest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E3
+CAPABILITY      ALL -TCB
+
+//TARGETPATH    
+DEFFILE         amtest.def
+
+SOURCEPATH      ../src
+SOURCE          dmatest.cpp
+SOURCE          TestDmDDFObject.cpp
+SOURCE          amtest.cpp
+SOURCE          amtestBlocks.cpp
+
+USERINCLUDE     ../inc 
+USERINCLUDE     ../../../inc
+
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include 
+
+SYSTEMINCLUDE 	/epoc32/include/ecom
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+SYSTEMINCLUDE 	/epoc32/include/devman
+#else
+// nothing
+#endif
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib 
+LIBRARY					ApplicationManagement.lib
+LIBRARY         efsrv.lib 
+LIBRARY         SWInstCli.lib
+LIBRARY					ecom.lib
+LIBRARY         apgrfx.lib
+LIBRARY         apmime.lib
+LIBRARY         estor.lib 
+
+LANG			      SC
+
+
+
+SMPSAFE
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/group/amtest.pkg	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  Package file for project Advance Device Management, Application Management component.
+;File: amtest.pkg;
+;File: amtest.pkg;
+;
+
+
+;*Languages
+&EN
+;
+;*Standard SIS file header. This section specifies the package name,
+;application UID, and version/build numbers. Add the package TYPE here if needed.
+#{"amtest"},(0x101FB3E3),1,0,1;
+;
+
+;*Unique (Non-Localised) Vendor name
+;This is used in combination with signing to prevent the unauthroized
+;upgrade ofa a package by someone other than the rightful vendor.
+:"Nokia"
+
+;*Localized Vendor Name
+;This specifies the localised vendor name(s) correspodning to language(s).
+%{"Nokia Test EN"}
+
+;*Files To Copy...<src> <destination>
+"\epoc32\release\armv5\urel\amtest.dll" -"C:\sys\bin\amtest.dll"
+"..\conf\amtest.cfg" -"C:\TestFramework\amtest.cfg"
+"..\init\amtest.ini" -"C:\TestFramework\amtest.ini"
+"..\data\dmtestmappings.txt" -"E:\Testing\Data\dmtestmappings.txt"
+"..\data\testhbuf_S60_3_X_v_1_0_0.SISx" -"E:\Testing\Data\testhbuf_S60_3_X_v_1_0_0.SISx"
+"..\data\verysilent_c_en.xml" -"E:\Testing\Data\verysilent_c_en.xml"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,51 @@
+/*
+* 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: Implementation of applicationmanagement components
+*
+*/
+
+
+
+PRJ_PLATFORMS
+// specify the platforms your component needs to be built for here
+// defaults to WINS MARM so you can ignore this if you just build these
+DEFAULT
+
+PRJ_TESTEXPORTS
+// NOTE: If using ARS requirements all export operations should be done under this.
+// 'abld test export'
+
+PRJ_EXPORTS
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in /epoc32/include
+
+
+PRJ_MMPFILES
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+
+
+PRJ_TESTMMPFILES
+// NOTE: If using ARS requirements .mmp file operation should be done under this.
+// 'abld test build'
+
+amtest.mmp
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/inc/TestDmDDFObject.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,199 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation of applicationmanagement components
+*
+*/
+
+
+
+#ifndef __TESTDMDDFOBJECT_H
+#define __TESTDMDDFOBJECT_H
+
+//  INCLUDES
+//#include <?include_file>
+#include <smldmadapter.h>
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+class CStifLogger;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CTestDmDDFObject : public CBase, public MSmlDmDDFObject
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CTestDmDDFObject* NewL( CStifLogger *aLog );
+        static CTestDmDDFObject* NewLC( CStifLogger *aLog );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CTestDmDDFObject();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+		virtual void SetNameL( const TDesC8& aName );
+		
+		void DumpL( const TDesC8& aParentName, TBool aFullDump = ETrue );
+		void ExternalizeL(RWriteStream& aStream) const;
+		
+		
+
+    public: // Functions from base classes
+    
+//sf-    *********************************
+    
+		void SetAccessTypesL( TSmlDmAccessTypes aAccessTypes );
+		void SetDefaultValueL( const TDesC8& aDefaultValue );
+		void SetDescriptionL( const TDesC8& aDescription );
+		void SetDFFormatL( TDFFormat aFormat );
+		void SetOccurenceL( TOccurence aOccurence );
+		void SetScopeL( TScope aScope );
+		void SetDFTitleL( const TDesC8& aTitle );
+		void AddDFTypeMimeTypeL( const TDesC8& aMimeType );
+		void SetAsObjectGroup();
+		MSmlDmDDFObject& AddChildObjectL(const TDesC8& aNodeName);
+		MSmlDmDDFObject& AddChildObjectGroupL();
+
+//sf-    #############################
+
+		const TDesC8& Name();
+		TSmlDmAccessTypes  AccessTypes();
+		const TDesC8& DefaultValue();
+		const TDesC8& Description();
+		TDFFormat DFFormat();
+		TOccurence Occurence();
+		TScope Scope();
+		const TDesC8& DFTitle();
+		const TDesC8& DFTypeMimeType();
+		TBool ObjectGroup();
+		
+		TInt ChildObjectCount();
+		CTestDmDDFObject& ChildObject( TInt aIndex );
+
+		CTestDmDDFObject* FindChildObject( const TDesC8& aName );
+		TInt SubObjectsCount();
+
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CTestDmDDFObject( CStifLogger *aLog );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CTestDmDDFObject( const CTestDmDDFObject& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CTestDmDDFObject& operator=( const CTestDmDDFObject& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+		HBufC8* iName;
+
+		TSmlDmAccessTypes iAccessTypes;
+		HBufC8* iDefaultValue;
+		HBufC8* iDescription;
+		TDFFormat iFormat;
+		TOccurence iOccurence;
+		TScope iScope;
+		HBufC8* iTitle;
+		HBufC8* iMimeType;
+		TBool iObjectGroup;
+		
+		RPointerArray<CTestDmDDFObject> iChildren;
+
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+        /**
+        * Logger.
+        */
+        CStifLogger*    iLog;
+
+    };
+
+#endif      // __TESTDMDDFOBJECT_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/inc/amtest.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,130 @@
+/*
+* 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: Implementation of applicationmanagement components
+*
+*/
+
+
+
+#ifndef AMTEST_H
+#define AMTEST_H
+
+//  INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <smldmadapter.h>
+#include "dmatest.h"
+
+const TUint KNSmlDMAMAdapterImplUid = 0x10207845;
+
+	
+
+const TUid KAdapterUid = 
+		{
+		KNSmlDMAMAdapterImplUid
+		};
+// Logging path
+_LIT( KamtestLogPath, "\\logs\\testframework\\amtest\\" ); 
+// Log file
+_LIT( KamtestLogFile, "amtest.txt" ); 
+
+
+// FORWARD DECLARATIONS
+class Camtest;
+
+
+// CLASS DECLARATION
+
+/**
+*  Camtest test class for STIF Test Framework TestScripter.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class Camtest : public Cdmatest
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static Camtest* NewL( CTestModuleIf& aTestModuleIf );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~Camtest();
+
+    public: // Functions from base classes
+
+        /**
+        * From CScriptBase Runs a script line.
+        * @since ?Series60_version
+        * @param aItem Script line containing method name and parameters
+        * @return Symbian OS error code
+        */
+        virtual TInt RunMethodL( CStifItemParser& aItem );
+                
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        Camtest( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // ?classname( const ?classname& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // ?classname& operator=( const ?classname& );
+    
+        /**
+        * Frees all resources allocated from test methods.
+        * @since ?Series60_version
+        */
+        virtual void Delete();
+        
+        /**
+        * Test methods are listed below. 
+        */
+        
+        /**
+        * Example test method.
+        * @since ?Series60_version
+        * @param aItem Script line containing parameters.
+        * @return Symbian OS error code.
+        */
+        virtual TInt ExampleL( CStifItemParser& aItem ) ;
+        virtual TInt DeliverL( CStifItemParser& aItem ) ;
+        virtual TInt DetailsL( CStifItemParser& aItem ) ;
+		virtual TInt InstallL( CStifItemParser& aItem ) ;
+		virtual TInt BareInstallL( CStifItemParser& aItem ) ;
+		
+
+    private:    // Data
+        HBufC8 *GetNextStringLC ( CStifItemParser& aItem, const TDesC &aName );
+
+
+    };
+
+#endif      // AMTEST_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/inc/dmatest.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,272 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Helper base class for dm adapter testing
+*
+*/
+
+
+
+#ifndef __DMA_TEST_H__
+#define __DMA_TEST_H__
+
+//  INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <apmstd.h>
+#include <smldmadapter.h>
+
+class Cdmatest;
+
+
+struct TMapping
+	{
+	TBuf8<256> iURI;
+	TBuf8<64> iLuid;
+	TMapping( const TDesC8 &aURI, const TDesC8 &aLuid )  : iURI( aURI ), iLuid( aLuid )
+	{
+		
+		}
+	};
+	
+typedef RArray<TMapping> RMappingArray;
+
+typedef void (Cdmatest::* ResultsFunction)( TInt , CBufBase& , const TDesC8&  ) ; 
+
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class Cdmatest : public CScriptBase, public MSmlDmCallback
+    {
+    
+    public:  // Constructors and destructor
+        
+        /**
+        * Destructor.
+        */
+        virtual ~Cdmatest();
+
+    public: // Functions from base classes
+
+        /**
+        * From CScriptBase Runs a script line.
+        * @since ?Series60_version
+        * @param aItem Script line containing method name and parameters
+        * @return Symbian OS error code
+        */
+        virtual TInt RunMethodL( CStifItemParser& aItem ) = 0;
+    
+
+	public:
+		/**
+		The function is used to return the data in case of FetchLeafObjectL(),
+		FetchLeafObjectSizeL() and ChildURIListL() functions. It should not be
+		called where the DM command has failed, i.e. the error code returned in
+		SetStatusL is something other than EOk.
+		@param aResultsRef	Reference to correct command
+		@param aObject		The data which should be returned
+		@param aType			MIME type of the object
+		@publishedPartner
+		@prototype
+		*/
+		void SetResultsL( TInt aResultsRef, CBufBase& aObject,
+								  const TDesC8& aType );
+		
+		/**
+		The function is used to return the data in case of FetchLeafObjectL() and
+		ChildURIListL() functions, where the size of the data being returned is
+		large enough for the Adapter to stream it. This function should not be
+		called when command was failed, i.e. the error code returned in SetStatusL
+		is something other than EOk.
+		@param aResultsRef	Reference to correct command
+		@param aStream		Large data which should be returned, DM engine
+								closes stream when it has read all the data
+		@param aType			MIME type of the object
+		@publishedPartner
+		@prototype
+		*/
+		void SetResultsL( TInt /*aResultsRef*/, RReadStream*& /*aStream*/,
+								  const TDesC8& /*aType*/ ) 
+		{
+			
+		}
+
+		/**
+		The function returns information about the Add,Update,Delete and Fetch
+		commands success to DM engine. The reference to correct command must be
+		used when calling the SetStatusL function, the reference is got from the
+		argument of the command functions. The SetStatusL function must be called
+		separately for every single command.
+		@param aStatusRef	Reference to correct command
+		@param aErrorCode	Information about the command success
+		@publishedPartner
+		@prototype
+		*/
+		void SetStatusL( TInt aStatusRef,
+								 MSmlDmAdapter::TError aErrorCode ) ;
+
+		/**
+		The function passes map information to DM Module. This function is called
+		for a new management object, both for node objects and for leaf objects.
+		In addition if ChildURIListL() function has returned new objects a mapping
+		information of the new objects must be passed. A mapping is treated as
+		inheritable. If the mapping is not set with this function, the mapping
+		LUID of the parent object is passed in following commands to the object.
+		@param aURI	URI of the object. 
+		@param aLUID	LUID of the object. LUID must contain the all information,
+						which is needed for retrieve the invidual object from the
+						database. Typically it is ID for the database table. In
+						more complicated structures it can be combination of IDs,
+						which represent path to the object.
+		@publishedPartner
+		@prototype
+		*/
+		void SetMappingL( const TDesC8& aURI, const TDesC8& aLUID );
+
+		/**
+		The function is used to make a fetch to other adapters. The most common
+		use is to make a fetch to the AP adapter, because when managing the access
+		points, the data comes as URI. For example, there are ToNAPId field in
+		some adapters, and data to it can be something like AP/IAPidx, and then
+		the link to AP adapter is needed.
+		Using FetchLinkL causes the DM Framework to make a Get request to the
+		appropriate DM adapter.  The receiving adapter MUST complete the Get
+		request synchronously.
+		@param aURI		URI of the object. 
+		@param aData		Reference to data, i.e. data is returned here
+		@param aStatus	The status of fetch command is returned here
+		@publishedPartner
+		@prototype
+		*/
+		void FetchLinkL( const TDesC8& /*aURI*/, CBufBase& /*aData*/,
+								 MSmlDmAdapter::TError& /*aStatus*/ ) 
+			{
+				
+			}
+
+		/**
+		The function returns the LUID which is mapped to aURI. If LUID is not
+		found, the function allocates a null length string, i.e. the function
+		allocates memory in every case.
+		@param aURI	URI of the object. 
+		@publishedPartner
+		@prototype
+		*/
+		HBufC8* GetLuidAllocL( const TDesC8& aURI ) ;
+
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    
+    void GetMappingInfoListL( const TDesC8& aURI,
+								CArrayFix<TSmlDmMappingInfo>& aSegmentList );
+
+#else
+// nothing
+#endif
+		        
+    protected:  // New functions
+
+        
+		void FetchNodeResultsL( TInt aResultsRef, CBufBase& aObject,
+							  const TDesC8& aType );
+		void SaveDataL( TInt aResultsRef, CBufBase& aObject,
+							  const TDesC8& aType ) ;
+							  
+		TPtrC8 LastURISeg( const TDesC8& aURI );
+		TPtrC8 RemoveLastURISeg( const TDesC8& aURI );
+		TPtrC RemoveLastURISeg( const TDesC& aURI );
+		void SetURIL( const TDesC& aURI );
+		void SetURIL( const TDesC8& aURI );
+		void SetURIL( HBufC8* aURI );		
+		HBufC8 *LoadFileLC( const TDesC &aFileName, TDataType &aType );
+		HBufC8 *LoadFileLC( const TDesC8 &aFileName, TDataType &aType );
+		HBufC8 *GetNextStringLC ( CStifItemParser& aItem, const TDesC &aName );
+		HBufC8* GetLuidAllocLC( const TDesC8& aURI ) ;
+		TPtrC8 RemoveLastSeg(const TDesC8& aURI);
+		
+		TInt FetchNodeL( CStifItemParser& aItem ) ;
+		TInt FetchLeafL( CStifItemParser& aItem ) ;
+		TInt AddNodeL( CStifItemParser& aItem );
+		TInt DeleteObjectL( CStifItemParser& aItem );	
+		TInt UpdateLeafL( CStifItemParser& aItem )	;
+		TInt UpdateLeafDataL( CStifItemParser& aItem ) ;
+		TInt UpdateLeafDataURLL( CStifItemParser& aItem ) ;
+		
+		TInt ExecuteLeafL ( CStifItemParser& aItem ) ;
+		TInt ExecuteLeafDataL ( CStifItemParser& aItem ) ;
+		TInt StartAtomicL( CStifItemParser& aItem )	;
+		TInt CommitAtomicL( CStifItemParser& aItem )	;
+		TInt RollbackAtomicL( CStifItemParser& aItem )	;
+		TInt CompleteCommandsL( CStifItemParser& aItem );
+		TInt DDFStructureL( CStifItemParser& aItem )	;
+		TInt FetchLeafObjectSizeL( CStifItemParser& aItem )	;
+		//Newly added	
+		TInt Cdmatest::AddLeafNode( CStifItemParser& aItem );
+		TInt Cdmatest::InstallActivate( CStifItemParser& aItem );			
+		//Newly ended
+
+    protected:
+
+        /**
+        * C++ default constructor.
+        */
+        Cdmatest( CTestModuleIf& aTestModuleIf, TUid aUid );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // Cdmatest( const Cdmatest& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // Cdmatest& operator=( const Cdmatest& );
+
+		/**
+        * Frees all resources allocated from test methods.
+        * @since ?Series60_version
+        */
+        virtual void Delete();
+        void LoadMappingsL();
+        void SaveMappingsL();
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+		MSmlDmAdapter::TError iStatus ;
+        ResultsFunction iResultsFunction;
+        CSmlDmAdapter *iAdapter ;
+        HBufC8 *iURI; 
+        CArrayFix<TSmlDmMappingInfo> *iEmptyMappingInfoArray;
+		TFileName iSaveFileName;
+		RMappingArray iMappingTable;
+		TUid iUid;
+		TInt iCounter;
+		//class CNSmlDmMgmtTree* iMgmtTree;
+		class CNSmlDmMgmtTree* iMgmtTree;
+		CSmlDmAdapter *Adapter() ;
+    };
+
+#endif      // __DMA_TEST_H__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/init/amtest.ini	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,221 @@
+#
+# This is STIF initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+#	- Set Test Reporting mode. TestReportMode's possible values are:
+#		+ 'Summary': Summary of the tested test cases.
+#		+ 'Environment': Hardware and software info.
+#		+ 'TestCases': Test case report.
+#		+ 'FullReport': Set of all above ones.
+#		+ Example 'TestReportMode= Summary TestCases'
+#
+# 	- CreateTestReport setting controls report creation mode
+#		+ YES, Test report will created.
+#		+ NO, No Test report.
+#
+# 	- File path indicates the base path of the test report.
+# 	- File name indicates the name of the test report.
+#
+# 	- File format indicates the type of the test report.
+#		+ TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#		+ HTML, Test report will be html type, for example 'TestReport.html'.
+#   + XML, Test report will be xml type, for example 'TestReport.xml'.
+#          Note, that xml format is available only when output is set to FILE.
+#
+# 	- File output indicates output source of the test report.
+#		+ FILE, Test report logging to file.
+#		+ RDEBUG, Test report logging to using rdebug.
+#
+# 	- File Creation Mode indicates test report overwriting if file exist.
+#		+ OVERWRITE, Overwrites if the Test report file exist.
+#		+ APPEND, Continue logging after the old Test report information if
+#                 report exist.
+# 	- Sets a device reset module's dll name(Reboot).
+#		+ If Nokia specific reset module is not available or it is not correct one
+#		  StifHWResetStub module may use as a template for user specific reset
+#		  module.
+# 	- Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation
+#		DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02
+#
+
+[Engine_Defaults]
+
+TestReportMode= FullReport    # Possible values are: 'Empty', 'Summary', 'Environment',
+                                                     'TestCases' or 'FullReport'
+
+CreateTestReport= YES         # Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT         # Possible values: TXT, HTML or XML
+TestReportOutput= FILE        # Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+DisableMeasurement= stifmeasurementdisablenone  # Possible values are:
+              # 'stifmeasurementdisablenone', 'stifmeasurementdisableall'
+              # 'stifmeasurementplugin01', 'stifmeasurementplugin02',
+              # 'stifmeasurementplugin03', 'stifmeasurementplugin04',
+              # 'stifmeasurementplugin05' or 'stifbappeaprofiler'
+
+Timeout= 0                    # Default timeout value for each test case. In milliseconds
+#UITestingSupport= YES        # Possible values: YES or NO
+#SeparateProcesses= YES       # Possible values: YES or NO (default: NO)
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= XXXXXXXXX
+# Modules might have initialisation file, specified as
+# IniFile= c:\testframework\YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:\testframework\NormalCases.txt
+# TestCaseFile= c:\testframework\SmokeCases.txt
+# TestCaseFile= c:\testframework\ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+#ModuleName= demomodule
+
+ModuleName= testscripter
+# ADM Test-Automation
+ConfigFile= C:\TestFramework\amtest.cfg
+[End_Module]
+
+
+# Load testmoduleXXX, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleXXX used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleXXX used configuration file(s)
+#TestCaseFile= c:\testframework\testcases1.cfg
+#TestCaseFile= c:\testframework\testcases2.cfg
+#TestCaseFile= c:\testframework\manualtestcases.cfg
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIF logging overwrite parameters for Logger.
+# 	Hardware and emulator environment logging path and styles can
+# 	be configured from here to overwrite the Logger's implemented values.
+#	
+#	Settings description:
+#	- Indicates option for creation log directory/directories. If log directory/directories
+#         is/are not created by user they will make by software.
+#		+ YES, Create log directory/directories if not allready exist.
+#		+ NO, Log directory/directories not created. Only created one is used.
+#
+#	- Overwrite emulator path setting.
+#		+ Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#		           Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#		           will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+#	- Overwrite emulator's logging format.
+#		+ TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#		+ HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+#	- Overwrited emulator logging output source.
+#		+ FILE, Logging to file(s).
+#		+ RDEBUG, Logging to using rdebug(s).
+#
+#	- Overwrite hardware path setting (Same description as above in emulator path).
+#	- Overwrite hardware's logging format(Same description as above in emulator format).
+#	- Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+#	- File Creation Mode indicates file overwriting if file exist.
+#		+ OVERWRITE, Overwrites if file(s) exist.
+#		+ APPEND, Continue logging after the old logging information if file(s) exist.
+#
+#	- Will thread id include to the log filename.
+#		+ YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#		+ NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+#	- Will time stamps include the to log file.
+#		+ YES, Time stamp added to each line in log file(s). Time stamp is 
+#                 for example'12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No time stamp(s).
+#
+#	- Will line breaks include to the log file.
+#		+ YES, Each logging event includes line break and next log event is in own line.
+#		+ NO, No line break(s).
+#
+#	- Will event ranking include to the log file.
+#		+ YES, Event ranking number added to each line in log file(s). Ranking number
+#                 depends on environment's tics, for example(includes time stamp also)
+#                 '012   12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No event ranking.
+#
+#	- Will write log file in unicode format.
+#		+ YES, Log file will be written in unicode format
+#		+ NO, Log will be written as normal, not unicode, file.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#'
+#NOTE: TestEngine and TestServer logging settings cannot change here
+
+#CreateLogDirectories= YES    # Possible values: YES or NO
+
+#EmulatorBasePath= C:\LOGS\TestFramework\
+#EmulatorFormat= HTML         # Possible values: TXT or HTML
+#EmulatorOutput= FILE         # Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML         # Possible values: TXT or HTML
+#HardwareOutput= FILE         # Possible values: FILE or RDEBUG
+
+#FileCreationMode= OVERWRITE  # Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES       # Possible values: YES or NO
+#WithTimeStamp= YES           # Possible values: YES or NO
+#WithLineBreak= YES           # Possible values: YES or NO
+#WithEventRanking= YES        # Possible values: YES or NO
+
+#FileUnicode= YES             # Possible values: YES or NO
+#AddTestCaseTitle= YES        # Possible values: YES or NO
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set filters to be used by ConsoleUI.
+# 	If you want to use filter with ConsoleUI, simply remove comments
+# 	from section below and provide valid filter entries.
+#   Each filter line has to start with "filter= " keyword.
+#   Filter can contain special wildcard characters:
+#     *  which stands for none or any literal;
+#     ?  which stands for single character.
+#   Filters are not case-sensitive.
+
+#[Filters]
+#filter= *math*
+#filter= *radio*
+#[End_Filters]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/src/TestDmDDFObject.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,512 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation of applicationmanagement components
+*
+*/
+
+
+
+// INCLUDE FILES
+
+#include "TestDmDDFObject.h"
+#include "StifLogger.h"
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CTestDmDDFObject::CTestDmDDFObject
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CTestDmDDFObject::CTestDmDDFObject( CStifLogger *aLog )
+	: iName( 0 )
+	, iAccessTypes()
+	, iDefaultValue( 0 )
+	, iDescription( 0 )
+	, iFormat( (TDFFormat)0 )
+	, iOccurence( (TOccurence)0 )
+	, iScope( (TScope)0 )
+	, iTitle ( 0 )
+	, iMimeType( 0 )
+	, iObjectGroup( EFalse )
+	, iLog( aLog )
+//	RPointerArray<CTestDmDDFObject> iChildren;
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTestDmDDFObject::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CTestDmDDFObject::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CTestDmDDFObject::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CTestDmDDFObject* CTestDmDDFObject::NewL( CStifLogger *aLog )
+    {
+    CTestDmDDFObject* self = CTestDmDDFObject::NewLC( aLog );
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+CTestDmDDFObject* CTestDmDDFObject::NewLC( CStifLogger *aLog )
+    {
+    CTestDmDDFObject* self = new( ELeave ) CTestDmDDFObject( aLog );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+
+    return self;
+    }
+
+    
+// Destructor
+CTestDmDDFObject::~CTestDmDDFObject()
+    {
+	delete iName;
+	delete iDefaultValue;
+	delete iDescription;
+	delete iTitle;
+	delete iMimeType;
+	iChildren.ResetAndDestroy();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CTestDmDDFObject::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+/*?type CTestDmDDFObject::?member_function(
+    ?arg_type arg,
+    ?arg_type arg )
+    {
+    
+    ?code
+    
+    }
+*/
+
+void CTestDmDDFObject::SetAccessTypesL( TSmlDmAccessTypes aAccessTypes )
+	{
+	iLog->Log( _L8( "SetAccessTypesL, aAccessTypes=%d" ), aAccessTypes.GetACL() );
+	iAccessTypes = aAccessTypes;
+	}
+
+void CTestDmDDFObject::SetDefaultValueL( const TDesC8& aDefaultValue )
+	{
+	iLog->Log( _L8( "SetDefaultValueL, aDefaultValue='%S'" ), &aDefaultValue );
+	delete iDefaultValue;
+	iDefaultValue = 0;
+	iDefaultValue = aDefaultValue.AllocL();
+	}
+
+void CTestDmDDFObject::SetDescriptionL( const TDesC8& aDescription )
+	{
+	iLog->Log( _L8( "SetDescriptionL, aDescription='%S'" ), &aDescription );
+	delete iDescription;
+	iDescription = 0;
+	iDescription = aDescription.AllocL();
+	}
+	
+void CTestDmDDFObject::SetDFFormatL( TDFFormat aFormat )
+	{
+	iLog->Log( _L8( "SetDFFormatL, aFormat=%d" ), aFormat );
+	iFormat = aFormat;
+	}
+	
+void CTestDmDDFObject::SetOccurenceL( TOccurence aOccurence )
+	{
+	iLog->Log( _L8( "SetOccurenceL, aOccurence=%d" ), aOccurence );
+	iOccurence = aOccurence;
+	}
+	
+void CTestDmDDFObject::SetScopeL( TScope aScope )
+	{
+	iLog->Log( _L8( "SetScopeL, aScope=%d" ), aScope );
+	iScope = aScope;
+	}
+	
+void CTestDmDDFObject::SetDFTitleL( const TDesC8& aTitle )
+	{
+	iLog->Log( _L8( "SetDFTitleL, aTitle='%S'" ), &aTitle );
+	delete iTitle;
+	iTitle = 0;
+	iTitle = aTitle.AllocL();
+	}
+	
+void CTestDmDDFObject::AddDFTypeMimeTypeL( const TDesC8& aMimeType )
+	{
+	iLog->Log( _L8( "AddDFTypeMimeTypeL, aMimeType='%S'" ), &aMimeType );
+	delete iMimeType;
+	iMimeType = 0;
+	iMimeType = aMimeType.AllocL();
+	}
+	
+void CTestDmDDFObject::SetAsObjectGroup()
+	{
+	iLog->Log( _L8( "SetAsObjectGroup, true" ) );
+	iObjectGroup = ETrue;
+	}
+	
+MSmlDmDDFObject& CTestDmDDFObject::AddChildObjectL(const TDesC8& aNodeName)
+	{
+	iLog->Log( _L8( "AddChildObjectL, aNodeName='%S'" ), &aNodeName );
+	CTestDmDDFObject* child = CTestDmDDFObject::NewLC( iLog ); //, aNodeName );
+	child->SetNameL( aNodeName );
+	iChildren.AppendL( child );
+	CleanupStack::Pop( child ); // Don't destroy
+	return *child;
+	}
+
+MSmlDmDDFObject& CTestDmDDFObject::AddChildObjectGroupL()
+	{
+	iLog->Log( _L8( "AddChildObjectGroupL, ''" ) );
+	CTestDmDDFObject* child = CTestDmDDFObject::NewLC( iLog ); //, KNullDesC );
+	child->SetAsObjectGroup();
+	iChildren.AppendL( child );
+	CleanupStack::Pop( child ); // Don't destroy
+	return *child;
+	}
+
+// Own functions
+
+void CTestDmDDFObject::SetNameL( const TDesC8& aName )
+	{
+	delete iName;
+	iName = 0;
+	iName = aName.AllocL();
+	}
+
+void CTestDmDDFObject::DumpL( const TDesC8& aParentName, TBool aFullDump )
+	{
+	TPtrC8 name( _L8("<X>") );
+	if (iName && iName->Length() > 0)
+		{
+		name.Set( *iName );
+		}
+
+	HBufC8* fullName = HBufC8::NewLC( aParentName.Length() + name.Length() + 1 );
+	*fullName = aParentName;
+	if (aParentName.Length() > 0 && aParentName[ aParentName.Length() - 1 ] != '/')
+		{
+		fullName->Des().Append( _L8("/"));
+		}
+	fullName->Des().Append( name );
+
+	/* Translate some members to text for dumping */
+	TBuf8<20> strAccessTypes;
+	TUint8 accessTypes = iAccessTypes.GetACL();
+	if ((accessTypes & iAccessTypes.EAccessType_Add) != 0)
+		{
+		strAccessTypes.Append( _L8("A") );
+		}
+	if ((accessTypes & iAccessTypes.EAccessType_Copy) != 0)
+		{
+		strAccessTypes.Append( _L8("C") );
+		}
+	if ((accessTypes & iAccessTypes.EAccessType_Delete) != 0)
+		{
+		strAccessTypes.Append( _L8("D") );
+		}
+	if ((accessTypes & iAccessTypes.EAccessType_Exec) != 0)
+		{
+		strAccessTypes.Append( _L8("E") );
+		}
+	if ((accessTypes & iAccessTypes.EAccessType_Get) != 0)
+		{
+		strAccessTypes.Append( _L8("G") );
+		}
+	if ((accessTypes & iAccessTypes.EAccessType_Replace) != 0)
+		{
+		strAccessTypes.Append( _L8("R") );
+		}
+	
+	TBuf8<20> strFormat;
+	switch( iFormat )
+		{
+	case EB64:
+		strFormat = _L8("Base64");
+		break;
+	case EBool:
+		strFormat = _L8("Bool");
+		break;
+	case EChr:
+		strFormat = _L8("Chr");
+		break;
+	case EInt:
+		strFormat = _L8("Int");
+		break;
+	case ENode:
+		strFormat = _L8("Node");
+		break;
+	case ENull:
+		strFormat = _L8("Null");
+		break;
+	case EXml:
+		strFormat = _L8("Xml");
+		break;
+	case EBin:
+		strFormat = _L8("Bin");
+		break;
+	default:
+		break;
+		}
+
+
+	TBuf8<20> strOccurence;
+	switch( iOccurence )
+		{
+	case EOne:
+		/** The node appears exactly once */
+		strOccurence = _L8("M:1");
+		break;
+	case EZeroOrOne:
+		/** The node is optional and may appear zero or once */
+		strOccurence = _L8("O:0-1");
+		break;
+	case EZeroOrMore:
+		/** The node is optional and may appear zero or more times */
+		strOccurence = _L8("O:0-*");
+		break;
+	case EOneOrMore:
+		/** The node is mandatory and may appear once or more times */
+		strOccurence = _L8("M:1-*");
+		break;
+	case EZeroOrN:
+		/** The node is optional and may appear between once and 'N' times */
+		strOccurence = _L8("O:1-N");
+		break;
+	case EOneOrN:
+		/** The node is mandatory and may appear between once and 'N' times */
+		strOccurence = _L8("M:1-N");
+		break;
+	default:
+		break;
+		}
+	
+	
+	TBuf8<20> strScope;
+	switch( iScope)
+		{
+	case EPermanent:
+		/** The node appears exactly once */
+		strScope = _L8("Permanent");
+		break;
+	case EDynamic:
+		/** The node is optional and may appear zero or once */
+		strScope = _L8("O:Dynamic");
+		break;
+	default:
+		break;
+		}
+
+	
+	/* Dump main data */
+	if (aFullDump)
+		{
+		iLog->Log( _L8( "DDFObject: '%S'" ), fullName );
+		}
+		else
+		{
+		iLog->Log( _L8( "DDFObject: '%S'   (%S), %S, %S, %S" ),
+					fullName, &strAccessTypes, &strFormat, &strOccurence, &strScope );
+		}
+	
+	/* Dump members */
+	if (aFullDump)
+		{
+		TPtrC8 empty( _L8( "<null>" ) );
+		#define CHK_NULL(a) ((a)==0?(TDesC8*)(&empty):(TDesC8*)(a))
+
+		iLog->Log( _L8( "    iName=='%S'" ), iName );
+		iLog->Log( _L8( "    iAccessTypes=%d (%S)" ), iAccessTypes.GetACL(), &strAccessTypes );
+		iLog->Log( _L8( "    iDefaultValue='%S'" ), CHK_NULL(iDefaultValue));
+		iLog->Log( _L8( "    iDescription='%S'" ), CHK_NULL(iDescription ));
+		iLog->Log( _L8( "    iFormat=%d (%S)" ), iFormat, &strFormat );
+		iLog->Log( _L8( "    iOccurence=%d (%S)" ), iOccurence, &strOccurence );
+		iLog->Log( _L8( "    iScope=%d (%S)" ), iScope, &strScope );
+		iLog->Log( _L8( "    iTitle='%S'" ), CHK_NULL(iTitle ));
+		iLog->Log( _L8( "    iMimeType='%S'" ), CHK_NULL(iMimeType ));
+		iLog->Log( _L8( "----------------------------------" ) );
+		}
+	
+	/* Dump children */
+	for (TInt i = 0 ; i < iChildren.Count() ; i++)
+		{
+		iChildren[i]->DumpL( *fullName, aFullDump );
+		}
+
+	CleanupStack::PopAndDestroy( fullName );
+	}
+
+/*
+void CTestDmDDFObject::ExternalizeL(RWriteStream& aStream) const
+	{
+	X;
+	aStream << *iName << eol;
+	}
+*/
+
+const TDesC8& CTestDmDDFObject::Name()
+	{
+	return (iName != 0) ? *iName : KNullDesC8();
+	}
+
+TSmlDmAccessTypes  CTestDmDDFObject::AccessTypes()
+	{
+	return iAccessTypes;
+	}
+
+const TDesC8& CTestDmDDFObject::DefaultValue()
+	{
+	return (iDefaultValue != 0) ? *iDefaultValue : KNullDesC8();
+	}
+
+const TDesC8& CTestDmDDFObject::Description()
+	{
+	return (iDescription != 0) ? *iDescription : KNullDesC8();
+	}
+
+CTestDmDDFObject::TDFFormat CTestDmDDFObject::DFFormat()
+	{
+	return iFormat;
+	}
+
+CTestDmDDFObject::TOccurence CTestDmDDFObject::Occurence()
+	{
+	return iOccurence;
+	}
+
+CTestDmDDFObject::TScope CTestDmDDFObject::Scope()
+	{
+	return iScope;
+	}
+
+const TDesC8& CTestDmDDFObject::DFTitle()
+	{
+	return (iTitle != 0) ? *iTitle : KNullDesC8();
+	}
+
+const TDesC8& CTestDmDDFObject::DFTypeMimeType()
+	{
+	return (iMimeType != 0) ? *iMimeType : KNullDesC8();
+	}
+
+TBool CTestDmDDFObject::ObjectGroup()
+	{
+	return iObjectGroup;
+	}
+
+TInt CTestDmDDFObject::ChildObjectCount()
+	{
+	return iChildren.Count();
+	}
+
+CTestDmDDFObject& CTestDmDDFObject::ChildObject( TInt aIndex )
+	{
+	return *iChildren[aIndex];
+	}
+
+CTestDmDDFObject* CTestDmDDFObject::FindChildObject( const TDesC8& aName )
+	{
+	CTestDmDDFObject* foundObject = 0;
+
+	for (TInt i = 0 ; i < iChildren.Count() ; i++)
+		{
+		if ( aName.CompareC( iChildren[i]->Name() ) == 0 )
+			{
+			foundObject = iChildren[i];
+			break;
+			}
+		}
+
+	return foundObject;
+	}
+
+TInt CTestDmDDFObject::SubObjectsCount()
+	{
+	TInt count = 0;
+
+	TInt i;
+	for (i = 0 ; i < iChildren.Count() ; i++)
+		{
+		count += iChildren[i]->SubObjectsCount();
+		}
+	count += i;
+
+	return count;
+	}
+
+/*
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+?type  ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg )  // ?description
+    {
+
+    ?code
+
+    }
+*/
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/src/amtest.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,103 @@
+/*
+* 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: Implementation of applicationmanagement components
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <Stiftestinterface.h>
+#include "amtest.h"
+#include <stiflogger.h>
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Camtest::Camtest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+Camtest::Camtest( CTestModuleIf& aTestModuleIf )
+		: Cdmatest( aTestModuleIf, KAdapterUid )
+    {
+    }
+// -----------------------------------------------------------------------------
+// Camtest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Camtest::ConstructL()
+    {
+    iLog = CStifLogger::NewL( KamtestLogPath, 
+                          KamtestLogFile,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile );
+                          
+    iLog->Log( _L( "Loading Adapter" ) );
+    
+	Cdmatest::ConstructL();                         	
+
+    }
+
+// -----------------------------------------------------------------------------
+// Camtest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Camtest* Camtest::NewL( 
+    CTestModuleIf& aTestModuleIf )
+    {
+    Camtest* self = new (ELeave) Camtest( aTestModuleIf );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    
+    }
+    
+// Destructor
+Camtest::~Camtest()
+    { 
+    
+    // Delete resources allocated from test methods
+//    Delete();
+    
+    // Delete logger
+//    delete iLog;  
+    
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL( 
+    CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+    {
+    
+    return ( CScriptBase* ) Camtest::NewL( aTestModuleIf );
+        
+    }
+
+
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/src/amtestBlocks.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,507 @@
+/*
+* 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: Implementation of applicationmanagement components
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32svr.h>
+#include <StifParser.h>
+#include <Stiftestinterface.h>
+#include "amtest.h"
+#include "applicationmanagementclient.h"
+#include <e32math.h>
+#include <f32file.h>
+#include <swinstapi.h>
+
+
+using namespace NApplicationManagement;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Camtest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void Camtest::Delete() 
+    {
+    
+    }
+    
+// -----------------------------------------------------------------------------
+// Camtest::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt Camtest::RunMethodL( 
+    CStifItemParser& aItem ) 
+    {
+   
+    TStifFunctionInfo const KFunctions[] =
+        {  
+        // Copy this line for every implemented function.
+        // First string is the function name used in TestScripter script file.
+        // Second is the actual implementation member function. 
+        ENTRY( "DDFStructure", Camtest::DDFStructureL),
+        ENTRY( "List", Camtest::ExampleL ),
+        ENTRY( "Deliver", Camtest::DeliverL ),
+        ENTRY( "Details", Camtest::DetailsL ),
+        ENTRY( "Install", Camtest::InstallL ),
+        ENTRY( "BareInstall", Camtest::BareInstallL ),
+        ENTRY( "FetchNode", Camtest::FetchNodeL ),
+        ENTRY( "FetchLeaf", Camtest::FetchLeafL ),
+        ENTRY( "FetchLeafObjectSizeL", Camtest::FetchLeafObjectSizeL ),
+        //ENTRY( "CompleteCommands", Cdmatest::CompleteCommandsL ),
+        ENTRY( "AddNode", Camtest::AddNodeL ),
+        ENTRY( "UpdateLeaf", Camtest::UpdateLeafL ),
+        ENTRY( "UpdateLeafData", Camtest::UpdateLeafDataL ),
+        ENTRY( "UpdateLeafDataURI", Camtest::UpdateLeafDataURLL ),
+        ENTRY( "Execute", Camtest::ExecuteLeafL ),
+        ENTRY( "ExecuteData", Camtest::ExecuteLeafDataL ),
+        ENTRY( "DeleteNode", Camtest::DeleteObjectL ),
+        ENTRY( "StartAtomic", Camtest::StartAtomicL),
+	    ENTRY( "CommitAtomic", Camtest::CommitAtomicL),
+	    ENTRY( "RollbackAtomic", Camtest::RollbackAtomicL),
+	    //Newly addded
+	    ENTRY( "AddLeafNode", Camtest::AddLeafNode),
+	    ENTRY( "InstallActivate", Camtest::InstallActivate),
+	    //Newly ended
+//	    ENTRY( "BareAppInstall", Camtest::BareAppInstallL),
+/*        ENTRY( "DDFStructure", Camtest::DDFStructureL),*///BareAppInstallL
+        };
+
+    const TInt count = sizeof( KFunctions ) / 
+                        sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+
+    }    
+
+// -----------------------------------------------------------------------------
+// Camtest::ExampleL
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Camtest::ExampleL( CStifItemParser& /*aItem*/ )
+    {
+    
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("amtest"), _L("In Example") );
+    // Print to log file
+    iLog->Log(_L("In Example"));
+
+    RApplicationManagement ams ;
+    TInt err( ams.Connect() );
+    
+    if ( err == KErrNone )
+    	{    	    
+	    RElementIdArray array;
+	    ams.DeploymentComponentIdsL(array);
+		iLog->Log( _L( "Found %d Ids" ), array.Count() );
+		for ( TInt i = 0; i < array.Count(); i++ )
+			{
+			iLog->Log( _L( "  Id %d: %d" ), i, array[i] );
+			}
+			
+			
+		TDeploymentComponent comp ;
+		comp.iId = _L8( "Iidee" );
+		TBuf8<10> buf;
+		TTime tm;
+		tm.HomeTime();
+		TInt64 rn = tm.Int64() ;
+		TInt rand = Math::Rand( rn ) ;
+		buf.NumFixedWidth( rand, EHex, 10);
+	
+		comp.iId.Append( buf );
+		comp.iVersion = _L8( "2.3" );
+		comp.iName = _L8( "Nimi" );
+		
+		err = ams.DeliverL(/*_L8("Leaf"), */comp.iId/*, comp.iName, comp.iVersion, EDCSDelivered, _L8("datadatadatadata"), _L8("iopts"), _L8("meta") */) ;
+		iLog->Log( _L( " Deliver response: %d, state: %d" ), err, comp.iState );
+		User::LeaveIfError ( err );
+		err = KErrNone;
+		
+		array.Reset();
+		ams.DeploymentComponentIdsL(array);
+		iLog->Log( _L( "Found 2ndtime %d Ids" ), array.Count() );
+		for ( TInt i = 0; i < array.Count(); i++ )
+			{
+			iLog->Log( _L( "  Id %d: %d" ), i, array[i] );
+			
+			TDeploymentComponent comp2 ;
+			err = ams.DeploymentComponent(array[i], comp);
+			iLog->Log( _L( " DeploymentComponent response: %d, state: %d" ), err, comp.iState );
+			if ( err == KErrNone )
+				{
+				HBufC *b = HBufC::NewLC( comp.iId.Length() );
+				TPtr p( b->Des() );
+				p.Copy( comp.iId );
+				
+				iLog->Log( _L( "CompId: %S" ), &p );
+				CleanupStack::PopAndDestroy();
+				}
+			else
+				{
+				
+				}
+			}
+		ams.Close();
+		}
+	else
+		{
+		iLog->Log( _L( "Failed to connect: %d" ), err);
+		}
+
+    return err;
+    
+    }
+    
+// -----------------------------------------------------------------------------
+// Camtest::ExampleL
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Camtest::DetailsL( CStifItemParser& aItem )
+    {
+    
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("amtest"), _L("In DetailsL") );
+    // Print to log file
+    iLog->Log(_L("In DetailsL"));
+
+    RApplicationManagement ams ;
+    TInt err( ams.Connect() );
+    
+    if ( err == KErrNone )
+    	{    	
+	    
+	    TInt i( 0 );
+	    TInt nodename;
+	    i = aItem.GetNextInt ( nodename ) ;
+	    if ( i != KErrNone ) 
+		    {
+		    iLog->Log( _L( "ERROR Reading id argument: 0x%X"), i);
+		    //return i;
+		    }
+		else
+			{
+			iLog->Log( _L("id: %d"), nodename);
+			}
+	    
+	    RElementIdArray array;
+	    ams.DeploymentComponentIdsL(array);
+		iLog->Log( _L( "Found %d Ids" ), array.Count() );
+		for ( TInt i = 0; i < array.Count(); i++ )
+			{
+			
+			iLog->Log( _L( "  Id %d: %d" ), i, array[i] );
+
+			TDeploymentComponent comp2 ;
+			err = ams.DeploymentComponent(array[i], comp2);
+			iLog->Log( _L( " DeploymentComponent response: %d, state: %d" ), err, comp2.iState );
+			if ( err == KErrNone )
+				{
+				HBufC *b = HBufC::NewLC( comp2.iId.Length() );
+				TPtr p( b->Des() );
+				p.Copy( comp2.iId );
+				
+				iLog->Log( _L( "CompId: %S" ), &p );
+				CleanupStack::PopAndDestroy();
+				}
+			else
+				{
+				
+				}
+			}
+		User::LeaveIfError ( err );
+		err = KErrNone;
+		ams.Close();
+		}
+	else
+		{
+		iLog->Log( _L( "Failed to connect: %d" ), err);
+		}
+    return err;
+    }
+    
+    
+// -----------------------------------------------------------------------------
+// Camtest::InstallL
+// -----------------------------------------------------------------------------
+//
+TInt Camtest::InstallL( CStifItemParser& aItem )
+    {
+    
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("amtest"), _L("In InstallL") );
+    // Print to log file
+    
+    iLog->Log(_L("In DetailsL"));
+    TCertInfo info ;
+	info.iFingerprint =_L8("finger");
+	info.iSerialNo = _L8("serial");
+	
+    RApplicationManagement ams ;
+    TInt err( ams.Connect( info ) );
+    
+    
+    if ( err == KErrNone )
+    	{    	
+    	
+        TInt i( 0 );
+	    TUint32 nodename;
+	    i = aItem.GetNextInt ( (TInt&)nodename ) ;
+	    if ( i != KErrNone ) 
+		    {
+		    iLog->Log( _L( "ERROR Reading id argument: 0x%X"), i);
+		    //return i;
+		    }
+		else
+			{
+			iLog->Log( _L("id: %d"), nodename);
+			}
+	    
+/*	    RElementIdArray array;
+	    ams.DeploymentComponentIdsL(array);
+		iLog->Log( _L( "Found %d Ids" ), array.Count() );
+		for ( TInt i = 0; i < array.Count(); i++ )
+			{
+			
+			iLog->Log( _L( "  Id %d: %d" ), i, array[i] );
+
+			TDeploymentComponent comp2 ;
+			err = ams.DeploymentComponent(array[i], comp2);
+			iLog->Log( _L( " DeploymentComponent response: %d, state: %d" ), err, comp2.iState );
+			if ( err == KErrNone )
+				{
+				HBufC *b = HBufC::NewLC( comp2.iId.Length() );
+				TPtr p( b->Des() );
+				p.Copy( comp2.iId );
+				
+				iLog->Log( _L( "CompId: %S" ), &p );
+				CleanupStack::PopAndDestroy();
+				
+				}
+			else
+				{
+				
+				}
+				
+			if ( nodename == array[i] )
+				{
+				iLog->Log( _L( "CompId: %S" ), &p );
+				}
+			}
+		*/
+		ams.InstallL( nodename ) ;
+		User::LeaveIfError ( err );
+		err = KErrNone;
+
+		ams.Close();
+		}
+	else
+		{
+		iLog->Log( _L( "Failed to connect: %d" ), err);
+		}
+    return err;
+    }
+    
+// -----------------------------------------------------------------------------
+// Camtest::InstallL
+// -----------------------------------------------------------------------------
+//
+TInt Camtest::BareInstallL( CStifItemParser& aItem )
+    {
+    
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("amtest"), _L("In InstallL") );
+    // Print to log file
+    iLog->Log(_L("In DetailsL"));
+
+/*void CAmAdapter::InstallL( 
+	TUint aLuidi, 
+	const TDesC8& aURI, 
+	const TDesC8& aLUID, 
+	const TDeploymentComponentState aTargetState,
+	TError &aRet
+    TInt aluidi( 0 );
+    TUint32 aLuidInt;
+    aluidi = aItem.GetNextInt ( (TInt&)aLuidInt ) ;
+	
+	
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Node name") )->Des() ) ;
+    
+	
+    SetURIL( nodename );
+    
+    HBufC8 *luid = GetLuidAllocLC( *iURI );
+    TError ret( EError );
+	
+	TRAPD( err, Adapter()->InstallL(aluidi,*iURI, *luid,3 ,ret));*/
+
+	//using namespace SwiUI;
+    SwiUI::RSWInstLauncher ams ;
+    TInt err( ams.Connect() );
+    
+    if ( err == KErrNone )
+    	{    	
+    	CleanupClosePushL( ams );
+	    iLog->Log( _L( "Connected!" ));
+	    TPtrC filename ;
+	    User::LeaveIfError( aItem.GetNextString( filename ) );
+	    
+	   	
+	   		
+   		TRequestStatus stat;
+   		
+   		ams.Install( stat, filename  );
+   		User::WaitForRequest( stat );
+   		CleanupStack::Pop();
+   		
+		ams.Close();
+		}
+	else
+		{
+		iLog->Log( _L( "Failed to connect: %d" ), err);
+		}
+    return err;
+    }
+        
+        
+HBufC8 *Camtest::GetNextStringLC ( CStifItemParser& aItem, const TDesC &aName )
+	{
+	TPtrC nodename;
+	nodename.Set( KNullDesC );
+
+    TInt i( aItem.GetNextString ( nodename ) );
+    if ( i != KErrNone ) 
+	    {
+	    iLog->Log( _L( "ERROR Reading '%S' argument: 0x%X" ), &aName, i );
+	    }
+	else
+		{
+		iLog->Log( _L("%S: %S"), &aName, &nodename);
+		}
+	
+	HBufC8 *buf = HBufC8::NewLC( nodename.Length() ) ;
+	buf->Des().Copy( nodename );
+	
+	return buf;
+	}
+	
+	
+HBufC8 *LoadFileL( const TDesC8 &aDataFile )
+	{
+	RFs fs ;
+	User::LeaveIfError( fs.Connect() );
+	CleanupClosePushL( fs ); // 1
+	RFile file ;
+	TFileName fn; 
+	fn.Copy( aDataFile );
+	User::LeaveIfError ( file.Open( fs, fn, EFileRead ) );
+	CleanupClosePushL( file ); // 2
+	TInt size;
+	User::LeaveIfError( file.Size( size ) );
+	
+	HBufC8 *res = HBufC8::NewLC( size ); //3
+	TPtr8 p( res->Des() );
+	User::LeaveIfError( file.Read( p ) );
+	CleanupStack::Pop(); // res
+	CleanupStack::PopAndDestroy( 2 ); // file, fs
+	CleanupStack::PushL( res );
+	return res ;
+	}
+	
+// -----------------------------------------------------------------------------
+// Camtest::ExampleL
+// Example test method function.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt Camtest::DeliverL( CStifItemParser& aItem )
+    {
+    
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("amtest"), _L("In DeliverL") );
+    // Print to log file
+    iLog->Log(_L("In DeliverL"));
+
+    RApplicationManagement ams ;
+    TInt err( ams.Connect() );
+    
+    if ( err == KErrNone )
+    	{    	
+    	CleanupClosePushL( ams );
+	    HBufC8 *id = GetNextStringLC ( aItem, _L("Id") ) ;
+	    HBufC8 *name = GetNextStringLC( aItem, _L( "Name" )  ) ;
+	    HBufC8 *version = GetNextStringLC (  aItem, _L( "Version" ) ) ;
+	    HBufC8 *data = GetNextStringLC ( aItem, _L( "data" ) ) ;
+	    HBufC8 *instopt = GetNextStringLC (aItem, _L( "InstOpts" ) ) ;
+	    if ( data != NULL )
+	    	{
+	    	//HBufC8 *datat = NULL;	
+		    HBufC8 *datat = LoadFileL( *data );
+		    RElementIdArray array;
+		    ams.DeploymentComponentIdsL(array);
+			iLog->Log( _L( "Found %d Ids" ), array.Count() );
+			for ( TInt i = 0; i < array.Count(); i++ )
+				{
+				iLog->Log( _L( "  Id %d: %d" ), i, array[i] );
+				}
+								
+			TDeploymentComponent comp ;
+			comp.iId = *id;
+			comp.iVersion = *version;
+			comp.iName = *name;
+			
+			err = ams.DeliverL(/*_L8("Jee"),*/ comp.iId/*, comp.iName, comp.iVersion, EDCSDelivered , *datat, *instopt, _L8("meta") */) ;
+			iLog->Log( _L( " Deliver response: %d, state: %d" ), err, comp.iState );
+			User::LeaveIfError ( err );
+			err = KErrNone;
+			
+			array.Reset();
+			ams.DeploymentComponentIdsL(array);
+			iLog->Log( _L( "Found 2ndtime %d Ids" ), array.Count() );
+			for ( TInt i = 0; i < array.Count(); i++ )
+				{
+				iLog->Log( _L( "  Id %d: %d" ), i, array[i] );
+				}
+				
+			CleanupStack::PopAndDestroy( datat ); 
+	    	}
+		CleanupStack::PopAndDestroy( instopt ); 
+		CleanupStack::PopAndDestroy( data ); 
+		CleanupStack::PopAndDestroy( version );
+		CleanupStack::PopAndDestroy( name );
+		CleanupStack::PopAndDestroy( id ); 
+		CleanupStack::PopAndDestroy( ); //ams
+		}
+	else
+		{
+		iLog->Log( _L( "Failed to connect: %d" ), err);
+		}
+
+    return err;
+    
+    }        
+   
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/applicationmanagement/tsrc/tarmappmng/src/dmatest.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,1127 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Implementation of applicationmanagement components
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "dmatest.h"
+
+#include <StifParser.h>
+#include <Stiftestinterface.h>
+#include <S32FILE.H>
+
+#include <s32mem.h>
+#include <apgcli.h>
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+	#include "nsmldmtreedtd.h"
+#else
+	//nothing
+#endif
+//#include "nsmldmtreedtd.h"
+#include "TestDmDDFObject.h"
+
+
+#include <e32svr.h>
+#include "applicationmanagementclient.h"
+#include <e32math.h>
+#include <f32file.h>
+#include <swinstapi.h>
+
+using namespace NApplicationManagement;
+
+_LIT8( KEmptyType, "" );
+_LIT8( KDefaultType, "text/plain" );
+_LIT( KMappingTableFile, "c:\\TestFramework\\dmtestmappings.txt" );
+//_LIT8( KNSmlDMSeparator8, "/" );
+
+//Newly added
+_LIT8( KAMInstallOptsNodeName, "InstallOpts" );
+_LIT8( KAMDataNodeName, "Data" );
+//Newly ended
+const TUint8 KNSmlDMUriSeparator = 0x2f; //forward slash
+
+#define LEAVE_IF_ERROR(x,msg) \
+	{ TInt __xres = (x); if ( __xres < 0 ) { if ( iLog ) iLog->Log( (msg), __xres ); User::Leave( __xres );	} }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Cdmatest::Cdmatest
+// C++ default constructor can NOT contain any code, that
+// leave.
+// -----------------------------------------------------------------------------
+//
+Cdmatest::Cdmatest(CTestModuleIf& aTestModuleIf, TUid aUid ):
+        CScriptBase( aTestModuleIf ), iMappingTable(2), iUid( aUid )
+    {
+    
+    }
+
+// -----------------------------------------------------------------------------
+// Cdmatest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void Cdmatest::ConstructL()
+    {
+    
+    
+    Adapter();
+  	iEmptyMappingInfoArray = new ( ELeave ) CArrayFixFlat<TSmlDmMappingInfo>(1);
+	
+	TRAPD( err, LoadMappingsL() );
+	if (err != KErrEof && err != KErrNone && err != KErrNotFound)
+		{
+		User::Leave( err );
+		}
+    }
+    
+CSmlDmAdapter *Cdmatest::Adapter() 
+	{
+	if ( iAdapter == NULL )
+		{
+		if ( iLog )
+			{
+			iLog->Log( _L( "Loading Adapter" ) );
+			}
+  			
+  		TRAPD( err, iAdapter = CSmlDmAdapter::NewL( iUid, *this ) );
+	if ( err == KErrNone )
+		{
+		if (iLog )
+			{
+			iLog->Log( _L( "Loaded" ) );	
+			}
+		}
+	else
+		{
+		if (iLog)
+			{
+			iLog->Log( _L( "Failed to load adapter: %d" ), err );
+			}
+	//	User::Leave( err ); 
+		iAdapter = NULL;
+		}
+		}
+	return iAdapter;
+	}
+    
+    
+void Cdmatest::LoadMappingsL()
+	{
+	TDataType type; 
+	HBufC8 *data = LoadFileLC( KMappingTableFile,  type );
+	RDesReadStream buf( *data );
+	CleanupClosePushL( buf );
+	//buf.Set( aChilds)
+	TInt len( data->Length() );
+	while (buf.Source()->TellL( MStreamBuf::ERead ).Offset() < len)
+		{
+		TUint32 val = buf.ReadUint32L();
+		TBuf8<256> uri;
+		TBuf8<64> luid;
+		buf.ReadL(uri, val);
+		val = buf.ReadUint32L();
+		buf.ReadL(luid, val);
+		TMapping m( uri, luid ) ;
+		TInt err( iMappingTable.Append( m )	);
+		if ( err == KErrNone )
+			{
+			iLog->Log( _L8( "Loaded mapping: '%S' : '%S'"), &m.iURI, &m.iLuid );
+			}
+		else
+			{
+			iLog->Log( _L8( "FAILED TO Load mapping: '%d' "), err );
+			}
+		}
+	CleanupStack::PopAndDestroy( &buf); // buf
+	CleanupStack::PopAndDestroy( data ); // data
+	}
+
+void Cdmatest::SaveMappingsL()
+    {
+	TInt c( iMappingTable.Count() );
+	if ( c > 0 )
+	{
+    	RFs fs;
+    	User::LeaveIfError( fs.Connect() );
+    	CleanupClosePushL( fs );
+    	RFileWriteStream buf;
+    	User::LeaveIfError( buf.Replace( fs, KMappingTableFile, EFileWrite ) );
+    	CleanupClosePushL( buf );
+		
+		TInt i( 0 ) ;
+		do 
+			{
+			buf.WriteUint32L( iMappingTable[i].iURI.Length() );
+			buf.WriteL( iMappingTable[i].iURI );
+			buf.WriteUint32L( iMappingTable[i].iLuid.Length() );
+			buf.WriteL( iMappingTable[i].iLuid );
+			}
+		while ( ++i < c )	;
+		buf.CommitL();
+		buf.Close();
+	
+		CleanupStack::PopAndDestroy(); // buf
+		CleanupStack::PopAndDestroy(); // fs
+		}
+    }
+    	
+   
+// Destructor
+Cdmatest::~Cdmatest()
+    {
+    // Delete resources allocated from test methods
+    TRAPD(err, SaveMappingsL() );
+    if ( err != KErrNone )
+    	{
+    		if(iLog)
+    			iLog->Log( _L8( "Failed to save mappings!: %d"), err );
+    	}
+    Delete();
+    
+    // Delete logger
+    delete iLog;  
+    delete iEmptyMappingInfoArray;
+    delete iAdapter;
+    delete iURI;
+    iMappingTable.Reset();
+    REComSession::FinalClose();
+    }
+
+
+// -----------------------------------------------------------------------------
+// Camatest::Delete
+// Delete here all resources allocated and opened from test methods. 
+// Called from destructor. 
+// -----------------------------------------------------------------------------
+//
+void Cdmatest::Delete() 
+    {
+    
+    }
+
+// -----------------------------------------------------------------------------
+// Cdmatest::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+
+
+        
+HBufC8 *Cdmatest::GetNextStringLC ( CStifItemParser& aItem, const TDesC &aName )
+	{
+	TPtrC nodename( KNullDesC );
+
+    TInt i( aItem.GetNextString ( nodename ) );
+    if ( i != KErrNone ) 
+	    {
+	    iLog->Log( _L( "ERROR Reading '%S' argument: 0x%X" ), &aName, i );
+	    }
+	else
+		{
+		iLog->Log( _L("%S: %S"), &aName, &nodename);
+		}
+	
+	HBufC8 *buf = HBufC8::NewLC( nodename.Length() ) ;
+	buf->Des().Copy( nodename );
+	return buf;
+	}
+	
+TInt Cdmatest::FetchNodeL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Cdmatest"), _L("FetchNodeL") );
+
+	iResultsFunction = FetchNodeResultsL;
+	
+    TPtrC8 nodename( GetNextStringLC( aItem, _L(" nodename" ) )->Des() ) ;
+//    TPtrC8 datafile( GetNextStringLC( aItem, _L("outputfile" )->Des() ) ;
+		
+	SetURIL(nodename) ;
+	HBufC8 *luid = GetLuidAllocLC( *iURI );
+	Adapter()->ChildURIListL( *iURI, *luid, *iEmptyMappingInfoArray, 4, 5) ;
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		}
+	else
+		{
+		iLog->Log( _L("FetchNodeL: ChildUriList Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy( luid ) ; 
+	CleanupStack::PopAndDestroy() ; // nodename
+	iLog->Log( _L("FetchNodeL: Test Complete with status %d" ), ret );	
+
+    return ret;
+	}
+	
+TInt Cdmatest::StartAtomicL( CStifItemParser& /*aItem*/ )	
+	{
+	TRAPD( err, Adapter()->StartAtomicL() ) ;
+	iLog->Log( _L("StartAtomicL: Atomic started resulting error %d" ), err );	
+    return err;
+	}
+
+TInt Cdmatest::RollbackAtomicL( CStifItemParser& /*aItem*/ )	
+	{
+	TRAPD( err, Adapter()->RollbackAtomicL() ) ;
+	iLog->Log( _L("RollbackAtomicL: Atomic rolled back resulting error %d" ), err );	
+    return err;
+	}
+	
+TInt Cdmatest::CommitAtomicL( CStifItemParser& /*aItem*/ )	
+	{
+	TRAPD( err, Adapter()->CommitAtomicL() ) ;
+	iLog->Log( _L("RollbackAtomicL: Atomic commited resulting error %d" ), err );	
+    return err;
+	}
+	
+
+TInt Cdmatest::DDFStructureL( CStifItemParser& /*aItem*/ )	
+	{
+	CTestDmDDFObject* ddfRoot = CTestDmDDFObject::NewLC( iLog ); //, aNodeName );
+
+
+	TRAPD( err, iAdapter->DDFStructureL( *ddfRoot ) ) ;
+	CleanupStack::PopAndDestroy( ddfRoot );
+
+	iLog->Log( _L("DDFStructureL: method called resulting error %d" ), err );	
+    return err;
+	}
+		
+		
+TInt Cdmatest::AddNodeL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Cdmatest"), _L("AddNodeL") );
+
+    
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("nodename" ) )->Des() ) ;
+    SetURIL( nodename );
+
+	Adapter()->AddNodeObjectL( *iURI, KEmptyType, 8 ) ;
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("AddNodeL: AddNodeObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("AddNodeL: AddNodeObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+		
+	CleanupStack::PopAndDestroy() ; // nodename
+	iLog->Log( _L("AddNodeL Test Complete with status %d" ), ret );	
+
+    return ret;
+	}
+		
+TInt Cdmatest::UpdateLeafL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Cdmatest"), _L("UpdateLeafL") );
+
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Node name") )->Des() ) ;
+    TPtrC8 datafile (GetNextStringLC( aItem, _L("datafile"))->Des() );
+    
+	HBufC8 *mime = GetNextStringLC( aItem, _L("mime") ) ;
+    //SetURIL( nodename );
+    
+    TPtrC8 last( LastURISeg( nodename ) );
+ 	HBufC8 *luid = GetLuidAllocLC( *iURI );
+    
+    TDataType type;
+    TPtrC8 data;
+    if ((last == KAMInstallOptsNodeName) ||(last == KAMDataNodeName))
+    {
+    	 
+    HBufC8*	bufdata =  LoadFileLC( datafile, type );//->Des() ;
+    data.Set(bufdata->Des());
+    }
+    
+	TPtrC8 mimePtr( *mime == KNullDesC8 ? type.Des8() : mime->Des() );
+	if ((last == KAMInstallOptsNodeName) ||(last == KAMDataNodeName))
+	{
+		Adapter()->UpdateLeafObjectL( nodename , *luid, data, mimePtr, 3);
+	}
+	else
+	{
+		Adapter()->UpdateLeafObjectL( nodename , *luid, datafile, mimePtr, 3);	
+	}
+	
+	
+		if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("UpdateLeafL: UpdateLeafObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("UpdateLeafL UpdateLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	if ((last == KAMInstallOptsNodeName) ||(last == KAMDataNodeName))
+	{
+		CleanupStack::PopAndDestroy(); // loadfile	
+	}
+	CleanupStack::PopAndDestroy(); // luid
+	CleanupStack::PopAndDestroy(); // mime
+	CleanupStack::PopAndDestroy(); // datafile
+	CleanupStack::PopAndDestroy(); // nodename
+	iLog->Log( _L("UpdateLeafL Test Complete with status %d" ), ret );	
+
+    return ret;
+	}
+/*		
+TInt Cdmatest::UpdateLeafL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Cdmatest"), _L("UpdateLeafL") );
+
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Node name") )->Des() ) ;
+    TPtrC8 datafile (GetNextStringLC( aItem, _L("datafile"))->Des() );
+    
+	HBufC8 *mime = GetNextStringLC( aItem, _L("mime") ) ;
+    SetURIL( nodename );
+    
+    
+ 	HBufC8 *luid = GetLuidAllocLC( *iURI );
+    
+    TDataType type; 
+    TPtrC8 data( LoadFileLC( datafile, type )->Des() );
+	TPtrC8 mimePtr( *mime == KNullDesC8 ? type.Des8() : mime->Des() );
+
+	Adapter()->UpdateLeafObjectL( *iURI , *luid, data, mimePtr, 3);
+		if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("UpdateLeafL: UpdateLeafObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("UpdateLeafL UpdateLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy(); // loadfile
+	CleanupStack::PopAndDestroy(); // luid
+	CleanupStack::PopAndDestroy(); // mime
+	CleanupStack::PopAndDestroy(); // datafile
+	CleanupStack::PopAndDestroy(); // nodename
+	iLog->Log( _L("UpdateLeafL Test Complete with status %d" ), ret );	
+
+    return ret;
+	}	
+	
+*/
+TInt Cdmatest::UpdateLeafDataURLL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Cdmatest"), _L("UpdateLeafDataL") );
+
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Node name") )->Des() ) ;
+    TPtrC8 http (GetNextStringLC( aItem, _L("http"))->Des() );
+    TPtrC8 url (GetNextStringLC( aItem, _L("rest of url"))->Des() );
+	HBufC8 *mime = GetNextStringLC( aItem, _L("mime") ) ;
+    SetURIL( nodename );
+    
+    _LIT8( KTag, "://" );
+    
+    HBufC8 *fullurl = HBufC8::NewLC( http.Length() + KTag().Length() + url.Length() );
+    TPtr8 pfullurl( fullurl->Des() );
+    pfullurl.Copy( http ) ;
+    pfullurl.Append( KTag );
+    pfullurl.Append( url );
+    TPtrC8 mimePtr( *mime == KNullDesC8 ? KDefaultType() : mime->Des() );
+    
+    TPtrC8 parentURI(RemoveLastSeg(nodename));
+    HBufC8 *luid = GetLuidAllocLC( parentURI );
+
+	Adapter()->UpdateLeafObjectL( *iURI , *luid, pfullurl, mimePtr, 3);
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("UpdateLeafDataL: UpdateLeafObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("UpdateLeafDataL UpdateLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy( luid ); // 
+	CleanupStack::PopAndDestroy( mime ); // mime
+	CleanupStack::PopAndDestroy(); // url
+	CleanupStack::PopAndDestroy(); // http
+	CleanupStack::PopAndDestroy(); // nodename
+	iLog->Log( _L("UpdateLeafDataL Test Complete with status %d" ), ret );	
+
+    return ret;
+	}
+    
+TInt Cdmatest::UpdateLeafDataL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+   TestModuleIf().Printf( 0, _L("Camtest"), _L("UpdateLeafDataL") );
+
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Node name") )->Des() ) ;
+    TPtrC8 data (GetNextStringLC( aItem, _L("data"))->Des() );
+
+	HBufC8 *mime = GetNextStringLC( aItem, _L("mime") ) ;
+	
+    SetURIL( nodename );
+    
+        
+    TPtrC8 mimePtr( *mime == KNullDesC8 ? KDefaultType() : mime->Des() );
+    
+     
+    HBufC8 *luid = GetLuidAllocLC( *iURI );
+//    
+//    virtual void UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+//									const TDesC8& aObject, const TDesC8& aType,
+//									TInt aStatusRef ) = 0;
+//   
+	Adapter()->UpdateLeafObjectL( *iURI, *luid, data, mimePtr, 3);
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("UpdateLeafDataL: UpdateLeafObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("UpdateLeafDataL UpdateLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	
+	CleanupStack::PopAndDestroy(); // mime
+	CleanupStack::PopAndDestroy(); // luid
+	CleanupStack::PopAndDestroy(); // data
+	CleanupStack::PopAndDestroy(); // nodename
+	iLog->Log( _L("UpdateLeafDataL Test Complete with status %d" ), ret );	
+
+    return ret;
+	}	
+			
+TInt Cdmatest::FetchLeafL( CStifItemParser& aItem )	
+	{
+
+    TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Camtest"), _L("FetchLeafL") );
+
+	iResultsFunction = NULL;
+	
+    TInt i( 0 );
+    TPtrC8 nodename ( GetNextStringLC( aItem, _L( "nodename" ) )->Des() ) ;
+    
+    //TPtrC datafile;
+    TPtrC datafile( KNullDesC );
+    i = aItem.GetNextString ( datafile ) ;
+    if ( i != KErrNone ) 
+	    {
+	    iLog->Log(_L("FetchLeafL: ERROR Reading outfile argument: 0x%X"), i );
+	    //return i;
+	    }
+	else
+		{
+		iSaveFileName = datafile;
+		iLog->Log( _L( " Save file nameis '%S'" ), &iSaveFileName );
+		iResultsFunction = SaveDataL;
+		}
+    
+	SetURIL(nodename) ;
+		
+		/*
+			void FetchLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID,
+								   const TDesC8& aType, TInt aResultsRef,
+								   TInt aStatusRef );
+		*/
+
+	HBufC8 *luid = GetLuidAllocLC( *iURI );
+	Adapter()->FetchLeafObjectL( *iURI, *luid, KEmptyType, 7, 8 ) ;
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("FetchLeafL: FetchLeafObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("FetchLeafL: FetchLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy( luid );
+	CleanupStack::PopAndDestroy(  ); // nodename
+	iLog->Log( _L("FetchLeafL Test Complete with status %d" ), ret );	
+    return ret;
+	}	
+
+
+TInt Cdmatest::ExecuteLeafL( CStifItemParser& aItem )		
+	{
+	TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Camtest"), _L("ExecuteLeafL") );
+
+	iResultsFunction = NULL;
+	
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Nodename") )->Des() ) ;
+    TPtrC8 datafile( GetNextStringLC ( aItem, _L("Input file") )->Des() ) ;
+	
+	SetURIL(nodename) ;
+
+		/*
+			virtual void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID,
+							      const TDesC8& aArgument, const TDesC8& aType,
+								  TInt aStatusRef ) = 0;
+		*/
+	TDataType type;
+	TPtrC8 data( LoadFileLC( datafile, type )->Des() );
+	
+    TPtrC8 parentURI(RemoveLastSeg(nodename));
+    HBufC8 *luid = GetLuidAllocLC( parentURI );
+
+	Adapter()->ExecuteCommandL( *iURI, data, data, KEmptyType, 11 ) ;
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("ExecuteLeafL: ExecuteCommandL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("ExecuteLeafL: ExecuteCommandL FetchLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy( luid ); // luid
+	CleanupStack::PopAndDestroy(); // data
+	CleanupStack::PopAndDestroy(); // datafile
+	CleanupStack::PopAndDestroy(); // nodename
+	
+	iLog->Log( _L("ExecuteLeafL: Test Complete with status %d" ), ret );	
+
+    return ret;
+	}
+	
+TInt Cdmatest::CompleteCommandsL( CStifItemParser& /*aItem*/ )
+	{
+	TRAPD( err, Adapter()->CompleteOutstandingCmdsL() );
+	delete iAdapter;
+	iAdapter = NULL;
+	return err;
+	}
+TInt Cdmatest::DeleteObjectL( CStifItemParser& aItem )
+{
+	TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Camtest"), _L("DeleteObjectL") );
+
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Nodename") )->Des() ) ;
+
+	SetURIL(nodename) ;
+
+	HBufC8 *luid = GetLuidAllocLC( *iURI );
+	Adapter()->DeleteObjectL( *iURI, *luid, 11 ) ;
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("DeleteObjectL: DeleteObjectL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("DeleteObjectL: DeleteObjectL FetchLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy( luid ); // luid
+	CleanupStack::PopAndDestroy(); // nodename	
+	iLog->Log( _L("DeleteObjectL Test Complete with status %d" ), ret );	
+
+    return ret;	
+}
+	
+TInt Cdmatest::ExecuteLeafDataL( CStifItemParser& aItem )		
+	{
+	TInt ret( KErrNone );
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("Camtest"), _L("ExecuteLeafL") );
+
+	iResultsFunction = NULL;
+	
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Nodename") )->Des() ) ;
+    TPtrC8 data( GetNextStringLC ( aItem, _L("Input data") )->Des() ) ;
+    
+	SetURIL(nodename) ;
+
+		/*
+			virtual void ExecuteCommandL( const TDesC8& aURI, const TDesC8& aLUID,
+							      const TDesC8& aArgument, const TDesC8& aType,
+								  TInt aStatusRef ) = 0;
+		*/
+
+    TPtrC8 parentURI(RemoveLastSeg(nodename));
+    HBufC8 *luid = GetLuidAllocLC( parentURI );
+    
+	//Adapter()->ExecuteCommandL( *iURI, *luid, data, KEmptyType, 11 ) ;
+	Adapter()->ExecuteCommandL( *iURI, data, data, KEmptyType, 11 ) ;
+	if ( iStatus == MSmlDmAdapter::EOk )
+		{
+		iLog->Log( _L("ExecuteLeafDataL: ExecuteCommandL Successful! %d" ), iStatus );	
+		}
+	else
+		{
+		iLog->Log( _L("ExecuteLeafDataL: ExecuteCommandL FetchLeafObjectL Error ! %d" ), iStatus );	
+		ret = KErrGeneral ;
+		}
+	CleanupStack::PopAndDestroy(); // luid
+	CleanupStack::PopAndDestroy(); // data		
+	CleanupStack::PopAndDestroy(); // nodename	
+	iLog->Log( _L("ExecuteLeafDataL Test Complete with status %d" ), ret );	
+
+    return ret;
+	}
+	
+	
+	//Newly added
+TInt Cdmatest::AddLeafNode( CStifItemParser& aItem )			
+{
+	return KErrNone;
+}
+	
+TInt Cdmatest::InstallActivate( CStifItemParser& aItem )			
+{
+	return KErrNone;	
+}	
+	
+	//Newly ended
+
+
+HBufC8 *Cdmatest::LoadFileLC( const TDesC &aFileName, TDataType &aType )	
+	{
+	RFs fs ;
+	LEAVE_IF_ERROR( fs.Connect(), _L( "Could not connect fileserver: %d"  ) );
+	
+	CleanupClosePushL( fs );
+	RFile file ;
+	LEAVE_IF_ERROR( file.Open(fs,aFileName,EFileRead), _L( "Could not open file: %d" ) );
+	
+	
+	
+	CleanupClosePushL( file );
+	TInt dataSize ;
+	LEAVE_IF_ERROR( file.Size( dataSize ), _L( "Could not get file size: %d" ) );
+	HBufC8 *nodedata = HBufC8::NewL ( dataSize );
+	CleanupStack::PushL( nodedata );
+	TPtr8 nodedataptr( nodedata->Des() );
+	LEAVE_IF_ERROR( file.Read( nodedataptr ), _L( "Could not read file: %d" ) );
+	TDataRecognitionResult aDataType;
+	RApaLsSession ls ;
+	TInt err( ls.Connect() );
+	if ( err == KErrNone )
+		{
+		CleanupClosePushL( ls );
+		err = ls.RecognizeData(aFileName, nodedataptr, aDataType)  ;
+		if ( err == KErrNone )
+			{
+			aType = aDataType.iDataType;
+			}
+		else
+			{
+			iLog->Log( _L("LoadFileLC: WARNING Failed to get type: %d" ), err );
+			aType = TDataType( KDefaultType );
+			}	
+		CleanupStack::PopAndDestroy( &ls ); 
+		}
+	else
+		{
+		iLog->Log( _L("LoadFileLC: WARNING Failed to connect rapalssession: %d" ), err );
+		}	
+	CleanupStack::Pop( nodedata );
+	CleanupStack::PopAndDestroy( &file ); 
+	CleanupStack::PopAndDestroy( &fs ); 
+	CleanupStack::PushL( nodedata );
+	return nodedata ;
+	}
+
+HBufC8 *Cdmatest::LoadFileLC( const TDesC8 &aFileName, TDataType &aType )	
+	{
+	TFileName fn ;
+	fn.Copy( aFileName );
+	return LoadFileLC( fn, aType );
+	}
+	
+
+void Cdmatest::SaveDataL( TInt /*aResultsRef*/, CBufBase& aObject,
+							  const TDesC8& aType ) 
+	{
+	iLog->Log( _L8( "Saving data of type: '%S'" ), &aType );
+	RFs fs;
+	User::LeaveIfError( fs.Connect() );
+	CleanupClosePushL( fs );
+	RFile file;
+	User::LeaveIfError( file.Replace ( fs, iSaveFileName, EFileWrite ) );
+	CleanupClosePushL( file );
+	TPtrC8 p( aObject.Ptr( 0 ) );
+	User::LeaveIfError( file.Write( p ) );
+	CleanupStack::PopAndDestroy( 2 ); // file, fs
+	}
+							  
+		
+	
+void Cdmatest::FetchNodeResultsL( TInt /*aResultsRef*/, CBufBase& aObject,
+							  const TDesC8& /*aType*/ )
+	{
+	TPtrC8 ptr( aObject.Ptr( 0 ) );	
+	iLog->Log( _L8("FetchNodeResultsL for '%S': '%S'" ), iURI, &ptr );
+	
+	if ( ptr.Length() > 0 )
+		{
+		TPtrC8 last( LastURISeg( ptr ) );
+		HBufC8 *oldUri = HBufC8::NewL( iURI->Length() );
+		(*oldUri) = *iURI; 
+		do 
+			{
+			iLog->Log ( _L8( " Node: '%S' "), &last );
+			HBufC8 *nUri = HBufC8::NewLC( oldUri->Length() + 1 + last.Length() );
+			nUri->Des().Copy( *oldUri ) ;
+			nUri->Des().Append( '/' );
+			nUri->Des().Append( last );
+			
+			SetURIL( nUri );
+					
+//		    TPtrC8 parentURI(RemoveLastSeg(*nUri));
+//		    HBufC8 *luid = GetLuidAllocLC( parentURI );
+			HBufC8 *luid = GetLuidAllocLC( *iURI );
+			
+			if(*luid != KNullDesC8)
+			{
+			Adapter()->ChildURIListL( *nUri, *luid, *iEmptyMappingInfoArray, 4, 5 );	
+			}
+			else
+			{
+			Adapter()->FetchLeafObjectL( *nUri, KNullDesC8, KEmptyType, 7, 8 ) ;	
+			}
+			//Adapter()->ChildURIListL( *nUri, KNullDesC8, *iEmptyMappingInfoArray, 4, 5 );
+			
+			
+
+			CleanupStack::PopAndDestroy( luid ); 
+			CleanupStack::Pop( nUri );			
+			
+			ptr.Set( RemoveLastURISeg( ptr ) );
+			last.Set( LastURISeg( ptr ) );
+			
+			}
+		while (last != KNullDesC8);	
+		}
+	
+	}
+	
+
+	
+TPtrC8 Cdmatest::LastURISeg( const TDesC8& aURI )
+	{
+	TInt i;
+	for( i = aURI.Length() - 1; i >= 0; i-- ) 
+		{
+		if( aURI[i] == '/' )
+			{
+			break;
+			}
+		}
+
+	if( i == 0 )
+		{
+		return aURI;
+		}
+	else
+		{
+		return aURI.Mid( i+1 );
+		}
+	}
+TPtrC8 Cdmatest::RemoveLastSeg(const TDesC8& aURI)
+	{
+	TInt i;
+	for(i=aURI.Length()-1;i>=0;i--)
+		{
+		if(aURI[i]==KNSmlDMUriSeparator)
+			{
+			break;
+			}
+		}
+
+	if(i>0)
+		{
+		return aURI.Left(i);
+		}
+	else
+		{
+		return KNullDesC8();
+		}
+	}
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 Cdmatest::RemoveLastURISeg(const TDesC8& aURI)
+// returns parent uri, i.e. removes last uri segment
+// ------------------------------------------------------------------------------------------------
+TPtrC8 Cdmatest::RemoveLastURISeg( const TDesC8& aURI )
+	{
+	TInt i;
+	for ( i = aURI.Length() - 1; i >= 0 ; i-- )
+		{
+		if( aURI[i] == '/' )
+			{
+			break;
+			}
+		}
+	if ( i > -1 )
+		{
+		return aURI.Left( i );	
+		}
+	else
+		{
+		return KNullDesC8();
+		}
+	}	
+	
+TPtrC Cdmatest::RemoveLastURISeg( const TDesC& aURI )
+	{
+	TInt i;
+	for ( i = aURI.Length() - 1; i >= 0 ; i-- )
+		{
+		if( aURI[i] == '/' )
+			{
+			break;
+			}
+		}
+	if ( i > -1 )
+		{
+		return aURI.Left( i );	
+		}
+	else
+
+		{
+		return KNullDesC();
+		}
+	}		
+	
+void Cdmatest::SetURIL( const TDesC& aURI )
+	{
+	if ( iURI != NULL )
+		{
+		delete iURI ;
+		iURI = NULL;
+		}
+	iURI = HBufC8::NewL( aURI.Length() ) ;
+	iURI->Des().Copy( aURI );
+	}
+	
+void Cdmatest::SetURIL( const TDesC8& aURI )
+	{
+	if ( iURI != NULL )
+		{
+		delete iURI ;
+		iURI = NULL;
+		}
+	iURI = HBufC8::NewL( aURI.Length() ) ;
+	iURI->Des().Copy( aURI );
+	}	
+
+void Cdmatest::SetURIL( HBufC8* aURI )
+	{
+	if ( iURI != NULL )
+		{
+		delete iURI ;
+		iURI = NULL;
+		}
+	iURI = aURI ;
+	}
+		
+		
+		
+void Cdmatest::SetResultsL( 
+	TInt aResultsRef, 
+	CBufBase& aObject,
+	const TDesC8& aType )
+	{
+	TPtrC8 ptr( aObject.Ptr(0) );
+	iLog->Log( _L8( "SetResults, ref=%d, object='%S', type='%S'" ), aResultsRef, &ptr, &aType );
+	if ( iResultsFunction )
+		{
+		(this->*iResultsFunction)( aResultsRef, aObject, aType );
+		iResultsFunction = NULL ;
+		}
+	
+	}
+
+
+void Cdmatest::SetStatusL( TInt aStatusRef,
+							 MSmlDmAdapter::TError aErrorCode ) 
+	{
+	iStatus = aErrorCode ;
+	iLog->Log( _L( "SetStatusL, ref=%d, code=%d" ), aStatusRef, aErrorCode );
+	
+	
+	}
+	
+void Cdmatest::SetMappingL( const TDesC8& aURI, const TDesC8& aLUID ) 
+	{
+	iLog->Log( _L8( "SetMappingL, aURI='%s', aLUID='%s'" ), aURI.Ptr(), aLUID.Ptr() );	
+	
+	iMappingTable.Append(TMapping( aURI, aLUID ) )	;
+	}
+	
+HBufC8* Cdmatest::GetLuidAllocL( const TDesC8& aURI ) 
+	{
+	iLog->Log( _L8( "GetLuidAllocL, aURI='%S'" ), &aURI );		
+	HBufC8 *res = NULL;		
+	for( TInt i(0); i < iMappingTable.Count(); i++ )	
+		{
+		if ( aURI == iMappingTable[i].iURI )
+			{
+			res = iMappingTable[i].iLuid.AllocL();
+			}
+		}
+	if ( res == NULL )
+		{
+		res = HBufC8::NewL( 0 );
+		}
+	iLog->Log( _L8( "GetLuidAllocL, response='%S'" ), res );
+	return res;
+	}	    
+    
+HBufC8* Cdmatest::GetLuidAllocLC( const TDesC8& aURI ) 
+	{
+	iLog->Log( _L8( "GetLuidAllocL, aURI='%S'" ), &aURI );
+	HBufC8 *res = NULL;		
+	for( TInt i(0); i < iMappingTable.Count(); i++ )	
+		{
+		if ( aURI == iMappingTable[i].iURI )
+			{
+			res = iMappingTable[i].iLuid.AllocLC();
+			break;
+			}
+		}
+	if ( res == NULL )
+		{
+		res = HBufC8::NewLC( 0 );
+		}
+	iLog->Log( _L8( "GetLuidAllocLC, response='%S'" ), res );
+	return res ;
+	}	
+    	
+#ifdef __TARM_SYMBIAN_CONVERGENCY
+    
+void Cdmatest::GetMappingInfoListL( const TDesC8& /*aURI*/,
+								CArrayFix<TSmlDmMappingInfo>& /*aSegmentList*/ )
+	{
+	// do nothing
+	}								
+
+#else
+// nothing
+#endif
+
+TInt Cdmatest::FetchLeafObjectSizeL( CStifItemParser& aItem )
+	{
+		TInt ret( KErrNone );
+	    // Print to UI
+	    TestModuleIf().Printf( 0, _L("Camtest"), _L("ExecuteLeafL") );
+
+		iResultsFunction = NULL;
+		
+	    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Nodename") )->Des() ) ;
+	    
+	    //TPtrC datafile;
+	    TInt i( 0 );
+	    TPtrC datafile( KNullDesC );
+	    i = aItem.GetNextString ( datafile ) ;
+	    if ( i != KErrNone ) 
+		    {
+		    iLog->Log(_L("FetchLeafL: ERROR Reading outfile argument: 0x%X"), i );
+		    //return i;
+		    }
+		else
+			{
+			iSaveFileName = datafile;
+			iLog->Log( _L( " Save file name is '%S'" ), &iSaveFileName );
+			iResultsFunction = SaveDataL;
+			}	    
+		SetURIL(nodename) ;
+
+//		HBufC8 *luid = GetLuidAllocLC( *iURI );
+	    TPtrC8 parentURI(RemoveLastSeg(nodename));
+	    HBufC8 *luid = GetLuidAllocLC( parentURI );
+
+		CleanupStack::PushL( luid );
+
+//		void FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aType, TInt aResultsRef, TInt aStatusRef );
+		iAdapter->FetchLeafObjectSizeL( *iURI, *luid, KEmptyType, 7, 8 );
+		if ( iStatus == MSmlDmAdapter::EOk )
+			{
+			iLog->Log( _L("FetchLeafObjectSizeL: FetchLeafObjectSizeL Successful! %d" ), iStatus );	
+			}
+		else
+			{
+			iLog->Log( _L("FetchLeafObjectSizeL: FetchLeafObjectSizeL Error ! %d" ), iStatus );	
+			ret = KErrGeneral ;
+			}
+
+
+
+		// Cleanup
+		CleanupStack::PopAndDestroy();
+		CleanupStack::Pop( luid );
+		CleanupStack::PopAndDestroy();//nodename
+//		CleanupStack::PopAndDestroy();//nodename
+		
+		
+			iLog->Log( _L("FetchLeafObjectSizeL Test Complete with status %d" ), ret );	
+		return ret;
+	}
+
+/*TInt Cdmatest::BareAppInstallL( CStifItemParser& aItem )
+    {
+    
+    // Print to UI
+    TestModuleIf().Printf( 0, _L("amtest"), _L("In InstallL") );
+    // Print to log file
+    iLog->Log(_L("In DetailsL"));
+
+    TInt aluidi( 0 );
+    TUint32 aLuidInt;
+    aluidi = aItem.GetNextInt ( (TInt&)aLuidInt ) ;
+	
+	
+    TPtrC8 nodename( GetNextStringLC ( aItem, _L("Node name") )->Des() ) ;
+    
+	
+    SetURIL( nodename );
+    
+    HBufC8 *luid = GetLuidAllocLC( *iURI );
+    MSmlDmAdapter::TError ret( MSmlDmAdapter::EError );
+	
+	TRAPD( err, Adapter()->InstallL(aluidi,*iURI, *luid,3 ,ret));
+
+    return err;
+
+    }*/
+
+
+//  End of File
--- a/clientprovisioning/cpqtsp/cpqtsp.pro	Tue Jul 13 03:51:25 2010 +0530
+++ b/clientprovisioning/cpqtsp/cpqtsp.pro	Tue Jul 13 04:01:20 2010 +0530
@@ -34,7 +34,7 @@
 INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
 include(Cpqtsp.pri)
 LIBS+=-lxqservice -lxqserviceutil -lflogger
-MMP_RULES += "LIBRARY msgs.lib centralrepository.lib provisioningengine.lib featmgr.lib apengine.lib favouritesengine.lib smcm.lib gsmu.lib"
+MMP_RULES += "LIBRARY msgs.lib centralrepository.lib provisioningengine.lib featmgr.lib smcm.lib gsmu.lib"
 
 TRANSLATIONS += deviceupdates.ts
 
--- a/clientprovisioning/cpqtsp/inc/CWPSaver.h	Tue Jul 13 03:51:25 2010 +0530
+++ b/clientprovisioning/cpqtsp/inc/CWPSaver.h	Tue Jul 13 04:01:20 2010 +0530
@@ -3,7 +3,7 @@
 *  Name        : CWPSaver.h
 *  Part of     : Provisioning / ProvisioningBC
 *  Description : Settings saver with progress note.
-*  Version     : %version: 1 % << Don't touch! Updated by Synergy at check-out.
+*  Version     : %version: 2 % << Don't touch! Updated by Synergy at check-out.
 *
 *  Copyright © 2002-2006 Nokia.  All rights reserved.
 *  This material, including documentation and any related computer
@@ -20,15 +20,12 @@
 #define CWPSAVER_H
 
 // INCLUDES
-#include <aknprogressdialog.h>
-#include <activeapdb.h>
-#include <favouritesdbobserver.h>
-#include <FavouritesDb.h>
+
 #include <HbProgressDialog>
 
 // FORWARD DECLARATIONS
 class CWPEngine;
-class CActiveFavouritesDbNotifier;
+//class CActiveFavouritesDbNotifier;
 
 // CLASS DECLARATION
 
@@ -36,10 +33,8 @@
  * Helper class for saving Provisioning settings. Provides a progress note.
  * @since 2.0
  */
-class CWPSaver : public CActive, 
-                 private MProgressDialogCallback,
-                 private MActiveApDbObserver, 
-                 private MFavouritesDbObserver
+class CWPSaver : public CActive
+                 
     {
     public:
         /**
@@ -75,40 +70,13 @@
         void RunL();
         TInt RunError( TInt aError );
 
-    private: // From MProgressDialogCallback
-
-        void DialogDismissedL( TInt aButtonId );
-
-    private: // from MActiveApDbObserver
-
-        void HandleApDbEventL( TEvent anEvent );
-
-    private: // from MFavouritesDbObserver
-
-        void HandleFavouritesDbEventL( RDbNotifier::TEvent aEvent );
-
     private:
         /**
         * Complete the request so that RunL() gets called.
         */
         void CompleteRequest();
-
-        /**
-        * Complete the request so that Timeout() gets called after
-        * a delay. Leaves with KErrTimeout if retry count is 
-        * exceeded.
-        */
-        void DelayedCompleteRequestL();
-
-        /**
-        * Retry save now.
-        */
         void Retry();
 
-        /**
-        * Timer timed-out.
-        */
-        static TInt Timeout(TAny* aSelf);
 
     private:
         /// The engine used for performing the save. Refs.
@@ -123,18 +91,6 @@
         /// Contains result to be passed to the called of ExecuteLD
         TInt iResult;
 
-        /// Active AP database. Owns.
-        CActiveApDb* iApDbNotifier;
-
-        /// Active Favourites Database. Owns.
-        CActiveFavouritesDbNotifier* iFavouritesNotifier;
-
-        /// Contains ETrue if commsdb is being waited on
-        TBool iWaitCommsDb;
-
-        /// Contains ETrue if favourites db is being waited on
-        TBool iWaitFavourites;
-
         /// Active scheduler.
         CActiveSchedulerWait iWait;
 
@@ -144,8 +100,6 @@
         /// Retry counter
         TInt iRetryCount;
         
-        RFavouritesDb       iBookmarkDb;
-        RFavouritesSession  iSession;        
         HbProgressDialog *iProgress;
         TBufC<200> iValue;
     };
--- a/clientprovisioning/cpqtsp/src/CWPSaver.cpp	Tue Jul 13 03:51:25 2010 +0530
+++ b/clientprovisioning/cpqtsp/src/CWPSaver.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -3,7 +3,7 @@
 *  Name        : CWPSaver.cpp
 *  Part of     : Provisioning / ProvisioningBC
 *  Description : Helper class for saving Provisioning settings. Provides a progress note.
-*  Version     : %version: 1 % << Don't touch! Updated by Synergy at check-out.
+*  Version     : %version: 2 % << Don't touch! Updated by Synergy at check-out.
 *
 *  Copyright © 2002-2006 Nokia.  All rights reserved.
 *  This material, including documentation and any related computer
@@ -17,13 +17,10 @@
 */
 
 // INCLUDE FILES
-#include <aknquerydialog.h>
-#include <eikprogi.h>
-//#include <ProvisioningBC.rsg>
 #include <commdb.h>
 #include <CWPEngine.h>
 #include <CWPAdapter.h>
-#include <ActiveFavouritesDbNotifier.h>
+
 #include "CWPSaver.h"
 #include <HbProgressDialog>
 #include <HbAction>
@@ -56,24 +53,9 @@
     {
     // Assume ownership of this.
     CleanupStack::PushL( this );
-
-    iApDbNotifier = CActiveApDb::NewL( EDatabaseTypeIAP );
-    iApDbNotifier->AddObserverL( this );
-    
-    User::LeaveIfError( iSession.Connect() );
-    User::LeaveIfError( iBookmarkDb.Open( iSession, KBrowserBookmarks ) );
-    iFavouritesNotifier = 
-                new(ELeave) CActiveFavouritesDbNotifier( iBookmarkDb, *this );  
-
-    iFavouritesNotifier->Start();
-
-    iRetryTimer = CPeriodic::NewL( EPriorityStandard );
     iProgress = new HbProgressDialog(HbProgressDialog::WaitDialog);
     iProgress->setText(hbTrId("txt_device_update_setlabel_saving_settings"));
-    //iProgress->setTextAlignment(Qt::AlignCenter);
     iProgress->clearActions();   
-    //iProgress->setPrimaryAction(new HbAction(""));
-    //iProgress->setSecondaryAction(new HbAction(""));
     iProgress->show();
 
  }
@@ -107,19 +89,7 @@
 CWPSaver::~CWPSaver()
     {
     Cancel();
-
-    delete iApDbNotifier;
-
-    if( iFavouritesNotifier )
-        {
-        iFavouritesNotifier->Cancel();
-        delete iFavouritesNotifier;
-        }
-
-    iBookmarkDb.Close();
-    iSession.Close();
-    delete iRetryTimer;
-    }
+  }
 
 // ----------------------------------------------------------------------------
 // CWPSaver::DoCancel
@@ -149,20 +119,7 @@
         {
         TRAP(err, QT_TRYCATCH_LEAVING( iEngine.SaveL( iCurrentItem ) )); 
         }
-    // If CommsDB or BookmarkDB are locked, schedule a retry
-    if( err == EWPCommsDBLocked || err == KErrLocked)
-        {
-        iWaitCommsDb = ETrue;
-        DelayedCompleteRequestL();
-        return;
-        }
-    else if( err == EWPBookmarksLocked )
-        {
-        iWaitFavourites = ETrue;
-        DelayedCompleteRequestL();
-        return;
-        }
-    else if( err != KErrNone )
+    if( err != KErrNone )
         {
         // For all other errors, pass them through.
         iValue = iEngine.SummaryText(iCurrentItem);
@@ -205,20 +162,6 @@
     }
 
 // ----------------------------------------------------------------------------
-// CWPSaver::DialogDismissedL
-// ----------------------------------------------------------------------------
-//
-void CWPSaver::DialogDismissedL( TInt aButtonId )
-    {
-    if( aButtonId < 0 )
-        {
-        iResult = KErrCancel;
-        }
-
-    iWait.AsyncStop();
-    }
-
-// ----------------------------------------------------------------------------
 // CWPSaver::CompleteRequest
 // ----------------------------------------------------------------------------
 //
@@ -227,86 +170,10 @@
     // Schedule an immediate complete. Make sure that there
     // is no timer alive first
     Cancel();
-    iRetryTimer->Cancel();
+    //iRetryTimer->Cancel();
 
     SetActive();
     TRequestStatus* sp = &iStatus;
     User::RequestComplete( sp, KErrNone );
     }
 
-// ----------------------------------------------------------------------------
-// CWPSaver::DelayedCompleteRequestL
-// ----------------------------------------------------------------------------
-//
-void CWPSaver::DelayedCompleteRequestL()
-    {
-    if( iRetryCount < KRetryCount )
-        {
-        // Schedule a delayed complete. Cancel first in case
-        // an immediate request was scheduled.
-        iRetryTimer->Cancel();
-        iRetryTimer->Start( KMaxWaitTime, KMaxTInt32, TCallBack( Timeout, this ) );
-        iRetryCount++;
-        }
-    else
-        {
-        User::Leave( KErrTimedOut );
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CWPSaver::Retry
-// ----------------------------------------------------------------------------
-//
-void CWPSaver::Retry()
-    {
-    // Immediate retry. Mark that we're not waiting
-    // for an event and complete request.
-    iWaitCommsDb = EFalse;
-    iWaitFavourites = EFalse;
-    CompleteRequest();
-    }
-
-// ----------------------------------------------------------------------------
-// CWPSaver::Timeout
-// ----------------------------------------------------------------------------
-//
-TInt CWPSaver::Timeout(TAny* aSelf)
-    {
-    // There was a time-out. Retry saving even though we
-    // didn't get a notify from database.
-    CWPSaver* self = static_cast<CWPSaver*>( aSelf );
-    self->Retry();
-
-    return KErrNone;
-    }
-
-// ----------------------------------------------------------------------------
-// CWPSaver::HandleApDbEventL
-// ----------------------------------------------------------------------------
-//
-void CWPSaver::HandleApDbEventL( TEvent aEvent )
-    {
-    // We received an event from CommsDB. Retry if we're
-    // waiting for it.
-    if( iWaitCommsDb && aEvent == EDbAvailable )
-        {
-        Retry();
-        }
-    }
-
-// ----------------------------------------------------------------------------
-// CWPSaver::HandleFavouritesDbEventL
-// ----------------------------------------------------------------------------
-//
-void CWPSaver::HandleFavouritesDbEventL( RDbNotifier::TEvent /*aEvent*/ )
-    {
-    // We received an event from BookmarkDB. Retry if we're
-    // waiting for it.
-    if( iWaitFavourites )
-        {
-        Retry();
-        }
-    }
-
-//  End of File
--- a/devicecontrol.pro	Tue Jul 13 03:51:25 2010 +0530
+++ b/devicecontrol.pro	Tue Jul 13 04:01:20 2010 +0530
@@ -16,8 +16,10 @@
 TEMPLATE = subdirs
 
 SUBDIRS  += devicemgmtdialogsplugin \
+            devicemgmtindicatorsplugin \
             deviceupdatesui \
-	    			clientprovisioning
+	    			clientprovisioning \
+				applicationmanagement
 
 CONFIG += ordered
 
--- a/devicemgmtdialogsplugin/devicemanagementnotifierdevman.qrc	Tue Jul 13 03:51:25 2010 +0530
+++ b/devicemgmtdialogsplugin/devicemanagementnotifierdevman.qrc	Tue Jul 13 04:01:20 2010 +0530
@@ -4,6 +4,11 @@
         <file>resources/dialoginformative.docml</file>
         <file>resources/dialogserverpushconfirm.docml</file>
         <file>resources/pin.docml</file>
+    	<file>resources/fotainformativedialog.docml</file>
+    	<file>resources/fotasoftkeydialog.docml</file>
+    	<file>resources/fotasoftkeysdialog.docml</file>
+    	<file>resources/fotaresumeupdate.docml</file>
+	<file>resources/error_notes.docml</file>
     </qresource>
     <qresource prefix="/devman_icon" >
     	<file>resources/iconnotifier.svg</file>
--- a/devicemgmtdialogsplugin/devicemgmtdialogsplugin.pro	Tue Jul 13 03:51:25 2010 +0530
+++ b/devicemgmtdialogsplugin/devicemgmtdialogsplugin.pro	Tue Jul 13 04:01:20 2010 +0530
@@ -33,12 +33,15 @@
 SOURCES += src/syncmlnotifierprivate.cpp
 SOURCES += src/omacppinquerydialog.cpp
 SOURCES += src/syncmlconnectnotifier.cpp
+SOURCES += src/fotadevicedialogs.cpp
 
 HEADERS += inc/devicemanagementnotifierplugin_p.h
 HEADERS += inc/devicemanagementnotifierwidget_p.h
 HEADERS += inc/devicemanagementnotifierutils.h 
 HEADERS += inc/syncmlnotifierprivate.h
 HEADERS += inc/omacppinquerydialog.h
+HEADERS += inc/fotadevicedialogs.h
+
 RESOURCES = devicemanagementnotifierdevman.qrc
 #TRANSLATIONS += deviceupdates_en.ts
 
--- a/devicemgmtdialogsplugin/inc/devicemanagementnotifierutils.h	Tue Jul 13 03:51:25 2010 +0530
+++ b/devicemgmtdialogsplugin/inc/devicemanagementnotifierutils.h	Tue Jul 13 04:01:20 2010 +0530
@@ -60,24 +60,26 @@
 virtual ~syncmlnotifier();
 public:
      void launchDialog(const QVariantMap &parameters);
-     void createserverinitnotifier(int profileid, int uimode,QString& servername);
+     void createserverinitnotifier(int& profileid, int& uimode,QString& servername,
+             bool& defaultprofile, int& timeout);
      void createserveralertinformative(const QString &string);
      void createserveralertconfirmative(const QString &string);
-
+     void createscomonotifier(QString notifiertype, QString name=NULL,QString size=NULL, QString format=NULL);
 public slots:
     void okSelected();
     void cancelSelected(); 
     void infoNoteOkSelected();
     void conirmNoteOkSelected();
     void conirmNoteCancelSelected();
-      
+    void noteTimedOut(HbAction* action);  
 
 signals:
     void servertextmessage(const QString &string);
  
 private:
   syncmlnotifierprivate* msymnotifier;
- devicemanagementnotifierwidget* iPtr;
+  devicemanagementnotifierwidget* iPtr;
+  bool mDefaultServerPkgZero;
 
 };
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtdialogsplugin/inc/fotadevicedialogs.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef FOTADEVICEDIALOGS_H_
+#define FOTADEVICEDIALOGS_H_
+
+#include <devicedialogconsts.h>
+
+#include <hbdevicedialoginterface.h>    // HbDeviceDialogInterface
+#include <hbdialog.h>
+#include <hblabel.h>
+#include <hbpushbutton.h>
+#include "syncmlnotifierprivate.h"
+#include "devicemanagementnotifierwidget_p.h"
+
+
+class fotadevicedialogs:public HbDialog, public HbDeviceDialogInterface {
+//class fotadevicedialogs:public devicemanagementnotifierwidget {
+
+Q_OBJECT
+
+public:
+/**
+  * Construction and setting of observer happens here
+  *
+  * @since   S60   SF4
+  * @param   aType - tell sthe type of the dialog to be shown
+  * @param   aObserver is the parent class which owns the notifier and information is
+  * passed to the parent class from the device dialog.
+  */
+
+fotadevicedialogs(const QVariantMap &parameters);
+
+private:
+    /**
+      * Function to call the appropriate device dialog based on the dialog ID.
+      *
+      * @since   S60   SF4
+      * @param   aType - tell sthe type of the dialog to be shown
+      * @param   parameters - contains the dialogID + information to be shown in the dialogs
+      */
+
+     void launchFotaDialog(const QVariantMap &parameters);
+     
+     /**
+       * Function to show the informative dialog of FOTA
+       *
+       * @since   S60   SF4
+       * @param   aType - tell sthe type of the dialog to be shown
+       * @param   parameters - contains the dialogID + information to be shown in the dialogs
+       */
+
+     void createfotainformativedialog(TFwUpdNoteTypes aType,const QVariantMap &parameters);
+     
+     /**
+        * Function to show the error message dialog of FOTA
+        *
+        * @since   S60   SF4
+        * @param   aType - tell sthe type of the dialog to be shown
+        * @param   parameters - contains the dialogID + information to be shown in the dialogs
+        */
+
+     void createfotamessagedialog(TFwUpdNoteTypes aType,const QVariantMap &parameters);
+     
+     /**
+         * Function to show the confirmative dialog of FOTA
+         *
+         * @since   S60   SF4
+         * @param   aType - tell sthe type of the dialog to be shown
+         * @param   parameters - contains the dialogID + information to be shown in the dialogs
+         */
+     void createfotaconfirmationdialog(TFwUpdNoteTypes aType,const QVariantMap &parameters);
+
+public slots:
+
+/**
+  * Construction and setting of observer happens here
+  *
+  * @since   S60   SF4
+  * @param   aObserver is the parent class which owns the notifier and information is
+  * passed to the parent class from the device dialog.
+  */
+
+    void fotaLSK();
+    /**
+      * Construction and setting of observer happens here
+      *
+      * @since   S60   SF4
+      * @param   aObserver is the parent class which owns the notifier and information is
+      * passed to the parent class from the device dialog.
+      */
+
+    void fotaRSK();
+    
+
+public: //derived from HbDeviceDialogInterface
+    /**
+      * Ccalled when device dialog is closed.
+      *
+      * @since   S60   SF4
+      * @param   byClient - The Name of the client which closed the dialog.
+      */
+
+	void closeDeviceDialog(bool byClient);
+    
+    bool setDeviceDialogParameters(const QVariantMap &parameters);
+    int deviceDialogError() const;
+//    void closeDeviceDialog(bool byClient);
+    HbDialog *deviceDialogWidget() const;
+
+signals:
+        void deviceDialogClosed();
+        void deviceDialogData(QVariantMap data);
+
+
+signals:
+/**
+  * servertextmessage
+  *
+  * @since   S60   SF4
+  * @param   aObserver is the parent class which owns the notifier and information is
+  * passed to the parent class from the device dialog.
+  */
+
+    void servertextmessage(const QString &string);
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtdialogsplugin/resources/error_notes.docml	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.0">
+    <object name="qtl_dialog_softkey_2_left" type="HbAction">
+        <string name="role" value="HbDialog:primaryAction"/>
+        <string name="role" value="HbDialog:primaryAction"/>
+        <string name="text" value="OK"/>
+    </object>
+    <object name="qtl_dialog_softkey_2_right" type="HbAction">
+        <string name="role" value="HbDialog:secondaryAction"/>
+        <string name="role" value="HbDialog:secondaryAction"/>
+        <string name="text" value="Cancel"/>
+    </object>
+    <widget name="dialog" type="HbDialog">
+        <widget name="heading_text" role="HbDialog:headingWidget" type="HbLabel">
+            <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+            <string name="plainText" value="Popup title"/>
+            <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+        </widget>
+        <widget name="qtl_dialog_pri5_large_graphic" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="icon" type="HbLabel">
+                <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
+                <icon iconName="note_warning" name="icon"/>
+                <sizepolicy horizontalPolicy="Fixed" horizontalStretch="0" verticalPolicy="Fixed" verticalStretch="0"/>
+                <sizehint height="var(hb-param-graphic-size-primary-large)" type="FIXED" width="var(hb-param-graphic-size-primary-large)"/>
+                <bool name="visible" value="TRUE"/>
+            </widget>
+            <widget name="content_text" type="HbLabel">
+                <enums name="textWrapping" value="TextWordWrap"/>
+                <bool name="visible" value="TRUE"/>
+                <string name="plainText" value="Lorem ipsum sed dolor sit amet. Consectetur adipiscing. Proin auctor ante dolorr sit amet. Consectetur adipiscing."/>
+                <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+            </widget>
+            <real name="z" value="0"/>
+            <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
+            <layout orientation="Horizontal" spacing="var(hb-param-margin-gene-popup)" type="linear">
+                <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+                <linearitem itemname="icon"/>
+                <linearitem itemname="content_text"/>
+            </layout>
+        </widget>
+        <sizehint height="42.08955un" type="PREFERRED" width="50.5un"/>
+        <ref object="qtl_dialog_softkey_2_left" role="HbDialog:primaryAction"/>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD portrait" unit="un">
+        <resource location="TemplateIcons.qrc"/>
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtdialogsplugin/resources/fotainformativedialog.docml	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+    <object name="qtl_dialog_softkey_2_left" type="HbAction">
+        <string name="role" value="HbDialog:primaryAction"/>
+        <string name="text" value="OK"/>
+    </object>
+    <object name="qtl_dialog_softkey_2_right" type="HbAction">
+        <string name="role" value="HbDialog:secondaryAction"/>
+        <string name="text" value="Cancel"/>
+    </object>
+    <widget name="dialog" type="HbDialog">
+        <sizehint height="42.38806un" type="PREFERRED" width="50.5un"/>
+        <widget name="lblHeading" role="HbDialog:headingWidget" type="HbLabel">
+            <enums name="alignment" value="AlignLeft|AlignLeading"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+            <string name="plainText" value="Device Updates"/>
+            <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+        </widget>
+        <widget name="container" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="lblContent" type="HbLabel">
+                <enums name="textWrapping" value="TextWordWrap"/>
+                <real name="z" value="2"/>
+                <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+                <bool name="visible" value="TRUE"/>
+                <string name="plainText" value="The phone was not updated.The update package was compactible with the phone.Please contact your service provider."/>
+                <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+            </widget>
+            <real name="z" value="0"/>
+            <layout spacing="0un" type="grid">
+                <contentsmargins bottom="var(hb-param-margin-view-bottom)" left="var(hb-param-margin-view-left)" right="var(hb-param-margin-view-right)" top="var(hb-param-margin-view-top)"/>
+                <griditem column="0" itemname="lblContent" row="0"/>
+            </layout>
+        </widget>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtdialogsplugin/resources/fotaresumeupdate.docml	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+    <object name="btnContinue" type="HbAction">
+        <string name="text" value="Continue"/>
+    </object>
+    <object name="btnResumeLater" type="HbAction">
+        <string name="text" value="Resume Later"/>
+    </object>
+    <widget name="dialog" type="HbDialog">
+        <sizehint height="49.73un" type="PREFERRED" width="49.73un"/>
+        <contentsmargins bottom="var(hb-param-margin-view-bottom)" left="var(hb-param-margin-view-left)" right="var(hb-param-margin-view-right)" top="var(hb-param-margin-view-top)"/>
+        <widget name="lblHeading" role="HbDialog:headingWidget" type="HbLabel">
+            <enums name="alignment" value="AlignLeft|AlignLeading"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+            <string name="plainText" value="Device Update"/>
+            <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+        </widget>
+        <widget name="listView" role="HbDialog:contentWidget" type="HbScrollArea">
+            <widget name="scrollAreaContents" role="HbScrollArea:contents" type="HbWidget">
+                <widget name="label" type="HbLabel">
+                    <string name="plainText" value="The Last update &lt;Name&gt; &lt;Version&gt; and &lt;Size&gt; was not completed. You can install it now."/>
+                    <enums name="textWrapping" value="TextWrapAnywhere"/>
+                </widget>
+                <widget name="label_1" type="HbLabel">
+                    <string name="plainText" value="During the download phone cannot be used even for emergency"/>
+                    <enums name="textWrapping" value="TextWrapAnywhere"/>
+                </widget>
+                <widget name="label_2" type="HbLabel">
+                    <string name="plainText" value="After the installation phone will restart."/>
+                    <enums name="textWrapping" value="TextWrapAnywhere"/>
+                </widget>
+                <widget name="label_3" type="HbLabel">
+                    <string name="plainText" value="It is recommended to connect the charger."/>
+                    <enums name="textWrapping" value="TextWrapAnywhere"/>
+                </widget>
+                <sizehint height="49.43284un" type="PREFERRED" width="49.55224un"/>
+                <layout type="grid">
+                    <griditem column="0" itemname="label" row="0"/>
+                    <griditem column="0" itemname="label_1" row="3"/>
+                    <griditem column="0" itemname="label_2" row="2"/>
+                    <griditem column="0" itemname="label_3" row="1"/>
+                </layout>
+            </widget>
+            <real name="z" value="1"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-popup-list)" left="var(hb-param-margin-gene-popup-list)" right="var(hb-param-margin-gene-popup-list)" top="var(hb-param-margin-gene-popup-list)"/>
+            <enums name="scrollDirections" value="Horizontal|Vertical"/>
+        </widget>
+        <ref object="btnContinue" role="HbWidget:addAction"/>
+        <ref object="btnResumeLater" role="HbWidget:addAction"/>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtdialogsplugin/resources/fotasoftkeydialog.docml	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+    <object name="lblOK" type="HbAction">
+        <string name="role" value="HbDialog:primaryAction"/>
+        <string name="text" value="OK"/>
+    </object>
+    <object name="qtl_dialog_softkey_2_right" type="HbAction">
+        <string name="role" value="HbDialog:secondaryAction"/>
+        <string name="text" value="Cancel"/>
+    </object>
+    <widget name="dialog" type="HbDialog">
+        <sizehint height="42.38806un" type="PREFERRED" width="50.5un"/>
+        <widget name="lblHeaind" role="HbDialog:headingWidget" type="HbLabel">
+            <enums name="alignment" value="AlignLeft|AlignLeading"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+            <string name="plainText" value="Device Updates"/>
+            <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+        </widget>
+        <widget name="container" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="lblContent" type="HbLabel">
+                <enums name="textWrapping" value="TextWordWrap"/>
+                <real name="z" value="2"/>
+                <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+                <bool name="visible" value="TRUE"/>
+                <string name="plainText" value="%N KB free memory needed for update. Delete some data now or update later."/>
+                <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+            </widget>
+            <real name="z" value="0"/>
+            <layout spacing="0un" type="grid">
+                <contentsmargins bottom="var(hb-param-margin-view-bottom)" left="var(hb-param-margin-view-left)" right="var(hb-param-margin-view-right)" top="var(hb-param-margin-view-top)"/>
+                <griditem column="0" itemname="lblContent" row="0"/>
+            </layout>
+        </widget>
+        <ref object="lblOK" role="HbWidget:addAction"/>
+    </widget>
+    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+    </metadata>
+</hbdocument>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtdialogsplugin/resources/fotasoftkeysdialog.docml	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hbdocument version="1.1">
+    <object name="btnContinue" type="HbAction">
+        <string name="role" value="HbDialog:primaryAction"/>
+        <string name="text" value="Continue"/>
+    </object>
+    <object name="btnResume" type="HbAction">
+        <string name="role" value="HbDialog:secondaryAction"/>
+        <string name="text" value="Resume Later"/>
+    </object>
+    <widget name="dialog" type="HbDialog">
+        <sizehint height="42.38806un" type="PREFERRED" width="50.5un"/>
+        <widget name="lblDialogHeading" role="HbDialog:headingWidget" type="HbLabel">
+            <enums name="alignment" value="AlignLeft|AlignLeading"/>
+            <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+            <string name="plainText" value="Device Updates"/>
+            <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+        </widget>
+        <widget name="container" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="lblDialogContent" type="HbLabel">
+                <enums name="textWrapping" value="TextWordWrap"/>
+                <real name="z" value="2"/>
+                <contentsmargins bottom="var(hb-param-margin-gene-popup)" left="var(hb-param-margin-gene-popup)" right="var(hb-param-margin-gene-popup)" top="var(hb-param-margin-gene-popup)"/>
+                <bool name="visible" value="TRUE"/>
+                <string name="plainText" value="The last Update &lt;Name&gt; &lt;Version&gt; and &lt;size&gt; was not completed. You can download it now."/>
+                <fontspec name="fontSpec" role="Primary" textheight="var(hb-param-text-height-primary)"/>
+            </widget>
+            <real name="z" value="0"/>
+            <layout spacing="0un" type="grid">
+                <contentsmargins bottom="var(hb-param-margin-view-bottom)" left="var(hb-param-margin-view-left)" right="var(hb-param-margin-view-right)" top="var(hb-param-margin-view-top)"/>
+                <griditem column="0" itemname="lblDialogContent" row="0"/>
+            </layout>
+        </widget>
+        <ref object="btnContinue" role="HbWidget:addAction"/>
+        <ref object="btnResume" role="HbWidget:addAction"/>
+    </widget>
+    <metadata activeUIState="Type name here" display="NHD-3.2-inch_portrait" unit="un">
+        <uistate name="Common ui state" sections="#common"/>
+        <uistate name="Type name here" sections="#common"/>
+    </metadata>
+</hbdocument>
--- a/devicemgmtdialogsplugin/src/devicemanagementnotifierplugin.cpp	Tue Jul 13 03:51:25 2010 +0530
+++ b/devicemgmtdialogsplugin/src/devicemanagementnotifierplugin.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -22,6 +22,7 @@
 #include "devicemanagementnotifierplugin_p.h"
 #include "devicemanagementnotifierwidget_p.h"
 #include "omacppinquerydialog.h"
+#include "fotadevicedialogs.h"
 
 
 Q_EXPORT_PLUGIN2(devicemanagementnotifiersplugin, devicemanagementnotifierplugin)
@@ -88,6 +89,12 @@
             // Return specific object for showing appropriate dialog
             return new omacppinquerydialog(parameters);
             }
+           
+        if (dialogtype >= EFwDLNeedMoreMemory && dialogtype <= EFwUpdResumeUpdate)
+            {
+            // Return specific object for showing appropriate dialog
+            return new fotadevicedialogs(parameters);
+            }
 
         }
     return new devicemanagementnotifierwidget(parameters);
--- a/devicemgmtdialogsplugin/src/devicemanagementnotifierutils.cpp	Tue Jul 13 03:51:25 2010 +0530
+++ b/devicemgmtdialogsplugin/src/devicemanagementnotifierutils.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -82,6 +82,7 @@
 syncmlnotifier::syncmlnotifier(devicemanagementnotifierwidget* ptr)
     {
     iPtr = ptr;
+    mDefaultServerPkgZero = false;
     qDebug("devicemanagementnotifierutils syncmlnotifier");
     QTranslator *translator = new QTranslator();
     QString lang = QLocale::system().name();
@@ -111,15 +112,21 @@
     bool uiserverinteraction = false;
     bool serverpushinformativeenabled = false;
     bool serverpushinteractiveenabled = false;
-
+    bool scomonotifierenabled = false;
+    
     int profileid = 0;
     int uimode = 0;
 
     QString serverpushinformmessage;
     QString serverpushconfirmmessage;
-
+    QString appname = NULL;
+    QString size = NULL;
+    QString sizeformat = NULL;
+    QString data = NULL;
     QString serverdispname;
-
+    bool defaultprofile = false;
+	QString scomonotifiertype;
+    int timeout = 0;
     while (i != parameters.constEnd())
         {
         if (i.key().toAscii() == "profileid")
@@ -153,7 +160,35 @@
             {
             serverdispname = i.value().toString();
             }
-
+        
+        if (i.key().toAscii() == "fotadefaultprofile")
+            {
+            defaultprofile = i.value().toBool();
+            }
+        
+        if (i.key().toAscii()== "scomonotifier")
+            {
+            scomonotifierenabled = true;
+            scomonotifiertype = i.value().toString();
+            }
+        if (i.key().toAscii()=="scomoappdata")
+            {
+            //getting data for download failed cases
+            data = i.value().toString();
+            QStringList list1 = data.split(",");
+            appname = list1[0];
+            size =list1[1];
+            sizeformat = list1[2];
+            }
+        if(i.key().toAscii()=="scomoappname")
+            {
+            //getting app name for install and uninstall failed cases
+            appname = i.value().toString();
+            }
+        if (i.key().toAscii() == "pkgzerotimeout")
+            {
+            timeout = i.value().toInt();
+            }
         ++i;
         }
 
@@ -162,7 +197,8 @@
         qDebug("server interaction packet 0 enabled ");
         qDebug()<<EHbSOSNotifierKeyStatus;
         msymnotifier->setnotifierorigin(EHbSOSNotifierKeyStatus);
-        createserverinitnotifier(profileid, uimode, serverdispname);
+        createserverinitnotifier(profileid, uimode, serverdispname,
+                defaultprofile, timeout);
         }
     else if (serverpushinformativeenabled)
         {
@@ -178,11 +214,90 @@
          msymnotifier->setnotifierorigin(EHbDMSyncNotifierKeyStatus);
         createserveralertconfirmative(serverpushconfirmmessage);
         }
+    else if (scomonotifierenabled)
+        {
+        createscomonotifier(scomonotifiertype,appname,size,sizeformat);
+        }
 
     }
 
-void syncmlnotifier::createserverinitnotifier(int profileid, int uimode,
-        QString& servername)
+void syncmlnotifier::createscomonotifier(QString notifiertype,QString app_name,QString asize,QString format)
+    {
+    HbDocumentLoader loader;
+    bool ok = false;
+    loader.load(":/xml/resources/error_notes.docml", &ok);
+    if (!ok)
+        {
+        return;
+        }
+    QString val;
+    HbDialog* dialog = qobject_cast<HbDialog*> (loader.findWidget("dialog"));
+    HbLabel* label;
+
+    dialog->setTimeout(HbPopup::ContextMenuTimeout);
+
+    if (notifiertype == "installfailed")
+        {
+        //install failed case
+        label = qobject_cast<HbLabel*> (loader.findWidget("heading_text"));
+        val = hbTrId("txt_device_update_title_installation_failed");
+        label->setPlainText(val);
+        val = hbTrId("txt_device_update_info_installation_of_1_kb_failed").arg(
+                app_name);
+        label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
+        label->setPlainText(val);
+        }
+    else if (notifiertype == "downloadfailed")
+        {
+        //download failed
+        label = qobject_cast<HbLabel*> (loader.findWidget("heading_text"));
+        val = hbTrId("txt_device_update_title_downloading_failed");
+
+        label->setPlainText(val);
+        int sizfor = -1;
+        format == QString("kb") ? sizfor = 0 : sizfor = 1;
+        format == QString("mb") ? sizfor = 1 : sizfor = 2;
+        switch (sizfor)
+            {
+            case 0:
+                val
+                        = hbTrId(
+                                "txt_device_update_info_downloading_of_1_Kb_failed").arg(
+                                app_name, asize);
+                break;
+            case 1:
+                val
+                        = hbTrId(
+                                "txt_device_update_info_downloading_of_1_Mb_failed").arg(
+                                app_name, asize);
+                break;
+            default:
+                val
+                        = hbTrId(
+                                "txt_device_update_info_downloading_of_1_Gb_failed").arg(
+                                app_name, asize);
+                break;
+            }
+        label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
+        label->setPlainText(val);
+        }
+    else
+        {
+        //uninstall failed
+        label = qobject_cast<HbLabel*> (loader.findWidget("heading_text"));
+        val = hbTrId("txt_device_update_title_Uninstallation_failed");
+        label->setPlainText(val);
+        val = hbTrId("txt_device_update_info_uninstalling_of_1_Mb_failed").arg(
+                app_name, asize);
+
+        label = qobject_cast<HbLabel*> (loader.findWidget("content_text"));
+        label->setPlainText(val);
+        }
+    dialog->setTimeout(HbPopup::StandardTimeout);
+    dialog->show();
+    }
+void syncmlnotifier::createserverinitnotifier(int& profileid, int& uimode,
+        QString& servername, bool& defaultprofile, int& timeout)
     {
     
     int inittype = msymnotifier->serverinittype(uimode);
@@ -209,29 +324,48 @@
         //set heading content
         HbLabel *contentheading = qobject_cast<HbLabel *> (loader.findWidget(
                 "qtl_dialog_pri_heading"));
-        QString heading = hbTrId("txt_device_update_title_update_available");
-        contentheading->setPlainText(heading);
-
+        QString heading;        
         //set body content
         HbLabel *contentbody = qobject_cast<HbLabel *> (loader.findWidget(
                 "qtl_dialog_pri5"));
-        QString serverinitmessage = hbTrId(
-                "txt_device_update_info_recommended_update_is_avail").arg(
-                servername);
+        QString serverinitmessage;
+        QString softkeyok;
+        QString softkeyCancel;
+        if(defaultprofile)
+            {
+            mDefaultServerPkgZero = true;	
+            heading = hbTrId("txt_device_update_title_update_available");
+            serverinitmessage = 
+              hbTrId("txt_device_update_info_recommended_update_is_avail").arg(
+                            servername);
+            softkeyok = hbTrId("txt_device_update_button_update");
+            softkeyCancel = hbTrId("txt_device_update_button_later");                 
+            }
+        else
+            {
+            mDefaultServerPkgZero = false;	
+            heading = hbTrId("txt_device_update_title_service_recomended");
+            serverinitmessage = 
+              hbTrId("txt_device_update_info_1_recommends_a_service_for").arg(
+                            servername);
+            softkeyok = hbTrId("txt_common_button_ok");
+            softkeyCancel = hbTrId("txt_common_button_cancel");                            
+            }
+        contentheading->setPlainText(heading);
         contentbody->setPlainText(serverinitmessage);
 
         //set softkeys
         HbAction *primaryAction = (HbAction *) dialog->actions().first();
-        QString softkeyok = hbTrId("txt_common_button_ok");
+        
         primaryAction->setText(softkeyok);
 
         HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
-        QString softkeyCancel = hbTrId("txt_common_button_cancel");
+        
         secondaryAction->setText(softkeyCancel);
 
         //set dialog properties
-        dialog->setTimeout(HbPopup::NoTimeout);
-
+        dialog->setTimeout(timeout);
+        dialog->setDismissPolicy(HbPopup::NoDismiss);
         //load appropriate icon from svg file
         HbLabel* label1 = qobject_cast<HbLabel*> (loader.findWidget("icon"));
         HbIcon* icon1 = new HbIcon(":/devman_icon/resources/iconnotifier.svg");
@@ -240,6 +374,8 @@
         //label1->setState(QIcon::Off);
         label1->setToolTip("Mode=Normal, State=Off");
 
+        QObject::connect(dialog, SIGNAL(finished(HbAction*)), 
+                this, SLOT(noteTimedOut(HbAction*)));
         QObject::connect(primaryAction, SIGNAL(triggered()), this,
                 SLOT(okSelected()));
 
@@ -268,7 +404,7 @@
                 "qtl_dialog_pri5"));
 
         QString serverinitmessage = hbTrId(
-                "txt_device_update_info_update_serverpush_informative").arg(
+                "txt_deviceupdate_info_updating_device_from_server").arg(
                 servername);
 
         //getserverspecifictexttodisplay(profileid, uimode, serverinitmessage);
@@ -397,6 +533,22 @@
     
     }
 
+void syncmlnotifier::noteTimedOut(HbAction* action)
+    {
+    qDebug("Pkg zero note timed out");
+    if (action == NULL)
+        {
+        int timeout = -33; //KErrTimedOut
+        msymnotifier->setstatus(timeout);
+        if(mDefaultServerPkgZero) //For default server action is RSK
+        iPtr->dmDevdialogDismissed(
+                devicemanagementnotifierwidget::EServerAlertNote, -3);
+        else //For Non default server action is LSK
+        iPtr->dmDevdialogDismissed(
+                devicemanagementnotifierwidget::EServerAlertNote, 0);	        	
+        }
+    }
+
 syncmlnotifier::~syncmlnotifier()
     {
     qDebug("syncmlnotifier::~syncmlnotifier");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtdialogsplugin/src/fotadevicedialogs.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,492 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#include "devicemanagementnotifierutils.h"
+#include <hbdocumentloader.h>
+#include <hbdialog.h>
+#include <hblabel.h>
+#include <hbmessagebox.h>
+#include <HbAction.h>
+#include <e32Property.h>
+#include "syncmlnotifierparams.h"
+#include "fotadevicedialogs.h"
+#include "PnpUtilLogger.h"
+#include <QDebug.h>
+#include <HbListView.h>
+#include <hbpushbutton.h>
+#include <e32math.h>
+#include <QStandardItemModel>
+
+
+// ---------------------------------------------------------------------------
+// fotadevicedialogs::fotadevicedialogs
+// Constructor for fota related device dialogs 
+// ---------------------------------------------------------------------------
+//
+
+fotadevicedialogs::fotadevicedialogs(const QVariantMap &parameters)
+//:	devicemanagementnotifierwidget(parameters)
+    {
+    qDebug("devicemanagementnotifierutils fotadevicedialogs");
+    QTranslator *translator = new QTranslator();
+    QString lang = QLocale::system().name();
+    QString path = "Z:/resource/qt/translations/";
+    bool fine = translator->load("deviceupdates_" + lang, path);
+    if (fine)
+        qApp->installTranslator(translator); 
+    
+    QTranslator *commontranslator = new QTranslator();
+    fine = commontranslator->load("common_" + lang, path);/*finally required once localisation available*/
+    if(fine)
+        qApp->installTranslator(commontranslator);
+    else
+        qDebug("device dialog common translator loading failed");
+
+    
+    launchFotaDialog(parameters);
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// fotadevicedialogs::launchFotaDialog
+// This function lauches is called to lauch the specific dialog based on the
+// dialogID passed to it.
+// ---------------------------------------------------------------------------
+//
+void fotadevicedialogs::launchFotaDialog(const QVariantMap &parameters)
+    {
+
+    QVariantMap::const_iterator i = parameters.constBegin();
+    qDebug("devicemanagementnotifierutils fotadevicedialogs launchDialog");    
+    TFwUpdNoteTypes aType = EFwUpdDeviceBusy;
+    
+    //QString temp = QString::fromUtf8(reinterpret_cast<const char*>(url.Ptr()), url.Length());
+    //TDesC8 * tempStr = KKeyDialog;
+    //const QString temp = QString::fromUtf8(reinterpret_cast<const char*>(tempStr.Ptr()), tempStr.Length());
+    i = parameters.find(keydialog);
+    if(i != parameters.end())
+        aType = (TFwUpdNoteTypes)i.value().toInt();
+    
+    
+    if(aType == EFwUpdRebootNote)
+    	{
+    		createfotainformativedialog(aType,parameters);
+    	}
+    	else if(aType == EFwUpdResumeDownload || aType == EFwUpdResumeUpdate)
+        {
+        createfotaconfirmationdialog(aType,parameters);
+        //createfotainformativedialog();
+        }
+    else if(aType == EFwDLNeedMoreMemory || aType == EFwDLConnectionFailure || aType == EFwDLGeneralFailure || 
+    	 aType == EFwUpdNotEnoughBattery || aType == EFwUpdDeviceBusy || aType == EFwUpdSuccess || aType == EFwUpdNotCompatible
+    || aType == EFwDLNonResumableFailure)
+        {
+        //createfotamessagedialog();
+        createfotamessagedialog(aType,parameters);
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// fotadevicedialogs::createfotainformativedialog
+// This function is called to show the informative dialog of FOTA
+// ---------------------------------------------------------------------------
+//
+void fotadevicedialogs::createfotainformativedialog(TFwUpdNoteTypes aType,const QVariantMap &parameters)
+    {
+    qDebug("createserveralertinformative start");
+		LOGSTRING("createserveralertinformative start");
+    HbDocumentLoader loader;
+    bool ok = false;
+    loader.load(":/xml/resources/fotainformativedialog.docml", &ok);
+    if (!ok)
+        {
+        return;
+        }
+    HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
+
+    HbLabel *content = qobject_cast<HbLabel *> (loader.findWidget(
+            "lblContent"));
+
+    // No translations required
+    //content->setPlainText("Testing");
+
+    dialog->setTimeout(3000);
+
+    if (dialog)
+        dialog->show();
+
+    QObject::connect(dialog, SIGNAL(aboutToClose()), this, SLOT(okSelected()));
+
+	qDebug("createserveralertinformative end");
+
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// fotadevicedialogs::createfotaconfirmationdialog
+// This function is called to show the confirmation dialog of FOTA.
+// ---------------------------------------------------------------------------
+//
+void fotadevicedialogs::createfotaconfirmationdialog(TFwUpdNoteTypes aType,const QVariantMap &parameters)
+    {
+    qDebug("createserveralertinformative start");
+        LOGSTRING("createserveralertinformative start");
+        
+    QVariantMap::const_iterator i;
+    HbDocumentLoader loader;
+    bool ok = false;
+    HbDialog *dialog = NULL;
+    
+    QString param1;
+    QString param2;
+    TInt size = 0;
+    TBool postpone = 0;
+
+    i = parameters.find(keyparam1);
+    if(i != parameters.end())
+        size = i.value().toInt();
+
+    i = parameters.find(keyparam2);
+    if(i != parameters.end())
+        param1 = i.value().toString();
+    i = parameters.find(keyparam3);
+    if(i != parameters.end())
+        param2 = i.value().toString();
+    i = parameters.find(keyparam4);
+    if(i != parameters.end())
+        postpone = i.value().toBool();
+
+    
+    switch(aType)
+        {
+        case EFwUpdResumeDownload:
+            {          
+            loader.load(":/xml/resources/fotasoftkeysdialog.docml", &ok);
+            if (!ok)
+            {
+            return;
+            }
+            dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
+            
+            HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
+                                "lblDialogHeading"));
+            
+            headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
+            
+            HbLabel *contentString = qobject_cast<HbLabel *> (loader.findWidget(
+                                "lblDialogContent"));
+            
+            TReal sizeRounded = 0;
+            TReal sizeKB = size / 1024;
+            if(sizeKB > 1024)
+                {
+                TReal sizeMB = sizeKB / 1024;
+                Math::Round(sizeRounded,sizeMB,2);
+                QString str = hbTrId("txt_device_update_info_the_last_updte_incomp_dwnld_Mb")
+                        //.arg(param1).arg(param2).arg(sizeMB);
+                        .arg(param2).arg(param1).arg(sizeRounded);
+                contentString->setPlainText(str);//HACK
+                }
+            else
+                {
+                Math::Round(sizeRounded,sizeKB,2);
+                contentString->setPlainText(hbTrId("txt_device_update_info_the_last_update_incomplete_dwnld_kb")
+                        .arg(param1).arg(param2).arg(sizeRounded));
+                }
+            //HbAction *primaryAction = dialog->primaryAction();
+            HbAction *primaryAction = (HbAction *) dialog->actions().first();
+            primaryAction->setText(hbTrId("txt_common_button_continue_dialog"));
+
+            //HbAction *secondaryAction = dialog->secondaryAction();
+            HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
+            secondaryAction->setText(hbTrId("txt_device_update_button_resume_later"));
+            if(!postpone)
+                secondaryAction->setEnabled(postpone);
+
+            dialog->setTimeout(HbPopup::NoTimeout);
+            dialog->setDismissPolicy(HbPopup::NoDismiss);
+
+            QObject::connect(primaryAction, SIGNAL(triggered()), this,
+                    SLOT(fotaLSK()));
+
+            QObject::connect(secondaryAction, SIGNAL(triggered()), this,
+                    SLOT(fotaRSK()));
+            break;
+            }
+        case EFwUpdResumeUpdate:
+            {
+            bool ok = false;
+                loader.load(":/xml/resources/fotaresumeupdate.docml", &ok);
+                if (!ok)
+                    {
+                    return;
+                    }
+                
+                dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
+                
+                dialog->setTimeout(HbPopup::NoTimeout);
+                dialog->setDismissPolicy(HbPopup::NoDismiss);
+                
+                HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
+                        "lblHeading"));
+                headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
+                            
+                
+                //HbAction *primaryAction = dialog->primaryAction();
+                HbAction *primaryAction = (HbAction *) dialog->actions().first();
+                primaryAction->setText(hbTrId("txt_common_button_continue_dialog"));
+                
+                //HbAction *secondaryAction = dialog->secondaryAction();
+                HbAction *secondaryAction = (HbAction *) dialog->actions().at(1);
+                secondaryAction->setText(hbTrId("txt_device_update_button_resume_later"));
+                if(!postpone)
+                    secondaryAction->setEnabled(postpone);
+                
+                HbLabel *contentSwDetails = qobject_cast<HbLabel *> (loader.findWidget(
+                                                "label"));
+                TReal sizeRounded = 0;
+                TReal sizeKB = size / 1024;
+                
+                QString content;
+                if(sizeKB > 1024)
+                    {
+                    TReal sizeMB = sizeKB / 1024;
+                    Math::Round(sizeRounded,sizeMB,2);
+                    contentSwDetails->setPlainText(hbTrId("txt_device_update_info_the_last_update_incomp_instal_Mb")
+                            .arg(param1).arg(param2).arg(sizeRounded));
+                    }
+                else
+                    {
+                    Math::Round(sizeRounded,sizeKB,2);
+                    contentSwDetails->setPlainText(hbTrId("txt_device_update_info_the_last_update_incomp_instal_kb")
+                            .arg(param1).arg(param2).arg(sizeRounded));
+                    }
+                
+                HbLabel *contentCharger = qobject_cast<HbLabel *> (loader.findWidget(
+                                                                "label_3"));
+                contentCharger->setPlainText(hbTrId("txt_device_update_info_it_is_recommended_to_connec"));
+                
+                HbLabel *contentInstall = qobject_cast<HbLabel *> (loader.findWidget(
+                                                                "label_2"));
+                contentInstall->setPlainText(hbTrId("txt_device_update_info_after_the_installation_the"));
+                
+                HbLabel *contentEmergency = qobject_cast<HbLabel *> (loader.findWidget(
+                                                                "label_1"));
+                contentEmergency->setPlainText(hbTrId("txt_device_update_info_during_the_installation_the"));
+
+                dialog->setTimeout(HbPopup::NoTimeout);
+
+                QObject::connect(primaryAction, SIGNAL(triggered()), this,
+                        SLOT(fotaLSK()));
+
+                QObject::connect(secondaryAction, SIGNAL(triggered()), this,
+                        SLOT(fotaRSK()));
+            }
+            break;
+        default:
+            {
+            break;
+            }
+        }
+
+    if (dialog)
+        dialog->show();
+
+    qDebug("createserveralertinformative end");
+
+    }
+
+
+// ---------------------------------------------------------------------------
+// fotadevicedialogs::createfotamessagedialog
+// This function is called to show the message dialog of FOTA
+// ---------------------------------------------------------------------------
+//
+void fotadevicedialogs::createfotamessagedialog(TFwUpdNoteTypes aType,const QVariantMap &parameters)
+    {
+    QVariantMap::const_iterator i;
+    qDebug("createserveralertinformative start");
+        LOGSTRING("createserveralertinformative start");
+    HbDocumentLoader loader;
+    bool ok = false;
+    loader.load(":/xml/resources/fotasoftkeydialog.docml", &ok);
+    if (!ok)
+        {
+        return;
+        }
+    HbDialog *dialog = qobject_cast<HbDialog *> (loader.findWidget("dialog"));
+    
+    HbLabel *headingString = qobject_cast<HbLabel *> (loader.findWidget(
+            "lblHeaind"));
+    headingString->setPlainText(hbTrId("txt_device_update_title_device_update"));
+    
+    HbLabel *contentString = qobject_cast<HbLabel *> (loader.findWidget(
+            "lblContent"));
+            
+    dialog->setTimeout(HbPopup::NoTimeout);
+    dialog->setDismissPolicy(HbPopup::NoDismiss);
+    
+    //HbAction *primaryAction = dialog->primaryAction();
+    HbAction *primaryAction = (HbAction *) dialog->actions().first();
+    primaryAction->setText(hbTrId("txt_common_button_ok_single_dialog"));
+
+    QObject::connect(primaryAction, SIGNAL(triggered()), this,
+                SLOT(fotaLSK()));
+                
+                
+    switch(aType)
+        {
+        	case EFwDLNeedMoreMemory:
+            {
+            QString content;
+            TInt aMemNeeded = 0;
+            i = parameters.find(keyparam1);
+            if(i != parameters.end())
+                aMemNeeded = i.value().toInt();
+            TInt aMemNeededKB = aMemNeeded / 1024;
+            if(aMemNeededKB <= 1024)
+                {
+                content = hbTrId("txt_de_info_l1_kb_free_memory_needed_for_update").arg(aMemNeededKB);
+                }
+            else
+                {
+                TInt aMemNeededMB = aMemNeededKB / 1024;
+                content = hbTrId("txt_de_info_l1_Mb_free_memory_needed_for_update").arg(aMemNeededMB);
+                }
+            contentString->setPlainText(content);
+            break;
+            }
+        case EFwDLConnectionFailure:
+            {
+            contentString->setPlainText(hbTrId("txt_device_update_info_connection_lost_while_do"));
+            break;
+            }
+        case EFwDLGeneralFailure:
+            {
+            contentString->setPlainText(hbTrId("txt_device_update_info_an_error_occurred_during_do"));
+            break;
+            }
+        case EFwDLNonResumableFailure:
+            {
+            contentString->setPlainText(hbTrId("txt_device_update_info_an_error_occurred_update_stop"));
+            break;
+            }
+        case EFwUpdDeviceBusy:
+            {
+            contentString->setPlainText(hbTrId("txt_device_update_info_FS_warning_device_memory_is_b"));
+            break;
+            }
+       case EFwUpdSuccess:
+           {
+           headingString->setPlainText(hbTrId("txt_device_update_title_phone_uptodate"));
+           contentString->setPlainText(hbTrId("txt_device_update_info_your_phone_is_now_updated_w"));
+           break;
+           }
+       case EFwUpdNotCompatible:
+           {           
+           contentString->setPlainText(hbTrId("txt_device_update_info_the_phone_was_not_updated"));
+           break;
+           }
+       case EFwUpdNotEnoughBattery:
+           {
+           contentString->setPlainText(hbTrId("txt_device_update_info_you_will_be_notified_once_t"));
+           break;
+           }
+       default:
+           {
+           break;
+           }
+        }
+
+    if (dialog)
+        dialog->show();
+
+    qDebug("createserveralertinformative end");
+
+    }
+
+
+// ---------------------------------------------------------------------------
+// fotadevicedialogs::fotaLSK
+// This slot is called when LSK is pressed in device dialog.
+// ---------------------------------------------------------------------------
+//
+void fotadevicedialogs::fotaLSK()
+    {
+    qDebug("ok selected");
+    QVariantMap resultMap;
+    resultMap.insert(returnkey, EHbLSK);
+    emit deviceDialogData(resultMap);
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// CFotaDownloadNotifHandler::aboutToClose
+// This slot is called when RSK is pressed in device dialog.
+// ---------------------------------------------------------------------------
+//
+void fotadevicedialogs::fotaRSK()
+    {
+    qDebug("cancel selected");
+    QVariantMap resultMap;
+    resultMap.insert(returnkey, EHbRSK);
+    emit deviceDialogData(resultMap);
+    }
+
+
+
+// Set parameters
+bool fotadevicedialogs::setDeviceDialogParameters(
+    const QVariantMap &parameters)
+{
+    
+    return true;
+}
+
+// Get error
+int fotadevicedialogs::deviceDialogError() const
+{
+    
+    return 0;
+}
+
+
+// Close device dialog
+// ---------------------------------------------------------------------------
+// fotadevicedialogs::closeDeviceDialog
+// This slot is called when device dialog is closed due to errors.
+// ---------------------------------------------------------------------------
+//
+
+void fotadevicedialogs::closeDeviceDialog(bool byClient)
+{
+		qDebug("cancel selected");
+    emit deviceDialogClosed();
+}
+
+
+// Return display widget
+HbDialog *fotadevicedialogs::deviceDialogWidget() const
+{
+   
+    return const_cast<fotadevicedialogs*>(this);
+    //return const_cast<devicemanagementnotifierwidget*>(this);
+}
--- a/devicemgmtdialogsplugin/src/syncmlconnectnotifier.cpp	Tue Jul 13 03:51:25 2010 +0530
+++ b/devicemgmtdialogsplugin/src/syncmlconnectnotifier.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -25,15 +25,13 @@
     QTranslator *translator = new QTranslator();
     QString lang = QLocale::system().name();
     QString path = "Z:/resource/qt/translations/";
-    bool fine = translator->load("deviceupdates_en.qm", path);
+    bool fine = translator->load("deviceupdates_" + lang, path);
     if (fine)
         qApp->installTranslator(translator);
-
     QTranslator *commontranslator = new QTranslator();
-
     fine = commontranslator->load("common_" + lang, path);
     if (fine)
-        qApp->installTranslator(commontranslator);   
+        qApp->installTranslator(commontranslator);
     pDialog = NULL;
     }
 
@@ -41,9 +39,10 @@
     {    
     qDebug("devicemanagementnotifierutils syncmlConnectNotifier launchDialog");        
     pDialog = new HbProgressDialog(HbProgressDialog::ProgressDialog);
-       HbAction *action = new HbAction(pDialog->tr("Cancel"), pDialog);
-       pDialog->setText("Connecting");
-       pDialog->actions().at(0)->setText(pDialog->tr("Hide"));
+       HbAction *action = new HbAction(hbTrId("txt_common_button_cancel"),
+       												 pDialog);
+       pDialog->setText(hbTrId("txt_device_update_info_connecting"));
+       pDialog->actions().at(0)->setText(hbTrId("txt_common_button_hide"));
        pDialog->setMaximum(0);
        pDialog->setMinimum(0);    
        pDialog->addAction(action);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/devicemgmtindicatorsplugin.pro	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,44 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+# Contributors:
+# Description:
+TEMPLATE = lib
+TARGET = dmindicatorsplugin
+CONFIG += plugin
+CONFIG += hb
+INCLUDEPATH += .
+DEPENDPATH += .
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+HEADERS += inc/dmpronoteindicators.h \
+    inc/dmindicatorsplugin.h \
+    inc/dmindicator.h
+    
+SOURCES += src/dmpronoteindicators.cpp \
+    src/dmindicatorsplugin.cpp \
+    src/dmindicator.cpp \
+    src/tarmtrustindicator.cpp
+
+
+symbian {
+    TARGET.EPOCALLOWDLLDATA=1
+    TARGET.CAPABILITY = CAP_GENERAL_DLL
+    TARGET.UID3 = 0x20030009
+
+    pluginstub.sources = dmindicatorsplugin.dll
+    pluginstub.path = /resource/plugins/indicators
+    DEPLOYMENT += pluginstub
+    }
+BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>" \
+    "rom/dmindicatorsplugin.iby CORE_APP_LAYER_IBY_EXPORT_PATH(dmindicatorsplugin.iby)" \
+    "resources/message1.svg /epoc32/winscw/c/resource/devicemanagement/message1.svg" \
+    "resources/qtg_small_smiley_kissing.svg /epoc32/winscw/c/resource/devicemanagement/qtg_small_smiley_kissing.svg"
+LIBS += -lxqservice \
+ 		 -lcsserverclientapi \
+ 		 -lapgrfx \
+ 		 -lcone  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/inc/dmindicator.h	Tue Jul 13 04:01:20 2010 +0530
@@ -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: Tarm Trust Indicator class
+ *
+ */
+
+#ifndef DMINDICATOR_H
+#define DMINDICATOR_H
+
+#include <QObject>
+#include <qvariant.h>
+#include <hbindicatorinterface.h>
+
+/**
+ * DM indicator base class. 
+ * Handles client request and showing the indications. 
+ */
+class DMIndicator : public HbIndicatorInterface
+    {
+public:
+    /**
+     * Constructor
+     */
+    DMIndicator(const QString &indicatorType,
+            HbIndicatorInterface::Category category,
+            HbIndicatorInterface::InteractionTypes interactionTypes);
+    /**
+     * Destructor
+     */
+    virtual ~DMIndicator();
+    
+    /**
+     * @see HbIndicatorInterface
+     */
+    //bool handleInteraction(InteractionType type);
+    
+
+    /**
+     * @see HbIndicatorInterface
+     */
+    QVariant indicatorData(int role) const;
+
+protected:
+
+    /**
+     * @see HbIndicatorInterface
+     */
+    bool handleClientRequest(RequestType type, const QVariant &parameter);
+    QVariant mParameter;
+    };
+
+#endif // DMINDICATOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/inc/dmindicatorsplugin.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Device Management Indicator Plugin Class 
+ *
+ */
+
+#ifndef DMINDICATORSPLUGIN_H
+#define DMINDICATORSPLUGIN_H
+
+#include <QObject>
+#include <QStringList>
+#include <QVariant>
+#include <hbindicatorplugininterface.h>
+#include <hbindicatorinterface.h>
+
+/**
+ * Device Management indicator plugin class. 
+ * Main class of DM indicator plugin. 
+ */
+class DMIndicatorsPlugin : public QObject, public HbIndicatorPluginInterface
+    {
+    Q_OBJECT
+    Q_INTERFACES(HbIndicatorPluginInterface)
+
+public:
+    /**
+     * Constructor
+     */
+    DMIndicatorsPlugin();
+
+    /**
+     * Destructor
+     */
+    ~DMIndicatorsPlugin();
+
+    /**
+     * @see HbIndicatorPluginInterface
+     */
+    QStringList indicatorTypes() const;
+
+    /**
+     * @see HbIndicatorPluginInterface
+     */
+    bool accessAllowed(const QString &indicatorType,
+                               const QVariantMap &securityInfo) const;   
+    /**
+     * @see HbIndicatorPluginInterface
+     */
+    HbIndicatorInterface* createIndicator(const QString &indicatorType);
+
+    /**
+     * @see HbIndicatorPluginInterface
+     */
+    int error() const;
+
+private:
+    Q_DISABLE_COPY(DMIndicatorsPlugin)
+
+    /**
+     * Error value
+     */
+    int mError;
+
+    /**
+     * Indicator types 
+     * supported indicator types. 
+     */
+    QStringList mIndicatorTypes;
+    
+	/**
+     * Secure Clients 
+     * Only these clients can activate/deactivate the indicators 
+     */
+    QList<TUid> mSecureClients;
+    };
+
+#endif // DMINDICATORSPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/inc/dmpronoteindicators.h	Tue Jul 13 04:01:20 2010 +0530
@@ -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: DM Progress and Notification Indicators classes
+ *
+ */
+
+#ifndef DMINDICATORS_H
+#define DMINDICATORS_H
+
+#include <QObject>
+#include <dmindicator.h>
+#include <hbindicatorinterface.h>
+
+/**
+ * DM Progress and Notification indicators class. 
+ * Handles client request and showing the indications. 
+ */
+class DMProNoteIndicator : public DMIndicator
+    {
+public:
+    /**
+     * Constructor
+     */
+    DMProNoteIndicator(const QString &indicatorType,
+            HbIndicatorInterface::Category category,
+            HbIndicatorInterface::InteractionTypes interactionTypes);
+
+    /**
+     * @see HbIndicatorInterface
+     */
+    bool handleInteraction(InteractionType type);
+
+    /**
+     * @see HbIndicatorInterface
+     */
+    QVariant indicatorData(int role) const;
+
+    };
+
+/**
+ * Scomo Progress and Notification indicators class. 
+ * Handles client request and showing the indications. 
+ */
+class ScomoProNoteIndicator : public DMProNoteIndicator
+    {
+public:
+    /**
+     * Constructor
+     */
+    ScomoProNoteIndicator(const QString &indicatorType,
+            HbIndicatorInterface::Category category,
+            HbIndicatorInterface::InteractionTypes interactionTypes);
+
+    /**
+     * @see HbIndicatorInterface
+     */
+    bool handleInteraction(InteractionType type);
+
+    };
+
+
+#endif // DMINDICATORS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/inc/tarmtrustindicator.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: Tarm Trust Indicator class
+ *
+ */
+
+#ifndef TARMTRUSTINDICATOR_H
+#define TARMTRUSTINDICATOR_H
+
+#include <QObject>
+#include <dmindicator.h>
+#include <hbindicatorinterface.h>
+
+/**
+ * Tarm Trust indicator class. 
+ * Handles client request and showing the indications. 
+ */
+class TarmTrustIndicator : public DMIndicator
+    {
+public:
+    /**
+     * Constructor
+     */
+    TarmTrustIndicator(const QString &indicatorType,
+            HbIndicatorInterface::Category category,
+            HbIndicatorInterface::InteractionTypes interactionTypes);
+
+    /**
+     * Destructor
+     */
+    ~TarmTrustIndicator();
+
+    /**
+     * @see HbIndicatorInterface
+     */
+    QVariant indicatorData(int role) const;
+
+    };
+
+#endif // TARMTRUSTINDICATOR_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/resources/message1.svg	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" baseProfile="tiny" height="40px" version="1.1" viewBox="0 0 30 40" width="30px" x="0px" y="0px">
+<g>
+<path d="M27.458,17.31l-0.81-0.416l0.81-0.418c0.624-0.317,0.62-1.024,0.405-1.392l-0.881-1.512   c-0.251-0.43-0.877-0.683-1.406-0.336l-0.748,0.484l0.051-0.892c0.025-0.453-0.309-1.056-0.998-1.056h-1.764   c-0.57,0-1.031,0.48-0.998,1.056l0.051,0.892l-0.748-0.484c-0.402-0.263-1.08-0.22-1.406,0.336l-0.879,1.512   c-0.219,0.376-0.126,0.735-0.049,0.916H6C4.346,16,3,17.345,3,19v12c0,1.621,1.293,2.944,2.901,2.997v2.695   c0,1.407,1.723,2.251,2.869,1.029l3.063-3.723h11.165C24.654,33.999,26,32.653,26,31V20.706c0.185,0.031,0.699-0.003,0.982-0.487   l0.881-1.516C28.278,17.989,27.701,17.435,27.458,17.31z" fill-opacity="0.2" stroke-opacity="0.2"/>
+<path d="M27,15.588l-0.882-1.512c0,1.023-6.239,1.58-6.239,0L19,15.588l7.118,4.126L27,18.199l-2.536-1.305   L27,15.588z" fill-opacity="0.5" stroke-opacity="0.5"/>
+<path d="M4,26.718V31c0,1.101,0.9,2,2,2h0.901v3.692c0,0.517,0.646,0.86,1.098,0.394L11.362,33H23c1.1,0,2-0.899,2-2   v-4.282c0-0.004-0.001-0.007-0.001-0.011L4,26.718z" fill-opacity="0.5" stroke-opacity="0.5"/>
+<linearGradient gradientTransform="matrix(1 0 0 1 -1530 0)" gradientUnits="userSpaceOnUse" id="SVGID_1_" x1="1544.5" x2="1544.5" y1="13.4609" y2="38.8497">
+<stop offset="0" style="stop-color:#FFE23D"/>
+<stop offset="0.2239" style="stop-color:#FAD337"/>
+<stop offset="0.6537" style="stop-color:#EFAB26"/>
+<stop offset="1" style="stop-color:#E48717"/>
+</linearGradient>
+<path d="M23,16H6c-1.1,0-2,0.9-2,2v12c0,1.101,0.9,2,2,2h0.901v3.692c0,0.438,0.599,0.907,1.098,0.394   L11.362,32H23c1.1,0,2-0.899,2-2V18C25,16.9,24.1,16,23,16z" fill="url(#SVGID_1_)"/>
+<rect fill="#A55B11" height="1" width="10" x="9.5" y="20.5"/>
+<rect fill="#A55B11" height="1" width="10" x="9.5" y="23.5"/>
+<rect fill="#A55B11" height="1" width="6.25" x="9.5" y="26.5"/>
+<linearGradient gradientUnits="userSpaceOnUse" id="SVGID_2_" x1="14.7773" x2="14.7773" y1="17" y2="32.9845">
+<stop offset="0" style="stop-color:#FFE23D"/>
+<stop offset="0.2239" style="stop-color:#FAD337"/>
+<stop offset="0.6537" style="stop-color:#EFAB26"/>
+<stop offset="1" style="stop-color:#E48717"/>
+</linearGradient>
+<path d="M25,18c0-0.572-0.243-1.089-0.631-1.454l-0.706,0.705C23.869,17.435,24,17.702,24,18   v11.999c0,0.554-0.5,1.002-1,1.002H10.891l-2.989,3.627v-3.627H6c-0.263,0-0.499-0.107-0.678-0.274   c0.009,0.009,0.013,0.021,0.022,0.03l-0.79,0.616C4.92,31.757,5.432,32,6,32h0.901v3.692c0.005,0.61,0.755,0.782,1.098,0.394   L11.362,32H23c1.172,0,2-0.947,2-2V18z" fill="url(#SVGID_2_)" fill-opacity="0.2" stroke-opacity="0.2"/>
+<path d="M7.901,34.628v-3.627l-1,0.999v3.692c0,0.262,0.164,0.494,0.411,0.583L7.901,34.628z" fill="#FFFFFF" fill-opacity="0.2" stroke-opacity="0.2"/>
+<path d="M5.345,30.757c-0.212-0.184-0.347-0.455-0.347-0.758V18c0-0.552,0.449-1.001,1.002-1.001h17   c0.254,0,0.457,0.069,0.663,0.252l0.706-0.705C24.011,16.208,23.528,16,23,16H6c-1.1,0-2,0.9-2,2v12   c0,0.532,0.211,1.017,0.552,1.376L5.345,30.757z" fill="#FFFFFF" fill-opacity="0.4" stroke-opacity="0.4"/>
+<path d="M7.901,31.001H6c-0.263,0-0.499-0.107-0.678-0.274c0.009,0.009,0.013,0.021,0.022,0.03l-0.79,0.616   C4.92,31.757,5.432,32,6,32h0.901L7.901,31.001z" fill-opacity="0.2" stroke-opacity="0.2"/>
+<path d="M25,18c0-0.572-0.243-1.089-0.631-1.454l-0.706,0.705C23.869,17.435,24,17.702,24,18v11.999   c0,0.585-0.562,1.002-1,1.002H10.891l-2.989,3.627l-0.589,1.647c0.067,0.024,0.422,0.105,0.687-0.189L11.362,32H23   c0.984,0,2-0.775,2-2V18z" fill-opacity="0.2" stroke-opacity="0.2"/>
+<path d="M25,16.619L24.25,16h-5.518c0.014,0.009,1.713,0.894,1.713,0.894l-1.675,0.86   c-0.317,0.205-0.271,0.577-0.204,0.694l0.879,1.515c0.352,0.402,0.623,0.224,0.705,0.171l1.574-1.017l-0.105,1.856   c0.021,0.438,0.361,0.527,0.498,0.527h1.764c0.4,0,0.508-0.391,0.498-0.527l-0.104-1.856L25,19.587V16.619z" fill-opacity="0.3" stroke-opacity="0.3"/>
+<polygon fill="#EA2227" points="27,17.199 26.118,18.714 23.722,17.162 23.881,20 22.117,20 22.277,17.162 19.879,18.714    19,17.199 21.537,15.895 19,14.588 19.879,13.076 22.277,14.625 22.117,11.771 23.881,11.771 23.722,14.625 26.118,13.076    27,14.588 24.464,15.895  "/>
+<rect fill="none" height="40" width="30"/>
+</g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/resources/qtg_small_smiley_kissing.svg	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="30" height="30" viewBox="0 0 30 30">
+<rect fill="none" height="30" width="30"/>
+<circle cx="15" cy="15" r="13.5"/>
+<radialGradient id="SVGID_1" gradientUnits="userSpaceOnUse" cx="14.77" cy="9.23" r="16.13">
+<stop stop-color="#FFF000" offset="0"/>
+<stop stop-color="#FFBF00" offset="1"/>
+</radialGradient>
+<circle cx="15" cy="15" fill="url(#SVGID_1)" r="12.536"/>
+<path d="M12.628,10.056h-0.004c-0.451,0.874-1.376,1.45-2.413,1.45c-0.143,0-0.295-0.017-0.441-0.038 c-1.209-0.19-2.085-1.113-2.282-2.215L6.065,9.5c0.039,0.219,0.138,0.413,0.21,0.618c-0.76,0.437-1.599,0.904-2.446,0.904 c0.943,0.376,2.037,0.525,3.217,0.459c0.625,0.721,1.478,1.256,2.505,1.42c0.217,0.03,0.436,0.045,0.66,0.045 c1.574,0,2.991-0.878,3.695-2.228L12.628,10.056z"/>
+<path d="M17.211,10.056h0.004c0.452,0.874,1.378,1.45,2.415,1.45c0.143,0,0.294-0.017,0.44-0.038 c1.209-0.192,2.085-1.115,2.283-2.217L23.774,9.5c-0.04,0.219-0.137,0.413-0.209,0.618c0.761,0.437,1.597,0.904,2.445,0.904 c-0.942,0.376-2.038,0.525-3.217,0.459c-0.625,0.721-1.477,1.256-2.505,1.42c-0.217,0.03-0.437,0.045-0.659,0.045 c-1.575,0-2.991-0.878-3.696-2.228L17.211,10.056z"/>
+<path d="M17.863,17.593c-1.624-0.45-2.78,1.298-2.78,1.298s-1.157-1.748-2.779-1.298 c-1.622,0.452-3.138,2.774-4.845,2.622c4.403,1.505,4.514,3.967,7.624,4.328c3.107-0.363,3.22-2.823,7.624-4.328 C21,20.366,19.486,18.045,17.863,17.593z" fill="#ED2F42"/>
+<path d="M15.081,18.151c-1.852-1.995-3.5-0.955-5.122,0.33c-0.86,0.682-2.041,1.431-3.093,1.672 c0.33,0.226,3.164,1.627,4.568,3.014c2.835,2.493,4.557,2.407,7.295,0c1.155-1.146,3.985-2.712,4.434-2.952 c-1.081-0.423-2.098-1.055-2.957-1.734C18.14,16.844,16.771,16.33,15.081,18.151z M17.733,18.057 c0.794,0.198,2.825,1.844,3.684,2.213c-1.44,0.684-2.569,1.514-3.324,2.173c-2.483,2.183-3.648,2.083-6.022,0 c-0.752-0.659-1.739-1.488-3.18-2.173c0.939-0.399,2.768-2.047,3.541-2.213c1.279-0.277,2.652,1.313,2.652,1.313 S16.461,17.74,17.733,18.057z"/>
+<radialGradient id="SVGID_2" gradientUnits="userSpaceOnUse" cx="6.02" cy="15.72" r="2.73">
+<stop stop-color="#F15A24" offset="0"/>
+<stop stop-color="#F78614" offset="0.42"/>
+<stop stop-color="#FFBF00" offset="1"/>
+</radialGradient>
+<circle cx="6.016" cy="15.725" fill="url(#SVGID_2)" r="2.733"/>
+<radialGradient id="SVGID_3" gradientUnits="userSpaceOnUse" cx="24.18" cy="15.72" r="2.73">
+<stop stop-color="#F15A24" offset="0"/>
+<stop stop-color="#F78614" offset="0.42"/>
+<stop stop-color="#FFBF00" offset="1"/>
+</radialGradient>
+<circle cx="24.178" cy="15.725" fill="url(#SVGID_3)" r="2.733"/>
+</svg>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/rom/dmindicatorsplugin.iby	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+#ifndef __DMINDICATORSPLUGIN_IBY__
+#define __DMINDICATORSPLUGIN_IBY__
+
+REM DLL
+file=ABI_DIR\UREL\dmindicatorsplugin.dll               SHARED_LIB_DIR\dmindicatorsplugin.dll UNPAGED
+data=\epoc32\data\z\resource\plugins\indicators\dmindicatorsplugin.qtplugin   \resource\plugins\indicators\dmindicatorsplugin.qtplugin
+data=\epoc32\winscw\c\resource\devicemanagement\qtg_small_smiley_kissing.svg   \resource\devicemanagement\qtg_small_smiley_kissing.svg
+data=\epoc32\winscw\c\resource\devicemanagement\message1.svg   \resource\devicemanagement\message1.svg
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/src/dmindicator.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -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: DM indicator base class implementation
+ *
+ */
+#include <QByteArray>
+#include <QVariant>
+#include <qtranslator.h>
+#include <qcoreapplication.h>
+#include <qlocale.h>
+#include "dmindicator.h" 
+
+// ----------------------------------------------------------------------------
+// DMIndicator::DMIndicator
+// @see DMIndicator.h
+// ----------------------------------------------------------------------------
+DMIndicator::DMIndicator(const QString &indicatorType,
+        HbIndicatorInterface::Category category,
+        HbIndicatorInterface::InteractionTypes interactionTypes) :
+    HbIndicatorInterface(indicatorType, category, interactionTypes)
+    {
+    qDebug("DMIndicator::DMIndicator() start");
+    mParameter = 0;
+
+    // Do translation
+    QTranslator *translator = new QTranslator();
+    QString lang = QLocale::system().name();
+    QString path = "Z:/resource/qt/translations/";
+    bool fine = translator->load("deviceupdates_" + lang, path);
+    if (fine)
+        qApp->installTranslator(translator);
+    qDebug("DMIndicator::DMIndicator() end");
+    }
+
+// ----------------------------------------------------------------------------
+// DMIndicator::~DMIndicator
+// @see DMIndicator.h
+// ----------------------------------------------------------------------------
+DMIndicator::~DMIndicator()
+    {
+    
+    }
+
+// ----------------------------------------------------------------------------
+// DMIndicator::indicatorData
+// @see DMIndicator.h
+// ----------------------------------------------------------------------------
+QVariant DMIndicator::indicatorData(int role) const
+    {
+    qDebug("DMIndicator::indicatorData() start");
+    switch (role)
+        {
+
+        case MonoDecorationNameRole:
+            {
+            //QString iconName("z:/resource/devicemanagement/qtg_small_smiley_kissing.svg");
+            //QString iconName("C:/resource/devicemanagement/qtg_small_smiley_kissing.svg");
+            QString iconName("qtg_small_smiley_kissing");
+            return iconName;
+            }
+
+        default:
+            return QVariant();
+
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// DMIndicator::handleClientRequest
+// @see DMIndicator.h
+// ----------------------------------------------------------------------------
+bool DMIndicator::handleClientRequest(RequestType type,
+        const QVariant &parameter)
+    {
+    qDebug("DMIndicator::handleClientRequest() start");
+    bool handled(false);
+    switch (type)
+        {
+        case RequestActivate:
+            {
+            qDebug("DMIndicator::handleClientRequest() RequestActivate");
+            mParameter = parameter;
+            emit
+            dataChanged();
+            handled = true;
+            }
+            break;
+        case RequestDeactivate:
+            {
+            qDebug("DMIndicator::handleClientRequest() RequestDeactivate");
+            emit deactivate();
+            }
+            break;
+        default:
+            break;
+        }
+    qDebug("DMIndicator::handleClientRequest() end");
+    return handled;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/src/dmindicatorsplugin.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: DM indicators plugin implementation
+ *
+ */
+
+#include <QtPlugin>
+#include <QVariant>
+#include <dmindicatorconsts.h>
+
+#include "dmindicatorsplugin.h"
+#include "dmindicator.h" 
+#include "tarmtrustindicator.h"
+#include "dmpronoteindicators.h" 
+
+
+Q_EXPORT_PLUGIN(DMIndicatorsPlugin)
+
+// Secure Clients UIDs
+TUid PolicyManagmentSecUID =
+    {
+    0x10207815
+    };
+
+TUid ScomoSecUID =
+    {
+    0x200267FB
+    };
+
+TUid FotaSecUID =
+    {
+    0x2002FF68
+    };
+
+
+// ----------------------------------------------------------------------------
+// DMIndicatorsPlugin::DMIndicatorsPlugin
+// @see DMIndicatorsPlugin.h
+// ----------------------------------------------------------------------------
+DMIndicatorsPlugin::DMIndicatorsPlugin() :
+    mError(0)
+    {
+    mIndicatorTypes.append(KDMProgressIndicatorType);
+    mIndicatorTypes.append(KDMNotificationIndicatorType);
+    mIndicatorTypes.append(KDMSettingsIndicatorType);
+    mIndicatorTypes.append(KScomoProgressIndicatorType);
+    mIndicatorTypes.append(KScomoNotificationIndicatorType);
+    mSecureClients.append(PolicyManagmentSecUID);
+    mSecureClients.append(ScomoSecUID);
+    mSecureClients.append(FotaSecUID);
+    
+    }
+
+// ----------------------------------------------------------------------------
+// DMIndicatorsPlugin::~DMIndicatorsPlugin
+// @see DMIndicatorsPlugin.h
+// ----------------------------------------------------------------------------
+DMIndicatorsPlugin::~DMIndicatorsPlugin()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// DMIndicatorsPlugin::indicatorTypes
+// Return notification types this plugin implements
+// @see DMIndicatorsPlugin.h
+// ----------------------------------------------------------------------------
+QStringList DMIndicatorsPlugin::indicatorTypes() const
+    {
+    qDebug("DMIndicatorsPlugin::indicatorTypes()");
+    return mIndicatorTypes;
+    }
+
+// ----------------------------------------------------------------------------
+// DMIndicatorsPlugin::accessAllowed
+// Check if client is allowed to use notification widget
+// @see DMIndicatorsPlugin.h
+// ----------------------------------------------------------------------------
+bool DMIndicatorsPlugin::accessAllowed(const QString &indicatorType,
+        const QVariantMap &securityInfo) const
+    {
+    qDebug("DMIndicatorsPlugin::accessAllowed()");
+    Q_UNUSED(indicatorType)
+
+#if defined(Q_OS_SYMBIAN)
+
+    TUid SecUID = TUid::Uid(securityInfo.value("sym-secureId").toUInt());
+
+    if (mSecureClients.contains(SecUID))
+        {
+        qDebug("DMIndicatorsPlugin::accessAllowed() SecUID is secure ");
+        return true;
+        }
+    else
+        {
+        qDebug("DMIndicatorsPlugin::accessAllowed() SecUID is not secure ");
+        return false;
+        }
+#elif
+    Q_UNUSED(securityInfo)
+    qDebug("DMIndicatorsPlugin::accessAllowed() not Symbian ");
+    return false;
+    
+#endif
+    }
+
+// ----------------------------------------------------------------------------
+// DMIndicatorsPlugin::createIndicator
+// @see DMIndicatorsPlugin.h
+// ----------------------------------------------------------------------------
+HbIndicatorInterface* DMIndicatorsPlugin::createIndicator(
+        const QString &indicatorType)
+    {
+    qDebug("DMIndicatorsPlugin::createIndicator() Start");
+    HbIndicatorInterface *indicator = 0;
+
+    if (indicatorType == KDMProgressIndicatorType)
+        {
+        indicator = new DMProNoteIndicator(indicatorType,
+                HbIndicatorInterface::ProgressCategory,
+                HbIndicatorInterface::InteractionActivated);
+        }
+    else if (indicatorType == KDMNotificationIndicatorType)
+        {
+        indicator = new DMProNoteIndicator(indicatorType,
+                HbIndicatorInterface::NotificationCategory,
+                HbIndicatorInterface::InteractionActivated);
+        }
+
+    else if (indicatorType == KDMSettingsIndicatorType)
+        {
+        indicator = new TarmTrustIndicator(indicatorType,
+                HbIndicatorInterface::SettingCategory,
+                HbIndicatorInterface::NoInteraction);
+        }
+    else if (indicatorType == KScomoProgressIndicatorType)
+        {
+        indicator = new ScomoProNoteIndicator(indicatorType,
+                HbIndicatorInterface::ProgressCategory,
+                HbIndicatorInterface::InteractionActivated);
+        }
+    else if (indicatorType == KScomoNotificationIndicatorType)
+        {
+        indicator = new ScomoProNoteIndicator(indicatorType,
+                HbIndicatorInterface::NotificationCategory,
+                HbIndicatorInterface::InteractionActivated);
+        }
+    
+    qDebug("DMIndicatorsPlugin::createIndicator() end");
+    return indicator;
+    }
+
+// ----------------------------------------------------------------------------
+// DMIndicatorsPlugin::error
+// @see DMIndicatorsPlugin.h
+// ----------------------------------------------------------------------------
+int DMIndicatorsPlugin::error() const
+    {
+    qDebug("DMIndicatorsPlugin::error()");
+    return mError;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/src/dmpronoteindicators.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: DM Progress and Notification indicators implementation
+ *
+ */
+#include "dmindicator.h" 
+#include "dmpronoteindicators.h" 
+#include <QByteArray>
+#include <QVariant>
+#include <e32base.h>
+#include <w32std.h>
+#include <apgtask.h>
+#include <apgtask.h>
+#include <HbIndicator.h>
+
+#include <eikenv.h>
+// ----------------------------------------------------------------------------
+// DMProNoteIndicator::DMProNoteIndicator
+// @see dmpronoteindicators.h
+// ----------------------------------------------------------------------------
+DMProNoteIndicator::DMProNoteIndicator(const QString &indicatorType,
+        HbIndicatorInterface::Category category,
+        HbIndicatorInterface::InteractionTypes interactionTypes) :
+    DMIndicator(indicatorType, category, interactionTypes)
+    {
+
+    }
+
+// ----------------------------------------------------------------------------
+// DMProNoteIndicator::indicatorData
+// @see dmpronoteindicators.h
+// ----------------------------------------------------------------------------
+QVariant DMProNoteIndicator::indicatorData(int role) const
+    {
+    qDebug("DMProNoteIndicator::indicatorData()");
+    switch (role)
+        {
+        case PrimaryTextRole:
+            {
+            QString text = hbTrId("txt_device_update_dblist_device_updates");
+            return text;
+            }
+        case SecondaryTextRole:
+            {
+            QString text = mParameter.toString();
+            return text;
+            }
+        case MonoDecorationNameRole:
+            {
+            //QString iconName("C:/resource/devicemanagement/qtg_small_smiley_kissing.svg");
+            QString iconName("qtg_small_smiley_kissing");
+            return iconName;
+            }
+
+        case DecorationNameRole:
+            {
+            //QString iconName("C:/resource/devicemanagement/qtg_small_smiley_kissing.svg");
+            QString iconName("qtg_small_smiley_kissing");
+            return iconName;
+            }
+        default:
+            qDebug(
+                    "DMProNoteIndicator::indicatorData() returning Null QVariant");
+            return QVariant();
+
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// DMProNoteIndicator::handleInteraction
+// @see dmpronoteindicators.h
+// ----------------------------------------------------------------------------
+bool DMProNoteIndicator::handleInteraction(InteractionType type)
+    {
+    qDebug("DMProNoteIndicator::handleInteraction() Start");
+	QVariantMap map;
+    map.insert("data", indicatorType());
+    emit userActivated(map);
+    emit deactivate();
+    qDebug("DMProNoteIndicator::handleInteraction() End");
+    return true;
+    }
+
+// ----------------------------------------------------------------------------
+// ScomoProNoteIndicator::ScomoProNoteIndicator
+// @see dmpronoteindicators.h
+// ----------------------------------------------------------------------------
+ScomoProNoteIndicator::ScomoProNoteIndicator(const QString &indicatorType,
+        HbIndicatorInterface::Category category,
+        HbIndicatorInterface::InteractionTypes interactionTypes) :
+DMProNoteIndicator(indicatorType, category, interactionTypes)
+    {
+
+    }
+
+// ----------------------------------------------------------------------------
+// ScomoProNoteIndicator::handleInteraction
+// @see dmpronoteindicators.h
+// ----------------------------------------------------------------------------
+bool ScomoProNoteIndicator::handleInteraction(InteractionType type)
+    {
+    qDebug("ScomoProNoteIndicator::handleInteraction() Start");
+    bool handled = false;
+    
+    emit deactivate();
+    CCoeEnv* coe = CCoeEnv::Static(); 
+    TApaTaskList taskList(coe->WsSession());
+    TApaTask task=taskList.FindApp(TUid::Uid(0x200267FB));
+    if(task.Exists())
+        {
+        task.BringToForeground();
+        }
+    qDebug("ScomoProNoteIndicator::handleInteraction() End");
+    return handled;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/devicemgmtindicatorsplugin/src/tarmtrustindicator.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -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: TarmTrust Indicator implementation
+ *
+ */
+#include "tarmtrustindicator.h" 
+#include "dmindicator.h" 
+#include <QByteArray>
+#include <QVariant>
+#include <dmindicatorconsts.h>
+
+// ----------------------------------------------------------------------------
+// TarmTrustIndicator::TarmTrustIndicator
+// @see tarmtrustindicator.h
+// ----------------------------------------------------------------------------
+TarmTrustIndicator::TarmTrustIndicator(const QString &indicatorType,
+        HbIndicatorInterface::Category category,
+        HbIndicatorInterface::InteractionTypes interactionTypes) :
+    DMIndicator(indicatorType, category, interactionTypes)
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// TarmTrustIndicator::~TarmTrustIndicator
+// @see tarmtrustindicator.h
+// ----------------------------------------------------------------------------
+TarmTrustIndicator::~TarmTrustIndicator()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// TarmTrustIndicator::indicatorData
+// @see tarmtrustindicator.h
+// ----------------------------------------------------------------------------
+QVariant TarmTrustIndicator::indicatorData(int role) const
+    {
+    qDebug("TarmTrustIndicator::indicatorData()");
+    switch (role)
+        {
+        case MonoDecorationNameRole:
+            {
+            QString StringText = mParameter.toString();
+            QString iconName;
+            if (StringText == KTarmTrustManagementActive)
+                {
+                qDebug("TarmTrustIndicator::indicatorData() Management Active");
+                //iconName = "C:/resource/devicemanagement/message1.svg";
+                iconName = "message1";
+                }
+            else if (StringText == KTarmTrustTerminalSecurity)
+                {
+                qDebug("TarmTrustIndicator::indicatorData() Terminal Security");
+                //iconName = "C:/resource/devicemanagement/qtg_small_smiley_kissing.svg";
+                 iconName = "qtg_small_smiley_kissing";
+                }
+            
+            return iconName;
+            }
+        default:
+            return QVariant();
+
+        }
+    }
+
--- a/deviceupdatesui/deviceupdates/deviceupdates.pro	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/deviceupdates.pro	Tue Jul 13 04:01:20 2010 +0530
@@ -40,7 +40,11 @@
         -letel3rdparty\
 		-letelpckt\
 		-lcmmanager\
-		-lsisregistryclient
+		-lsisregistryclient \
+		-lfotaengine	\
+		-leuser	\
+		-lflogger	\
+		-lxqutils
 	}
 TEMPLATE = app
 TARGET = deviceupdates
@@ -64,7 +68,10 @@
 ./inc/dmadvancedview.h\
 ./inc/settingsdataformcustomitem.h\
 ./inc/dmfotaview.h\
-./inc/nsmldmdbnotifier.h
+./inc/nsmldmdbnotifier.h	\
+./inc/deviceupdatemoniter.h	\
+./inc/deviceupdatemoniterobserver.h	\
+./inc/DeviceUpdateDebug.h
 
 SOURCES += ./src/dmadvancedview.cpp \
 			./src/main.cpp \
@@ -77,8 +84,9 @@
 			./src/dminforetrieval.cpp\
 			./src/serversettingsview.cpp\
 			./src/settingsdataformcustomitem.cpp\
-			../src/dmfotaview.cpp \
-			../src/nsmldmdbnotifier.cpp
+			./src/dmfotaview.cpp \
+			./src/nsmldmdbnotifier.cpp	\
+			./src/deviceupdatemoniter.cpp
 			
 RESOURCES += ./resources/deviceupdates.qrc
 CONFIG += hb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deviceupdatesui/deviceupdates/inc/DeviceUpdateDebug.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,73 @@
+/*
+* 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 defines logging macros 
+*
+*/
+
+
+
+#ifndef FOTADEBUG_H
+#define FOTADEBUG_H
+
+    // IMPORT_C static TInt Print(TRefByValue<const TDesC> aFmt,...);
+#if defined (__WINS__)
+    #define _FOTA_DEBUG
+    #define _FOTA_DEBUG_RDEBUG
+#else
+    #define _FOTA_DEBUG
+#endif
+    //#endif
+    #ifdef _FOTA_DEBUG
+
+
+        #include <e32std.h>
+        #include <f32file.h>
+        #include <flogger.h>
+        #include <e32svr.h>
+
+        _LIT( KLogFile, "deviceupdates.log" );
+        _LIT( KLogDir, "fota" );
+
+        inline void FWrite (TRefByValue<const TDesC> aFmt,...)
+            {
+            VA_LIST list;
+            VA_START( list, aFmt );
+            RFileLogger::WriteFormat( KLogDir,KLogFile,EFileLoggingModeAppend ,TPtrC(aFmt) ,list );
+            }
+
+        #ifdef _FOTA_DEBUG_RDEBUG 
+            #ifndef __GNUC__          
+                #define FLOG            RDebug::Print
+            #else   // __GNUC__       
+                #define FLOG(arg...)    RDebug::Print(arg);
+            #endif // __GNUC__        
+        #else // _FOTA_DEBUG_RDEBUG
+            #ifndef __GNUC__          
+                #define FLOG            FWrite
+            #else   // __GNUC__       
+                #define FLOG(arg...)    FWrite(arg);
+            #endif // __GNUC__        
+        #endif // _FOTA_DEBUG_RDEBUG
+
+    #else   // _FOTA_DEBUG    
+        #ifndef __GNUC__
+            #define FLOG
+        #else
+            #define FLOG(arg...)
+        #endif // __GNUC__
+    #endif // _FOTA_DEBUG
+
+#endif      // FOTADEBUG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deviceupdatesui/deviceupdates/inc/deviceupdatemoniter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:   Fota server update and download functionality 
+ *
+ */
+
+#ifndef DEVICEUPDATEMONITER_H
+#define DEVICEUPDATEMONITER_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <centralrepository.h>
+#include "deviceupdatemoniterobserver.h"
+#include <e32cmn.h>
+// CLASS DECLARATION
+
+/**
+ *  CClassName
+ * 
+ */
+#include <e32property.h>
+
+#define  KOmaDMAppUid   0x101F6DE5
+
+//static const TUid KOmaDMAppUid = { 0x101F6DE5 };
+
+const TUint32 KFotaServerActive = 0x0000008;
+
+
+//#include <hb/hbcore/hbsymbiandevicedialog.h>    // MDeviceMoniterObserver
+
+class  CDeviceUpdateMoniter  
+        :
+        public CActive
+        //public MDeviceMoniterObserver
+        //: public QObject, public MHbDeviceDialogObserver
+    {
+public: // new functions
+    static CDeviceUpdateMoniter* NewL (MDeviceMoniterObserver* aObserver);
+    
+    CDeviceUpdateMoniter();
+    
+    ~CDeviceUpdateMoniter();
+    
+    void StartMoniter();
+    
+    void ConstructL();
+    
+public:
+    /**
+     * Handle user action
+     *
+     * @since   S60   v3.1
+     * @param   None
+     * @return  None
+     */
+    virtual void RunL();
+
+
+     /**
+     * Handle leaving Runl
+     *
+     * @since   S60   v3.1
+     * @param   aError  error code
+     * @return  Error code
+     */
+    virtual TInt RunError(TInt aError);
+
+
+     /**
+     * Handle cancel of active object
+     *
+     * @since   S60   v3.1
+     * @param   none
+     * @return  none
+     */
+    void DoCancel();
+    
+    
+    TInt CancelRequest();
+
+    
+private:
+
+    //MDeviceMoniterObserver* iDownload;
+    MDeviceMoniterObserver * iObserver;
+    
+    RProperty iProperty;
+    
+    };
+
+#endif // DEVICEUPDATEMONITER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deviceupdatesui/deviceupdates/inc/deviceupdatemoniterobserver.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,33 @@
+/*
+ * 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:   Fota server update and download functionality 
+ *
+ */
+
+#ifndef DEVICEUPDATEMONITEROBSERVER_H
+#define DEVICEUPDATEMONITEROBSERVER_H
+
+class MDeviceMoniterObserver
+    {
+public:
+    /**
+    * Notify the input of the device dialog to the respective caller.
+    */
+    virtual void UpdateDMUI(TBool aVal) = 0;
+    };
+
+#endif // DEVICEUPDATEMONITEROBSERVER_H
+
+// End of File
+
--- a/deviceupdatesui/deviceupdates/inc/dmadvancedview.h	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/inc/dmadvancedview.h	Tue Jul 13 04:01:20 2010 +0530
@@ -67,13 +67,14 @@
 #define PORTRAIT "portrait"
 
 const TInt KWlanMacAddrLength = 100;
-const TInt KBTAddrLength = 64; 
+const TInt KBTAddrLength = 64;
+class DMFotaView;
 class DmAdvancedView : public HbView
 {
     Q_OBJECT
 
 public:
-    explicit DmAdvancedView(HbMainWindow *mainWindow, HbView *mainView, QGraphicsItem *parent=0);
+    explicit DmAdvancedView(HbMainWindow *mainWindow, DMFotaView *mainView,DmInfo *info=NULL, QGraphicsItem *parent=0);
     virtual ~DmAdvancedView();   
     bool displayItems();
     void saveProfile(QStringList& itemdata, bool& sessmode, QString& currap,unsigned int& portnum, bool& nauth );
@@ -84,7 +85,8 @@
     void NetworkBand(RMobilePhone::TMobilePhoneNetworkBandInfo val, QString& string); 
     void NetworkCiphering(RMobilePhone::TMobilePhoneNetworkSecurity val, QString& string);  
     void mainCalltoUpdateView();
-    
+    void addVersionInfo();
+    void addOtherDetails();
 private:
     void updateEarlierdefaultProfileIcon();
     void updateListview();
@@ -115,9 +117,8 @@
     HbPushButton* newserverprofile;
     int count;
     QTranslator *translator;
-    DmInfo* dminfo;
     QStandardItemModel *model;
-    QStandardItemModel *otherdetailsmodel;
+    QStandardItemModel *m_otherdetailsmodel;
     int currentdefaultprofile;
     bool connectionRequested;
     bool backbehaviorset;
@@ -128,7 +129,8 @@
     ServerSettingsView* serverSetView;
     HbAnchorLayout* layout;
     int currentview;
-    HbView* iMainView;
+    //HbView* iMainView;
+    DMFotaView* iMainView;
     HbAction* backaction;
     RMobilePhone imobPhone;
     RTelServer iServer;
@@ -138,6 +140,8 @@
 	//This item should not be deleted,it just refer an item and deletion
 	//will be taken care by List view
 	QStandardItem *modelItem;
+public:
+    DmInfo* dminfo;
 };
 
 #endif // DMADVANCEDVIEW_H
--- a/deviceupdatesui/deviceupdates/inc/dmfotaview.h	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/inc/dmfotaview.h	Tue Jul 13 04:01:20 2010 +0530
@@ -24,6 +24,7 @@
 #include <QGraphicsLinearLayout>
 #include <hbgroupbox.h>
 #include <hbview.h>
+#include <SysUtil.h>
 #include <hblabel.h>
 #include <hbdocumentloader.h>
 #include <hbmenu.h>
@@ -34,12 +35,18 @@
 #include <centralrepository.h>
 #include <QTranslator>
 #include <nsmldmdef.h>
+#include "dminforetrieval.h"
+#include <fotaengine.h>
+#include "deviceupdatemoniterobserver.h"
 //_LIT( KSmlEOL,      "\n" );
 
 
 class HbDialog;
+class HbPushButton;
 class DmAdvancedView;
-class DMFotaView : public HbView
+class CDeviceUpdateMoniter;
+
+class DMFotaView : public HbView, public MDeviceMoniterObserver
     {
     Q_OBJECT
 public:
@@ -47,15 +54,22 @@
     virtual ~DMFotaView();
     bool addFotaView();
     //HbDialog* createDialog() const;
+    void displayNoteAndDisableButtons();
+    void enableButtons();
 private:
     void FormatList(QString val, QString str);
+    RFotaEngineSession& FotaEngineL();
+    void fotaSupportEnabled();
 public slots :
     void OnHelp();
     void OnExit();
 	void CheckforUpdate();
-	void AdvancedDeviceManager();
+	void AdvancedDeviceManager(bool launchadvanceview = true);	
 	void backtoMainWindow();
 	void readSection( Qt::Orientation orientation );
+	void ResumeUpdate();
+public:
+	void UpdateDMUI(TBool aVal);
 private:
 	HbMainWindow* mMainWindow;
 	HbView* fotaPortraitView;
@@ -68,8 +82,20 @@
     QTranslator* mTranslator;
     HbLabel *label,*label2,*label3,*label4;
     QStringList list1,list2;
-    TInt i;
+    TInt i;   
+    DmInfo* mainDmInfo;
     HbDocumentLoader loader,loader2;
+    HbPushButton *updateButton;
+    TInt fotaValue;
+    HbPushButton *advancedButton;
+    HbPushButton *updateButtonLandscape;
+    HbPushButton *advancedButtonLandscape;
+    
+    RFotaEngineSession iFotaEngine;
+    RFotaEngineSession::TState iFotaState;
+    
+    CDeviceUpdateMoniter * iMoniter;
+    TBool Connected;
     };
     
 
--- a/deviceupdatesui/deviceupdates/inc/dminforetrieval.h	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/inc/dminforetrieval.h	Tue Jul 13 04:01:20 2010 +0530
@@ -38,7 +38,7 @@
     Q_OBJECT
 
    public:
-    DmInfo(DmAdvancedView* serversview, QGraphicsItem *parent=0);
+    DmInfo(DmAdvancedView* serversview=NULL, QGraphicsItem *parent=0);
        virtual ~DmInfo();   
        void refreshProfileList(TBool aIncludeHidden = ETrue);
        int profilescount();
@@ -54,6 +54,7 @@
        bool checksrvid(QString& serverid);
        void getIaplist(QStringList& iaplist, int& iapselected, int& listindex);
        void synchronize(int& itemnum);
+       void sync(int aProfileId);
        void synccomplete(int);     
        /**
        * Handles DB events
@@ -61,13 +62,13 @@
        * @return None
        */
        void HandleDbEventL( TNSmlDMDbEvent aEvent );
-       
+       TInt DefaultFotaProfileIdL() const;           
        void DisableDbNotifications( TBool aEvent );
               
 private:
        void GetProfiles( );
+       TInt findProfile(TInt aProfileId);
        void OpenSyncSession();
-       TInt DefaultFotaProfileIdL() const;
        void SetDefaultFotaProfileIdL( const TInt aProfileId );
        
    public slots:
--- a/deviceupdatesui/deviceupdates/inc/nsmldmsynchandler.h	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/inc/nsmldmsynchandler.h	Tue Jul 13 04:01:20 2010 +0530
@@ -27,6 +27,9 @@
 #include "nsmldmsyncutil.h"
 #include "nsmldmsyncprofile.h"
 #include "nsmldmsyncappengine.h"
+#include <hbdialog.h>
+#include <hblabel.h>
+#include <hbaction.h>
 // FORWARD DECLARATIONS
 class CNSmlDMSyncState;
 class CNSmlDMActiveCaller;
@@ -280,6 +283,10 @@
         
         // Identifies Fota progress note launched or not
         TBool iFotaProgressLaunched;
+        
+        HbDialog * iDialog;
+        
+        HbAction * iPrimaryAction;
 	};
 
 #endif  // NSMLDMSYNCHANDLER_H
--- a/deviceupdatesui/deviceupdates/inc/serversettingsview.h	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/inc/serversettingsview.h	Tue Jul 13 04:01:20 2010 +0530
@@ -53,6 +53,7 @@
     void backButtonClicked();
     void checkServerIdvalue();    
     void accessPointItemChanged(int apindex);
+    void portItemChanged(QString port);
 
 public:    
     HbMainWindow *iMainWindow;        
@@ -78,7 +79,8 @@
     SettingsDataFormCustomItem* customPrototype;
     int currentiapindex;
     QStringList apnameslist;
-    bool backbehaviorset;    
+    bool backbehaviorset; 
+    unsigned int iPort;
 };
 
 #endif /* SERVERSETTINGSVIEW_H_ */
--- a/deviceupdatesui/deviceupdates/inc/settingsdataformcustomitem.h	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/inc/settingsdataformcustomitem.h	Tue Jul 13 04:01:20 2010 +0530
@@ -21,6 +21,7 @@
 
 #include <hbdataformviewitem.h>
 
+class HbLineEdit;
 class SettingsDataFormCustomItem : public HbDataFormViewItem
 {
 Q_OBJECT
@@ -34,6 +35,12 @@
 
 protected:
     virtual HbWidget* createCustomWidget();
+    
+public slots:
+virtual void restore();
+
+private:
+HbLineEdit* mLineEdit;
 };
 
 #endif // SETTINGS_DATAFORM_CUSTOMITEM_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deviceupdatesui/deviceupdates/src/deviceupdatemoniter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,125 @@
+/*
+ * 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:   Fota server update and download functionality 
+ *
+ */
+
+#include "deviceupdatemoniter.h"
+#include "DeviceUpdateDebug.h"
+
+// --------------------------------------------------------------------------
+// CDeviceUpdateMoniter::NewL 
+// --------------------------------------------------------------------------
+//
+CDeviceUpdateMoniter* CDeviceUpdateMoniter::NewL (MDeviceMoniterObserver* aObserver)
+    {
+    FLOG(_L("CDeviceUpdateMoniter::NewL >>"));    
+    CDeviceUpdateMoniter* h=new (ELeave)CDeviceUpdateMoniter;
+    h->iObserver = aObserver;
+    h->ConstructL();
+    FLOG(_L("CDeviceUpdateMoniter::NewL <<"));
+    return h;
+    }
+
+void CDeviceUpdateMoniter::ConstructL()
+    {
+    FLOG(_L("CDeviceUpdateMoniter::ConstructL >>"));
+    TInt err = RProperty::Define(TUid::Uid(KOmaDMAppUid), KFotaServerActive, RProperty::EInt);
+    
+    if(err == KErrAlreadyExists)
+        {
+        TInt value;
+        RProperty::Get(TUid::Uid(KOmaDMAppUid), KFotaServerActive, value);
+        if(value)
+            iObserver->UpdateDMUI(EFalse);
+        }
+    err = iProperty.Attach(TUid::Uid(KOmaDMAppUid), KFotaServerActive);
+    if(err == KErrNone)
+        {
+        iProperty.Subscribe(iStatus);
+        if ( !IsActive() )
+            {
+            SetActive();
+            }
+        }
+    FLOG(_L("CDeviceUpdateMoniter::ConstructL <<"));
+    }
+
+
+void CDeviceUpdateMoniter::StartMoniter()
+    {
+    FLOG(_L("CDeviceUpdateMoniter::StartMoniter() >>"));
+    iProperty.Subscribe(iStatus);
+    if ( !IsActive() )
+        {
+        SetActive();
+        }
+    FLOG(_L("CDeviceUpdateMoniter::StartMoniter <<"));
+    }
+
+// --------------------------------------------------------------------------
+CDeviceUpdateMoniter::CDeviceUpdateMoniter()
+            : CActive(EPriorityNormal)
+    {
+    FLOG(_L("CDeviceUpdateMoniter::CDeviceUpdateMoniter() >>"));
+    CActiveScheduler::Add( this );
+    FLOG(_L("CDeviceUpdateMoniter::CDeviceUpdateMoniter <<"));
+    }
+
+// --------------------------------------------------------------------------
+CDeviceUpdateMoniter::~CDeviceUpdateMoniter()
+    {
+    FLOG(_L("CDeviceUpdateMoniter::~CDeviceUpdateMoniter >>"));
+    //iNotifier.Close(); FOTA_10.1 changes
+    //Cancel();
+    FLOG(_L("CDeviceUpdateMoniter::~CDeviceUpdateMoniter <<"));
+    }
+
+// --------------------------------------------------------------------------
+void CDeviceUpdateMoniter::RunL()
+    {
+    FLOG(_L("CDeviceUpdateMoniter::RunL >>"));
+    TInt value;
+    TUid uid = {0x102072C4};
+    
+    RProperty::Get(TUid::Uid(KOmaDMAppUid), KFotaServerActive, value);
+    if(value)
+        iObserver->UpdateDMUI(EFalse);
+    else
+        iObserver->UpdateDMUI(ETrue);
+    StartMoniter();
+    FLOG(_L("CDeviceUpdateMoniter::RunL <<"));
+    }
+
+// --------------------------------------------------------------------------
+TInt CDeviceUpdateMoniter::RunError(TInt aError)
+    {   
+    FLOG(_L("CDeviceUpdateMoniter::RunL %d"),aError);
+    return aError;
+    }
+
+TInt CDeviceUpdateMoniter::CancelRequest()
+    {
+    FLOG(_L("CDeviceUpdateMoniter::CancelRequest %d"));
+    
+    }
+
+// --------------------------------------------------------------------------
+void CDeviceUpdateMoniter::DoCancel()
+    {
+    FLOG(_L("CDeviceUpdateMoniter::DoCancel >>"));
+    iProperty.Cancel();
+    FLOG(_L("CDeviceUpdateMoniter::DoCancel <<"));
+    }
+
--- a/deviceupdatesui/deviceupdates/src/dmadvancedview.cpp	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/src/dmadvancedview.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -17,22 +17,30 @@
 */
 #include <hbnamespace.h>
 #include "dmadvancedview.h"
+#include "dmfotaview.h"
 #include "serversettingsview.h"
 
-DmAdvancedView::DmAdvancedView(HbMainWindow *mainWindow, HbView *mainView, QGraphicsItem *parent):HbView(parent),
+DmAdvancedView::DmAdvancedView(HbMainWindow *mainWindow,DMFotaView *mainView, DmInfo *info, QGraphicsItem *parent):HbView(parent),
     bluetooth(":/icons/qgn_prop_sml_bt.svg"),
     internet(":/icons/qgn_prop_sml_http.svg"), 
     defaultprofileicon(":/icons/qtg_large_avatar.svg")                
     {
+    qDebug("omadm DeviceManagerUi::DmAdvancedView >>");
     iMainWindow = mainWindow;
     serverSetView = NULL;
     iMainView = mainView;
-    dminfo = new DmInfo(this);
+    if(info==NULL)
+        {
+        dminfo = new DmInfo(this);
+        }
+    else 
+        dminfo = info;
     currentdefaultprofile = -1;
     currentview = 0;
     connectionRequested = false;    
     backbehaviorset = false;
     currentselecteditem = -1;
+    qDebug("omadm DeviceManagerUi::DmAdvancedView >>");
     }
 
 DmAdvancedView::~DmAdvancedView()
@@ -47,7 +55,8 @@
 
 void DmAdvancedView::handleLongPress(HbAbstractViewItem* item , QPointF coOrdinates)
     {
-    if (connectionRequested)
+    qDebug("omadm DeviceManagerUi::handleLongPress >>");
+    if(connectionRequested)
         return;
     if (item)
         {
@@ -80,11 +89,13 @@
         csmenu->setPreferredPos(coOrdinates);
         csmenu->open();
         }
+    qDebug("omadm DeviceManagerUi::handleLongPress >>");
     }
 
 
 void DmAdvancedView::handleClicked(QModelIndex index)
     {
+    qDebug("omadm DeviceManagerUi::handleClicked >>");
     if(connectionRequested)
         return;
     //Stop listening DB events for profile addition
@@ -117,10 +128,12 @@
         iMainWindow->setCurrentView(serverSetView);
   
         }
+    qDebug("omadm DeviceManagerUi::handleClicked >>");
     }
 
 bool DmAdvancedView::displayItems()
     {    	
+    qDebug("omadm DeviceManagerUi::displayItems >>");
     docmlLoader = new HbDocumentLoader;
     bool ok ;    
     docmlLoader->load( DOCML_FILE_NAME,  &ok  );
@@ -233,11 +246,13 @@
         {
         qDebug("omadm docml section loading failed");
         }    
+    qDebug("omadm DeviceManagerUi::displayItems >>");
     return ok;
     }
 
 void DmAdvancedView::updateEarlierdefaultProfileIcon()
     {
+    qDebug("omadm DeviceManagerUi::updateEarlierdefaultProfileIcon >>");
     if(currentdefaultprofile >= 0)
         {
         QStandardItem *earlierDefaultProfile = model->item(currentdefaultprofile);
@@ -253,10 +268,12 @@
             earlierDefaultProfile->setIcon(bluetooth);
             }        
         }
+    qDebug("omadm DeviceManagerUi::updateEarlierdefaultProfileIcon >>");
     }
 
 void DmAdvancedView::createNewProfile()
     {
+    qDebug("omadm DeviceManagerUi::createNewProfile >>");
     if(dminfo->createNewprofile())
         {
         //Open server settings view    
@@ -286,18 +303,22 @@
         {
         qDebug("OMADM New server profile creation failed");
         }
+    qDebug("omadm DeviceManagerUi::createNewProfile >>");
     }
 
 void DmAdvancedView::saveProfile(QStringList& itemdata, bool& sessmode, QString& currap,unsigned int& portnum, bool& nauth )
     {
+    qDebug("omadm DeviceManagerUi::saveProfile >>");
     dminfo->DisableDbNotifications(true);
     dminfo->saveProfile(itemdata,sessmode,currap,portnum,nauth);
     updateListview();
     dminfo->DisableDbNotifications(false);
+    qDebug("omadm DeviceManagerUi::saveProfile >>");
     }
 
 void DmAdvancedView::updateListview()
     {
+    qDebug("omadm DeviceManagerUi::updateListview >>");
     model->clear();
     int IndicatorCount =dminfo->profilescount();    
     for (int i = 0; IndicatorCount > 0 && i < IndicatorCount; ++i) {    
@@ -342,34 +363,41 @@
     model->setItem(i, item);    
     }    
     model->sort(0);
+    qDebug("omadm DeviceManagerUi::updateListview >>");
     }
 
 void DmAdvancedView::serversListGroupClicked(bool state)
     {
+    qDebug("omadm DeviceManagerUi::serversListGroupClicked >>");
     Q_UNUSED(state);
     if(serversListGroup->isCollapsed())
         otherDetailsGroup->setCollapsed(false);
     else
         otherDetailsGroup->setCollapsed(true);
+    qDebug("omadm DeviceManagerUi::serversListGroupClicked >>");
     }
 
 void DmAdvancedView::otherDetailsGroupClicked(bool state)
     {
+    qDebug("omadm DeviceManagerUi::otherDetailsGroupClicked >>");
     Q_UNUSED(state);
     if(otherDetailsGroup->isCollapsed())
         serversListGroup->setCollapsed(false);
     else
         serversListGroup->setCollapsed(true);
+    qDebug("omadm DeviceManagerUi::otherDetailsGroupClicked >>");
     }
 
 bool DmAdvancedView::checkServerId(QString& serverid)
     {
+    qDebug("omadm DeviceManagerUi::CheckforUpdate >>");
     return dminfo->checksrvid(serverid);
+    qDebug("omadm DeviceManagerUi::CheckforUpdate >>");
     }
 
 void DmAdvancedView::reLayout(Qt::Orientation orientation)
-    {
-    qDebug("OMADM servers view DmAdvancedView::reLayout");
+    {   
+    qDebug("OMADM servers view DmAdvancedView::reLayout <<");
     if(orientation == Qt::Horizontal)
         {
         qDebug("OMADM servers view landscape");
@@ -381,12 +409,12 @@
         bool ok;
         docmlLoader->load( DOCML_FILE_NAME,  PORTRAIT, &ok  );
         }
-    
-    
+    qDebug("OMADM servers view DmAdvancedView::reLayout >>");
     }
 
 void DmAdvancedView::setBackBehavior()
     {
+    qDebug("OMADM servers view DmAdvancedView::setBackBehavior <<");
     if (!backbehaviorset)
         {
         qDebug("OMADM servers view back behavior setting");
@@ -396,11 +424,12 @@
         setNavigationAction(backaction);
         backbehaviorset = true;
         }
-    qDebug("OMADM servers view back behavior setting done");
+    qDebug("OMADM servers view back behavior setting done setBackBehavior >>");
     }
 
 void DmAdvancedView::backButtonClicked()
     {    
+    qDebug("OMADM servers view DmAdvancedView::backButtonClicked <<");
     QList <HbView*> views = iMainWindow->views();    
     if(iMainWindow->orientation()==Qt::Vertical)
             {
@@ -410,151 +439,374 @@
             {
             iMainWindow->setCurrentView(views[1]);
             }    
+    qDebug("OMADM servers view DmAdvancedView::backButtonClicked >>");
     }
 
-
-void DmAdvancedView::mainCalltoUpdateView()
-{   
-    int IndicatorCount =6;
-    otherdetailsmodel = new QStandardItemModel();
-    TInt i=0;
-    TRequestStatus status;
+void DmAdvancedView::addVersionInfo()
+    {
+    qDebug("OMADM servers view DmAdvancedView::addVersionInfo <<");
     QStringList liststr;
     QStandardItem* item;
     QString val;
     QString str;
-    
-    iServer.Connect();
-    iServer.GetPhoneInfo(0, info);
-    imobPhone.Open(iServer, info.iName);
-    //Bands supported
-    
-    RMobilePhone::TMobilePhoneNetworkInfoV1 nwInfov1;
-    RMobilePhone::TMobilePhoneNetworkInfoV1Pckg nwInfov1Pckg(nwInfov1);						
-    imobPhone.GetCurrentNetwork(status, nwInfov1Pckg);
-    User::WaitForRequest( status );
-    status = KRequestPending;
-    nwInfov1 = nwInfov1Pckg();
-    NetworkBand(nwInfov1.iBandInfo, str);
-    item = new QStandardItem();
-    val = hbTrId("txt_device_update_dblist_gsm_bands");
-    liststr << val;
-    liststr << str;
-    item->setData(liststr , Qt::DisplayRole);
-    otherdetailsmodel->setItem(i++, item);
-    
-    //Packet Service
-    
-    TInt packetsrvc =0;
-    RMobilePhone::TMobilePhoneNetworkInfoV5 nwInfov5;
-    RMobilePhone::TMobilePhoneNetworkInfoV5Pckg nwInfov5Pckg(nwInfov5);
-    imobPhone.GetCurrentNetwork( status, nwInfov5Pckg );
-    User::WaitForRequest( status );
-    status = KRequestPending;
-    nwInfov5 = nwInfov5Pckg();
-    
-    if(nwInfov5.iHsdpaAvailableIndicator) packetsrvc =1;
-    
-    if(nwInfov5.iEgprsAvailableIndicator) packetsrvc =2;
-    
-    if(!packetsrvc)
+    TInt runtimesupport(0);
+        CRepository* cenrep = NULL;
+        TRAPD( error, cenrep = CRepository::NewL( KCRUidNSmlDMSyncApp ) );  
+        if(error)
+           {     
+           FLOG( "[OMADM] CNSmlDMFotaContainer::FormatListboxL() cenrep problem" );
+           }    
+        if ( cenrep )
+           {
+           cenrep->Get( KNsmlDmRuntimeVerSupport, runtimesupport );
+           delete cenrep; cenrep = NULL;
+           }
+        //Browser version
+        Swi::RSisRegistrySession sisses ;
+        TInt r( sisses.Connect() );
+        CleanupClosePushL( sisses );
+        if (r== KErrNone && runtimesupport)
+            {           
+             Swi::RSisRegistryEntry sientry;
+             TInt oerr = sientry.Open(sisses, browseruid);
+             TVersion bversion;
+             TBuf <255> browserversion;
+             if(oerr == KErrNone)
+                 {
+                 TRAPD(err2,bversion= sientry.VersionL());     
+                 if (err2 == KErrNone)
+                     {
+                     browserversion.AppendNum(bversion.iMajor);
+                     browserversion.Append(_L("."));
+                     browserversion.AppendNum(bversion.iMinor);
+                     if( browserversion.Length()>0 )
+                         {                                
+                         str = QString::fromUtf16(browserversion.Ptr(), browserversion.Length());
+                         item = new QStandardItem();
+                         val = hbTrId("txt_device_update_dblist_browser_version");
+                         liststr.clear();
+                         liststr << val;
+                         liststr << str;
+                         item->setData(liststr , Qt::DisplayRole);
+                         //m_otherdetailsmodel->setItem(i++, item);
+                         m_otherdetailsmodel->appendRow(item);
+                         }
+                     }
+                 }
+            }
+        
+        //flash version
+        if (r== KErrNone&& runtimesupport)
+            {           
+              Swi::RSisRegistryEntry sientry;
+              TInt oerr = sientry.Open(sisses, flashuid);
+              TVersion fversion;
+              TBuf <255> flashversion;
+              if(oerr == KErrNone)
+                  {
+                  TRAPD(err2,fversion= sientry.VersionL());         
+                  if (err2 == KErrNone)
+                      {
+                      flashversion.AppendNum(fversion.iMajor);
+                      flashversion.Append(_L("."));
+                      flashversion.AppendNum(fversion.iMinor); 
+                      if( flashversion.Length()>0 )
+                          {                               
+                          str = QString::fromUtf16(flashversion.Ptr(), flashversion.Length());
+                          item = new QStandardItem();
+                          val = hbTrId("txt_device_update_dblist_flash_version");
+                          liststr.clear();
+                          liststr << val;
+                          liststr << str;
+                          item->setData(liststr , Qt::DisplayRole);
+                          //m_otherdetailsmodel->setItem(i++, item);
+                          m_otherdetailsmodel->appendRow(item);
+                          }                                   
+                      }      
+                  }
+            }
+               
+         if (r== KErrNone&& runtimesupport)
+             {            
+              Swi::RSisRegistryEntry sientry;
+              TInt oerr = sientry.Open(sisses, javauid);
+              TVersion jversion;
+              TBuf <255> javaversion;
+              if(oerr == KErrNone)
+                  {       
+                  TRAPD(err2,jversion= sientry.VersionL());     
+                  if (err2 == KErrNone)
+                      {
+                      javaversion.AppendNum(jversion.iMajor);
+                      javaversion.Append(_L("."));
+                      javaversion.AppendNum(jversion.iMinor);  
+                      if( javaversion.Length()>0 )
+                          { 
+                          str = QString::fromUtf16(javaversion.Ptr(), javaversion.Length());
+                          item = new QStandardItem();
+                          val = hbTrId("txt_device_update_dblist_java_version");
+                          liststr.clear();
+                          liststr << val;
+                          liststr << str;
+                          item->setData(liststr , Qt::DisplayRole);
+                          m_otherdetailsmodel->appendRow(item);
+                          } 
+                      }            
+                  }            
+             } 
+        CleanupStack::PopAndDestroy(1);
+        qDebug("OMADM servers view DmAdvancedView::addVersionInfo >>");
+    }
+
+void DmAdvancedView::addOtherDetails()
     {
-        RMobilePhone::TMobilePhoneNetworkInfoV8 nwInfov8;
-        RMobilePhone::TMobilePhoneNetworkInfoV8Pckg nwInfov8Pckg(nwInfov8);
-        imobPhone.GetCurrentNetwork( status, nwInfov8Pckg );
+        qDebug("OMADM servers view DmAdvancedView::addOtherDetails >>");
+        TRequestStatus status;
+        QStringList liststr;
+        QStandardItem* item;
+        QString val;
+        QString str;
+        TInt error(iServer.Connect());
+        if ( error != KErrNone )
+        	return;
+        iServer.GetPhoneInfo(0, info);
+        error = imobPhone.Open(iServer, info.iName);
+        if ( error != KErrNone )
+        {
+        	iServer.Close();
+        	return;
+        }
+        //Bands supported
+        
+        RMobilePhone::TMobilePhoneNetworkInfoV1 nwInfov1;
+        RMobilePhone::TMobilePhoneNetworkInfoV1Pckg nwInfov1Pckg(nwInfov1);                     
+        imobPhone.GetCurrentNetwork(status, nwInfov1Pckg);
+        User::WaitForRequest( status );
+        status = KRequestPending;
+        nwInfov1 = nwInfov1Pckg();
+        NetworkBand(nwInfov1.iBandInfo, str);
+        item = new QStandardItem();
+        val = hbTrId("txt_device_update_dblist_gsm_bands");
+        liststr.clear();
+        liststr << val;
+        liststr << str;
+        item->setData(liststr , Qt::DisplayRole);
+        m_otherdetailsmodel->appendRow(item);
+        
+        //Packet Service
+        
+        TInt packetsrvc =0;
+        RMobilePhone::TMobilePhoneNetworkInfoV5 nwInfov5;
+        RMobilePhone::TMobilePhoneNetworkInfoV5Pckg nwInfov5Pckg(nwInfov5);
+        imobPhone.GetCurrentNetwork( status, nwInfov5Pckg );
         User::WaitForRequest( status );
         status = KRequestPending;
-        nwInfov8 = nwInfov8Pckg();
-        if(nwInfov8.iHsupaAvailableIndicator) packetsrvc =3;
-    }	  
-    liststr.clear();
-    val = hbTrId("txt_device_update_dblist_wcdma_uldl_data_rates");
-    liststr << val;
-    item = new QStandardItem();
-    PacketService(packetsrvc, str);
-    liststr << str;
-    item->setData(liststr , Qt::DisplayRole);
-    otherdetailsmodel->setItem(i++, item);
-				
-    // Ciphering
-    
-    liststr.clear();
-    item = new QStandardItem();
-    val = hbTrId("txt_device_update_dblist_gsm_cipherings");
-    liststr << val;
-    imobPhone.GetNetworkSecurityLevel(status,idispSecurity);
-    User::WaitForRequest( status );
-    NetworkCiphering(idispSecurity, str);
-    liststr << str;
-    item->setData(liststr, Qt::DisplayRole);
-    otherdetailsmodel->setItem(i++, item);
-    
-    // WLAN MAC
-    
-    TUint KPhoneWlanSeparator (':');
-    _LIT( KWLanMACDataFormat, "%02x");  
-    // Fetch WLAN MAC address
-    TBuf<KWlanMacAddrLength> address;
-    RProperty::Get( KPSUidWlan, KPSWlanMacAddress, address );   
-    // Format fetched address
-    TBuf<KWlanMacAddrLength> wlanMACAddress;        
-    for ( TInt i( 0 ); i < address.Length(); i++ )
+        nwInfov5 = nwInfov5Pckg();
+        
+        if(nwInfov5.iHsdpaAvailableIndicator) packetsrvc =1;
+        
+        if(nwInfov5.iEgprsAvailableIndicator) packetsrvc =2;
+        
+        if(!packetsrvc)
         {
-        // Set separator
-        if( i > 0 )
+            RMobilePhone::TMobilePhoneNetworkInfoV8 nwInfov8;
+            RMobilePhone::TMobilePhoneNetworkInfoV8Pckg nwInfov8Pckg(nwInfov8);
+            imobPhone.GetCurrentNetwork( status, nwInfov8Pckg );
+            User::WaitForRequest( status );
+            status = KRequestPending;
+            nwInfov8 = nwInfov8Pckg();
+            if(nwInfov8.iHsupaAvailableIndicator) packetsrvc =3;
+        }     
+        liststr.clear();
+        val = hbTrId("txt_device_update_dblist_wcdma_uldl_data_rates");
+        liststr << val;
+        item = new QStandardItem();
+        PacketService(packetsrvc, str);
+        liststr << str;
+        item->setData(liststr , Qt::DisplayRole);
+        m_otherdetailsmodel->appendRow(item);
+                    
+        // Ciphering
+        
+        liststr.clear();
+        item = new QStandardItem();
+        val = hbTrId("txt_device_update_dblist_gsm_cipherings");
+        liststr << val;
+        imobPhone.GetNetworkSecurityLevel(status,idispSecurity);
+        User::WaitForRequest( status );
+        NetworkCiphering(idispSecurity, str);
+        liststr << str;
+        item->setData(liststr, Qt::DisplayRole);
+        m_otherdetailsmodel->appendRow(item);
+        
+        // WLAN MAC
+        
+        TUint KPhoneWlanSeparator (':');
+        _LIT( KWLanMACDataFormat, "%02x");  
+        // Fetch WLAN MAC address
+        TBuf<KWlanMacAddrLength> address;
+        RProperty::Get( KPSUidWlan, KPSWlanMacAddress, address );   
+        // Format fetched address
+        TBuf<KWlanMacAddrLength> wlanMACAddress;        
+        for ( TInt i( 0 ); i < address.Length(); i++ )
             {
-            wlanMACAddress.Append( KPhoneWlanSeparator );
+            // Set separator
+            if( i > 0 )
+                {
+                wlanMACAddress.Append( KPhoneWlanSeparator );
+                }
+            // Set data
+            TBuf<50> tmp;
+            tmp.Format( KWLanMACDataFormat, address[i] );
+            wlanMACAddress.Append( tmp );
+            } 
+        liststr.clear();
+        item = new QStandardItem();
+        val = hbTrId("txt_device_update_dblist_wlan_mac_address");
+        liststr << val;
+        str = QString::fromUtf16(wlanMACAddress.Ptr(), wlanMACAddress.Length());
+        liststr << str;
+        item->setData(liststr, Qt::DisplayRole);
+        m_otherdetailsmodel->appendRow(item);
+          
+        // BT MAC
+          
+        TBuf<KBTAddrLength> addressBuffer;
+        // Fetch from Cenrep
+        CRepository* repository = NULL;
+        TRAPD( err, repository = CRepository::NewL( KCRUidBluetoothLocalDeviceAddress ) );
+        if ( err == KErrNone )
+            {
+            qDebug("KCRUidBluetoothLocalDeviceAddress errnone");
+            err = repository->Get( KBTLocalDeviceAddress, addressBuffer );
+            
+            if (err == KErrNone)
+                qDebug("KBTLocalDeviceAddress errnone");
+            else
+                qDebug("KBTLocalDeviceAddress Error");
+                
+            delete repository;
+            }
+        else
+            {
+                qDebug("KCRUidBluetoothLocalDeviceAddress Error openin cenrep");
             }
-        // Set data
-        TBuf<50> tmp;
-        tmp.Format( KWLanMACDataFormat, address[i] );
-        wlanMACAddress.Append( tmp );
-        } 
-    liststr.clear();
-    item = new QStandardItem();
-    val = hbTrId("txt_device_update_dblist_wlan_mac_address");
-    liststr << val;
-    str = QString::fromUtf16(wlanMACAddress.Ptr(), wlanMACAddress.Length());
-    liststr << str;
-    item->setData(liststr, Qt::DisplayRole);
-    otherdetailsmodel->setItem(i++, item);
-      
-    // BT MAC
-      
-    TBuf<KBTAddrLength> addressBuffer;
-    // Fetch from Cenrep
-    CRepository* repository = NULL;
-    TRAPD( err, repository = CRepository::NewL( KCRUidBluetoothLocalDeviceAddress ) );
-    if ( err == KErrNone )
+        liststr.clear();
+        val = hbTrId("txt_device_update_dblist_bt_mac_address");
+        liststr << val;
+        item = new QStandardItem();
+        str = QString::fromUtf16(addressBuffer.Ptr(), addressBuffer.Length());
+        liststr << str;
+        item->setData(liststr , Qt::DisplayRole);
+        m_otherdetailsmodel->appendRow(item);
+        
+        imobPhone.Close();
+        iServer.Close();
+
+    }
+void DmAdvancedView::mainCalltoUpdateView()
+{   
+    qDebug("OMADM servers view DmAdvancedView::mainCalltoUpdateView >>");
+    m_otherdetailsmodel = new QStandardItemModel();
+    TInt i=0;
+    
+    QStringList liststr;
+    QStandardItem* item;
+    QString val;
+    QString str;
+    //1. Device Updated
+
+    
+    addVersionInfo();
+    
+    addOtherDetails();
+
+    //sw version date
+    TBuf< KSysUtilVersionTextLength > swversiondate;
+    TBuf< KSysUtilVersionTextLength > version;
+    version.Zero();
+    swversiondate.Zero();
+    if( SysUtil::GetSWVersion(version)==KErrNone)
         {
-        qDebug("KCRUidBluetoothLocalDeviceAddress errnone");
-        err = repository->Get( KBTLocalDeviceAddress, addressBuffer );
-        
-        if (err == KErrNone)
-        	qDebug("KBTLocalDeviceAddress errnone");
-        else
-        	qDebug("KBTLocalDeviceAddress Error");
-        	
-        delete repository;
+        TInt len= version.Length();
+        TInt pos1 = version.Find(KSmlEOL);
+             if( pos1 != KErrNotFound && len > pos1 )
+                {
+                 TBuf<KSysUtilVersionTextLength> version1;
+                 version1.Zero();
+                 version1.Append( version.Right( len-pos1-1 ));
+                 len= version1.Length();
+                 pos1 = version1.Find(KSmlEOL);
+                 if( pos1 != KErrNotFound  && len > pos1 )
+                     {
+                     swversiondate.Append(version1.Left( pos1 ));
+                     }
+                }
+            val = hbTrId("txt_device_update_dblist_sw_version_date");
+            item = new QStandardItem();
+            str = QString::fromUtf16(swversiondate.Ptr(), swversiondate.Length());
+            liststr.clear();
+            liststr << val;
+            liststr << str;
+            item->setData(liststr , Qt::DisplayRole);
+            m_otherdetailsmodel->appendRow(item);
+            }
+            
+    //Custom version and date
+    //SysVersionInfo::TVersionInfoType x = SysVersionInfo::EOPVersion;
+    TBuf< KNSmlMaxTextLength64 >  customsw;
+    TBuf< KNSmlMaxTextLength64 >  customswdate;
+    version.Zero();
+    if( SysVersionInfo::GetVersionInfo(SysVersionInfo::EOPVersion,version) == KErrNone )
+      {
+         TInt len= version.Length();
+         TInt pos1 = version.Find(KSmlEOL);
+         if( pos1 != KErrNotFound  && len > pos1 )
+          {        
+          customsw.Append( version.Left(pos1));
+          customswdate.Append( version.Right( len-pos1-1 ));         
+          }
+      } 
+    
+    if(customsw.Length()>0)
+        {
+        str = QString::fromUtf16(customsw.Ptr(), customsw.Length());
+        item = new QStandardItem();
+        val = hbTrId("txt_device_update_dblist_custom_version");
+        liststr.clear();
+        liststr << val;
+        liststr << str;
+        item->setData(liststr , Qt::DisplayRole);
+        m_otherdetailsmodel->appendRow(item);
         }
-    else
-    	{
-    		qDebug("KCRUidBluetoothLocalDeviceAddress Error openin cenrep");
-    	}
-    liststr.clear();
-    val = hbTrId("txt_device_update_dblist_bt_mac_address");
-    liststr << val;
-    item = new QStandardItem();
-    str = QString::fromUtf16(addressBuffer.Ptr(), addressBuffer.Length());
-    liststr << str;
-    item->setData(liststr , Qt::DisplayRole);
-    otherdetailsmodel->setItem(i++, item);
-	
-	    
+    if(customswdate.Length()>0)
+        {
+        str = QString::fromUtf16(customswdate.Ptr(), customswdate.Length());
+        item = new QStandardItem();
+        val = hbTrId("txt_device_update_dblist_custom_version_date");
+        liststr.clear();
+        liststr << val;
+        liststr << str;
+        item->setData(liststr , Qt::DisplayRole);
+        m_otherdetailsmodel->appendRow(item);
+        }
+    
     TBuf<KSysUtilVersionTextLength> Langversion; 
     TBuf<KSysUtilVersionTextLength> lversion;
+    if( SysUtil::GetLangVersion(Langversion ) == KErrNone )
+      {
+        str = QString::fromUtf16(Langversion.Ptr(), Langversion.Length());
+        item = new QStandardItem();
+        val = hbTrId("txt_device_update_dblist_language_set");
+        liststr.clear();
+        liststr << val;
+        liststr << str;
+        item->setData(liststr , Qt::DisplayRole);
+        m_otherdetailsmodel->appendRow(item);
+      }
+    
 
-	    //lang variant version
+    //lang variant version
     Langversion.Zero();
     if( SysUtil::GetLangSWVersion(Langversion ) == KErrNone )
         {
@@ -572,15 +824,17 @@
          liststr << val;
          liststr << str;
          item->setData(liststr , Qt::DisplayRole);
-         otherdetailsmodel->appendRow(item);
+         m_otherdetailsmodel->appendRow(item);
         }
-    
-    otherdetailslist->setModel(otherdetailsmodel);
+     
+    otherdetailslist->setModel(m_otherdetailsmodel);
+    qDebug("OMADM servers view DmAdvancedView::mainCalltoUpdateView <<");
 		
 }
 
 void DmAdvancedView::PacketService(TInt val, QString& string)
     {
+    qDebug("OMADM servers view DmAdvancedView::PacketService >>");
      switch (val)
          {
          case (0):
@@ -603,11 +857,13 @@
                  string = hbTrId("txt_device_update_dblist_wcdma_uldl_data_val_l5");
                  break;
          }
+     qDebug("OMADM servers view DmAdvancedView::PacketService <<");
      }
 
 
 void DmAdvancedView::NetworkCiphering(RMobilePhone::TMobilePhoneNetworkSecurity val, QString& string)
     {
+    qDebug("OMADM servers view DmAdvancedView::NetworkCiphering >>");
      switch (val)
          {
          case (RMobilePhone::ECipheringGSM):
@@ -624,10 +880,12 @@
                  string = hbTrId("txt_device_update_dblist_gsm_cipherings_val_l1");
                  break;
          }
+     qDebug("OMADM servers view DmAdvancedView::NetworkCiphering <<");
     }
     
 void DmAdvancedView::NetworkBand(RMobilePhone::TMobilePhoneNetworkBandInfo val, QString& string)
     {
+    qDebug("OMADM servers view DmAdvancedView::NetworkBand >>");
     switch (val)
         {
         case (RMobilePhone::E800BandA):
@@ -662,25 +920,32 @@
                 string = hbTrId("txt_device_update_dblist_gsm_bands_val_l1");
                 break;
         }   
+    qDebug("OMADM servers view DmAdvancedView::NetworkBand <<");
     }
 
 void DmAdvancedView::syncCompleted(int jobstatus)
     {
+    qDebug("OMADM servers view DmAdvancedView::syncCompleted >>");
     Q_UNUSED(jobstatus);
     connectionRequested = false;    
     updateListview();
+    iMainView->enableButtons();
+    qDebug("OMADM servers view DmAdvancedView::syncCompleted <<");
     }
 	
 void DmAdvancedView::defaultMenuItemSelected()
     {
+    qDebug("OMADM servers view DmAdvancedView::defaultMenuItemSelected >>");
     dminfo->setDefaultProfile(currentselecteditem);
     updateEarlierdefaultProfileIcon();
     modelItem->setIcon(defaultprofileicon);
     currentdefaultprofile = currentselecteditem;
+    qDebug("OMADM servers view DmAdvancedView::defaultMenuItemSelected <<");
     }
 
 void DmAdvancedView::deleteMenuItemSelected()
     {
+    qDebug("OMADM servers view DmAdvancedView::deleteMenuItemSelected >>");
     dminfo->DisableDbNotifications(true);
     //check currentdefaultprofile is current item
     if(currentselecteditem == currentdefaultprofile) // deleting default profile
@@ -691,11 +956,16 @@
     model->removeRow(currentselecteditem);
         }
     dminfo->DisableDbNotifications(false);
+    qDebug("OMADM servers view DmAdvancedView::deleteMenuItemSelected <<");
     }
 
 void DmAdvancedView::connectMenuItemSelected()
     {
-    dminfo->synchronize(currentselecteditem);
+    qDebug("OMADM servers view DmAdvancedView::connectMenuItemSelected >>");
+    iMainView->displayNoteAndDisableButtons();
+    backButtonClicked();
+    dminfo->synchronize(currentselecteditem);    
     connectionRequested = true;
+    qDebug("OMADM servers view DmAdvancedView::connectMenuItemSelected <<");
     }
 	
--- a/deviceupdatesui/deviceupdates/src/dmfotaview.cpp	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/src/dmfotaview.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -30,6 +30,9 @@
 #include "nsmldmsyncprivatecrkeys.h"
 #include "dmadvancedview.h"
 #include "dmfotaview.h"
+#include <xqconversions.h>
+#include "deviceupdatemoniter.h"
+#include "DeviceUpdateDebug.h"
 // ============================ MEMBER FUNCTIONS ===============================
     
 // -----------------------------------------------------------------------------
@@ -37,10 +40,13 @@
 // -----------------------------------------------------------------------------
 //
 DMFotaView::DMFotaView(HbMainWindow *mainWindow):
-    mMainWindow(mainWindow),profilesView(NULL)
+    mMainWindow(mainWindow),profilesView(NULL),Connected(EFalse)
 {
+    qDebug("DMFotaView::DMFotaView >>");
     fotaPortraitView=0;
     fotaLandscapeView=0;
+    mainDmInfo=0;
+    qDebug("DMFotaView::DMFotaView <<");
 }
 
 // -----------------------------------------------------------------------------
@@ -49,7 +55,20 @@
 // -----------------------------------------------------------------------------
 //
 DMFotaView::~DMFotaView()
-{ 
+{
+    qDebug("DMFotaView::~DMFotaView >>");
+    if(mainDmInfo)
+        delete mainDmInfo;
+    
+    if (iFotaEngine.Handle())
+        iFotaEngine.Close();
+
+    if (iMoniter)
+        {
+        iMoniter->Cancel();
+        delete iMoniter;
+        }
+    qDebug("DMFotaView::~DMFotaView <<");
 }
 
 // -----------------------------------------------------------------------------
@@ -59,6 +78,7 @@
 //
 bool DMFotaView::addFotaView()
     {
+    qDebug("DMFotaView::addFotaView >>");
     connect( mMainWindow, SIGNAL( orientationChanged(Qt::Orientation) ), this, SLOT( readSection(Qt::Orientation) ) );
         
     bool ok = false;
@@ -107,12 +127,7 @@
     label->setPlainText(val);
     label2->setPlainText(val);
     
-    //Setting help text for update button
-    label = qobject_cast<HbLabel*> (loader.findWidget("p:updatelabel"));
-    label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:updatelabel"));
-    val = hbTrId("txt_device_update_setlabel_to_update_your_device_s");
-    label->setPlainText(val);
-    label2->setPlainText(val);
+    
     
     HbScrollArea* area = qobject_cast<HbScrollArea*> (loader.findWidget("scrollArea"));
     area->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOn);
@@ -203,10 +218,10 @@
     TBuf <50> imei;
     if (status==KErrNone)
     {
+    TBuf<100> phoneName;
     imei.Copy(telid.iSerialNumber);
     }
     phone.Close();
-    
     telServer.Close();
 
     //type
@@ -253,24 +268,83 @@
         FormatList(val,str);
         }
 
+   
+    iFotaState = FotaEngineL().GetState(-1);
     
-    val = hbTrId("txt_device_update_button_update");
-    HbPushButton *updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
-    updateButton->setText(val);
-    QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
-    updateButton = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
-    updateButton->setText(val);
-    QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
+    TBuf8<80> Name;
+    TBuf8<80> Version;
+    TInt Size;
+    
+    if(iFotaState == RFotaEngineSession::EDownloadComplete || iFotaState == RFotaEngineSession::EStartingUpdate
+            || iFotaState == RFotaEngineSession::EStartingDownload || iFotaState == RFotaEngineSession::EDownloadProgressing)
+        {
+        label = qobject_cast<HbLabel*> (loader.findWidget("p:updatelabel"));
+        label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:updatelabel"));
+        FotaEngineL().GetCurrentFirmwareDetailsL(Name, Version, Size);
+        
+        const QString
+        name =
+                QString::fromUtf8(
+                        reinterpret_cast<const char*> (Name.Ptr()),
+                                Name.Length());
+        const QString
+        ver =
+                QString::fromUtf8(
+                        reinterpret_cast<const char*> (Version.Ptr()),
+                                Version.Length());
+        
+        TInt sizeKB = Size / 1024;
+        if(sizeKB < 1024)
+            {
+            val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_kb").arg(name)
+                    .arg(ver).arg(sizeKB);
+            }
+        else
+            {
+            TInt sizeMB = sizeKB / 1024;
+            val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_mb").arg(name)
+                    .arg(ver).arg(sizeMB);
+            }
+        label->setPlainText(val);
+        label2->setPlainText(val);
+		
+		val = hbTrId("txt_device_update_button_resume_update");
+    
+        updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
+        updateButton->setText(val);
+        QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
+        updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
+        updateButtonLandscape->setText(val);
+		QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
+		Connected = ETrue;
+        }
+    else
+        {
+        //Setting help text for update button
+        label = qobject_cast<HbLabel*> (loader.findWidget("p:updatelabel"));
+        label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:updatelabel"));
+        val = hbTrId("txt_device_update_setlabel_to_update_your_device_s");
+        label->setPlainText(val);
+        label2->setPlainText(val);
+        
+        val = hbTrId("txt_device_update_button_update");
+        updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
+        updateButton->setText(val);
+        QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
+        updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
+        updateButtonLandscape->setText(val);
+        QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
+        Connected = ETrue;
+        }
     
     val = hbTrId("txt_device_update_button_advanced");
-    HbPushButton *advancedButton = qobject_cast<HbPushButton*>(loader.findWidget("p:advanced")); 
+    advancedButton = qobject_cast<HbPushButton*>(loader.findWidget("p:advanced")); 
     advancedButton->setText(val);
     QObject::connect(advancedButton, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
-    advancedButton = qobject_cast<HbPushButton*>(loader2.findWidget("l:advanced"));
-    advancedButton->setText(val);
-    QObject::connect(advancedButton, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
-
-    
+    advancedButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:advanced"));
+    advancedButtonLandscape->setText(val);
+    QObject::connect(advancedButtonLandscape, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
+    fotaSupportEnabled();
     mMainWindow->addView(fotaPortraitView);
     mMainWindow->addView(fotaLandscapeView);
     
@@ -278,6 +352,10 @@
             mMainWindow->setCurrentView(fotaPortraitView);
         else
             mMainWindow->setCurrentView(fotaLandscapeView);
+    
+    iMoniter = CDeviceUpdateMoniter::NewL(this);
+    //iMoniter->StartMoniter();
+    qDebug("DMFotaView::addFotaView <<");
     return ETrue;
     }
 
@@ -288,21 +366,23 @@
 //
 void DMFotaView::CheckforUpdate()
  {
-    /*TInt profileId=NULL;
+    qDebug("omadm DeviceManagerUi::CheckforUpdate >>");
+    
+    TInt profileId=NULL;
     if(mainDmInfo==0)
         {
         if(!profilesView)
             {
-            mainDmInfo = new DmInfo();
-            mainDmInfo->refreshProfileList();
+            bool launchview = false;
+            AdvancedDeviceManager(launchview);
+           /* mainDmInfo = new DmInfo();
+            mainDmInfo->refreshProfileList();*/
             }
-        else 
-            {
-            mainDmInfo = profilesView->dminfo;
-            }
+       // else 
+        mainDmInfo = profilesView->dminfo;      
         }
     if((profileId = mainDmInfo->DefaultFotaProfileIdL())==KErrNotFound)
-        {*/
+        {
 
         HbNotificationDialog* note = new HbNotificationDialog();
         QString val = hbTrId("txt_device_update_info_no_server_configured_to_get");
@@ -312,26 +392,94 @@
         note->setTimeout(HbPopup::StandardTimeout);
         note->setAttribute(Qt::WA_DeleteOnClose, true);
         note->open();
-       /* }
+        }
     else
         {
         mainDmInfo->sync(profileId);
-        }*/
+        //Connecting note to be displayed
+        //Buttons to be disabled
+        displayNoteAndDisableButtons();
+        
+        }
+    qDebug("omadm DeviceManagerUi::CheckforUpdate >>");
  }
 
+
+void DMFotaView::ResumeUpdate()
+    {
+    qDebug("omadm DeviceManagerUi::ResumeUpdate >>");
+    
+    
+    if(iFotaState == RFotaEngineSession::EDownloadComplete || iFotaState == RFotaEngineSession::EStartingUpdate)
+        {
+        qDebug("Calling resuming of update");
+        FotaEngineL().Update(-1,(TSmlProfileId)1, _L8(""), _L8(""));
+        }
+    else if(iFotaState == RFotaEngineSession::EStartingDownload || iFotaState == RFotaEngineSession::EDownloadProgressing)
+        {
+        qDebug("Calling resuming of download");
+        FotaEngineL().TryResumeDownload(EFalse);        
+        }
+    
+    qDebug("omadm DeviceManagerUi::ResumeUpdate <<");
+    }
+
+// -----------------------------------------------------------------------------
+// DMFotaView::displayNoteAndDisableButtons
+// Displays the connecting note and disable all buttons
+// -----------------------------------------------------------------------------
+//
+void DMFotaView::displayNoteAndDisableButtons()
+    {
+    qDebug("DMFotaView::displayNoteAndDisableButtons >>");
+    updateButton->setEnabled(false);
+    advancedButton->setEnabled(false);
+    updateButtonLandscape->setEnabled(false);
+    advancedButtonLandscape->setEnabled(false);
+    HbNotificationDialog* note = new HbNotificationDialog();
+    //QString val = hbTrId("txt_device_update_dpophead_device_update");
+    note->setTitle(hbTrId("txt_device_update_dpophead_device_update"));
+    note->setTitleTextWrapping(Hb::TextWordWrap);
+    note->setText(hbTrId("txt_device_update_info_connecting"));
+    HbIcon icon1;
+    icon1.setIconName(":/icons/qgn_prop_sml_http.svg");
+    note->setIcon(icon1);
+    note->setAttribute(Qt::WA_DeleteOnClose, true);
+    note->open();
+    qDebug("DMFotaView::displayNoteAndDisableButtons <<");
+    }
+
+// -----------------------------------------------------------------------------
+// DMFotaView::enableButtons
+// Enables checkupdate and Advancedsetting buttons
+// -----------------------------------------------------------------------------
+//
+void DMFotaView::enableButtons()
+    {
+    qDebug("DMFotaView::enableButtons >>");
+    TInt value (0);
+    RProperty::Get(TUid::Uid(KOmaDMAppUid), KFotaServerActive, value);
+    if (!value)
+        {
+        fotaSupportEnabled();
+        advancedButtonLandscape->setEnabled(true);
+        advancedButton->setEnabled(true);
+        }
+    qDebug("DMFotaView::enableButtons <<");
+    }
+
 // -----------------------------------------------------------------------------
 // DMFotaView::AdvancedDeviceManager
 // Displays the Profiles view
 // -----------------------------------------------------------------------------
 //
-void DMFotaView::AdvancedDeviceManager()
- {
-    
+void DMFotaView::AdvancedDeviceManager(bool launchadvanceview)
+ { 
     qDebug("omadm DeviceManagerUi::AdvancedDeviceManager");
     if(!profilesView)
         {
         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 1");
-        profilesView = new DmAdvancedView(mMainWindow,this);
+        profilesView = new DmAdvancedView(mMainWindow,this,mainDmInfo);
         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 2");
         bool loadingok = profilesView->displayItems();
         if(loadingok)
@@ -341,6 +489,7 @@
             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 4");
             profilesView->setBackBehavior();  
             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 5");
+            if(launchadvanceview)
             mMainWindow->setCurrentView(profilesView);
             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 6");
             }
@@ -355,6 +504,7 @@
         profilesView->setBackBehavior();                
         mMainWindow->setCurrentView(profilesView);   
         }
+    qDebug("DMFotaView::AdvancedDeviceManager <<");
  }
 
 // -----------------------------------------------------------------------------
@@ -364,6 +514,7 @@
 //
 void DMFotaView::FormatList(QString val,QString str)
     {
+    qDebug("DMFotaView::FormatList >>");
     label = qobject_cast<HbLabel*> (loader.findWidget(list1[i]));
     label2 = qobject_cast<HbLabel*> (loader2.findWidget(list2[i++]));         
     label3 = qobject_cast<HbLabel*> (loader.findWidget(list1[i]));
@@ -376,6 +527,17 @@
     label2->setVisible(ETrue);
     label3->setVisible(ETrue);
     label4->setVisible(ETrue);
+    qDebug("DMFotaView::FormatList <<");
+    }
+
+
+inline RFotaEngineSession & DMFotaView::FotaEngineL()
+    {
+    qDebug("DMFotaView::FotaEngineL >>");
+    if (!iFotaEngine.Handle())
+        iFotaEngine.OpenL();
+    qDebug("DMFotaView::FotaEngineL <<");
+    return iFotaEngine;
     }
 // -----------------------------------------------------------------------------
 // DMFotaView::backtoMainWindow
@@ -384,7 +546,9 @@
 //
 void DMFotaView::backtoMainWindow()
     {
+    qDebug("DMFotaView::backtoMainWindow >>");
         qApp->quit();
+        qDebug("DMFotaView::backtoMainWindow <<");
     }
 
 // -----------------------------------------------------------------------------
@@ -402,11 +566,14 @@
 //
 void DMFotaView::OnExit()
 {
+    qDebug("DMFotaView::OnExit >>");
     qApp->quit();
+    qDebug("DMFotaView::OnExit <<");
 }
 
 void DMFotaView::readSection( Qt::Orientation orientation )
 {
+    qDebug("DMFotaView::readSection >>");
     if(mMainWindow->currentView() == fotaPortraitView || mMainWindow->currentView() == fotaLandscapeView)
         {
         if( orientation == Qt::Vertical ) {
@@ -422,8 +589,122 @@
         {
         profilesView->reLayout(orientation);
         }
+    qDebug("DMFotaView::readSection <<");
 
 }   
 
 
+void DMFotaView::UpdateDMUI(TBool aVal)
+    {
+    qDebug("DMFotaView::UpdateDMUI >>");
+    qDebug("DMFotaView::UpdateDMUI >>");
+	    QString val;
+    if (aVal == 1)
+        {
+        qDebug("DMFotaView::aVal == 1 >>");
+        if(Connected)
+            {
+            qDebug("DMFotaView::Connected >>");
+            QObject::disconnect(updateButton,0,0,0);
+            QObject::disconnect(updateButtonLandscape,0,0,0);
+            Connected = EFalse;
+            }
+    
+        iFotaState = FotaEngineL().GetState(-1);
 
+        if (iFotaState == RFotaEngineSession::EDownloadComplete || iFotaState
+                == RFotaEngineSession::EStartingUpdate || iFotaState
+                == RFotaEngineSession::EStartingDownload || iFotaState
+                == RFotaEngineSession::EDownloadProgressing)
+            {
+            qDebug("CDeviceUpdateMoniter::Resume >>");
+            QString value = hbTrId("txt_device_update_button_resume_update");
+            //updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update");
+            updateButton->setText(value);
+            QObject::connect(updateButton, SIGNAL(clicked()), this,SLOT(ResumeUpdate()));
+            //updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update");
+            updateButtonLandscape->setText(value);
+		QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
+		Connected = ETrue;
+
+		TBuf8<80> Name;
+		TBuf8<80> Version;
+		TInt Size;
+
+		FotaEngineL().GetCurrentFirmwareDetailsL(Name, Version, Size);
+        
+        	const QString
+	        name =
+        	        QString::fromUtf8(
+	                        reinterpret_cast<const char*> (Name.Ptr()),
+                                Name.Length());
+	        const QString
+	        ver =
+        		QString::fromUtf8(
+                        reinterpret_cast<const char*> (Version.Ptr()),
+                                Version.Length());
+        
+        	TInt sizeKB = Size / 1024;
+	        if(sizeKB < 1024)
+	            {
+	            val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_kb").arg(name)
+	                    .arg(ver).arg(sizeKB);
+	            }
+	        else
+	            {
+	            TInt sizeMB = sizeKB / 1024;
+	            val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_mb").arg(name)
+        	            .arg(ver).arg(sizeMB);
+	            }
+	        
+	        label->setPlainText(val);
+	        label2->setPlainText(val);
+	    }
+        else
+	    {
+        qDebug("DMFotaView::Update >>");
+        val = hbTrId("txt_device_update_setlabel_to_update_your_device_s");
+	    label->setPlainText(val);
+	    label2->setPlainText(val);
+	    val = hbTrId("txt_device_update_button_update");
+	    updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
+	    updateButton->setText(val);
+	    QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
+	    updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
+	    updateButtonLandscape->setText(val);
+	    QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
+	    Connected = ETrue;
+	    }
+	}
+    fotaSupportEnabled();
+    if(fotaValue == 1 && aVal == 0)
+    {
+    	updateButton->setEnabled(aVal);
+      updateButtonLandscape->setEnabled(aVal);
+    }
+    advancedButton->setEnabled(aVal);
+    advancedButtonLandscape->setEnabled(aVal);
+    qDebug("DMFotaView::UpdateDMUI <<");
+    qDebug("DMFotaView::UpdateDMUI <<");
+}
+
+void DMFotaView::fotaSupportEnabled()
+    { 
+    fotaValue = 1;	
+    CRepository* centrep( NULL);
+    TUid uidValue = {0x101F9A08}; // KCRFotaAdapterEnabled
+    TInt err = KErrNone;
+    TRAP(err,centrep = CRepository::NewL( uidValue)); 
+    if(centrep && err == KErrNone )
+    {  
+        centrep->Get( 1 , fotaValue ); // KCRFotaAdapterEnabled     
+        delete centrep;
+    }
+    if(fotaValue == 0 || fotaValue == 1)
+        {
+        updateButton->setEnabled(fotaValue);
+        updateButtonLandscape->setEnabled(fotaValue);
+        }
+    }
+    
+
--- a/deviceupdatesui/deviceupdates/src/dminforetrieval.cpp	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/src/dminforetrieval.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -483,6 +483,15 @@
     if(error == KErrNone)   {}             
     }
 
+void DmInfo::sync(int aProfileId)
+    {
+    int itemNum = findProfile(aProfileId);
+    if(itemNum!=KErrNotFound)
+        {
+        synchronize(itemNum);
+        }
+    }
+
 void DmInfo::synccomplete(int jobstatus)
     {
     if (jobstatus == ENSmlSyncComplete)
@@ -491,7 +500,10 @@
         //Update profile list
         refreshProfileList();
         }
-    serversView->syncCompleted(jobstatus);
+    if(serversView!=NULL)
+        {
+        serversView->syncCompleted(jobstatus);
+        }
     iDbEventsBlocked = EFalse;
     }
 
@@ -543,3 +555,14 @@
     FLOG( "[OMADM] DmInfo::DisableDbNotifications() completed" );
     }
 
+TInt DmInfo::findProfile(TInt aProfileId)
+    {
+    for(TInt i=0;i<iProfileList->Count();i++)
+        {
+        if(iProfileList->At(i).iProfileId == aProfileId)
+            {
+            return i;
+            }
+        }
+    return KErrNotFound;
+    }
--- a/deviceupdatesui/deviceupdates/src/nsmldmsynchandler.cpp	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/src/nsmldmsynchandler.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -29,6 +29,7 @@
 #include "nsmldmsynchandler.h"
 #include "nsmldmsyncdebug.h"
 #include "nsmldmsyncinternalpskeys.h"
+#include "nsmldmsyncprivatecrkeys.h"
 
 // -----------------------------------------------------------------------------
 // CNSmlDMSyncHandler::NewL
@@ -64,6 +65,12 @@
 	    TRAP_IGNORE( iSyncJob.StopL() );
         iSyncJob.Close();
 	    }
+	if(iPrimaryAction)
+	    iPrimaryAction->deleteLater();
+	
+	if(iDialog)
+	    iDialog->deleteLater();
+	
 	  FeatureManager::UnInitializeLib();
 	FLOG( "CNSmlDMSyncHandler::~CNSmlDMSyncHandler() completed" );
     }
@@ -227,6 +234,53 @@
 	iSyncError = aError;    
     iCheckUpdate = EFalse;        	
 
+#ifndef NO_UPDATE 
+        CRepository* centrep = NULL;
+        TRAPD( err, centrep = CRepository::NewL( KCRUidNSmlDMSyncApp ) );
+	TInt profileId;
+	centrep->Get( KNSmlDMDefaultFotaProfileKey, profileId );
+	//FLOG( "CNSmlDMSyncHandler::SynchronizeCompletedL profileId = %d", profileId );
+	delete centrep;
+	if ( profileId ==  iProfileId )
+        {
+        
+	//FLOG( "CNSmlDMSyncHandler::SynchronizeCompletedL - connected witrh default profile ID" );
+        TInt configFlags( 0 );
+        //TInt SetGenValue(0);
+        TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ) );
+        if ( centrep )
+            {
+
+	  //  FLOG( "CNSmlDMSyncHandler::SynchronizeCompletedL Centrep is defined" );
+	       if( err == KErrNone )
+        	{
+	        centrep->Get( KDevManSessionType, configFlags );
+	    //	FLOG( "CNSmlDMSyncHandler::SynchronizeCompletedL DevManSessiontype = %d", configFlags );
+             	}
+	       centrep->Set( KDevManSessionType, 0 );
+	    	//FLOG( "CNSmlDMSyncHandler::SynchronizeCompletedL KDevManSessionType getting reset" );
+	        delete centrep;
+            } 
+        // configFlags=2 for FOTA Package not downloaded case ,1- successful download
+        if ( (aError == KErrNone) 
+        			&& configFlags == 2 )
+            {
+            //FLOG( "[OMADM]\t CNSmlDMSyncHandler::SynchronizeCompletedL(): No changes in FW Update states." );
+        iDialog = new HbDialog();
+        iDialog->setHeadingWidget(new HbLabel(hbTrId("txt_device_update_title_phone_uptodate")));
+        iDialog->setContentWidget(new HbLabel(hbTrId("txt_device_update_dpopinfo_your_phone_is_already_u")));
+        iPrimaryAction = new HbAction();
+        iPrimaryAction->setText(hbTrId("OK"));
+	    iDialog->setPrimaryAction(iPrimaryAction);
+	    iDialog->setTimeout(HbPopup::NoTimeout);
+	    iDialog->setDismissPolicy(HbPopup::NoDismiss);
+	    iDialog->show();
+            // show the dialog
+            }
+
+        }  
+#endif
+
 	iUseFotaProgressNote = EFalse;
     iSyncJob.Close();
     
--- a/deviceupdatesui/deviceupdates/src/serversettingsview.cpp	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/src/serversettingsview.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -31,6 +31,7 @@
     exit = viewspecificmenu->addAction(hbTrId("txt_common_menu_exit"));
     connect(exit, SIGNAL(triggered()), QCoreApplication::instance(), SLOT(quit()));    
     setMenu(viewspecificmenu);
+    iPort = 0;
     }
 ServerSettingsView::~ServerSettingsView()
     {
@@ -86,8 +87,10 @@
         else
             accesspoint->setContentWidgetData(QString("currentIndex"), apdata.count()-1); 
         form->addConnection(accesspoint, SIGNAL(currentIndexChanged  (int  ) ),this, SLOT(accessPointItemChanged(int)));                
-        hostaddress->setContentWidgetData(QString("text"),settingdatalist[3]);        
-        port->setContentWidgetData(QString("text"),portnum);//Integer only setting needs to be done                   
+        hostaddress->setContentWidgetData(QString("text"),settingdatalist[3]);  
+        iPort = portnum;
+        port->setContentWidgetData(QString("text"),iPort);//Integer only setting needs to be done    
+        form->addConnection(port, SIGNAL(textChanged  (QString) ),this, SLOT(portItemChanged(QString)));
         username->setContentWidgetData(QString("text"),settingdatalist[4]);        
         userpwd->setContentWidgetData(QString("echoMode"),HbLineEdit::Password );
         userpwd->setContentWidgetData(QString("text"),settingdatalist[5]);                
@@ -147,13 +150,11 @@
     if ((itemlist[0].length() > 0) && (itemlist[1].length() > 0)
             && (itemlist[3].length() > 0) && (itemlist[4].length() > 0))
         {
-        serversView->saveProfile(itemlist, sessmode, curriap, portval,
-                netauthval);
-        qDebug("omadm before crash");
+        serversView->saveProfile(itemlist, sessmode, curriap, iPort,
+                netauthval);        
         form->removeConnection(accesspoint,
                 SIGNAL(currentIndexChanged (int ) ), this,
-                SLOT(accessPointItemChanged(int)));
-        qDebug("omadm after crash");
+                SLOT(accessPointItemChanged(int)));        
         iMainWindow->setCurrentView(serversView);
         //Form wk08 soft key owned by view
         //iMainWindow->removeSoftKeyAction(Hb::SecondarySoftKey,backaction);
@@ -161,12 +162,35 @@
         }
     else
         {
+        TInt x = itemlist.count();
+        TInt valSet=0;
+        int i=0;
+        for(i=0;i<x;i++)
+            {
+            if(itemlist[i].length()>0)
+                {
+                valSet=1;
+                break;
+                }
+            }
+        if(valSet==1)
+            {
         HbMessageBox *note = new HbMessageBox(HbMessageBox::MessageTypeInformation);
         note->setText(hbTrId(
                 "txt_device_update_dialog_enter_mandatory_field_values"));
         note->setAttribute( Qt::WA_DeleteOnClose);         
         note->setTimeout(HbPopup::NoTimeout);
         note->open();
+            }
+        else
+            {
+            form->removeConnection(accesspoint,SIGNAL(currentIndexChanged (int ) ), this,SLOT(accessPointItemChanged(int)));
+            iMainWindow->setCurrentView(serversView);
+        //Form wk08 soft key owned by view
+        //iMainWindow->removeSoftKeyAction(Hb::SecondarySoftKey,backaction);
+            dataformmodel->clear();   
+            }
+        
         }        
     }
 
@@ -251,3 +275,8 @@
     qDebug("omadm iap changed");        
     }
 
+void ServerSettingsView::portItemChanged(QString port)
+    {    
+    iPort = port.toInt();
+    qDebug("omadm new port value is %d ",iPort);
+    }
--- a/deviceupdatesui/deviceupdates/src/settingsdataformcustomitem.cpp	Tue Jul 13 03:51:25 2010 +0530
+++ b/deviceupdatesui/deviceupdates/src/settingsdataformcustomitem.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -22,9 +22,11 @@
 #include <hbinputeditorinterface.h>
 #include <qgraphicslinearlayout.h>
 #include <hblabel.h>
+#include <hbabstractitemview.h>
+#include <hbdataformmodel.h>
 
 SettingsDataFormCustomItem::SettingsDataFormCustomItem(QGraphicsItem *parent) :
-HbDataFormViewItem(parent)
+HbDataFormViewItem(parent),mLineEdit(NULL)
 {
 }
 
@@ -45,9 +47,8 @@
     switch (itemType)
     {
       case HbDataFormModelItem::CustomItemBase :
-            {             
-            HbLineEdit* mLineEdit = new HbLineEdit();
-            mLineEdit->setText(QString("8080"));
+            {            
+            mLineEdit = new HbLineEdit();            
             HbEditorInterface editorInterface(mLineEdit);
             editorInterface.setMode(HbInputModeNumeric); 
             editorInterface.setInputConstraints(HbEditorConstraintFixedInputMode);            
@@ -63,3 +64,18 @@
      int itemType = aIndex.data(HbDataFormModelItem::ItemTypeRole).toInt();
      return itemType == HbDataFormModelItem::CustomItemBase;
  }
+
+ void SettingsDataFormCustomItem::restore()
+  {  
+     HbDataFormViewItem::restore();    
+     HbDataFormModelItem::DataItemType itemType = static_cast<HbDataFormModelItem::DataItemType>(
+         modelIndex().data(HbDataFormModelItem::ItemTypeRole).toInt());
+     if( itemType == HbDataFormModelItem::CustomItemBase  ) {
+         QModelIndex itemIndex = modelIndex();
+         HbDataFormModelItem *modelItem = static_cast<HbDataFormModelItem*>(
+         static_cast<HbDataFormModel*>(itemView()->model())->itemFromIndex(itemIndex));
+         QString port = modelItem->contentWidgetData("text").toString();         
+         qDebug("port is %d",port.toInt());        
+         mLineEdit->setText(port);        
+     }     
+ }
--- a/group/bld.inf	Tue Jul 13 03:51:25 2010 +0530
+++ b/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -25,3 +25,12 @@
 
 //omadmadapters
 #include "../omadmadapters/bld/bld.inf"
+
+//omadcmoadapters
+#include "../omadcmoadapters/group/bld.inf"
+
+//omacpadapters
+#include "../omacpadapters/bld/bld.inf"
+
+//application management
+#include "../applicationmanagement/group/bld.inf"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/MbxNbrAdapter/Data/10207281.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 1020 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM DLL interface & implementation description resource for
+*                this DLL.
+*
+*/
+
+
+//  INCLUDES
+#include <registryinfo.rh>
+
+#include "ProvisioningUIDs.h"
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// theInfo
+// ECOM DLL interface & implementation description resource.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid = 0x10207281;
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = KProvisioningAdapterInterface;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x10207282;
+                    version_no = 1;
+                    display_name = "WAP Mbx Nbr PA"; // Use short name to save RAM and ROM space
+                    default_data = "";
+                    opaque_data = "10"; // Adapter priority
+                    }
+                };
+            }
+        };
+    }
+            
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/MbxNbrAdapter/Data/WPMbxNbrAdapterResource.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,35 @@
+/*
+* 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:  Resource file.
+*
+*/
+
+
+//  INCLUDES
+#include    <badef.rh>
+#include    <mailboxadapter.loc>
+
+//  RESOURCE DEFINITIONS
+// -----------------------------------------------------------------------------
+//
+// Mailbox number adapter title resource.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE LBUF r_mailbox_number_adapter_title
+	{
+	txt = qtn_op_head_mailbox;
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/MbxNbrAdapter/Group/MbxNbrAdapter.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2002-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:  Project definition file for mailbox number settings adapter.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+#include <data_caging_paths.hrh>
+
+TARGET          wpmbxnbradapter.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x10207281
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_ECOM_PLUGIN
+
+SOURCEPATH      ../Src
+SOURCE          MbxNbrAdapter.cpp
+SOURCE          MbxNbrAdapterGroupProxy.cpp
+
+SOURCEPATH      ../Data
+
+START RESOURCE 10207281.rss
+TARGET wpmbxnbradapter.rsc
+END
+
+START RESOURCE WPMbxNbrAdapterResource.rss
+HEADER
+TARGET wpmbxnbradapterresource.rsc
+TARGETPATH RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+USERINCLUDE     .
+USERINCLUDE     ../Inc
+USERINCLUDE     ../../bld
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom
+
+LIBRARY         euser.lib
+LIBRARY         provisioningengine.lib
+LIBRARY         commonengine.lib
+LIBRARY       vmbxengine
+LIBRARY 				centralrepository.lib
+DEBUGLIBRARY    flogger.lib
+
+
+SMPSAFE
+//end of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/MbxNbrAdapter/Group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,2 @@
+PRJ_MMPFILES
+MbxNbrAdapter.mmp
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/MbxNbrAdapter/Inc/MbxNbrAdapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,177 @@
+/*
+* 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:  Handles mailbox number settings in OMA provisioning.
+*
+*/
+
+
+#ifndef MbxNbrAdapter_H
+#define MbxNbrAdapter_H
+
+// INCLUDES
+
+#include    <CWPAdapter.h>
+
+// FORWARD DECLARATIONS
+//struct TMbxNbrAdapterData;
+
+
+// MODULE DATA STRUCTURES
+    
+// ENUMERATIONS
+
+
+// CLASS DECLARATION
+
+/**
+ * CMbxNbrAdapter handles accesspoint settings.
+ */ 
+class CMbxNbrAdapter : public CWPAdapter
+    {
+    private:    // ENUMERATIONS
+    
+        enum TMailboxType
+            {
+            ECSVoiceMailbox = 1,    // Default if type is not received in XML
+            ECSVideoMailbox
+            };
+            
+    private:    // MODULE DATA STRUCTURES
+    
+        struct TMbxNbrAdapterData
+            {
+            TPtrC iName;
+            TPtrC iMailboxNumber;
+            TBool iVidiosupport;
+            TBool iIsVideosupport;
+            TMailboxType iMailboxType;
+            };    
+                
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @return a instance of class.
+        */
+        static CMbxNbrAdapter* NewL();
+
+        /**
+        * Destructor
+        */
+        virtual ~CMbxNbrAdapter();
+
+    public: // Functions from base classes
+
+        /**
+        * From CWPAdapter
+        */
+        TInt ItemCount() const;
+
+        /**
+        * From CWPAdapter
+        */
+        const TDesC16& SummaryTitle( TInt aIndex ) const;
+
+        /**
+        * From CWPAdapter
+        */
+        const TDesC16& SummaryText( TInt aIndex ) const;
+
+        /**
+        * From CWPAdapter
+        */
+        TInt DetailsL( TInt aItem, MWPPairVisitor& aVisitor );
+
+        /**
+        * From CWPAdapter
+        */
+        void SaveL( TInt aItem );
+
+        /**
+        * From CWPAdapter
+        */
+        TBool CanSetAsDefault( TInt aItem ) const;
+
+        /**
+        * From CWPAdapter
+        */
+        void SetAsDefaultL( TInt aItem );
+
+        /**
+        * From CWPAdapter
+        */
+        void VisitL( CWPCharacteristic& aElement );
+
+        /**
+        * From CWPAdapter
+        */
+        void VisitL( CWPParameter& aElement );
+
+        /**
+        * From CWPAdapter
+        */
+        void VisitLinkL( CWPCharacteristic& aCharacteristic );
+
+    private:  // Default constructors
+
+        /**
+        * C++ default constructor.
+        */
+        CMbxNbrAdapter();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    private: // New functions
+
+        /**
+        * Validates the data in iTempData.
+        */
+        TBool IsValid();
+
+        /**
+        * Validates the phone number string.
+        */
+        TBool IsValidPhoneNumber( const TDesC& aPtr );
+
+        /**
+        * Parses an mailbox type from a descriptor.
+        */
+        void ParseMbxTypeL( const TDesC& aPtr, TMailboxType& aInt );
+
+        /**
+        * Parses an video ON/OFF type from a descriptor.
+        */
+
+        void ParseVideoTypeL( const TDesC& aPtr, TBool& aInt, TBool& aInt1 );
+
+    private: // Data
+
+        HBufC* iTitle;
+
+        TPtrC iAppId;
+        RArray<TMbxNbrAdapterData> iSettings;
+        TMbxNbrAdapterData iTempData;
+
+	private:
+		friend class T_CWPMbxNbrAdapter;
+	
+
+    };
+
+#endif  // MbxNbrAdapter_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/MbxNbrAdapter/Src/MbxNbrAdapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,397 @@
+/*
+* 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:  Handles mailbox number settings in OMA provisioning.
+*
+*/
+
+
+// INCLUDE FILES
+#include    <f32file.h>
+#include    <CWPCharacteristic.h>
+#include    <CWPParameter.h>
+#include    <wpmbxnbradapterresource.rsg>
+#include    <CVoiceMailBox.h>
+#include 		<cvoicemailboxentry.h>
+#include    <commonphoneparser.h>
+#include 	<voicemailboxdomaincrkeys.h>
+#include 	<centralrepository.h>
+
+#include    "WPAdapterUtil.h"
+#include    "MbxNbrAdapter.h"
+#include    "ProvisioningDebug.h"
+
+// CONSTANTS
+#if ( defined (__WINS__) || defined (__WINSCW) ) // this different on hw
+    _LIT( KAdapterName, "WPMbxNbrAdapterResource" );
+#else
+    _LIT( KAdapterName, "WPMbxNbrAdapter" );
+#endif
+_LIT( KMailboxNumberStr, "MBNMBR" );
+_LIT( KMailboxTypeStr, "MBTYPE" );
+_LIT( KCSVideoMailboxType, "VIDEO" );
+_LIT( KVideoSupportType, "VIDEO_MBOX_SUPPORT" );
+_LIT( KVideoSupportTypeTrue, "TRUE" );
+_LIT( KVideoSupportTypeFalse, "FALSE" );
+_LIT( KMailboxAppId, "w9027" );        // From OMA provisioning registration document
+const TInt KSettingsGranularity = 2;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::CMbxNbrAdapter
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CMbxNbrAdapter::CMbxNbrAdapter() : 
+    iSettings( KSettingsGranularity )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CMbxNbrAdapter::ConstructL()
+    {
+    FLOG( _L( "[Provisioning] CMbxNbrAdapter::ConstructL:" ) );
+    
+    TFileName fileName;
+    Dll::FileName( fileName );
+    iTitle = WPAdapterUtil::ReadHBufCL( fileName,
+                                        KAdapterName,
+                                        R_MAILBOX_NUMBER_ADAPTER_TITLE );
+                                        
+    FLOG( _L( "[Provisioning] CMbxNbrAdapter::ConstructL: Done" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CMbxNbrAdapter* CMbxNbrAdapter::NewL()
+    {
+    CMbxNbrAdapter* self = new( ELeave ) CMbxNbrAdapter; 
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::~CMbxNbrAdapter
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CMbxNbrAdapter::~CMbxNbrAdapter()
+    {
+    delete iTitle;
+    iSettings.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::ItemCount
+// -----------------------------------------------------------------------------
+//
+TInt CMbxNbrAdapter::ItemCount() const
+    {
+	// SummaryTitle(), SummaryText(), SaveL(), SetAsDefaultL() and 
+	// CanSetAsDefault() are called ItemCount() times
+	return iSettings.Count();
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::SummaryTitle
+// -----------------------------------------------------------------------------
+//
+const TDesC16& CMbxNbrAdapter::SummaryTitle( TInt /*aIndex*/ ) const
+    {
+    return *iTitle;
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::SummaryText
+// -----------------------------------------------------------------------------
+//
+const TDesC16& CMbxNbrAdapter::SummaryText( TInt aIndex ) const
+    {
+    // SummaryText should be called ItemCount() times
+    __ASSERT_DEBUG( iSettings.Count() > aIndex, 
+        User::Panic( _L("CMbxNbrAdapter::SummaryText"),  KErrCorrupt ) );
+    __ASSERT_DEBUG( aIndex >= 0, 
+        User::Panic( _L("CMbxNbrAdapter::SummaryText"),  KErrCorrupt ) );              
+    return iSettings[ aIndex ].iName;
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::DetailsL
+// -----------------------------------------------------------------------------
+//
+TInt CMbxNbrAdapter::DetailsL( TInt /*aItem*/, MWPPairVisitor& /*aVisitor*/ )
+    {
+    // Detail view is a feature for later release.
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::SaveL
+// -----------------------------------------------------------------------------
+//
+void CMbxNbrAdapter::SaveL( TInt aItem )
+    {
+    FLOG( _L( "[Provisioning] CMbxNbrAdapter::SaveL:" ) );
+    __ASSERT_DEBUG( iSettings.Count() > aItem, User::Leave( KErrCorrupt ) ); 
+    __ASSERT_DEBUG( aItem >= 0, User::Leave( KErrCorrupt ) ); 
+   
+    //RVmbxNumber model;
+    //User::LeaveIfError( model.Open() );
+    //CleanupClosePushL( model );  
+       
+    TInt err( KErrNone );    
+    switch( iSettings[aItem].iMailboxType )
+        {
+        case ECSVoiceMailbox:
+        		
+        		CVoiceMailbox* voiceModel = CVoiceMailbox::NewLC();
+    				CVoiceMailboxEntry* voiceEntry = CVoiceMailboxEntry::NewLC();
+        		voiceEntry->SetVoiceMailboxType(EVmbxVoice);
+        		voiceEntry->SetVmbxNumber(iSettings[aItem].iMailboxNumber);
+        		voiceModel->SaveProvisionedEntry(*voiceEntry);
+        		CleanupStack::PopAndDestroy(voiceEntry);
+        		CleanupStack::PopAndDestroy(voiceModel);	            
+            break;
+        case ECSVideoMailbox:
+        
+        		CVoiceMailbox* videoModel = CVoiceMailbox::NewLC();
+    				CVoiceMailboxEntry* videoEntry = CVoiceMailboxEntry::NewLC();        		
+            videoEntry->SetVoiceMailboxType(EVmbxVideo);
+            videoEntry->SetVmbxNumber(iSettings[aItem].iMailboxNumber);
+            videoModel->SaveProvisionedEntry(*videoEntry);
+            CleanupStack::PopAndDestroy(videoEntry);
+        		CleanupStack::PopAndDestroy(videoModel);
+        			
+            if ( iSettings[aItem].iIsVideosupport )
+            {
+            CRepository* cenrep = CRepository::NewL( KCRUidVideoMailbox );
+	        FLOG( _L( "[Provisioning] CMbxNbrAdapter::SaveL:case Saving it to Cenrep" ) );
+	        TBuf<100> buf1;
+	        buf1.AppendNum( iSettings[aItem].iVidiosupport );
+	        
+	        FLOG( buf1 );
+            CleanupStack::PushL(cenrep);
+			User::LeaveIfError(
+			cenrep->Set( KVideoMbxSupport, iSettings[aItem].iVidiosupport )); 
+			FLOG( _L( "[Provisioning] CMbxNbrAdapter::SaveL:case Saved" ) );
+			CleanupStack::PopAndDestroy(cenrep);
+            }
+            break;
+        default:
+            User::Leave( KErrCorrupt );
+            break;  
+        }
+
+    User::LeaveIfError( err );        
+    //CleanupStack::PopAndDestroy();  // Close model
+    
+    FLOG( _L( "[Provisioning] CStreamingAdapter::SaveL: Done" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::CanSetAsDefault
+// -----------------------------------------------------------------------------
+//
+TBool CMbxNbrAdapter::CanSetAsDefault( TInt /*aItem*/ ) const
+    {
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::SetAsDefault
+// -----------------------------------------------------------------------------
+//
+void CMbxNbrAdapter::SetAsDefaultL( TInt /*aItem*/ )
+    {
+    // This shouldn't be called because CanSetAsDefault
+    // always returns EFalse.
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::VisitL
+// -----------------------------------------------------------------------------
+//
+void CMbxNbrAdapter::VisitL( CWPCharacteristic& aCharacteristic )
+    {
+    switch( aCharacteristic.Type() )
+        {
+        case KWPApplication:
+            // Initialize iTempData's members
+            iTempData.iName.Set( KNullDesC );
+            iTempData.iMailboxNumber.Set( KNullDesC );
+            iTempData.iVidiosupport = EFalse;
+            iTempData.iIsVideosupport = EFalse;
+            iTempData.iMailboxType = ECSVoiceMailbox;
+
+            // Accept characteristic
+            aCharacteristic.AcceptL( *this );
+
+            // Check iAppId and validate data
+            if( iAppId == KMailboxAppId && IsValid() )
+                {
+                // iAppId is correct and data is valid
+                // -> Lets append it to array                
+                iSettings.Append( iTempData );
+                }
+            break;
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::VisitL
+// -----------------------------------------------------------------------------
+//
+void CMbxNbrAdapter::VisitL( CWPParameter& aParameter )
+    {   
+    switch( aParameter.ID() )
+        {
+        case EWPParameterAppID:
+            iAppId.Set( aParameter.Value() );
+            break;
+        case EWPParameterName:
+            iTempData.iName.Set( aParameter.Value() );
+            break;
+		case EWPNamedParameter:
+			{
+			if( aParameter.Name().Compare( KMailboxNumberStr ) == 0 )
+			    {
+			    iTempData.iMailboxNumber.Set( aParameter.Value() );
+			    }
+			else if( aParameter.Name().Compare( KMailboxTypeStr ) == 0 )
+			    {
+			    ParseMbxTypeL( aParameter.Value(), iTempData.iMailboxType );
+			    }
+			else if( aParameter.Name().Compare( KVideoSupportType ) == 0)
+				{
+			FLOG( _L( "[Provisioning] CMbxNbrAdapter::VisitL:Visiting to ParseVideoTypeL" ) );
+				ParseVideoTypeL( aParameter.Value(), iTempData.iVidiosupport, iTempData.iIsVideosupport );	
+			    }
+			break;
+			}
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::VisitLinkL
+// -----------------------------------------------------------------------------
+//
+void CMbxNbrAdapter::VisitLinkL( CWPCharacteristic& /*aCharacteristic*/ )
+    { 
+    }
+
+
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::IsValid
+// -----------------------------------------------------------------------------
+//
+TBool CMbxNbrAdapter::IsValid()
+    {
+    TBool validity( EFalse );
+    
+    // Validity check:
+    //  iMailboxType is either ECSVideoMailbox or ECSVoiceMailbox and
+    //  iMailboxNumber is valid number in e.164 format  
+    if( ( iTempData.iMailboxType == ECSVideoMailbox || 
+        iTempData.iMailboxType == ECSVoiceMailbox ) &&
+        IsValidPhoneNumber( iTempData.iMailboxNumber ) )
+        {
+        validity = ETrue;
+        }    
+        
+    return validity;
+    }
+    
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::IsValidPhoneNumber
+// -----------------------------------------------------------------------------
+//
+TBool CMbxNbrAdapter::IsValidPhoneNumber( const TDesC& aPtr ) 
+    {
+    return CommonPhoneParser::IsValidPhoneNumber( aPtr, 
+                                CommonPhoneParser::EPhoneClientNumber );
+    }       
+    
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::ParseMbxTypeL
+// -----------------------------------------------------------------------------
+//
+void CMbxNbrAdapter::ParseMbxTypeL( const TDesC& aPtr, TMailboxType& aType ) 
+    {
+    if( aPtr.Length() )
+        {
+        if( aPtr.Compare( KCSVideoMailboxType ) == 0 )
+            {
+            aType = ECSVideoMailbox;   
+            }
+        else
+            {
+            User::Leave( KErrNotSupported );
+            }
+        }
+    else
+        {
+        aType = ECSVoiceMailbox;
+        }
+    }
+// -----------------------------------------------------------------------------
+// CMbxNbrAdapter::ParseVideoTypeL
+// -----------------------------------------------------------------------------
+//
+void CMbxNbrAdapter::ParseVideoTypeL( const TDesC& aPtr, TBool& aType, TBool& aType1 ) 
+    {
+    FLOG( _L( "[Provisioning] CMbxNbrAdapter::ParseVideoTypeL:in" ) );
+    if( aPtr.Length() )
+        {
+        FLOG( _L( "[Provisioning] CMbxNbrAdapter::ParseVideoTypeL:If there is ON/OFF Value" ) );
+        if( aPtr.Compare( KVideoSupportTypeTrue ) == 0 )
+            {
+            FLOG( _L( "[Provisioning] CMbxNbrAdapter::ParseVideoTypeL:if ON set TRUE" ) );
+            aType = ETrue;
+            aType1 = ETrue;
+            }
+        else if( aPtr.Compare( KVideoSupportTypeFalse ) == 0 )
+            {
+            FLOG( _L( "[Provisioning] CMbxNbrAdapter::ParseVideoTypeL:if OFF set False" ) );
+            aType = EFalse;
+            aType1 = ETrue;
+            }
+        else
+        {
+        	FLOG( _L( "[Provisioning] CMbxNbrAdapter::ParseVideoTypeL:if some thing else set False" ) );
+        	aType1 = EFalse;
+        }
+        }
+    else
+        {
+        FLOG( _L( "[Provisioning] CMbxNbrAdapter::ParseVideoTypeL:no ON/OFF" ) );
+        aType1 = EFalse;
+        }
+    }
+	
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/MbxNbrAdapter/Src/MbxNbrAdapterGroupProxy.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,46 @@
+/*
+* 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:  Table of plugins for ECom
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    <e32std.h>
+#include    <implementationproxy.h>
+#include    "MbxNbrAdapter.h"
+
+
+// CONSTANTS
+const TImplementationProxy ImplementationTable[] =
+    {
+	IMPLEMENTATION_PROXY_ENTRY( 0x10207282, CMbxNbrAdapter::NewL )
+    };
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ImplementationProxy
+// ECOM implementation table entry.
+// -----------------------------------------------------------------------------
+//
+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/omacpadapters/MbxNbrAdapter/loc/MailboxAdapter.loc	Tue Jul 13 04:01:20 2010 +0530
@@ -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 is a localisation file for MediaSettings
+*     A .loc file is the one and only place where the logical strings
+*     to be localised are defined. 
+*
+*/
+
+
+
+// LOCALISATION STRINGS
+
+//d: Summary text for mailbox settings
+//l: popup_info_list_pane_t2/opt1
+//
+#define qtn_op_head_mailbox "Mailbox settings"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/StreamingAdapter/Data/101F85CB.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  ECOM DLL interface & implementation description resource for
+*                this DLL.
+*
+*/
+
+
+//  INCLUDES
+#include <registryinfo.rh>
+
+#include "ProvisioningUIDs.h"
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// theInfo
+// ECOM DLL interface & implementation description resource.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid = 0x101F85CB;
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = KProvisioningAdapterInterface;
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x101F85CC;
+                    version_no = 1;
+                    display_name = "WP STREAMING PA";// Use short name to save RAM and ROM space
+                    default_data = "";
+                    opaque_data = "10"; // Adapter priority
+                    }
+                };
+            }
+        };
+    }
+            
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/StreamingAdapter/Data/WPStreamingAdapterResource.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,29 @@
+/*
+* 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:  Resource file.
+*
+*/
+
+
+//  INCLUDES
+#include    <badef.rh>
+#include    <streamingadapter.loc>
+
+
+RESOURCE LBUF r_streaming_adapter_title
+	{
+	txt = qtn_op_head_streaming;
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/StreamingAdapter/Group/StreamingAdapter.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2002-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:  Project specification file for streaming app settings adapter.
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+#include <data_caging_paths.hrh>
+
+TARGET          wpstreamingadapter.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x101F85CB
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_ECOM_PLUGIN
+
+SOURCEPATH      ../Src
+SOURCE          Streamingadapter.cpp
+SOURCE          StreamingadapterGroupProxy.cpp
+
+SOURCEPATH      ../Data
+
+START RESOURCE 101F85CB.rss
+TARGET wpstreamingadapter.rsc
+END
+
+START RESOURCE WPStreamingAdapterResource.rss
+HEADER
+TARGET wpstreamingadapterresource.rsc
+TARGETPATH RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+
+USERINCLUDE     .
+USERINCLUDE     ../Inc
+USERINCLUDE     ../../bld
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom
+
+LIBRARY         euser.lib
+LIBRARY         provisioningengine.lib
+LIBRARY         mpsettengine.lib
+LIBRARY         cmmanager.lib
+LIBRARY         commdb.lib
+DEBUGLIBRARY    flogger.lib
+
+
+SMPSAFE
+//end of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/StreamingAdapter/Group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,2 @@
+PRJ_MMPFILES
+StreamingAdapter.mmp
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/StreamingAdapter/Inc/StreamingAdapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,182 @@
+/*
+* 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:  Handles streaming app settings in OMA provisioning.
+*
+*/
+
+
+#ifndef STREAMINGADAPTER_H
+#define STREAMINGADAPTER_H
+
+// INCLUDES
+
+#include    <CWPAdapter.h>
+#include    <MWPContextExtension.h>
+
+// FORWARD DECLARATIONS
+class CMPSettingsModel;
+struct TStreamingAdapterData;
+
+// CLASS DECLARATION
+
+/**
+ * CStreamingAdapter handles accesspoint settings.
+ */ 
+class CStreamingAdapter : public CWPAdapter,
+                          public MWPContextExtension
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @return a instance of class.
+        */
+        static CStreamingAdapter* NewL();
+
+        /**
+        * Destructor
+        */
+        virtual ~CStreamingAdapter();
+
+    public: // Functions from base classes
+
+        /**
+        * From CWPAdapter
+        */
+        TInt ItemCount() const;
+
+        /**
+        * From CWPAdapter
+        */
+        const TDesC16& SummaryTitle(TInt aIndex) const;
+
+        /**
+        * From CWPAdapter
+        */
+        const TDesC16& SummaryText(TInt aIndex) const;
+
+        /**
+        * From CWPAdapter
+        */
+        TInt DetailsL( TInt aItem, MWPPairVisitor& aVisitor );
+
+        /**
+        * From CWPAdapter
+        */
+        void SaveL(TInt aItem);
+
+        /**
+        * From CWPAdapter
+        */
+        TBool CanSetAsDefault(TInt aItem) const;
+
+        /**
+        * From CWPAdapter
+        */
+        void SetAsDefaultL(TInt aItem);
+
+        /**
+        * From CWPAdapter
+        */
+        void VisitL(CWPCharacteristic& aElement);
+
+        /**
+        * From CWPAdapter
+        */
+        void VisitL(CWPParameter& aElement);
+
+        /**
+        * From CWPAdapter
+        */
+        void VisitLinkL(CWPCharacteristic& aCharacteristic);
+
+        /**
+        * From CWPAdapter
+        */
+        TInt ContextExtension(MWPContextExtension*& aExtension);
+
+        /**
+        * From MWPContextExtension
+        */
+		const TDesC8& SaveDataL(TInt aIndex) const;
+
+        /**
+        * From MWPContextExtension
+        */
+		void DeleteL(const TDesC8& aSaveData);
+
+        /**
+        * From MWPContextExtension
+        */
+        TUint32 Uid() const;
+
+
+    private:  // Default constructors
+
+        /**
+        * C++ default constructor.
+        */
+        CStreamingAdapter();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    private: // New functions
+
+        /**
+        * Validates the data in iTempData.
+        */
+        TBool IsValid();
+
+        /**
+        * Parses an integer from a descriptor.
+        * Returns error code.
+        */
+        TInt ParseIntegerL(const TDesC& aPtr, TInt& aInt);
+
+		/**
+        * ResetAndDestroy() cleanup for ecom implementation array.
+        * @param aAny the implementation array
+        */
+        static void Cleanup( TAny* aAny );
+        
+        /**
+        * Initialise CMPSettingsModel
+        * @param None
+        * @return None
+        */
+        void InitSettingsModelL();
+
+    private: // Data
+
+        HBufC* iTitle;
+        CMPSettingsModel* iModel;
+
+        TPtrC iAppId;
+        TStreamingAdapterData* iCurrentData;
+        TStreamingAdapterData* iTempData;
+
+        TPckgBuf<TUint32> iSavedID;
+
+	private:
+		friend class TM_CWPStreamingAdapterTestCase;
+	
+
+    };
+
+#endif  // STREAMINGADAPTER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/StreamingAdapter/Src/Streamingadapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,541 @@
+/*
+* 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:  Handles streaming app settings in OMA provisioning.
+*
+*/
+
+
+// INCLUDE FILES
+#include    <f32file.h>
+#include    <CWPCharacteristic.h>
+#include    <CWPParameter.h>
+#include    <wpstreamingadapterresource.rsg>
+#include    <mpsettingsmodel.h>
+#include    <cmconnectionmethoddef.h>
+#include    <cmmanagerext.h>
+#include    "WPAdapterUtil.h"
+#include    "StreamingAdapter.h"
+#include    "ProvisioningDebug.h"
+
+// CONSTANTS
+#if ( defined (__WINS__) || defined (__WINSCW) ) // this different on hw
+    _LIT( KAdapterName, "WPStreamingAdapterResource" );
+#else
+    _LIT( KAdapterName, "WPStreamingAdapter" );
+#endif
+_LIT(KMaxBandwidthStr,"MAX-BANDWIDTH");
+_LIT(KMaxUdpPortStr,"MAX-UDP-PORT");
+_LIT(KMinUdpPortStr,"MIN-UDP-PORT");
+_LIT(KStreamingAppId, "554");
+
+const TInt KInvalidValue = -1;
+const TInt KProxyEnabled = 1;
+
+const TInt KMinUDPPort = 1024; //6970;
+const TInt KMaxUDPPort = 65535; //32000;
+const TInt KDefaultMinUDPPort = 6970;
+const TInt KDefaultMaxUDPPort = 32000;
+
+const TInt KBandwidthValue1 = 9050;
+const TInt KBandwidthValue2 = 13400;
+const TInt KBandwidthValue3 = 18100;
+const TInt KBandwidthValue4 = 26800;
+const TInt KBandwidthValue5 = 27150;
+const TInt KBandwidthValue6 = 40200;
+
+// MODULE DATA STRUCTURES
+struct TStreamingAdapterData
+    {
+    TPtrC iName;
+    TInt iMaxBw;
+    TInt iMinUdpPort;
+    TInt iMaxUdpPort;
+    CWPCharacteristic* iNapDef;
+    };
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::CStreamingAdapter
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CStreamingAdapter::CStreamingAdapter()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CStreamingAdapter::ConstructL()
+    {
+    FLOG( _L( "[Provisioning] CStreamingAdapter::ConstructL:" ) );
+    
+    TFileName fileName;
+    Dll::FileName( fileName );
+    iTitle = WPAdapterUtil::ReadHBufCL( fileName,
+                                        KAdapterName,
+                                        R_STREAMING_ADAPTER_TITLE );
+                                        
+    FLOG( _L( "[Provisioning] CStreamingAdapter::ConstructL: Done" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CStreamingAdapter* CStreamingAdapter::NewL()
+    {
+    CStreamingAdapter* self = new(ELeave) CStreamingAdapter; 
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::~CStreamingAdapter
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CStreamingAdapter::~CStreamingAdapter()
+    {
+    delete iTitle;
+    delete iCurrentData;
+    delete iTempData;
+	delete iModel;
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::ItemCount
+// -----------------------------------------------------------------------------
+//
+TInt CStreamingAdapter::ItemCount() const
+    {
+    // If ItemCount() returns zero, the adapter is unloaded at startup. 
+	// SummaryTitle(), SummaryText(), SaveL(), SetAsDefaultL() and 
+	// CanSetAsDefault() are called ItemCount() times
+    return iCurrentData ? 1 : 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::SummaryTitle
+// -----------------------------------------------------------------------------
+//
+const TDesC16& CStreamingAdapter::SummaryTitle(TInt /*aIndex*/) const
+    {
+    return *iTitle;
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::SummaryText
+// -----------------------------------------------------------------------------
+//
+const TDesC16& CStreamingAdapter::SummaryText(TInt /*aIndex*/) const
+    {
+    return iCurrentData->iName;
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::DetailsL
+// -----------------------------------------------------------------------------
+//
+TInt CStreamingAdapter::DetailsL(TInt /*aItem*/, MWPPairVisitor& /*aVisitor*/)
+    {
+    // Detail view is a feature for later release.
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::SaveL
+// -----------------------------------------------------------------------------
+//
+void CStreamingAdapter::SaveL( TInt /*aItem*/ )
+    {
+    FLOG( _L( "[Provisioning] CStreamingAdapter::SaveL:" ) );
+    
+    __ASSERT_DEBUG( iCurrentData->iNapDef, User::Leave( KErrCorrupt ) );
+
+    InitSettingsModelL();
+        
+    // Load default values
+    iModel->LoadSettingsL(EConfigDefault);
+
+    // Set max bandwidth value if valid
+    if (iCurrentData->iMaxBw != KInvalidValue)
+        {
+        iModel->SetMaxBandwidth(iCurrentData->iMaxBw, EBearerGPRS);
+        }
+
+    // Set udp port range if valid
+    if (iCurrentData->iMinUdpPort != KInvalidValue && 
+        iCurrentData->iMaxUdpPort != KInvalidValue)
+        {
+        iModel->SetMinUDPPort(iCurrentData->iMinUdpPort);
+        iModel->SetMaxUDPPort(iCurrentData->iMaxUdpPort);
+        }
+
+    // Get the IAP id
+    
+    RCmManagerExt  cmmanagerExt;
+    cmmanagerExt.OpenL();
+    CleanupClosePushL(cmmanagerExt);
+
+    TPckgBuf<TUint32> uid;
+    TBool proxyDefined(EFalse);
+    TBool apDefined(EFalse);
+    TBool apWithoutProxyDefined(EFalse);
+
+    for (TInt i(0); iCurrentData->iNapDef->Data(i).Length() == uid.MaxLength()
+        && !(proxyDefined && apWithoutProxyDefined); i++)
+        {
+        uid.Copy(iCurrentData->iNapDef->Data(i));
+        RCmConnectionMethodExt cm;
+        cm = cmmanagerExt.ConnectionMethodL( uid() );
+        CleanupClosePushL( cm );
+
+        TBool useProxy = cm.GetBoolAttributeL( CMManager::ECmProxyUsageEnabled );
+        
+        if (!apDefined || (!useProxy && !apWithoutProxyDefined))
+            {
+            iModel->SetDefaultAp(uid());
+            apDefined = ETrue;
+
+            iSavedID.Copy(uid);
+
+            if (!useProxy)
+                {
+                apWithoutProxyDefined = ETrue;
+                }
+            }
+        
+        if (!proxyDefined && useProxy)
+            {
+           // Get proxy port
+            TUint32 proxyPort = cm.GetIntAttributeL( CMManager::ECmProxyPortNumber );
+            
+
+            // Get proxy host name
+            const HBufC* proxyHost = cm.GetStringAttributeL( CMManager::ECmProxyServerName );
+
+            if(*proxyHost != KNullDesC && proxyPort <= 65535)
+                {
+                iModel->SetProxyHostNameL(*proxyHost);
+                iModel->SetProxyPort(static_cast<TInt>(proxyPort));
+                iModel->SetProxyMode(KProxyEnabled);
+                
+                proxyDefined = ETrue;
+                }
+            delete proxyHost;
+            }
+        CleanupStack::PopAndDestroy();//cm
+        }
+
+    CleanupStack::PopAndDestroy(); // cmmanagerext
+
+    iModel->StoreSettingsL();
+    
+    FLOG( _L( "[Provisioning] CStreamingAdapter::SaveL: Done" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::CanSetAsDefault
+// -----------------------------------------------------------------------------
+//
+TBool CStreamingAdapter::CanSetAsDefault(TInt /*aItem*/) const
+    {
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::SetAsDefault
+// -----------------------------------------------------------------------------
+//
+void CStreamingAdapter::SetAsDefaultL(TInt /*aItem*/)
+    {
+    // This shouldn't be called because CanSetAsDefault
+    // always returns EFalse.
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::VisitL
+// -----------------------------------------------------------------------------
+//
+void CStreamingAdapter::VisitL(CWPCharacteristic& aCharacteristic)
+    {
+    switch(aCharacteristic.Type())
+        {
+        case KWPApplication:
+            // Create new iTempData
+            if (iTempData)
+                {
+                delete iTempData;
+                iTempData = NULL;
+                }
+
+            iTempData = new (ELeave) TStreamingAdapterData;
+
+            // Initialize iTempData's members
+            iTempData->iName.Set(KNullDesC);
+            iTempData->iMaxBw = KInvalidValue;
+            iTempData->iMinUdpPort = KInvalidValue;
+            iTempData->iMaxUdpPort = KInvalidValue;
+            iTempData->iNapDef = NULL;
+
+            // Accept characteristic
+            aCharacteristic.AcceptL(*this);
+
+            // Check iAppId and validate data
+            if (iAppId == KStreamingAppId && IsValid())
+                {
+                // iAppId is correct and data is valid
+                delete iCurrentData;
+                iCurrentData = iTempData;
+                iTempData = NULL;
+                }
+            else
+                {
+                // iAppId is incorrect or data is invalid
+                delete iTempData;
+                iTempData = NULL;
+                }
+            break;
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::VisitL
+// -----------------------------------------------------------------------------
+//
+void CStreamingAdapter::VisitL(CWPParameter& aParameter)
+    { 
+    // Check the contents of whole characteristic before overwriting iMaxBw, 
+    // iMinUdpPort and iMaxUdpPort. Might be looking at the wrong application
+	// characteristic
+    
+    __ASSERT_DEBUG(iTempData, User::Leave(KErrCorrupt));
+    
+    TInt value;
+    switch(aParameter.ID())
+        {
+        case EWPParameterAppID:
+            iAppId.Set(aParameter.Value());
+            break;
+        case EWPParameterName:
+            if (iTempData->iName == KNullDesC)
+                {
+                iTempData->iName.Set(aParameter.Value());
+                }
+            break;
+		case EWPNamedParameter:
+			{
+			if( aParameter.Name().Compare( KMaxBandwidthStr ) == 0
+				&& !ParseIntegerL( aParameter.Value(), value ) )
+				{							
+				iTempData->iMaxBw = value;
+				}
+			else if( aParameter.Name().Compare( KMaxUdpPortStr ) == 0
+				&& !ParseIntegerL( aParameter.Value(), value ) )
+				{							
+				iTempData->iMaxUdpPort = value;
+				}
+			else if( aParameter.Name().Compare( KMinUdpPortStr ) == 0
+				&& !ParseIntegerL( aParameter.Value(), value ) )
+				{							
+                iTempData->iMinUdpPort = value;
+				}
+			break;
+			}
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::VisitLinkL
+// -----------------------------------------------------------------------------
+//
+void CStreamingAdapter::VisitLinkL(CWPCharacteristic& aCharacteristic)
+    { 
+    // Here again, do not overwrite iPXLogical before you're sure
+    // you're looking at the correct APPLICATION
+
+    __ASSERT_DEBUG(iTempData, User::Leave(KErrCorrupt));
+
+    switch(aCharacteristic.Type())
+        {
+        //intentional fall-through
+        case KWPNapDef:        
+        case KWPPxLogical:    
+            iTempData->iNapDef = &aCharacteristic;          
+            break;
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::ContextExtension
+// -----------------------------------------------------------------------------
+//
+TInt CStreamingAdapter::ContextExtension(MWPContextExtension*& aExtension)
+    {
+    aExtension = this;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::SaveDataL
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CStreamingAdapter::SaveDataL(TInt /*aIndex*/) const
+    {
+    return iSavedID;
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::DeleteL
+// -----------------------------------------------------------------------------
+//
+void CStreamingAdapter::DeleteL(const TDesC8& aSaveData)
+    {
+    TUint32 id;
+    
+    InitSettingsModelL();
+    
+    iModel->GetDefaultAp(id);
+
+    TPckgBuf<TUint32> pckg;
+    pckg.Copy(aSaveData);
+
+    if (id == pckg())
+        {
+        iModel->LoadSettingsL(EConfigDefault);
+        iModel->StoreSettingsL();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::Uid
+// -----------------------------------------------------------------------------
+//
+TUint32 CStreamingAdapter::Uid() const
+    {
+    return iDtor_ID_Key.iUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::IsValid
+// -----------------------------------------------------------------------------
+//
+TBool CStreamingAdapter::IsValid()
+    {
+    TBool validity(EFalse);
+    
+    if (iTempData->iNapDef)
+        {
+        // Validity checks for min and max UDP port values
+        if (iTempData->iMinUdpPort < KMinUDPPort)
+            {
+            iTempData->iMinUdpPort = KDefaultMinUDPPort; 
+            }
+
+        if (iTempData->iMaxUdpPort > KMaxUDPPort)
+            {
+            iTempData->iMaxUdpPort = KDefaultMaxUDPPort; 
+            }
+
+        if (iTempData->iMinUdpPort > iTempData->iMaxUdpPort)
+            {
+            iTempData->iMinUdpPort = KInvalidValue;
+            iTempData->iMaxUdpPort = KInvalidValue;
+            }
+        
+        // Validity check for max bandwidth value
+        switch (iTempData->iMaxBw)
+            {
+            case KBandwidthValue1:
+            case KBandwidthValue2:
+            case KBandwidthValue3:
+            case KBandwidthValue4:
+            case KBandwidthValue5:
+            case KBandwidthValue6:
+                // iMaxBw is valid
+                break;
+            default:
+                // iMaxBw is invalid
+                iTempData->iMaxBw = KInvalidValue;
+                break;
+            }
+
+        validity = ETrue;
+        }
+            
+    return validity;
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::ParseIntegerL
+// -----------------------------------------------------------------------------
+//
+TInt CStreamingAdapter::ParseIntegerL(const TDesC& aPtr, TInt& aInt) 
+    {
+    TLex lex(aPtr);
+    return lex.Val(aInt);
+    }
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::Cleanup
+// -----------------------------------------------------------------------------
+//
+void CStreamingAdapter::Cleanup( TAny* aAny )
+	{
+	RImplInfoPtrArray* implArray = 
+		reinterpret_cast< RImplInfoPtrArray*> ( aAny );
+	implArray->ResetAndDestroy();
+	implArray->Close();
+	}
+
+// -----------------------------------------------------------------------------
+// CStreamingAdapter::InitSettingsModelL
+// -----------------------------------------------------------------------------
+//
+void CStreamingAdapter::InitSettingsModelL()
+	{
+	FLOG( _L( "[Provisioning] CStreamingAdapter::InitSettingsModelL:" ) );
+	
+    if ( !iModel )
+        {
+        RImplInfoPtrArray impl; 
+    	CleanupStack::PushL( TCleanupItem( Cleanup, &impl ) );
+    	CMPSettingsModel::ListImplementationsL( impl );
+    	if( impl.Count() > 0 )
+            {
+            FLOG( _L( "[Provisioning] CStreamingAdapter::InitSettingsModelL: Creating CMPSettingsModel" ) );
+    	    // using the first available implementation
+            iModel= CMPSettingsModel::NewL( impl[0]->ImplementationUid() );
+            FLOG( _L( "[Provisioning] CStreamingAdapter::InitSettingsModelL: Creating CMPSettingsModel Done" ) );
+        	}
+    	CleanupStack::PopAndDestroy(); // implArray
+        }
+	}
+	
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/StreamingAdapter/Src/StreamingadapterGroupProxy.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2002-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:  Table of plugins for ECom
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    <e32std.h>
+#include    <implementationproxy.h>
+#include    "StreamingAdapter.h"
+
+
+// CONSTANTS
+const TImplementationProxy ImplementationTable[] =
+    {
+	IMPLEMENTATION_PROXY_ENTRY(0x101F85CC, CStreamingAdapter::NewL )
+//        {{0x101F85CC}, CStreamingAdapter::NewL},
+    };
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ImplementationProxy
+// ECOM implementation table entry.
+// -----------------------------------------------------------------------------
+//
+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/omacpadapters/StreamingAdapter/loc/StreamingAdapter.loc	Tue Jul 13 04:01:20 2010 +0530
@@ -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 is a localisation file for MediaSettings
+*     A .loc file is the one and only place where the logical strings
+*     to be localised are defined. 
+*
+*/
+
+
+
+// LOCALISATION STRINGS
+
+//d: Summary text for streaming settings
+//l: popup_info_list_pane_t2/opt1
+//
+#define qtn_op_head_streaming "Streaming settings"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Data/101F84DC.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,64 @@
+/*
+* 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:  Resource file defining the ProvisioningAdapter plugin.
+*
+*/
+
+
+
+//  INCLUDES
+#include <registryinfo.rh>
+#include "ProvisioningUIDs.h"
+
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// theInfo
+// Resource defining the ProvisioningAdapter plugin.
+//
+// -----------------------------------------------------------------------------
+//
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid = KProvisioningWAPAdapterDllUid3;
+    interfaces = 
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = KProvisioningAdapterInterface;
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = KProvisioningMMSAdapterUid;
+                    version_no = 1;
+                    display_name = "";
+                    default_data = "";
+                    opaque_data = "101";
+                    },
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = KProvisioningBrowserAdapterUid;
+                    version_no = 1;
+                    display_name = "";
+                    default_data = "";
+                    opaque_data = "100";
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Data/WPWAPAdapterResource.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,49 @@
+/*
+* 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:  Resource file.
+*
+*/
+
+
+
+//  INCLUDES
+#include <badef.rh>
+#include <provisioning.loc>
+
+// Rich text labels
+
+RESOURCE LBUF r_qtn_op_head_browser
+    { 
+    txt = qtn_op_head_browser; 
+    }
+
+RESOURCE LBUF r_qtn_sm_mms_accesspoints
+    { 
+    txt = qtn_sm_mms_accesspoints; 
+    }
+
+RESOURCE LBUF r_qtn_sm_wapap_name
+    { 
+    txt = qtn_sm_wapap_name; 
+    }
+
+RESOURCE LBUF r_qtn_sm_bookmark_name
+    { 
+    txt = qtn_sm_bookmark_name; 
+    }
+
+RESOURCE LBUF r_qtn_sm_bookmarks
+    { 
+    txt = qtn_sm_bookmarks;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Group/WPWAPAdapter.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2002-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:  Project definition file for the WPWAPAdapter.
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+#include "../../bld/ProvisioningUIDs.h"
+#include "../Inc/WPWAPDebug.h"
+
+TARGET          wpwapadapter.dll
+TARGETTYPE      PLUGIN
+UID             KProvisioningWAPAdapterDllUid2 KProvisioningWAPAdapterDllUid3
+
+
+VENDORID        VID_DEFAULT
+CAPABILITY      CAP_ECOM_PLUGIN
+
+SOURCEPATH      ../Src
+SOURCE          CWPWAPAdapterBase.cpp
+SOURCE          CWPWAPMMSAdapter.cpp 
+SOURCE          CWPWAPMMSItem.cpp 
+SOURCE          CWPWAPBookmarkItem.cpp
+SOURCE          CWPWAPItemBAse.cpp
+SOURCE          WPWAPUtil.cpp
+SOURCE          WPWAPItemFactory.cpp
+SOURCE          WPWAPAdapterGroupProxy.cpp
+SOURCE          WPWAPAdapterMain.cpp
+
+SOURCEPATH      ../Data
+START RESOURCE 101F84DC.rss
+TARGET wpwapadapter.rsc
+END
+
+START RESOURCE WPWAPAdapterResource.rss
+HEADER
+TARGET wpwapadapterresource.rsc
+TARGETPATH RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+USERINCLUDE     ../Inc ../Group ../../bld
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom
+
+LIBRARY         euser.lib 
+LIBRARY         provisioningengine.lib
+LIBRARY         msgs.lib
+LIBRARY         cmmanager.lib
+LIBRARY         commdb.lib
+LIBRARY         commonengine.lib
+LIBRARY         centralrepository.lib
+
+DEBUGLIBRARY    flogger.lib
+
+#ifdef __MESSAGING_API_V2__
+LIBRARY         mmsserversettings.lib
+#endif
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,2 @@
+PRJ_MMPFILES
+WPWAPAdapter.mmp
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Inc/CWPWAPAdapterBase.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,112 @@
+/*
+* 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: 
+*     Base for WAP adapters.
+*
+*/
+
+
+#ifndef CWPWAPADAPTERBASE_H
+#define CWPWAPADAPTERBASE_H
+
+// INCLUDES
+#include <CWPAdapter.h>
+#include <MWPContextExtension.h>
+
+// FORWARD DECLARATIONS
+class CWPCharacteristic;
+class MWPWAPItemBase;
+class CCommsDatabase;
+class RCmConnectionMethodExt;
+class RCmManagerExt;
+
+// CLASS DECLARATION
+
+/**
+ * CWPWAPAdapterBase is a base for WAP adapters.
+ *
+ * @lib WPWAPAdapter
+ * @since 2.0
+ */ 
+class CWPWAPAdapterBase : public CWPAdapter, private MWPContextExtension
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Destructor.
+        */
+        ~CWPWAPAdapterBase();
+
+    public: // from CWPAdapter
+        
+        TInt ItemCount() const;     
+        const TDesC16& SummaryTitle(TInt aIndex) const;     
+        const TDesC16& SummaryText(TInt aIndex) const;      
+        void SaveL( TInt aItem );
+        TBool CanSetAsDefault( TInt aItem ) const;
+        void SetAsDefaultL( TInt aItem );
+        TInt DetailsL( TInt aItem, MWPPairVisitor& aVisitor );
+        void VisitL(CWPCharacteristic& aElement);
+        void VisitL(CWPParameter& aElement);
+        void VisitLinkL(CWPCharacteristic& aCharacteristic );
+        TInt ContextExtension( MWPContextExtension*& aExtension );
+
+    public: // from MWPContextExtension
+        virtual const TDesC8& SaveDataL( TInt aIndex ) const;
+        virtual void DeleteL( const TDesC8& aSaveData );
+        TUint32 Uid() const;
+
+    public: // New methods
+        /**
+        * Handles one application characteristic.
+        * @param aCharacteristic The application characteristic
+        */
+        virtual void ApplicationL( CWPCharacteristic& aCharacteristic ) = 0;
+
+    protected:  // New functions
+        /**
+        * C++ default constructor.
+        */
+        CWPWAPAdapterBase();
+
+        /**
+        * 2nd phase base constructor. Derived classes must call this.
+        */
+        void BaseConstructL();
+
+        /**
+        * Create CCommsDatabase and APEngine if NULL.
+        */
+        void CreateDbL();
+
+    protected:  // Data
+        // The application if of the current characteristic
+        TPtrC iAppID;
+
+        // The visible setting items. Owns.
+        RPointerArray<MWPWAPItemBase> iItems;
+
+        // The hidden setting items. Owns.
+        RPointerArray<MWPWAPItemBase> iHiddenItems;
+
+        // Comms database for saving. Owns.
+        CCommsDatabase* iCommsDb;
+
+        // APEngine for saving. Owns.
+        RCmManagerExt* iCmManager;
+    };
+
+#endif  // CWPWAPADAPTERBASE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Inc/CWPWAPBookmarkItem.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,140 @@
+/*
+* Copyright (c) 2002-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:  One bookmark item in browser settings.
+*
+*/
+
+
+#ifndef CWPWAPBOOKMARKITEM_H
+#define CWPWAPBOOKMARKITEM_H
+
+// INCLUDES
+#include <e32base.h>
+#include <MWPVisitor.h>
+
+#include "CWPWAPItemBAse.h"
+
+
+// FORWARD DECLARATIONS
+class CBookmarkDb;
+
+// CLASS DECLARATION
+
+/**
+ * CWPWAPBookmarkItem handles one bookmark item in browser settings.
+ *
+ * @lib WPWAPAdapter
+ * @since 2.0
+ */ 
+class CWPWAPBookmarkItem : public CBase, public MWPWAPItemBase, private MWPVisitor
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @param aTitle The title to be returned in Name().
+        * @param aDefaultName The default name for bookmarks.
+        * @param aCharacteristic The RESOURCE characteristic.
+        * @param aLink Link to NAPDEF
+        * @param aDb The bookmark database to use. Created if NULL.
+        * @return CWPWAPBookmarkItem instance
+        */
+        static CWPWAPBookmarkItem* NewL(  const TDesC& aTitle, 
+            const TDesC& aDefaultName, 
+            CWPCharacteristic& aCharacteristic, 
+            CWPCharacteristic*& aLink
+            );
+
+
+        /**
+        * Destructor.
+        */
+        ~CWPWAPBookmarkItem();
+
+    public:   // From MWPMMSItemBase
+
+        const TDesC& Name() const;
+        const TDesC& Title() const;
+        TBool CanSetAsDefault() const;
+        void SaveL();
+        void SetAsDefaultL();
+        TBool ValidateL();
+        void AddL( RPointerArray<MWPWAPItemBase>& aShownItems, 
+            RPointerArray<MWPWAPItemBase>& aHiddenItems );
+        const TDesC8& SaveData() const;
+        const TDesC& Address() const;
+
+    public:  // From MWPVisitor
+
+        void VisitL(CWPCharacteristic& aCharacteristic);
+        void VisitL(CWPParameter& aParameter);
+        void VisitLinkL(CWPCharacteristic& aCharacteristic );
+
+    private:  // New functions
+        /**
+        * C++ constructor.
+        * @param aTitle The title to be returned in Name().
+        * @param aDefaultName The default name for bookmarks.
+        * @param aLink Link to access point
+        * @param aDb The bookmark database to use. Created if NULL.
+        */
+        CWPWAPBookmarkItem( const TDesC& aTitle, 
+            const TDesC& aDefaultName, 
+            CWPCharacteristic*& aLink
+             );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        * @param aCharacteristic The RESOURCE characteristic 
+        * to scan.
+        */
+        void ConstructL( CWPCharacteristic& aCharacteristic );
+
+        /**
+        * Create the bookmarks db.
+        */
+        void CreateDbL();
+
+    private:
+        // The title for bookmark items
+        const TDesC& iTitle;
+
+        // The default name for bookmarks.
+        const TDesC& iDefaultName;
+
+        // The access point characteristic. Refs.
+        CWPCharacteristic*& iLink;
+
+        // The name of the bookmark
+        TPtrC iName;
+
+        // The URI of the bookmark
+        TPtrC iURI;
+
+        // Startpage parameter
+        TBool iHasStartPage;
+
+        //RFavouritesDb       iBookmarkDb;
+        //RFavouritesSession  iSession;
+
+        // Access point uid.
+        TUint32 iUID;
+
+        // UIDs of the saved items
+        TPckgBuf<TWPWAPSaveItem> iSaveItem;
+    };
+
+#endif  // CWPWAPBOOKMARKITEM_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Inc/CWPWAPBrowserAdapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2002-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:  Handles browser settings in provisioning.
+*
+*/
+
+
+#ifndef CWPWAPBROWSERADAPTER_H
+#define CWPWAPBROWSERADAPTER_H
+
+// INCLUDES
+#include "CWPWAPAdapterBase.h"
+
+#include <favouritessession.h>
+#include <FavouritesDb.h>
+
+
+// FORWARD DECLARATIONS
+class CWPCharacteristic;
+class CBookmarkDb;
+// CLASS DECLARATION
+
+/**
+ * CWPWAPBrowserAdapter handles browser settings.
+ *
+ * @lib WPWAPAdapter
+ * @since 2.0
+ */ 
+class CWPWAPBrowserAdapter : public CWPWAPAdapterBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @return CWPWAPBrowserAdapter instance
+        */
+        static CWPWAPBrowserAdapter* NewL();
+
+        /**
+        * Destructor.
+        */
+        ~CWPWAPBrowserAdapter();
+
+    public: // from CWPWAPAdapterBase
+        
+        void ApplicationL( CWPCharacteristic& aCharacteristic );
+        void DeleteL( const TDesC8& aSaveData );
+        
+    private:  // New functions
+        /**
+        * C++ default constructor.
+        */
+        CWPWAPBrowserAdapter();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Create the bookmarks db.
+        */
+        void CreateDbL();
+
+    private:    // Data
+        // Title for browser items. Owns.
+        HBufC* iTitle;
+
+        // Title for bookmarks. Owns.
+        HBufC* iBookmarkTitle;
+
+        // Default name for browser items. Owns.
+        HBufC* iDefaultName;
+
+        // Default name for bookmarks. Owns.
+        HBufC* iDefaultBookmarkName;
+
+        // ETrue if one browser application has been processed.
+        TBool iProcessed;
+        
+        // Favourites database. Owns.
+        CBookmarkDb* iBookmarkDb;        
+
+        RFavouritesSession iSession;
+        
+        RFavouritesDb iFavouritesDb;
+    };
+
+#endif  // CWPWAPBROWSERADAPTER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Inc/CWPWAPBrowserItem.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2002-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:  Setting item for browser settings.
+*
+*/
+
+
+#ifndef CWPWAPBROWSERITEM_H
+#define CWPWAPBROWSERITEM_H
+
+// INCLUDES
+#include <e32base.h>
+#include <MWPVisitor.h>
+#include <favouritesdb.h>
+#include "CWPWAPItemBAse.h"
+
+// FORWARD DECLARATIONS
+class MWPWAPItemBase;
+class CBookmarkDb;
+class RCmManagerExt;
+// CLASS DECLARATION
+
+/**
+ * CWPWAPBrowserItem handles one browser setting.
+ *
+ * @lib WPWAPAdapter
+ * @since 2.0
+ */ 
+
+
+class CWPWAPBrowserItem : public CWPWAPItemBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @param aFirst ETrue if this browser item is first
+        * @param aTitle Title for browser items
+        * @param aBookmarkTitle Title for bookmark items
+        * @param aDefaultName Default name for browser items
+        * @param aDefaultBookmarkName Default name for bookmarks.
+        * @param aCharacteristic The APPLICATION characteristic
+        * @param aCommsDb The CommsDB to use. Created if NULL.
+        * @param aAPHandler The APEngine data handler to use. Created if NULL.
+        * @param aBookmarkDb The bookmark database to use. Created if NULL.
+        * @return CWPWAPBrowserItem instance
+        */
+        static CWPWAPBrowserItem* NewL( TBool aFirst,
+            const TDesC& aTitle, 
+            const TDesC& aBookmarkTitle,
+            const TDesC& aDefaultName, 
+            const TDesC& aDefaultBookmarkName,
+            CWPCharacteristic& aCharacteristic, 
+            CCommsDatabase*& aCommsDb, 
+            RCmManagerExt*& aCmManager           
+            );
+
+        /**
+        * Destructor.
+        */
+        ~CWPWAPBrowserItem();
+
+    public:   // From CWPMMSItemBase
+
+        TBool CanSetAsDefault() const;
+        void SaveL();
+        void SetAsDefaultL();
+        TBool ValidateL();
+        void ResourceL( CWPCharacteristic& aResource );
+        void AddL( RPointerArray<MWPWAPItemBase>& aShownItems, 
+            RPointerArray<MWPWAPItemBase>& aHiddenItems );
+
+    private:  // New functions
+        /**
+        * C++ default constructor.
+        * @see CWPWAPBrowserItem::NewL() for description of parameters.
+        */
+        CWPWAPBrowserItem( TBool aFirst,
+            const TDesC& aTitle, 
+            const TDesC& aBookmarkTitle,
+            const TDesC& aDefaultName, 
+            const TDesC& aDefaultBookmarkName,
+            CWPCharacteristic& aCharacteristic, 
+            CCommsDatabase*& aCommsDb, 
+            RCmManagerExt*& aCmManager,            
+            );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    private:
+        // The bookmarks. Owns.
+        RPointerArray<MWPWAPItemBase> iBookmarks;
+
+        // The default name for bookmarks.
+        const TDesC& iDefaultBookmarkName;
+
+        // The title for bookmarks
+        const TDesC& iBookmarkTitle;
+        
+        //RFavouritesDb iDb;
+
+        // ETrue if this browser item is first in list.
+        TBool iFirst;
+    };
+
+#endif  // CWPWAPBROWSERITEM_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Inc/CWPWAPItemBAse.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,144 @@
+/*
+* 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: 
+*     Base class for WAP setting items.
+*
+*/
+
+
+#ifndef CWPWAPITEMBASE_H
+#define CWPWAPITEMBASE_H
+
+// INCLUDES
+#include <e32base.h>
+#include <MWPVisitor.h>
+#include "MWPWAPItemBase.h"
+#include <cmmanagerext.h>
+#include <cmconnectionmethodext.h>
+
+// FORWARD DECLARATIONS
+class CCommsDatabase;
+
+
+// CLASS DECLARATION
+
+/**
+ * CWPWAPItemBase is a base class for browser settings.
+ *
+ * @lib WPWAPAdapter
+ * @since 2.0
+ */ 
+class CWPWAPItemBase : public CBase, private MWPVisitor, public MWPWAPItemBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Destructor.
+        */
+        ~CWPWAPItemBase();
+
+    public:  // From MWPVisitor
+
+        void VisitL(CWPCharacteristic& aCharacteristic);
+        void VisitL(CWPParameter& aParameter);
+        void VisitLinkL(CWPCharacteristic& aCharacteristic );
+
+    public:   // From MWPWAPItemBase
+
+        const TDesC& Name() const;
+        const TDesC& Title() const;
+        const TDesC& Address() const;
+        const TDesC8& SaveData() const;
+
+    protected:   // New methods
+        /**
+        * C++ default constructor.
+        * @param aTitle Title for items
+        * @param aDefaultName Default name for items
+        * @param aCharacteristic The APPLICATION characteristic
+        * @param aCommsDb The CommsDB to use. Created if NULL.
+        * @param aAPHandler The APEngine data handler to use. Created if NULL.
+        */
+        CWPWAPItemBase( const TDesC& aTitle, 
+            const TDesC& aDefaultName, 
+            CWPCharacteristic& aCharacteristic, 
+            CCommsDatabase*& aCommsDb, 
+            RCmManagerExt*& aCmManager);
+
+        /**
+        * 2nd phase base constructor. Derived classes must call this.
+        */
+        void BaseConstructL();
+
+        /**
+        * Handles one resource item.
+        * @param aResource The RESOURCE item
+        */
+        virtual void ResourceL( CWPCharacteristic& aResource ) = 0;
+
+        /**
+        * Create CCommsDatabase and APEngine if NULL.
+        */
+        void CreateDbL();
+
+        /**
+        * Writes a home page to an access point. If access point already
+        * has a home page, create a new one.
+        * @param aItem Access point to access
+        */
+        void WriteHomePageL( RCmConnectionMethodExt& aCmItem );
+
+        /**
+        * Create a valid name for the access point.
+        * @param aName The base name for access point
+        * @param aDb CommsDb instance
+        */
+        void MakeValidNameL( TDes& aName, CCommsDatabase& aDb ) const;
+
+    protected:
+        // The parent characteristic. Refs.
+        CWPCharacteristic& iCharacteristic;
+
+        // The preferred access point name
+        TPtrC iName;
+
+        // The access point address, Owns.
+        HBufC* iAddr;
+
+        // The UID of the access point
+        TUint32 iUID;
+
+        // UID of the saved item
+        TPckgBuf<TWPWAPSaveItem> iSaveItem;
+
+        // Temporary current proxy while visiting. Refs.
+        CWPCharacteristic* iLink;
+
+        // Text to return in SummaryTitle().
+        const TDesC& iTitle;
+
+        // Default name of access point.
+        const TDesC& iDefaultName;
+
+        // Comms db. Refs.
+        CCommsDatabase*& iCommsDb;
+
+                // @var Pointer to Connection Method Manager that is required to access
+        // Access Point data
+        RCmManagerExt*&   iCmManager;
+    };
+
+#endif  // CWPWAPITEMBASE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Inc/CWPWAPMMSAdapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,76 @@
+/*
+* 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: 
+*     Handles MMS settings in provisioning.
+*
+*/
+
+
+#ifndef CWPWAPMMSADAPTER_H
+#define CWPWAPMMSADAPTER_H
+
+// INCLUDES
+#include "CWPWAPAdapterBase.h"
+
+// FORWARD DECLARATIONS
+class CWPCharacteristic;
+
+// CLASS DECLARATION
+
+/**
+ * CWPWAPMMSAdapter handles MMS settings.
+ *
+ * @lib WPWAPAdapter
+ * @since 2.0
+ */ 
+class CWPWAPMMSAdapter : public CWPWAPAdapterBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CWPWAPMMSAdapter* NewL();
+
+        /**
+        * Destructor.
+        */
+        ~CWPWAPMMSAdapter();
+
+    public: // from CWPWAPAdapterBase
+        
+        void ApplicationL( CWPCharacteristic& aCharacteristic );
+        
+    private:  // New functions
+        /**
+        * C++ default constructor.
+        */
+        CWPWAPMMSAdapter();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    private:    // Data
+        // Title for MMS items. Owns.
+        HBufC* iTitle;
+
+        // Default name for MMS items. Owns.
+        HBufC* iDefaultName;
+    };
+
+#endif  // CWPWAPMMSADAPTER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Inc/CWPWAPMMSItem.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,106 @@
+/*
+* 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: 
+*     Setting item for MMS settings.
+*
+*/
+
+
+#ifndef CWPWAPMMSITEM_H
+#define CWPWAPMMSITEM_H
+
+// INCLUDES
+#include <e32base.h>
+#include <msvapi.h>
+#include "CWPWAPItemBAse.h"
+
+// FORWARD DECLARATIONS
+class CBookmarkDb;
+class RCmManagerExt;
+
+// CLASS DECLARATION
+
+/**
+ * CWPWAPMMSItem contains one MMS setting.
+ *
+ * @lib WPWAPAdapter
+ * @since 2.0
+ */ 
+class CWPWAPMMSItem : public CWPWAPItemBase, private MMsvSessionObserver
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @param aTitle Title for MMS items
+        * @param aDefaultName Default name for MMS items
+        * @param aCharacteristic The APPLICATION characteristic
+        * @param aCommsDb The CommsDB to use. Created if NULL.
+        * @param aAPHandler The APEngine data handler to use. Created if NULL.
+        */
+        static CWPWAPMMSItem* NewL( const TDesC& aTitle, 
+            const TDesC& aDefaultName, 
+            CWPCharacteristic& aCharacteristic, 
+            CCommsDatabase*& aCommsDb, 
+            RCmManagerExt*& aCmManager);
+
+        /**
+        * Destructor.
+        */
+        ~CWPWAPMMSItem();
+
+    public:   // From CWPWAPMMSItemBase
+
+        TBool CanSetAsDefault() const;
+        void SaveL();
+        void SetAsDefaultL();
+        TBool ValidateL();
+        void ResourceL( CWPCharacteristic& aResource );
+        void AddL( RPointerArray<MWPWAPItemBase>& aShownItems, 
+            RPointerArray<MWPWAPItemBase>& aHiddenItems );
+        void VisitLinkL( CWPCharacteristic& aCharacteristic );
+
+    private: // from MMsvSessionObserver
+
+        void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
+
+    private:  // New functions
+        /**
+        * C++ default constructor.
+        * @see CWPWAPMMSItem::NewL() for description of parameters.
+        */
+        CWPWAPMMSItem(  const TDesC& aTitle, 
+            const TDesC& aDefaultName, 
+            CWPCharacteristic& aCharacteristic, 
+            CCommsDatabase*& aCommsDb, 
+            RCmManagerExt*& aCmManager);
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+
+
+    private:   // Data
+        // The bookmarks database. Refs.
+        CBookmarkDb* iDb;
+
+        // The potential links
+        RPointerArray<CWPCharacteristic> iLinks;
+    };
+
+#endif  // CWPWAPMMSITEM_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Inc/MWPWAPItemBase.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,122 @@
+/*
+* 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: 
+*     Base class for WAP setting items.
+*
+*/
+
+
+#ifndef MWPWAPITEMBASE_H
+#define MWPWAPITEMBASE_H
+
+// INCLUDES
+#include <e32base.h>
+
+// CONSTANTS
+const TUint32 KWPWAPNoUID = 0;
+const TUint32 KWPWAPItemTypeNone = 0;
+const TUint32 KWPWAPItemTypeBookmark = 1;
+const TUint32 KWPWAPItemTypeAccesspoint = 2;
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+ * MWPWAPItemBase is a base class for wap settings.
+ *
+ * @lib WPWAPAdapter
+ * @since 2.0
+ */ 
+class MWPWAPItemBase
+    {
+	public:
+		struct TWPWAPSaveItem
+			{
+			TUint32 iSaveItemType;
+			TUint32 iUID;
+			};
+
+    public:  // Constructors and destructor
+
+        /**
+        * Destructor.
+        */
+        virtual ~MWPWAPItemBase() {};
+
+    public:   // New functions
+
+        /**
+        * Returns the name of the item to be returned in
+        * SummaryText().
+        * @return Name of the item
+        */
+        virtual const TDesC& Name() const = 0;
+
+        /**
+        * Returns the title of the item to be returned in
+        * SummaryTitle().
+        * @return Name of the item
+        */
+        virtual const TDesC& Title() const = 0;
+
+        /**
+        * Returns the address of the service pointed by 
+        * the item.
+        * @return Address of the service
+        */
+        virtual const TDesC& Address() const = 0;
+
+        /**
+        * Saves the item. Call BaseSaveL() in beginning.
+        */
+        virtual void SaveL() = 0;
+
+        /**
+        * Returns ETrue if the item can be saved as
+        * default setting.
+        * @return Whether the item can be made default
+        */
+        virtual TBool CanSetAsDefault() const = 0;
+
+        /**
+        * Sets the item as default setting.
+        */
+        virtual void SetAsDefaultL() = 0;
+
+        /**
+        * Returns ETrue if the item is valid.
+        * @return ETrue if valid
+        */
+        virtual TBool ValidateL() = 0;
+
+        /**
+        * Adds the item and its children to a list of items.
+        * @param aShownItems The list of shown items to be appended to
+        * @param aHiddenItems The list of hidden items to be appended to
+        */
+        virtual void AddL( RPointerArray<MWPWAPItemBase>& aShownItems, 
+            RPointerArray<MWPWAPItemBase>& aHiddenItems  ) = 0;
+
+        /**
+        * Returns the ID of the saved item.
+        * @return ID of the saved item, or KWPWAPNoUID
+        */
+        virtual const TDesC8& SaveData() const = 0;
+
+    };
+
+#endif  // MWPWAPITEMBASE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Inc/WPWAPDebug.h	Tue Jul 13 04:01:20 2010 +0530
@@ -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: 
+*     WPWAPDebug contains debug macros.
+*
+*/
+
+
+#ifndef WPWAPDEBUG_H 
+#define WPWAPDEBUG_H 
+
+// MACROS
+
+// Define this to enable debug output
+//#define WAPDEBUG
+
+// DEBUG can be used for outputting debug
+#ifdef WAPDEBUG
+#define DEBUG(TEXT) Debug( _L(#TEXT) );
+#define DVA(TEXT, ARG1) Debug( _L(#TEXT), (ARG1) );
+#define DVA2(TEXT, ARG1, ARG2) Debug( _L(#TEXT), (ARG1), (ARG2) );
+#define DVA3(TEXT, ARG1, ARG2, ARG3) Debug( _L(#TEXT), (ARG1), (ARG2), (ARG3) );
+#else
+#define DEBUG(TEXT)
+#define DVA(TEXT, ARG1)
+#define DVA2(TEXT, ARG1, ARG2)
+#define DVA3(TEXT, ARG1, ARG2, ARG3)
+#endif
+
+#if defined(__WINS__) || defined(__EPOC32__)
+GLDEF_C void Debug( TRefByValue<const TDesC> aText, ...);
+#endif
+
+#endif /* WPWAPDEBUG_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Inc/WPWAPItemFactory.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2002-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:  Factory for WAP items.
+*
+*/
+
+
+#ifndef WPITEMFACTORY_H
+#define WPITEMFACTORY_H
+
+// INCLUDE FILES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class MWPWAPItemBase;
+class CWPCharacteristic;
+class CCommsDatabase;
+class RCmConnectionMethodExt;
+class RCmDestinationExt;
+class CBookmarkDb;
+
+// CLASS DECLARATION
+class RCmManagerExt;
+/**
+ * WPWAPItemFactory is a factory for all WAP items.
+ *
+ * @lib WPWAPAdapter
+ * @since 2.0
+ */ 
+class WPWAPItemFactory
+    {
+    public:
+        /**
+        * Create an MMS item.
+        * @param aTitle Title for MMS items
+        * @param aDefaultName Default name for MMS items
+        * @param aCharacteristic The APPLICATION characteristic
+        * @param aCommsDb The CommsDB to use. Created if NULL.
+        * @param aAPHandler The APEngine data handler to use. Created if NULL.
+        * @return MWPWAPItemBase instance
+        */
+        static MWPWAPItemBase* CreateMMSLC( const TDesC& aTitle, 
+            const TDesC& aDefaultName, 
+            CWPCharacteristic& aCharacteristic, 
+            CCommsDatabase*& aCommsDb, 
+            RCmManagerExt*& aCmManager );
+
+
+        /**
+        * Create a browser item.
+        * @param aFirst ETrue if this browser item is first
+        * @param aTitle Title for browser items
+        * @param aBookmarkTitle Title for bookmark items
+        * @param aDefaultName Default name for browser items
+        * @param aCharacteristic The APPLICATION characteristic
+        * @param aDb The CommsDB to use. Created if NULL.
+        * @param aAPHandler The APEngine data handler to use. Created if NULL.
+        * @param aBookmarkDb The bookmark database to use. Created if NULL.
+        * @return MWPWAPItemBase instance
+        */
+        /*static MWPWAPItemBase* CreateBrowserLC( TBool aFirst,
+            const TDesC& aTitle, 
+            const TDesC& aBookmarkTitle,
+            const TDesC& aDefaultName, 
+            const TDesC& aDefaultBookmarkName,
+            CWPCharacteristic& aCharacteristic, 
+            CCommsDatabase*& aCommsDb, 
+            RCmManagerExt*& aCmManager,
+            RFavouritesDb aBookmarkDb );
+            
+        /**
+        * Create a bookmark item.
+        * @param aTitle The title to be returned in Name().
+        * @param aDefaultName The default name for bookmarks.
+        * @param aResource The RESOURCE characteristic.
+        * @param aLink Link to NAPDEF
+        * @param aDb The bookmark database to use. Created if NULL.
+        * @return MWPWAPItemBase instance
+        */
+        static MWPWAPItemBase* CreateBookmarkLC( const TDesC& aTitle, 
+            const TDesC& aDefaultName, 
+            CWPCharacteristic& aResource, 
+            CWPCharacteristic*& aNapdef);
+
+    };
+
+
+#endif  // WPITEMFACTORY_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Inc/WPWAPUtil.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,70 @@
+/*
+* 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: 
+*     Utility class for reading resource strings.
+*
+*/
+
+
+#ifndef WPWAPUTIL_H
+#define WPWAPUTIL_H
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class RResourceFile;
+
+// CLASS DECLARATION
+
+/**
+ * WPWAPUtil is a utility class for reading resource strings.
+ *
+ * @lib WPWAPAdapter
+ * @since 2.0
+ */ 
+class WPWAPUtil
+    {
+    public: // New functions
+        /**
+        * Loads a specified resource string from resource file.
+        * @param aResourceId is of a resource string.
+        * @return pointer to loaded descriptor.
+        */
+        static HBufC* ReadHBufCL( TInt aResourceId );
+
+        /**
+        * Searches for the resource file with the correct language extension 
+        * for the language of the current locale, or failing this, the best 
+        * matching file.
+        * @param aFs reference to file server.
+        * @param aResFileName resource file name.
+        * @param aResFile reference to resource file.
+        */
+        static void FindAndOpenResourceFileLC(RFs& aFs, 
+            const TDesC& aResFileName, 
+            RResourceFile& aResFile);
+
+        /**
+        * Checks if a URL is valid.
+        * @param aURL the URL to check
+        * @return ETrue if the URL is valid
+        */
+        static TBool CheckURI( const TDesC& aUrl );
+
+    };
+
+#endif  // WPWAPUTIL_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Src/CWPWAPAdapterBase.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,261 @@
+/*
+* 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:  Base for WAP adapters.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <commdb.h>
+#include <cmmanagerext.h>
+#include <cmconnectionmethodext.h>
+#include <CWPAdapter.h>
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+#include <wpwapadapterresource.rsg>
+#include "CWPWAPItemBAse.h"
+#include "CWPWAPAdapterBase.h"
+#include "WPWAPDebug.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::CWPWAPAdapterBase
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPWAPAdapterBase::CWPWAPAdapterBase()
+    : CWPAdapter()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::BaseConstructL
+// 2nd phase base class constructor.
+// -----------------------------------------------------------------------------
+//
+void CWPWAPAdapterBase::BaseConstructL()
+    {
+    }
+
+// Destructor
+CWPWAPAdapterBase::~CWPWAPAdapterBase()
+    {
+    iItems.ResetAndDestroy();
+    iHiddenItems.ResetAndDestroy();
+    delete iCommsDb;
+    
+    if ( iCmManager !=  NULL )
+        {
+        iCmManager->Close();
+        delete iCmManager;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::SummaryCount
+// -----------------------------------------------------------------------------
+//
+TInt CWPWAPAdapterBase::ItemCount() const
+    {
+    return iItems.Count();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::SummaryTitle
+// -----------------------------------------------------------------------------
+//
+const TDesC16& CWPWAPAdapterBase::SummaryTitle(TInt aIndex) const
+    {
+    return iItems[aIndex]->Title();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::SummaryText
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPWAPAdapterBase::SummaryText(TInt aIndex) const
+    {
+    return iItems[aIndex]->Name();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::SaveL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPAdapterBase::SaveL(TInt aIndex)
+    {
+    iItems[aIndex]->SaveL();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::CanSetAsDefault
+// -----------------------------------------------------------------------------
+//
+TBool CWPWAPAdapterBase::CanSetAsDefault(TInt aIndex) const
+    {
+    return iItems[aIndex]->CanSetAsDefault();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::SetAsDefaultL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPAdapterBase::SetAsDefaultL(TInt aIndex)
+    {
+    iItems[aIndex]->SetAsDefaultL();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::DetailsL
+// -----------------------------------------------------------------------------
+//
+TInt CWPWAPAdapterBase::DetailsL( TInt /*aItem*/, MWPPairVisitor& /*aVisitor*/ )
+    {
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPAdapterBase::VisitL( CWPCharacteristic& aCharacteristic )
+    {
+    switch( aCharacteristic.Type() )
+        {
+        case KWPApplication:
+            {
+            aCharacteristic.AcceptL( *this );
+            ApplicationL( aCharacteristic );
+            iAppID.Set( KNullDesC );
+            break;
+            }
+
+        default:
+            {
+            break;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPAdapterBase::VisitL( CWPParameter& aParameter )
+    {
+    if( aParameter.ID() == EWPParameterAppID )
+        {
+        iAppID.Set( aParameter.Value() );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPAdapterBase::VisitLinkL( CWPCharacteristic& /*aLink*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::ContextExtension
+// -----------------------------------------------------------------------------
+//
+TInt CWPWAPAdapterBase::ContextExtension( MWPContextExtension*& aExtension )
+    {
+    aExtension = this;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::SaveDataL
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CWPWAPAdapterBase::SaveDataL( TInt aIndex ) const
+    {
+    return iItems[aIndex]->SaveData();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::DeleteL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPAdapterBase::DeleteL( const TDesC8& aSaveData )
+    {
+    CreateDbL();
+
+    TPckgBuf<MWPWAPItemBase::TWPWAPSaveItem> pckg;
+    pckg.Copy( aSaveData );
+
+    // Base class handles only access point deletion
+    if( pckg().iSaveItemType == KWPWAPItemTypeAccesspoint )
+        {
+        DVA( "DeleteL: Deleting access point %08x", pckg().iUID );
+        TRAPD( err, iCmManager->ConnectionMethodL( pckg().iUID).DeleteL());
+        DVA( "DeleteL: Deleted, %d", err );
+        
+        switch( err )
+            {
+            case KErrNotFound:
+                {
+                // Item not existing is what we want, so this error is ok
+                break;
+                }
+                
+            case KErrLocked:
+                {
+                // Transform the code so that the caller can retry
+                User::Leave( EWPCommsDBLocked );
+                break;
+                }
+                
+            default:
+                {
+                User::LeaveIfError( err );
+                break;
+                }
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::Uid
+// -----------------------------------------------------------------------------
+//
+TUint32 CWPWAPAdapterBase::Uid() const
+    {
+    return iDtor_ID_Key.iUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPAdapterBase::CreateDbL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPAdapterBase::CreateDbL()
+    {
+    if( !iCommsDb )
+        {
+        iCommsDb = CCommsDatabase::NewL();
+        }
+    iCmManager = new RCmManagerExt;
+    iCmManager->OpenL();
+
+    
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Src/CWPWAPBookmarkItem.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,268 @@
+/*
+* Copyright (c) 2002-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:  One bookmark item.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+#include <wpwapadapterresource.rsg>
+#include <CWPAdapter.h>
+#include "CWPWAPBookmarkItem.h"
+#include "WPWAPUtil.h"
+
+// CONSTANTS
+const TInt KUrlMaxLength = 255;
+const TInt KNameMaxLength = 50;
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::CWPWAPBookmarkItem
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPWAPBookmarkItem::CWPWAPBookmarkItem( const TDesC& aTitle, 
+    const TDesC& aDefaultName, 
+    CWPCharacteristic*& aLink)
+: iTitle( aTitle ), iDefaultName( aDefaultName ), iLink( aLink )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBookmarkItem::ConstructL( CWPCharacteristic& aCharacteristic )
+    {
+    aCharacteristic.AcceptL( *this );
+    if( iName == KNullDesC )
+        {
+        iName.Set( iDefaultName );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWPWAPBookmarkItem* CWPWAPBookmarkItem::NewL(  const TDesC& aTitle, 
+    const TDesC& aDefaultName, 
+    CWPCharacteristic& aCharacteristic, 
+    CWPCharacteristic*& aLink)
+    {
+    CWPWAPBookmarkItem* self = new(ELeave) CWPWAPBookmarkItem( aTitle, 
+        aDefaultName, aLink); 
+    CleanupStack::PushL(self);
+    self->ConstructL( aCharacteristic );
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// Destructor
+CWPWAPBookmarkItem::~CWPWAPBookmarkItem()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::Name
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPWAPBookmarkItem::Name() const
+    {
+    return iName;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::Title
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPWAPBookmarkItem::Title() const
+    {
+    return iTitle;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::Title
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPWAPBookmarkItem::Address() const
+    {
+    return iURI;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::SaveID
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CWPWAPBookmarkItem::SaveData() const
+    {
+    if( iSaveItem().iSaveItemType != KWPWAPItemTypeNone )
+        {
+        return iSaveItem;
+        }
+    else
+        {
+        return KNullDesC8;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::AddL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBookmarkItem::AddL( RPointerArray<MWPWAPItemBase>& aShownItems,
+                              RPointerArray<MWPWAPItemBase>& /*aHiddenItems*/ )
+    {
+    User::LeaveIfError( aShownItems.Append( this ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::SaveL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBookmarkItem::SaveL()
+    {
+    TPckgBuf<TUint32> uid;
+    if( iLink && iLink->Data().Length() == uid.MaxLength() )
+        {
+        uid.Copy( iLink->Data() );
+        iUID = uid();
+        }
+
+    CreateDbL();
+    
+    //CFavouritesItem* item = CFavouritesItem::NewL();
+    //CleanupStack::PushL( item );
+    
+    //item->SetType( CFavouritesItem::EItem );
+    //item->SetParentFolder( KFavouritesRootUid );
+    //item->SetNameL( iName );
+    //item->SetUrlL( iURI ); 
+    
+    //if( iUID != KWPWAPNoUID )
+    //    {
+    //    TFavouritesWapAp ap;
+    //    ap.SetApId( iUID );
+    //    item->SetWapAp( ap );
+    //    } 
+    //TInt err( iBookmarkDb.Add( *item, ETrue ) );
+    //if( err == KErrLocked )
+    //    {
+     //   err = EWPBookmarksLocked;
+    //    }
+    //User::LeaveIfError( err );
+    //iSaveItem().iSaveItemType = KWPWAPItemTypeBookmark;
+    //iSaveItem().iUID = item->Uid();
+    
+    CleanupStack::PopAndDestroy(); // item
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::CanSetAsDefault
+// -----------------------------------------------------------------------------
+//
+TBool CWPWAPBookmarkItem::CanSetAsDefault() const
+    {
+    // Startpage support. This can be set as default if this is to be 
+    // interpreted as startpage.
+    return iHasStartPage;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::SetAsDefaultL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBookmarkItem::SetAsDefaultL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::ValidateL
+// -----------------------------------------------------------------------------
+//
+TBool CWPWAPBookmarkItem::ValidateL()
+    {
+    return iURI.Length() <= KUrlMaxLength
+        && iName.Length() <= KNameMaxLength
+        && iURI.Length() > 0
+        && WPWAPUtil::CheckURI( iURI );
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBookmarkItem::VisitL( CWPCharacteristic& /*aCharacteristic*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBookmarkItem::VisitL( CWPParameter& aParameter )
+    {
+    switch( aParameter.ID() )
+        {
+        case EWPParameterURI:
+            {
+            iURI.Set( aParameter.Value() );
+            break;
+            }
+
+        case EWPParameterName:
+            {
+            iName.Set( aParameter.Value() );
+            break;
+            }
+
+        case EWPParameterStartPage:
+            {
+            iHasStartPage = ETrue;
+            break;
+            }
+        default:
+            {
+            break;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBookmarkItem::VisitLinkL( CWPCharacteristic& /*aLink*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBookmarkItem::CreateDbL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBookmarkItem::CreateDbL()
+    {
+    //User::LeaveIfError( iSession.Connect() );
+    //User::LeaveIfError( iBookmarkDb.Open( iSession, KBrowserBookmarks ) );
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Src/CWPWAPBrowserAdapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,194 @@
+/*
+* Copyright (c) 2002-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:  Handles browser settings in provisioning.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <favouritesdb.h>
+#include <CWPAdapter.h>
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+#include <wpwapadapterresource.rsg>
+#include "CWPWAPBrowserAdapter.h"
+#include "MWPWAPItemBase.h"
+#include "WPWAPItemFactory.h"
+#include "WPWAPUtil.h"
+#include "WPWAPDebug.h"
+
+// CONSTANTS
+_LIT( KBrowserAppID, "w2" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserAdapter::CWPWAPBrowserAdapter
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPWAPBrowserAdapter::CWPWAPBrowserAdapter()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserAdapter::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBrowserAdapter::ConstructL()
+    {
+    BaseConstructL();
+
+    iTitle = WPWAPUtil::ReadHBufCL( R_QTN_OP_HEAD_BROWSER );
+    iBookmarkTitle = WPWAPUtil::ReadHBufCL( R_QTN_SM_BOOKMARKS );
+    iDefaultName = WPWAPUtil::ReadHBufCL( R_QTN_SM_WAPAP_NAME );
+    iDefaultBookmarkName = WPWAPUtil::ReadHBufCL( R_QTN_SM_BOOKMARK_NAME );
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserAdapter::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWPWAPBrowserAdapter* CWPWAPBrowserAdapter::NewL()
+    {
+    CWPWAPBrowserAdapter* self = new(ELeave) CWPWAPBrowserAdapter; 
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// Destructor
+CWPWAPBrowserAdapter::~CWPWAPBrowserAdapter()
+    {
+    delete iTitle;
+    delete iBookmarkTitle;
+    delete iDefaultName;
+    delete iDefaultBookmarkName;
+    iFavouritesDb.Close();
+    iSession.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserAdapter::ApplicationL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBrowserAdapter::ApplicationL( CWPCharacteristic& aCharacteristic )
+    {
+    if( iAppID == KBrowserAppID )
+        {
+        MWPWAPItemBase* item = WPWAPItemFactory::CreateBrowserLC( !iProcessed, *iTitle, 
+            *iBookmarkTitle, *iDefaultName, *iDefaultBookmarkName, 
+            aCharacteristic, iCommsDb, iCmManager, iFavouritesDb );
+
+        if( item->ValidateL() )
+            {
+            iProcessed = ETrue;
+            item->AddL( iItems, iHiddenItems );
+            CleanupStack::Pop(); // item
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy(); // item
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserAdapter::DeleteL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBrowserAdapter::DeleteL( const TDesC8& aSaveData )
+    {
+    CreateDbL();
+
+    TPckgBuf<MWPWAPItemBase::TWPWAPSaveItem> item;
+    item.Copy( aSaveData );
+
+    switch( item().iSaveItemType )
+        {
+        case KWPWAPItemTypeAccesspoint:
+            {
+            // Access point deletion is handled by the base class
+            CWPWAPAdapterBase::DeleteL( aSaveData );
+            break;
+            }
+
+        case KWPWAPItemTypeBookmark:
+            {
+            DVA( "DeleteL: Deleting bookmark %08x", item().iUID );
+            TInt err = iFavouritesDb.Begin( ETrue );
+            iFavouritesDb.CleanupRollbackPushL();  // push a rollback
+            
+            DVA( "DeleteL: Transaction, %d", err );
+            if( err == KErrNone )
+                {
+                err = iFavouritesDb.Delete( item().iUID );
+                DVA( "DeleteL: Deleted, %d", err );
+                iFavouritesDb.Commit();
+                DEBUG( "DeleteL: Committed" );
+                }
+            CleanupStack::Pop();    // pop the rollback
+
+            switch( err )
+                {
+                case KErrNotFound:
+                    {
+                    // Item not existing is what we want, so this error is ok
+                    break;
+                    }
+                    
+                case KErrLocked:
+                    {
+                    User::Leave( EWPBookmarksLocked );
+                    break;
+                    }
+                    
+                default:
+                    {
+                    User::LeaveIfError( err );
+                    break;
+                    }
+                }
+            break;
+            }
+
+        default:
+            {
+            // Don't know how to delete an item of this type. Better
+            // just ignore it.
+            break;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserAdapter::CreateDbL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBrowserAdapter::CreateDbL()
+    {
+    User::LeaveIfError( iSession.Connect() );
+    User::LeaveIfError( iFavouritesDb.Open( iSession, KBrowserBookmarks ) );
+
+    CWPWAPAdapterBase::CreateDbL();
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Src/CWPWAPBrowserItem.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,268 @@
+/*
+* Copyright (c) 2002-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:  One browser setting item.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <msvapi.h>
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+#include <CWPAdapter.h>
+#include <centralrepository.h>
+#include <browseruisdkcrkeys.h>
+#include "CWPWAPBrowserItem.h"
+#include "WPWAPItemFactory.h"
+#include "ProvisioningDebug.h"
+
+// CONSTANTS
+/// Delay to wait for WmlBrowser to catch up with changes in CommsDb. Microseconds.
+const TInt KWmlDelay = 4*500000;
+// Force browser to use User Defined AP
+const TInt KUserDefined = 0;
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserItem::CWPWAPBrowserItem
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPWAPBrowserItem::CWPWAPBrowserItem( TBool aFirst,
+                                      const TDesC& aTitle,
+                                      const TDesC& aBookmarkTitle,
+                                      const TDesC& aDefaultName, 
+                                      const TDesC& aDefaultBookmarkName,
+                                      CWPCharacteristic& aCharacteristic, 
+                                      CCommsDatabase*& aCommsDb, 
+                                      RCmManagerExt*& aCmManager,
+                                      RFavouritesDb aBookmarkDb 
+                                    )
+                                    : CWPWAPItemBase( aTitle,
+                                                      aDefaultName, 
+                                                      aCharacteristic, 
+                                                      aCommsDb, 
+                                                      aCmManager ), 
+                                    iDefaultBookmarkName( aDefaultBookmarkName ),
+                                    iBookmarkTitle( aBookmarkTitle ), 
+                                    iDb( aBookmarkDb ),
+                                    iFirst( aFirst )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserItem::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBrowserItem::ConstructL()
+    {
+    BaseConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserItem::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWPWAPBrowserItem* CWPWAPBrowserItem::NewL( TBool aFirst,
+                                            const TDesC& aTitle, 
+                                            const TDesC& aBookmarkTitle,
+                                            const TDesC& aDefaultName,  
+                                            const TDesC& aDefaultBookmarkName,
+                                            CWPCharacteristic& aCharacteristic, 
+                                            CCommsDatabase*& aCommsDb, 
+                                            RCmManagerExt*& aCmManager,
+                                            RFavouritesDb aBookmarkDb
+                                            )
+    {
+    CWPWAPBrowserItem* self = new(ELeave) CWPWAPBrowserItem( aFirst,
+                                                             aTitle, 
+                                                             aBookmarkTitle, 
+                                                             aDefaultName, 
+                                                             aDefaultBookmarkName,
+                                                             aCharacteristic, 
+                                                             aCommsDb, 
+                                                             aCmManager, 
+                                                             aBookmarkDb ); 
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CWPWAPBrowserItem::~CWPWAPBrowserItem()
+    {
+    iBookmarks.ResetAndDestroy();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserItem::SaveL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBrowserItem::SaveL()
+    {
+    CreateDbL();
+
+    TPckg<TUint32> uid( iUID );
+    // Check if the iLink->Data() contains an item of the same size as uid. 
+    // This is an extra check to ensure that iLink->Data() contains a packaged
+    // TUin32.
+    if( iLink && iLink->Data().Length() == uid.MaxLength() )
+        {
+        uid.Copy( iLink->Data() );
+        }
+    RCmConnectionMethodExt cm;
+    cm = iCmManager->ConnectionMethodL( iUID );
+    CleanupClosePushL( cm );
+    if( iAddr )
+        {
+        // Update the access point startpage
+        WriteHomePageL( cm );
+        }
+    CleanupStack::PopAndDestroy(); // cm
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserItem::CanSetAsDefault
+// -----------------------------------------------------------------------------
+//
+TBool CWPWAPBrowserItem::CanSetAsDefault() const
+    {
+    return iUID != KWPWAPNoUID;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserItem::SetAsDefaultL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBrowserItem::SetAsDefaultL()
+    {
+    FLOG( _L( "[Provisioning] CWPWAPBrowserItem::SetAsDefaultL:" ) );
+    
+  /*  CreateDbL();
+    TRAPD( err, iAPHandler->SetAsDefaultL( (TInt)iUID, EIspTypeWAPOnly) );
+    if( err == KErrLocked )
+        {
+        err = EWPCommsDBLocked;
+        }
+    // This function need to leave at the end of the function
+    // otherwise we dont set the default AP when db is locked
+    //User::LeaveIfError( err );
+    
+    // There's some delay before the WmlBrowser can find the stored 
+    // accesspoint from CommsDb so therefore we wait for a while before
+    // telling the WmlBrowser that default accesspoint should be changed.
+    // The value 500000 is chosen just by trying out.
+    User::After( KWmlDelay );
+
+    CRepository* repository = CRepository::NewLC( KCRUidBrowser );
+    FTRACE(RDebug::Print(
+                _L("[Provisioning] CWPWAPBrowserItem::SetAsDefaultL: AP:(%d)"),
+                                                                  (TInt)iUID));
+    
+    // Force the browser to use the User Defined AP selection mode.
+    User::LeaveIfError( repository->Set( KBrowserAccessPointSelectionMode,
+                                         KUserDefined ) );
+    // This sets the accesspoint default for browser.
+    User::LeaveIfError( repository->Set( KBrowserDefaultAccessPoint,
+                                         (TInt)iUID ) );
+
+    //Set the HomePage to default
+    if(iUID)
+        {
+        User::LeaveIfError( repository->Set( KBrowserNGHomepageType, EBrowserCenRepAccessPoint) );
+        }
+
+    CleanupStack::PopAndDestroy(); // repository
+    FLOG( _L( "[Provisioning] CWPWAPBrowserItem::SetAsDefaultL: Set Done" ) );
+
+    User::LeaveIfError( err );*/
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserItem::ValidateL
+// -----------------------------------------------------------------------------
+//
+TBool CWPWAPBrowserItem::ValidateL()
+    {
+    return iLink != NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserItem::ResourceL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBrowserItem::ResourceL( CWPCharacteristic& aResource )
+    {
+    MWPWAPItemBase* item = WPWAPItemFactory::CreateBookmarkLC( 
+                                                          iBookmarkTitle, 
+                                                          iDefaultBookmarkName,
+                                                          aResource, 
+                                                          iLink, 
+                                                          iDb );
+
+    if( item->CanSetAsDefault() && !iAddr )
+        {
+        iAddr = item->Address().AllocL();
+        CleanupStack::PopAndDestroy(); // item
+        }
+    else
+        {
+        User::LeaveIfError( iBookmarks.Append( item ) );
+        CleanupStack::Pop(); // item
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPBrowserItem::AddL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPBrowserItem::AddL( RPointerArray<MWPWAPItemBase>& aShownItems,
+                              RPointerArray<MWPWAPItemBase>& aHiddenItems )
+    {
+    for( TInt i( iBookmarks.Count()-1 ); i >= 0 ; i-- )
+        {
+        MWPWAPItemBase* item = iBookmarks[i];
+
+        if( item->ValidateL() )
+            {
+            // Transfer ownership of iBookmarks[i] to aItems
+            iBookmarks[i]->AddL( aShownItems, aHiddenItems );
+            }
+        else
+            {
+            // invalid items get deleted
+            delete item;
+            }
+        iBookmarks.Remove( i );
+        }
+
+    // Only first browser item is shown to the user.
+    if( iFirst )
+        {
+        User::LeaveIfError( aShownItems.Append( this ) );
+        }
+    else
+        {
+        User::LeaveIfError( aHiddenItems.Append( this ) );
+        }
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Src/CWPWAPItemBAse.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,303 @@
+/*
+* 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:  Base class for WAP setting items.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <msvapi.h>
+#include <mmsclient.h> 
+#include <mtclreg.h>
+#include <f32file.h>
+#include <barsc.h>
+#include <bautils.h>
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+#include <WPAdapterUtil.h>
+#include <commdb.h>
+#include <CWPAdapter.h>
+#include "CWPWAPItemBAse.h"
+#include "ProvisioningDebug.h"
+#include <cmconnectionmethoddef.h>
+
+// CONSTANTS
+const TInt KNamesGranularity = 1;
+const TInt KNameMaxLength = 50;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::CWPWAPItemBase
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPWAPItemBase::CWPWAPItemBase(  const TDesC& aTitle,
+                                 const TDesC& aDefaultName, 
+                                 CWPCharacteristic& aCharacteristic, 
+                                 CCommsDatabase*& aCommsDb, 
+                                 RCmManagerExt*& aCmManager)
+                                : iCharacteristic( aCharacteristic ), 
+                                  iTitle( aTitle ), 
+                                  iDefaultName( aDefaultName ), 
+                                  iCommsDb( aCommsDb ), 
+                                  iCmManager( aCmManager )
+    {
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::BaseConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPWAPItemBase::BaseConstructL()
+    {
+    iCharacteristic.AcceptL( *this );
+
+    if( iName == KNullDesC )
+        {
+        iName.Set( iDefaultName );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CWPWAPItemBase::~CWPWAPItemBase()
+    {
+    delete iAddr;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPItemBase::VisitL( CWPCharacteristic& aCharacteristic )
+    {
+    if( aCharacteristic.Type() == KWPResource )
+        {
+        ResourceL( aCharacteristic );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPItemBase::VisitL( CWPParameter& aParameter )
+    {
+    switch( aParameter.ID() )
+        {
+        case EWPParameterName:
+            {
+            iName.Set( aParameter.Value() );
+            break;
+            }
+
+        case EWPParameterAddr:
+            {
+            if( !iAddr )
+                {
+                iAddr = aParameter.Value().AllocL();
+                }
+            break;
+            }
+
+        default:
+            {
+            break;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::VisitLinkL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPItemBase::VisitLinkL( CWPCharacteristic& aLink )
+    {
+    if( !iLink )
+        {
+        iLink = &aLink;
+
+        if( iName == KNullDesC )
+            {
+            // Get the name
+            CArrayFix<TPtrC>* names = new(ELeave) CArrayFixFlat<TPtrC>( KNamesGranularity );
+            CleanupStack::PushL( names );
+            aLink.ParameterL( EWPParameterName, names );
+            if( names->Count() > 0 )
+                {
+                iName.Set( names->At(0) );
+                }
+            CleanupStack::PopAndDestroy(); // names
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::Name
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPWAPItemBase::Name() const
+    {
+    return iName;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::Title
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPWAPItemBase::Title() const
+    {
+    return iTitle;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::Address
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPWAPItemBase::Address() const
+    {
+    if( iAddr )
+        {
+        return *iAddr;
+        }
+    else
+        {
+        return KNullDesC;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::SaveData
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CWPWAPItemBase::SaveData() const
+    {
+    if( iSaveItem().iSaveItemType != KWPWAPItemTypeNone )
+        {
+        return iSaveItem;
+        }
+    else
+        {
+        return KNullDesC8;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::CreateDbL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPItemBase::CreateDbL()
+    {
+    if( !iCommsDb )
+        {
+        iCommsDb = CCommsDatabase::NewL();
+        }
+
+    if( !iCmManager )
+        {
+        iCmManager = new RCmManagerExt;
+        iCmManager->OpenL();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::WriteHomePageL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPItemBase::WriteHomePageL( RCmConnectionMethodExt& aCmItem )
+    {
+    FLOG( _L( "[Provisioning] CWPWAPItemBase::WriteHomePageL:" ) );
+
+    if( iAddr )
+    {
+      	HBufC* startPage = aCmItem.GetStringAttributeL(CMManager::ECmStartPage);
+        TInt length = startPage->Length();
+        delete startPage;
+        
+        if( length > 0 )
+            {
+            FLOG( _L( "[Provisioning] CWPWAPItemBase::WriteHomePageL: EApWapStartPage " ) );
+            // Make a copy of the AP
+            RCmConnectionMethodExt cm = aCmItem.CreateCopyL();
+            CleanupClosePushL( cm );
+            
+            // Create a proper name for the copy
+            TBuf<KNameMaxLength> name( iName.Left( KNameMaxLength ) );
+           // MakeValidNameL( name, *iCommsDb );
+            
+            
+            // Write name 
+            cm.SetStringAttributeL(CMManager::ECmName,name);
+            //cm.SetStringAttributeL(CMManager::ENamingUnique,name);
+            
+            // Write MMSC address
+            cm.SetStringAttributeL(CMManager::ECmStartPage,*iAddr);
+            
+            // Create the new access point
+            TRAPD( err, cm.UpdateL() );
+            
+            FTRACE(RDebug::Print(_L("[Provisioning] CWPWAPItemBase::WriteHomePageL: CreateFromDataL err (%d)"), err));
+            FTRACE(RDebug::Print(_L("[Provisioning] CWPWAPItemBase::WriteHomePageL: CreateFromDataL iUID (%d)"), iUID));
+            
+            if( err == KErrLocked )
+                {
+                err = EWPCommsDBLocked;
+                }
+            User::LeaveIfError( err );
+
+            iSaveItem().iSaveItemType = KWPWAPItemTypeAccesspoint;
+            iUID = aCmItem.GetIntAttributeL(CMManager::ECmIapId);
+            iSaveItem().iUID = iUID;
+
+            CleanupStack::PopAndDestroy(); // newItem
+            }
+        else
+            {
+            FLOG( _L( "[Provisioning] CWPWAPItemBase::WriteHomePageL: EApWapStartPage 0 " ) );
+            aCmItem.SetStringAttributeL(CMManager::ECmStartPage,*iAddr);
+            
+            // Update the access point
+            TBool nameChanged( EFalse );
+            TRAPD( err, aCmItem.UpdateL() );
+            FTRACE(RDebug::Print(_L("[Provisioning] CWPWAPItemBase::WriteHomePageL: CreateFromDataL err (%d)"), err));
+            if( err == KErrLocked )
+                {
+                err = EWPCommsDBLocked;
+                }
+            User::LeaveIfError( err );
+            iUID = aCmItem.GetIntAttributeL(CMManager::ECmIapId);
+            FTRACE(RDebug::Print(_L("[Provisioning] CWPWAPItemBase::WriteHomePageL: CreateFromDataL iUID (%d)"), iUID));
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPItemBase::MakeValidNameL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPItemBase::MakeValidNameL( TDes& aName, CCommsDatabase& aDb ) const
+    {
+   /* CApUtils* utils = CApUtils::NewLC( aDb );
+    utils->MakeValidNameL( aName );
+    CleanupStack::PopAndDestroy(); // utils*/
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Src/CWPWAPMMSAdapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,102 @@
+/*
+* 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:  Handles MMS settings in provisioning.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "CWPWAPMMSAdapter.h"
+#include <e32base.h>
+#include <CWPAdapter.h>
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+#include <wpwapadapterresource.rsg>
+#include "MWPWAPItemBase.h"
+#include "WPWAPUtil.h"
+#include "WPWAPItemFactory.h"
+
+// CONSTANTS
+_LIT( KMMSAppID, "w4" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSAdapter::CWPWAPMMSAdapter
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPWAPMMSAdapter::CWPWAPMMSAdapter()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSAdapter::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPWAPMMSAdapter::ConstructL()
+    {
+    BaseConstructL();
+
+    iTitle = WPWAPUtil::ReadHBufCL( R_QTN_SM_MMS_ACCESSPOINTS );
+    iDefaultName = WPWAPUtil::ReadHBufCL( R_QTN_SM_WAPAP_NAME );
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSAdapter::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWPWAPMMSAdapter* CWPWAPMMSAdapter::NewL()
+    {
+    CWPWAPMMSAdapter* self = new(ELeave) CWPWAPMMSAdapter; 
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// Destructor
+CWPWAPMMSAdapter::~CWPWAPMMSAdapter()
+    {
+    delete iTitle;
+    delete iDefaultName;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSAdapter::ApplicationL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPMMSAdapter::ApplicationL( CWPCharacteristic& aCharacteristic )
+    {
+    if( iItems.Count() == 0 && iAppID == KMMSAppID )
+        {
+        MWPWAPItemBase* item = WPWAPItemFactory::CreateMMSLC( *iTitle, *iDefaultName, 
+            aCharacteristic, iCommsDb, iCmManager );
+        if( item->ValidateL() )
+            {
+            item->AddL( iItems, iHiddenItems );
+            CleanupStack::Pop(); // item
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy(); // item
+            }
+        }
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Src/CWPWAPMMSItem.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,250 @@
+/*
+* Copyright (c) 2002-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:  One MMS setting item.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <msvapi.h>
+#include <mmsclient.h> 
+#include <mtclreg.h>
+#include <cmmanagerext.h>
+#include <cmconnectionmethodext.h>
+#include <cmpluginpacketdatadef.h>
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+#include <CWPAdapter.h>
+#include "CWPWAPMMSItem.h"
+#include "WPWAPItemFactory.h"
+#include "WPWAPUtil.h"
+
+#ifdef __MESSAGING_API_V2__
+#include <mmssettings.h>
+#endif
+
+// CONSTANTS
+const TInt KUrlMaxLength = 255;
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSItem::CWPWAPMMSItem
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPWAPMMSItem::CWPWAPMMSItem(  const TDesC& aTitle, 
+    const TDesC& aDefaultName, 
+    CWPCharacteristic& aCharacteristic, 
+    CCommsDatabase*& aDb, 
+    RCmManagerExt*& aCmManager )
+: CWPWAPItemBase( aTitle, aDefaultName, aCharacteristic, aDb, aCmManager )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSItem::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPWAPMMSItem::ConstructL()
+    {
+    BaseConstructL();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSItem::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWPWAPMMSItem* CWPWAPMMSItem::NewL( const TDesC& aTitle, 
+    const TDesC& aDefaultName, 
+    CWPCharacteristic& aCharacteristic, 
+    CCommsDatabase*& aDb, 
+    RCmManagerExt*& aCmManager )
+    {
+    CWPWAPMMSItem* self = new(ELeave) CWPWAPMMSItem( aTitle, aDefaultName, 
+        aCharacteristic, aDb, aCmManager ); 
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// Destructor
+CWPWAPMMSItem::~CWPWAPMMSItem()
+    {
+    iLinks.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSItem::SaveL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPMMSItem::SaveL()
+    {
+    CreateDbL();
+	TBool check = EFalse;
+    RCmConnectionMethodExt cm;
+    TUint32 bearer = 0;
+    for( TInt i( 0 ); i < iLinks.Count() && check == EFalse ; i++ )
+       {
+       CWPCharacteristic* curr = iLinks[i];
+       TPckgBuf<TUint32> uidPckg;
+       const TInt pkgLength( uidPckg.MaxLength() );
+       for( TInt dataNum( 0 ); check == EFalse && curr->Data( dataNum ).Length() == pkgLength;dataNum++ )
+          {
+          uidPckg.Copy( curr->Data( dataNum ) );
+          // Read the access point pointed to by TO-NAPID or TO-PROXY
+          cm = iCmManager->ConnectionMethodL( uidPckg() );
+          CleanupClosePushL( cm );
+          bearer = cm.GetIntAttributeL( CMManager::ECmBearerType );
+          if( bearer == KUidPacketDataBearerType )
+            {
+            // Item left on cleanup stack
+            check = ETrue;
+            }
+          else
+            {
+            CleanupStack::PopAndDestroy(); // cm
+            }
+          }
+        }
+    
+    WriteHomePageL( cm );    
+    CleanupStack::PopAndDestroy(); // cm
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSItem::CanSetAsDefault
+// -----------------------------------------------------------------------------
+//
+TBool CWPWAPMMSItem::CanSetAsDefault() const
+    {
+    return ETrue;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSItem::SetAsDefaultL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPMMSItem::SetAsDefaultL()
+    {
+    // Open Messaging Server session
+    CMsvSession* session = CMsvSession::OpenSyncL( *this );
+    CleanupStack::PushL( session );
+
+    // Read the MMS client information via registry
+    CClientMtmRegistry* registry = CClientMtmRegistry::NewL( *session );
+    CleanupStack::PushL( registry );
+    
+    CMmsClientMtm* mmsClient = 
+        static_cast<CMmsClientMtm*>( registry->NewMtmL( KUidMsgTypeMultimedia ) );
+    CleanupStack::PushL( mmsClient );
+
+#ifdef __MESSAGING_API_V2__
+
+    CMmsSettings* mmsSettings = CMmsSettings::NewL();
+    CleanupStack::PushL( mmsSettings );
+    
+    mmsClient->RestoreSettingsL();
+
+    mmsSettings->CopyL( mmsClient->MmsSettings() );
+    TInt apCount =  mmsSettings->AccessPointCount();
+    TInt index;
+    for ( index = 0; index < apCount; index++)
+	    {
+	  	    mmsSettings->DeleteAccessPointL( 0 );	
+	    }
+	  mmsSettings->AddAccessPointL( iUID, 0 );    
+    mmsClient->SetSettingsL( *mmsSettings );
+    mmsClient->StoreSettingsL();
+
+    CleanupStack::PopAndDestroy(); // mmsSettings
+
+#else
+
+    mmsClient->LoadMessageL();
+    // Set the correct access point and save
+    mmsClient->SetFirstAccessPoint( iUID );
+    mmsClient->SaveMessageL();
+
+#endif
+
+    CleanupStack::PopAndDestroy(3); // mmsClient, registry, session
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSItem::ValidateL
+// -----------------------------------------------------------------------------
+//
+TBool CWPWAPMMSItem::ValidateL()
+    {
+    return iLinks.Count() > 0
+        && iAddr
+        && iAddr->Length() <=KUrlMaxLength
+        && WPWAPUtil::CheckURI( *iAddr );
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSItem::ResourceL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPMMSItem::ResourceL( CWPCharacteristic& aResource )
+    {     
+    MWPWAPItemBase* item = WPWAPItemFactory::CreateBookmarkLC( KNullDesC, 
+        KNullDesC, aResource, iLink ); // iDb is NULL but it's not used.
+
+    // Not supporting resources without startpage.
+    if ( item->CanSetAsDefault() && !iAddr )
+        {
+        iAddr = item->Address().AllocL();
+        }
+    CleanupStack::PopAndDestroy();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSItem::AddL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPMMSItem::AddL( RPointerArray<MWPWAPItemBase>& aShownItems,
+                              RPointerArray<MWPWAPItemBase>& /*aHiddenItems*/ )
+    {
+    User::LeaveIfError( aShownItems.Append( this ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSItem::VisitLinkL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPMMSItem::VisitLinkL( CWPCharacteristic& aLink )
+    {
+    CWPWAPItemBase::VisitLinkL( aLink );
+    User::LeaveIfError( iLinks.Append( &aLink ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CWPWAPMMSItem::HandleSessionEventL
+// -----------------------------------------------------------------------------
+//
+void CWPWAPMMSItem::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, 
+    TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
+    {
+    }
+
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Src/WPWAPAdapterGroupProxy.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,46 @@
+/*
+* 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:  Table of plugins for ECom
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <implementationproxy.h>
+#include "ProvisioningUIDs.h"
+#include "CWPWAPMMSAdapter.h"
+//#include "CWPWAPBrowserAdapter.h"
+
+// CONSTANTS
+const TImplementationProxy KImplementationTable[] = 
+    {
+		IMPLEMENTATION_PROXY_ENTRY( KProvisioningMMSAdapterUid, CWPWAPMMSAdapter::NewL )
+    };
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(KImplementationTable) / sizeof(TImplementationProxy);
+
+    return KImplementationTable;
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Src/WPWAPAdapterMain.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2002-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:  DLL entry point
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32debug.h>
+#include <e32std.h>
+#include <flogger.h>
+#include "WPWAPDebug.h"
+
+// CONSTANTS
+
+#ifdef WAPDEBUG
+#ifdef WINS
+/// Folder where the log resides
+_LIT( KLogFolder, "provisioning" );
+
+/// The name of the log file
+_LIT( KLogFileName, "wapadapter" );
+
+/// The format in which the time is formatted in log
+_LIT( KLogTimeFormat, "%02d.%02d:%02d:%06d ");
+
+/// The length of the string produced by KLogTimeFormat
+const TInt KLogTimeFormatLength = 16;
+
+/// How many characters a log line can contain
+const TInt KLogLineLength = 256;
+#endif
+#endif 
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// Debug
+// -----------------------------------------------------------------------------
+//
+#ifdef WAPDEBUG
+GLDEF_C void Debug( TRefByValue<const TDesC> aText, ... )
+    {
+    #ifdef WINS
+    VA_LIST args;
+    VA_START( args, aText );
+
+    TBuf<KLogLineLength> buf;
+    buf.FormatList( aText, args );
+
+    RFileLogger logger;
+    TInt ret=logger.Connect();
+    if (ret==KErrNone)
+        {
+        logger.SetDateAndTime( EFalse,EFalse );
+        logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend );       
+        TBuf<KLogTimeFormatLength> timeStamp;
+        TTime now;
+        now.HomeTime();
+        TDateTime dateTime;
+        dateTime = now.DateTime();
+        timeStamp.Format( KLogTimeFormat, 
+            dateTime.Hour(), dateTime.Minute(),
+            dateTime.Second(), dateTime.MicroSecond() );
+        buf.Insert( 0, timeStamp );
+
+        logger.Write(buf);
+        }
+
+    logger.Close();
+
+    VA_END( args );
+    #else
+    RDebug::Print(aText);
+    #endif
+    }
+#else
+GLDEF_C void Debug( TRefByValue<const TDesC> /*aText*/, ... )
+    {
+    }
+#endif
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Src/WPWAPItemFactory.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2002-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:  WPWAPItemFactory creates WAP settings items.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "WPWAPItemFactory.h"
+#include "CWPWAPMMSItem.h"
+//#include "CWPWAPBrowserItem.h"
+#include "CWPWAPBookmarkItem.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// WPWAPItemFactory::CreateMMSL
+// -----------------------------------------------------------------------------
+//
+MWPWAPItemBase* WPWAPItemFactory::CreateMMSLC( const TDesC& aTitle, 
+            const TDesC& aDefaultName, 
+            CWPCharacteristic& aCharacteristic, 
+            CCommsDatabase*& aCommsDb, 
+            RCmManagerExt*& aCmManager )
+    {
+    CWPWAPMMSItem* item = CWPWAPMMSItem::NewL( aTitle, aDefaultName, 
+        aCharacteristic, aCommsDb, aCmManager );
+    CleanupStack::PushL( item );
+    return item;
+    }
+
+// -----------------------------------------------------------------------------
+// WPWAPItemFactory::CreateBrowserL
+// -----------------------------------------------------------------------------
+//
+/*MWPWAPItemBase* WPWAPItemFactory::CreateBrowserLC( TBool aFirst,
+            const TDesC& aTitle, 
+            const TDesC& aBookmarkTitle,
+            const TDesC& aDefaultName, 
+            const TDesC& aDefaultBookmarkName,
+            CWPCharacteristic& aCharacteristic, 
+            CCommsDatabase*& aCommsDb, 
+            RCmManagerExt*& aCmManager,
+            RFavouritesDb aBookmarkDb )
+    {
+    CWPWAPBrowserItem* item = CWPWAPBrowserItem::NewL( aFirst, aTitle, aBookmarkTitle, 
+        aDefaultName, aDefaultBookmarkName, aCharacteristic, aCommsDb, aCmManager, aBookmarkDb );
+    CleanupStack::PushL( item );
+    return item;
+    }
+*/
+// -----------------------------------------------------------------------------
+// WPWAPItemFactory::CreateMMSL
+// -----------------------------------------------------------------------------
+//
+MWPWAPItemBase* WPWAPItemFactory::CreateBookmarkLC( const TDesC& aTitle, 
+            const TDesC& aDefaultName, 
+            CWPCharacteristic& aResource, 
+            CWPCharacteristic*& aLink
+            )
+    {
+    CWPWAPBookmarkItem* item = CWPWAPBookmarkItem::NewL( aTitle, 
+        aDefaultName, aResource, aLink);
+    CleanupStack::PushL( item );
+    return item;
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/WAPAdapter/Src/WPWAPUtil.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,60 @@
+/*
+* 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:  WPWAPUtil is a utility class for reading resource strings.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <f32file.h>
+#include <barsc.h>
+#include <bautils.h>
+#include <WPAdapterUtil.h>
+#include <CWPCharacteristic.h>
+#include <uri16.h>                // TUriParser8
+#include "WPWAPUtil.h"
+
+// CONSTANTS
+#if ( defined (__WINS__) || defined (__WINSCW) ) // this different on hw
+    _LIT( KAdapterName, "WPWAPAdapterResource" );
+#else
+    _LIT( KAdapterName, "WPWAPAdapter" );
+#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// WPWAPUtil::ReadHBufCL
+// -----------------------------------------------------------------------------
+//
+HBufC* WPWAPUtil::ReadHBufCL( TInt aResourceId )
+    {
+    TFileName fileName;
+    Dll::FileName( fileName );
+
+    return WPAdapterUtil::ReadHBufCL( fileName, KAdapterName, aResourceId );
+    }
+
+// -----------------------------------------------------------------------------
+// WPWAPUtil::CheckURL
+// -----------------------------------------------------------------------------
+//
+TBool WPWAPUtil::CheckURI( const TDesC& aUrl )
+    {
+    return WPAdapterUtil::CheckURI( aUrl );
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/CWPAPAccesspointItem.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,167 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Class stores data for one accesspoint
+*
+*/
+
+
+
+#ifndef CWPAPACCESSPOINTITEM_H
+#define CWPAPACCESSPOINTITEM_H
+
+// INCLUDES
+#include <e32def.h>
+#include <e32std.h>
+#include <e32base.h>
+#include <cmmanagerext.h>
+
+// FORWARD DECLARATIONS
+class CWPEngine;
+class CWPAPItemBase;
+class CWPParameter;
+class CWPCharacteristic;
+class CCommsDatabase;
+class CWPAPNapdef;
+class RCmManagerExt;
+
+// CLASS DECLARATION
+
+/**
+ * CWPAPAccesspointItem handles accesspoint settings. It links data from
+ * logical proxy, physical proxy and napdef into one item.
+ */ 
+class CWPAPAccesspointItem : public CBase
+	{
+	public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        * @param aDefaultName The default name if none is found
+        * @param aLogicalProxy The logical proxy 
+        * @param aPhysicalProxy The physical proxy 
+        * @param aNapdef The napdef
+        * @param aCharacteristic The characteristic 
+        */
+		static CWPAPAccesspointItem* NewLC(
+		                            const TDesC& aDefaultName,
+                                    CWPAPItemBase* iLogicalProxy,
+                                    CWPAPItemBase* iPhysicalProxy,
+                                    CWPAPItemBase* aNapdef,
+                                    CWPCharacteristic& aCharacteristic );
+
+        /**
+        * Destructor.
+        */
+		virtual ~CWPAPAccesspointItem();
+
+	public: // New methods
+
+		/**
+		* Get the accesspoint name.
+		* @return reference to name.
+		*/
+		const TDesC& Name() const;
+		
+		/**
+		* Get the NAPdef pointer
+		* @return pointer to napdef.
+		*/
+	  	CWPAPItemBase* NapDef();
+	  	
+	  	/**
+		* Set the pointer to the CM manager
+		* @return void
+		*/
+	  	void SetCMManager( RCmManagerExt* aCm );
+	  	
+	  	/**
+		* Get the characteristic value
+		* @return iCharacteristic.
+		*/
+	  	TInt Characteristic();
+		
+		/**
+		* Save this accesspoint to comms database.
+		* @param aCommsDb reference to CCommsdatabase
+		*/
+		TUint32 SaveL( CCommsDatabase& aCommsDb );
+
+        /**
+        * Return the UID of the saved access point.
+        * @return UID
+        */
+        const TDesC8& Uid() const;
+
+        /**
+        * Delete old data from engine model.
+        */
+        void DeleteUidData() const;
+
+	private:  // New functions
+
+		/**
+		* Store the accesspoint data to comms database.
+		* @param aCommsDb reference to CCommsdatabase
+		*/ 
+		TUint32 StoreL( CCommsDatabase& aCommsDb );
+
+		/**
+        * C++ default constructor.
+        * @param aDefaultName The default name if none is found
+        * @param aLogicalProxy The logical proxy 
+        * @param aPhysicalProxy The physical proxy 
+        * @param aNapdef The napdef
+        * @param aCharacteristic The characteristic 
+        */
+		CWPAPAccesspointItem( const TDesC& aDefaultName,
+                              CWPAPItemBase* iLogicalProxy,
+                              CWPAPItemBase* iPhysicalProxy,
+                              CWPAPItemBase* aNapdef,
+                              CWPCharacteristic& aCharacteristic );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+		void ConstructL();
+
+	private: // Data (Total ownership is assumed unless otherwise stated)
+
+        /// The default name if no other is found
+        const TDesC& iDefaultName;
+
+        /// The napdef
+        CWPAPItemBase* iNapdef;
+
+        /// The physical proxy
+        CWPAPItemBase* iPhysicalProxy;
+
+        /// The logical proxy
+        CWPAPItemBase* iLogicalProxy;
+
+        /// The uid created when saving
+        TPckgBuf<TUint32> iUid;
+
+        /// The characteristic the caused the creation of an access point
+        CWPCharacteristic& iCharacteristic;
+        RCmManagerExt* iCmManager;
+
+	private: // For testing usage.
+		friend class T_CWPAPAccesspointItem;
+		friend class T_CWPAPAdapter;
+		friend class T_WPAPTestUtils;
+	};
+
+#endif	// CWPAPACCESSPOINTITEM_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/CWPAPAdapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,119 @@
+/*
+* 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:    Main class for handling provisioning accesspoint data
+*
+*/
+
+
+
+#ifndef CWPAPADAPTER_H
+#define CWPAPADAPTER_H
+
+// INCLUDES
+
+#include <CWPAdapter.h>
+#include <MWPContextExtension.h>
+#include <cmmanagerext.h>
+
+// FORWARD DECLARATIONS
+
+class CWPAPAccesspointItem;
+class CCommsDatabase;
+
+// CLASS DECLARATION
+
+/**
+ * CWPAPAdapter handles accesspoint settings.
+ */ 
+class CWPAPAdapter : public CWPAdapter, public MWPContextExtension
+	{
+	public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+		* @return a instance of class.
+        */
+		static CWPAPAdapter* NewL();
+
+		/**
+		* Destructor
+		*/
+		~CWPAPAdapter();
+
+	public: // From CWPAdapter
+
+		TInt ItemCount() const;
+		const TDesC16& SummaryTitle(TInt aIndex) const;
+		const TDesC16& SummaryText(TInt aIndex) const;
+		TInt DetailsL( TInt aItem, MWPPairVisitor& aVisitor );
+		void SaveL( TInt aItem );
+		TBool CanSetAsDefault( TInt aItem ) const;
+		void SetAsDefaultL( TInt aItem );
+		void VisitL(CWPCharacteristic& aElement);
+		void VisitL(CWPParameter& aElement);
+		void VisitLinkL(CWPCharacteristic& aCharacteristic );
+		TInt ContextExtension( MWPContextExtension*& );
+
+	public: // From MWPContextExtension
+
+		const TDesC8& SaveDataL( TInt aIndex ) const;
+		void DeleteL( const TDesC8& aSaveData );
+        TUint32 Uid() const;
+
+	private:  // New functions
+
+        /**
+        * C++ default constructor.
+        */
+		CWPAPAdapter();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+		void ConstructL();
+
+		/**
+		* Check whether this characteristic is already linked.
+		* @param aCharacteristic characteristic to compare.
+		* @return ETrue if link to given characteristic was found.
+		*/
+		TBool IsAlreadyLinked( CWPCharacteristic& aCharacteristic );
+
+	private: // Data
+
+		/// Array of linked NAPDEF and PXLOGICAL characteristics. Refs.
+		RPointerArray<CWPCharacteristic> iLinks;
+		/// Array of data items for memory management. Owns.
+		RPointerArray<CBase> iDataItems;
+        /// Array of save items. Owns.
+        RPointerArray<CWPAPAccesspointItem> iSaveItems;
+		/// Pointer to commsdatabase used in saving. Owns.
+		CCommsDatabase* iCommsDb;
+		/// Summary title. Owns.
+		HBufC* iTitle;
+        /// Default name. Owns.
+        HBufC* iDefaultName;
+		/// Indicates whether these settings are already saved.
+		TBool iAlreadySavedOnce;
+		// CMManager for managing connection methods
+		RCmManagerExt* iCmManager;
+	  RArray<TInt> iAPValue;
+
+	private: // For testing.
+		friend class T_CWPAPAdapter;
+	};
+
+#endif	// CWPAPADAPTER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/CWPAPItemBase.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,136 @@
+/*
+* 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:     Defines a base class for all the items in WPAPAdapter
+*
+*/
+
+
+
+
+
+#ifndef CWPAPITEMBASE_H
+#define CWPAPITEMBASE_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <cmconnectionmethodext.h>
+#include <cmmanagerext.h>
+
+// DATA TYPES
+
+// Field types that can be marked received.
+// Values defined to the power of to to enable masking.
+enum TMarkedField
+	{
+	EWPParameterPxAddrType_id	= 2,
+	EWPParameterPxAddrFQDN_id	= 4,
+	EWPParameterNapID_id		= 8,
+	EWPParameterService_id		= 16,
+	EWPParameterPortNbr_id		= 32,
+	EWPParameterPxAddr_id		= 64,
+	EWPParameterAuthentication_id = 512,
+    EWPParameterIfNetworks_id   = 1024,
+    EWPParameterInternet_id     = 2048,
+    EWPParameterWlan_id         = 4096
+	};
+
+// FORWARD DECLARATIONS
+
+class CWPAPAccesspointItem;
+class CCommsDatabase;
+
+// CLASS DECLARATION
+
+/**
+ * CWPAPItemBase is a base class for all the items in WPAPAdapter.
+ */ 
+class CWPAPItemBase : public CBase
+	{
+	public:
+
+        /**
+        * Destructor.
+        */
+		~CWPAPItemBase();
+
+	public: // New methods
+
+		/**
+		* Store the item data to APEngine's accesspoint item.
+		* @param aAPItem item where data is stored.
+		*/
+		virtual void AddDataL( RCmConnectionMethodExt& ) = 0;
+
+        /**
+        * Add access point items to an array.
+        * @param aItems The array to add to
+        * @param aLogicalProxy The related logical proxy, if any
+        * @param aPhysicalProxy The related physical proxy, if any
+        */
+        virtual TInt AddItemsL( RPointerArray<CWPAPAccesspointItem>& aItems,
+            CWPAPItemBase* aLogicalProxy,
+            CWPAPItemBase* aPhysicalProxy ) = 0;
+
+        /**
+        * The name of the item to be displayed to the user.
+        * @return The name
+        */
+        virtual const TDesC& Name() = 0;
+        
+        /**
+        * SaveWlanDataL
+        */    
+        virtual void SaveWlanDataL( TUint32 aIapId, CCommsDatabase& aCommsDb ) = 0;
+    
+        virtual void UpdateLingerL(const TUint32 aIapId) = 0;
+
+	protected: // New methods. Only for subclasses use.
+
+        /**
+        * Base constructor.
+        * @param aDefaultName The default name to use for an access point
+        */
+        CWPAPItemBase( const TDesC& aDefaultName );
+
+		/**
+		* Mark that this field has arrived and was correctly handled.
+		* @param aField received field enumeration
+		*/
+		void MarkReceived( TMarkedField aField );
+
+		/**
+		* Check has the given field been received.
+		* @param aField received field enumeration
+		* @return ETrue if the field has already been received and handled
+		*/
+		TBool IsReceived( TMarkedField aField );
+
+	protected:
+
+        /// The default name for an access point
+        const TDesC& iDefaultName;
+
+	private: // Data
+
+		/// Received fields marked here.
+		TUint32 iReceivedFieldsFlags;
+
+	private: // For testing.
+		friend class T_CWPAPItemBase;
+	};
+
+#endif	// CWPAPITEMBASE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/CWPAPLogicalProxy.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,117 @@
+/*
+* 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:     Defines a class, which holds logical proxy information.
+*
+*/
+
+
+
+
+
+#ifndef CWPAPLOGICALPROXY_H
+#define CWPAPLOGICALPROXY_H
+
+// INCLUDES
+
+#include <MWPVisitor.h>
+#include "CWPAPItemBase.h"
+#include <cmconnectionmethodext.h>
+
+// FORWARD DECLARATIONS
+
+class CWPAPPhysicalProxy;
+class CWPAPAccesspointItem;
+class CWPAPPort;
+
+// CLASS DECLARATION
+
+/**
+ * CWPAPLogicalProxy contains logical proxy data.
+ */ 
+class CWPAPLogicalProxy : public CWPAPItemBase, private MWPVisitor
+	{
+	public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @param aDefaultName The default name of an access point
+        * @param aCharacteristic The PXLOGICAL characteristic
+        */
+		static CWPAPLogicalProxy* NewLC( const TDesC& aDefaultName, 
+            CWPCharacteristic& aCharacteristic );
+
+        /**
+        * Destructor.
+        */
+		~CWPAPLogicalProxy();
+
+	public: // From CWPAPItemBase
+
+		TBool ValidateL();
+		void AddDataL( RCmConnectionMethodExt& aCmItem );
+        TInt AddItemsL( RPointerArray<CWPAPAccesspointItem>& aItems,
+            CWPAPItemBase* aLogicalProxy,
+            CWPAPItemBase* aPhysicalProxy );
+        const TDesC& Name();
+        void SaveWlanDataL( TUint32 /*aIapId*/, CCommsDatabase& /*aCommsDb*/ ) {};
+
+        void UpdateLingerL(const TUint32 /*aIapId*/){};
+
+	private: // From CWPAPItemBase
+
+		void VisitL(CWPCharacteristic& aElement);		
+		void VisitL(CWPParameter& aElement);
+        void VisitLinkL( CWPCharacteristic& /*aLink*/ ) {};
+
+	private: // New methods
+
+        /**
+        * C++ default constructor.
+        * @param aDefaultName The default name of an access point
+        */
+		CWPAPLogicalProxy( CWPCharacteristic& aCharacteristic,
+            const TDesC& aDefaultName );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+		void ConstructL();
+		
+	private: // Data
+
+		/// Pointer to data model parameter. Refs.
+		CWPParameter* iHomepage;
+
+		/// Pointer to data model parameter. Refs.
+		CWPParameter* iName;
+
+		/// Pointer to port object. Owns.
+		CWPAPPort* iPort;
+
+		/// Array of physical proxy objects. Owns.
+		RPointerArray<CWPAPPhysicalProxy> iPhysicalProxies;
+
+        /// Characteristic
+        CWPCharacteristic& iCharacteristic;
+
+	private: // For testing
+
+		friend class T_CWPAPLogicalProxy;
+		friend class T_CWPAPAdapter;
+		friend class T_WPAPTestUtils;
+	};
+
+#endif	// CWPAPLOGICALPROXY_H
+            
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/CWPAPNapdef.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,388 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     Class stores data for one accesspoint
+*
+*/
+
+
+
+
+
+#ifndef CWPAPNAPDEF_H
+#define CWPAPNAPDEF_H
+
+// INCLUDES
+#include <e32def.h>
+#include <e32std.h>
+#include <MWPVisitor.h>
+#include "CWPAPItemBase.h"
+#include "WPAPDefs.h"
+#include <cmconnectionmethodext.h>
+#include <cmplugindialcommondefs.h>
+#include <cmmanagerext.h>
+#include <etelpckt.h>
+
+// FORWARD DECLARATIONS
+class CWPAPPhysicalProxy;
+
+class CWPParameter;
+class CCommsDatabase;
+class EAPSettings;
+class EapCertificateEntry;
+class RCmManagerExt;
+class TEapExpandedType;
+
+
+// CLASS DECLARATION
+
+/**
+ * CEapTypeElement is arrray element for several EapTypes  
+ */ 
+class CEapTypeElement: public CBase
+        {
+        public:
+        ~CEapTypeElement();
+        TBuf8<KExpandedEapIdLength> iEapTypeString;
+        TBuf8<KExpandedEapIdLength> iEncapsulatingExpandedEapId;
+        EAPSettings* iEAPSettings;
+        EapCertificateEntry* iCertificate;
+        };
+
+struct SECssID
+		{
+        CWPParameter* iSSSID;
+        CWPParameter* iSUSSID;
+		}; 
+/**
+ * CWPAPNapdef handles NAPDEF characteristics.
+ */ 
+class CWPAPNapdef : public CWPAPItemBase, private MWPVisitor
+	{
+	public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        * @param aFollowingLink ETrue if the NAPDEF was reached
+        *                       via a link.
+        * @param aDefaultName   The default name of an access point
+        * @param aLogicalCharacteristic The PXLOGICAL, if following a link from 
+        *                       there, or NAPDEF, if a direct link to NAPDEF.
+        * @param aLink          The NAPDEF characteristic
+        */
+		static CWPAPNapdef* NewLC( TBool aFollowingLink,
+                                   const TDesC& aDefaultName, 
+                                   CWPCharacteristic& aLogicalCharacteristic,
+                                   CWPCharacteristic& aLink );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CWPAPNapdef();
+
+	public: // From CWPAPItemBase
+
+		/**
+		* @precondition characteristic must be set otherwise Panics.
+		*/
+		TBool ValidateL();
+		
+        /**
+        * AddDataL
+        */     		
+		void AddDataL( RCmConnectionMethodExt& aCmItem );
+		
+        /**
+        * AddItemsL
+        */           
+        TInt AddItemsL( RPointerArray<CWPAPAccesspointItem>& aItems,
+                        CWPAPItemBase* aLogicalProxy,
+                        CWPAPItemBase* aPhysicalProxy );
+        /**
+        * Name
+        */
+        const TDesC& Name();
+    
+        /**
+        * SaveWlanDataL
+        */    
+        void SaveWlanDataL( TUint32 aIapId, CCommsDatabase& aCommsDb );
+
+        /**
+        * UpdateLingerL from the ItemBase
+        */    
+
+        void UpdateLingerL(const TUint32 aIapId);
+        
+        /**
+        * Set The Internet Parameter Indicator 
+        */
+        void SetInternetIndicator(TInt value);
+
+        /**
+        * Get The Internet Parameter Indicator 
+        */
+        TInt GetInternetIndicator();
+
+
+	private: // From MWPVisitor
+
+        /**
+        * VisitL
+        */   
+		void VisitL( CWPCharacteristic& aElement );		
+
+        /**
+        * VisitL
+        */   
+		void VisitL( CWPParameter& aElement );
+      
+        /**
+        * VisitLinkL
+        */   
+        void VisitLinkL( CWPCharacteristic& /*aLink*/ ) {};
+
+	private:  // New functions
+
+		/**
+        * C++ default constructor.
+        * @param aFollowingLink ETrue if the NAPDEF was reached
+        *                       via a link.
+        * @param aDefaultName   The default name of an access point
+        * @param aLogicalCharacteristic The PXLOGICAL, if following a link from 
+        *                       there, or NAPDEF, if a direct link to NAPDEF.
+        */
+		CWPAPNapdef( TBool aFollowingLink,
+                     const TDesC& aDefaultName, 
+                     CWPCharacteristic& aLogicalCharacteristic );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+		void ConstructL();
+
+        /**
+        * Writes a DNS address in either IPv4 or IPv6 format
+        * to an access point item.
+        * @param aAPItem The access point item
+        * @param aValue The DNS address to write
+        */
+        void WriteDNSAddressL( RCmConnectionMethodExt& aCmItem,
+                               const TDesC& aValue );
+                               
+        /**
+        * AddWlanDataL
+        */            
+        void AddWlanDataL( RCmConnectionMethodExt& aCmItem );
+        
+        /**
+        * HandleWLanParameters
+        */            
+        void HandleWLanParametersL( CWPParameter& aParameter );
+        
+        void HandleEAPParametersCCL( CWPParameter& aParameter );
+        
+        /**
+        * ConvertAsciiToHex
+        */            
+        void ConvertAsciiToHex( const TDesC8& aSource, HBufC8*& aDest );
+        
+        /**
+        * StrCopy
+        */                    
+        void StrCopy( TDes8& aTarget, const TDesC& aSource );
+        
+        /**
+        * Add linger value
+        */                    
+        void AddLingerL( const TInt , const TInt );
+        
+        /**
+        * Update linger value	
+        */                    
+        void UdateligerValueL(CWPParameter* aLinger);
+        /**
+        * Isalpha	
+        */                    
+        TBool Notalpha(const TDesC& aValue);
+        /**
+        * CheckIPv4values	
+        */  
+        TBool CheckIPv4values(const TDesC& aValue );
+        
+        /**
+        * CheckAddressPart	
+        */  
+        TBool CheckAddressPart( TLex& aLex );
+        
+        /**
+        * ConvertEAPStringToIds
+        */  
+        void ConvertEAPStringToIds(const TDesC& aEAPString, TDes8& aExpandedId, TEapExpandedType& aID);
+  public: // new function
+  
+        /**
+        * NapId value
+        */  
+        const TDesC& NapId();
+        /**
+        * Bearer value
+        */
+        TUint Bearer();
+        
+        /**
+        * SetCMManager
+        */
+        void SetCMManager( RCmManagerExt* aCm );
+
+	private: // Data (Total ownership is assumed unless otherwise stated)
+
+        enum TAPWEPKeyFormat
+            {
+            EAscii,                 // Ascii format
+            EHexadecimal            // Hex format
+            };
+        /// PXLOGICAL characteristic
+        CWPCharacteristic& iCharacteristic;
+
+        /// The human-readable name of the connection. Refs.
+		CWPParameter* iConnectionName; 
+
+        /// The access point address. Refs.
+		CWPParameter* iAccesspointName;
+
+        /// The access point address. Refs.
+		CWPParameter* iAccesspointNameType;
+
+        /// The user name. Refs.
+		CWPParameter* iUserName;
+
+        /// The password. Refs.
+		CWPParameter* iPassword;
+
+        /// The IP address of the phone. Refs.
+		CWPParameter* iPhoneIPAddress;
+
+        /// The network type of the access point. Refs.
+        CWPParameter* iIfNetworks;
+
+        /// Array of name servers. Refs.
+        RPointerArray<CWPParameter> iNameServers;
+
+        /// Number of IPv4 name servers found so far.
+        TInt iNumIPv4NameServers;
+
+        /// Number of IPv6 name servers found so far.
+        TInt iNumIPv6NameServers;
+
+        /// The bearer of the access point.
+        //TApBearerType iBearer;
+        TUint iBearer;
+        
+        // Received bearer was unsupported
+        TBool iBearerUnsupported;
+
+        /// The PDP type of a GPRS access point.
+        TUint32 iPdpType;
+
+        /// ETrue of secure authentication must be used.
+		TBool iSecureAuthentication;
+
+        /// ETrue if the user must be prompted for password.
+		TBool iPromptPassword;
+
+        /// ETrue if we arrived to NAPDEF via a link
+        TBool iFollowingLink;
+        
+//JMan for WLan        
+
+		// Is WLAN supported (queried from Feature Manager)
+        TBool iWlanSupported;
+        
+        // The Network Access Point ID.
+        CWPParameter* iNapID;
+        
+        // WLAN characteristic parameters
+        
+        // The Primary Service Set Identifier name.
+        CWPParameter* iPriSSID;
+        
+        // The Used Primary Service Set Identifier name.
+        CWPParameter* iPriUSSID;
+        
+        // The Hidden Primary Service Set Identifier name.
+        CWPParameter* iPriHSSID;
+        
+        //for secssid 
+        RPointerArray<SECssID> iSecSSID;
+        
+        
+        // The operation mode of the WLAN network.
+        TUint32 iNetMode;
+        
+        // The Security mode of the WLAN network.
+        TUint32 iSecMode;
+        
+        // The ascii formed pre-shared key.
+        CWPParameter* iWpaPresKeyAsc;
+                
+        // The wep authentication mode
+        CWPParameter* iWepAuthMode;
+        
+        // Indicates the default wepkey
+        TUint iDefaultWepKeyIndex;
+        
+        // WEPKEY characteristic parameters
+        
+        // The lenght of the wepkey
+        CWPParameter* iWepKeyLength;
+
+        // The index of the wepkey
+        TUint iWepInd;
+        
+        // The wepkey data
+        CWPParameter* iWepKeyData;
+        
+        // Type of authentication (EAuthOpen, EAuthShared)
+        TWEPAuthentication iAuthentication;
+
+        // Data of the key
+        TBuf8<KMaxLengthOfKeyData> iKeyData[KMaxNumberofKeys];
+        
+        // Format of the key
+        TAPWEPKeyFormat iKeyFormat[KMaxNumberofKeys];
+        
+        RPointerArray<CEapTypeElement> iEapTypeArray;      
+        
+		// Pointer to Linger value parameter. Refs.
+		CWPParameter*   iLinger;
+
+		//linger value
+		TUint iLingerValue;
+		TBool iLingerFlag;
+		
+		// Pointer to the used CMManager, needed to save WLAN data
+		RCmManagerExt* iCm;
+		
+		//Internet parameter Indicator
+    TInt iInternetIndicator;
+
+	private: // For testing usage.
+		friend class T_CWPAPNapdef;
+		friend class T_CWPAPAdapter;
+		friend class T_WPAPTestUtils;
+	};
+
+#endif	// CWPAPNAPDEF_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/CWPAPPhysicalProxy.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,136 @@
+/*
+* 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:     Defines a class, which holds physical proxy information.
+*
+*/
+
+
+
+
+
+#ifndef CWPAPPHYSICALPROXY_H
+#define CWPAPPHYSICALPROXY_H
+
+// INCLUDES
+
+#include <MWPVisitor.h>
+#include "CWPAPItemBase.h"
+#include <cmconnectionmethodext.h>
+
+// DATA TYPES
+
+enum TWPAPPxAddrType
+	{
+	EPxAddrTypeIPv4 = 1,
+    EPxAddrTypeIPv6,
+	EPxAddrTypeUnsupported // (IPv6, E164, ALPHA are not supported)
+	};
+
+// FORWARD DECLARATIONS
+
+class CWPAPLogicalProxy;
+class CWPAPPort;
+class CWPAPNapdef;
+
+// CLASS DECLARATION
+
+/**
+ * CWPAPPhysicalProxy contains physical proxy information
+ */ 
+class CWPAPPhysicalProxy : public CWPAPItemBase, private MWPVisitor
+	{
+	public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+		* @param aDefaultName The default name of an access point
+        * @param aCharacteristic The PXPHYSICAL characteristic.
+        * @param aPort Reference to a pointer containing PORT of a PXLOGICAL.
+        */
+		static CWPAPPhysicalProxy* NewLC( const TDesC& aDefaultName, 
+            CWPCharacteristic& aCharacteristic, 
+            CWPCharacteristic& aLogicalCharacteristic,
+            CWPAPPort*& aPort );
+
+        /**
+        * Destructor.
+        */
+		~CWPAPPhysicalProxy();
+
+	public: // From CWPAPItemBase
+
+		TBool ValidateL();
+		void AddDataL( RCmConnectionMethodExt& aCmItem );
+        TInt AddItemsL( RPointerArray<CWPAPAccesspointItem>& aItems,
+            CWPAPItemBase* aLogicalProxy,
+            CWPAPItemBase* aPhysicalProxy  );
+        const TDesC& Name();
+        void SaveWlanDataL( TUint32 /*aIapId*/, CCommsDatabase& /*aCommsDb*/ ) {};
+        void UpdateLingerL(const TUint32 /*aIapId*/){};
+
+	private: // From CWPAPItemBase. Override default implementation.
+
+		void VisitL( CWPCharacteristic& aElement );		
+		void VisitL( CWPParameter& aElement );	
+		void VisitLinkL( CWPCharacteristic& aCharacteristic );
+
+	private:  // New functions
+
+        /**
+        * C++ default constructor.
+		* @param aDefaultName The default name of an access point
+        * @param aPort Reference to a pointer containing PORT of a PXLOGICAL.
+        */
+		CWPAPPhysicalProxy( const TDesC& aDefaultName, 
+            CWPCharacteristic& aLogicalCharacteristic,
+            CWPAPPort*& aPort );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+		void ConstructL();
+		
+	private: // Data
+
+		/// Pointer to data model parameter. Refs.
+		CWPParameter* iProxyAddr;
+
+        /// Pointer to data model parameter. Refs.
+        CWPParameter* iName;
+
+		/// Proxy address type
+		TWPAPPxAddrType iPxAddrType;
+
+		/// Pointer to port object. Owns.
+		CWPAPPort* iPort;
+
+        /// Pointer to port object owned by logical proxy. Refs.
+        CWPAPPort*& iLogicalPort;
+
+        /// Napdefs linked to by PXPHYSICAL
+        RPointerArray<CWPAPNapdef> iNapdefs;
+
+        /// Pointer to characteristic
+        CWPCharacteristic& iLogicalCharacteristic;
+
+	private: // For testing
+
+		friend class T_CWPAPLogicalProxy;
+		friend class T_CWPAPAdapter;
+		friend class T_WPAPTestUtils;
+	};
+
+#endif	// CWPAPPHYSICALPROXY_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/CWPAPPort.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,110 @@
+/*
+* 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:     Defines a class, which holds proxy port information.
+*
+*/
+
+
+
+
+
+#ifndef CWPAPPORT_H
+#define CWPAPPORT_H
+
+// INCLUDES
+
+#include <MWPVisitor.h>
+#include "CWPAPItemBase.h"
+
+// FORWARD DECLARATIONS
+
+
+
+// CLASS DECLARATION
+
+/**
+ * CWPAPPort contains port information
+ */ 
+class CWPAPPort : public CWPAPItemBase, private MWPVisitor
+	{
+	public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @param aCharacteristic The PORT characteristic
+        */
+		static CWPAPPort* NewLC( CWPCharacteristic& aCharacteristic );
+
+        /**
+        * Destructor.
+        */
+		virtual ~CWPAPPort();
+
+	public: // From CWPAPItemBase 
+
+		TBool ValidateL();
+		void AddDataL( RCmConnectionMethodExt& aCmItem ); //CMManager
+        TInt AddItemsL( RPointerArray<CWPAPAccesspointItem>& aItems,
+                        CWPAPItemBase* aLogicalProxy,
+                        CWPAPItemBase* aPhysicalProxy );
+        const TDesC& Name();
+        void SaveWlanDataL( TUint32 /*aIapId*/, CCommsDatabase& /*aCommsDb*/ ) {};
+        void UpdateLingerL(const TUint32 /*aIapId*/){};
+
+	private: // From MWPVisitor
+
+		void VisitL(CWPCharacteristic& aCharacteristic);
+		void VisitL(CWPParameter& aParameter);
+        void VisitLinkL( CWPCharacteristic& /*aLink*/ ) {};
+		
+	private:  // New functions
+		
+        /**
+        * Constructor.
+        */
+		CWPAPPort();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+		void ConstructL();
+		
+		/**
+		* Helper method to set the internal values.
+		* @param aConnectionSecurity sets value for iConnectionSecurity.
+		* @param aSessionMode sets value for iSessionMode.
+		* @param aReceivedField marks the field as received
+		*/
+		void SetValues( TBool aConnectionSecurity, 
+			            TInt aSessionMode,
+			            TMarkedField aReceivedField );
+
+	private:  // Data
+
+        /// ETrue if secure connection should be established
+		TBool           iConnectionSecurity;
+        /// Session mode for WAP connections: connection oriented/less.
+		TInt            iSessionMode;
+		/// Pointer to port number parameter. Refs.
+		CWPParameter*   iPortNbr;
+
+	private:
+		friend class T_CWPAPProxyData;
+		friend class T_CWPAPAdapter;
+		friend class T_WPAPTestUtils;
+	};
+
+#endif // CWPAPPORT_H
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/ProvisioningDebug.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,194 @@
+/*
+* 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 defines logging macros for Provisioning
+*
+*/
+
+
+
+
+
+
+#ifndef PROVISIONINGDEBUG_H
+#define PROVISIONINGDEBUG_H
+
+#include <e32debug.h> 
+#include <f32file.h>
+
+//Examples
+//FLOG( _L( "[Provisioning] ProvisioningEngine::ConstructL:" ) );
+//FTRACE(RDebug::Print(_L("[Provisioning] ProvisioningEngine::ConstructL: err (%d)"), err));
+#ifdef _DEBUG
+
+const TInt KBTHexDumpWidth=16;
+const TInt KBTLogBufferSize=100;
+const TText KFullStopChar='.';
+
+_LIT(KBTFirstFormatString,"%04x: ");
+_LIT(KBTSecondFormatString,"%02x ");
+_LIT(KBTThirdFormatString,"%c");
+_LIT(KBTThreeSpaces,"   ");
+_LIT(KBTSeparator," ");
+
+inline void HexDump(const TUint8* aPtr, TInt aLen)
+    {
+	if( aPtr != NULL )
+	    {
+    	TBuf<KBTLogBufferSize> line;
+	    TInt i = 0;
+
+    	while (aLen>0)
+    		{
+    		TInt n = (aLen>KBTHexDumpWidth ? KBTHexDumpWidth : aLen);
+    		line.AppendFormat(KBTFirstFormatString,i);
+    		TInt j;
+    		for (j=0; j<n; j++)
+    			line.AppendFormat(KBTSecondFormatString,aPtr[i+j]);
+    		while (j++<KBTHexDumpWidth)
+    			line.Append(KBTThreeSpaces);
+    		line.Append(KBTSeparator);
+    		for (j=0; j<n; j++)
+    			line.AppendFormat(KBTThirdFormatString,(aPtr[i+j]<32 || aPtr[i+j]>126 || aPtr[i+j]==37) ? KFullStopChar : aPtr[i+j]);
+
+    		RDebug::Print(line);
+
+            line.Zero();
+    		aLen-=n;
+    		i+=n;
+    	    }
+        }
+    }
+
+
+// ------------------------------------------
+
+inline void FHex(const TUint8* aPtr, TInt aLen)
+    {
+    HexDump( aPtr, aLen );
+    }
+
+// ------------------------------------------
+
+inline void FHex(const TDesC8& aDes)
+    {
+	RFs fs;
+	RFile file;
+	_LIT( TmpOutputName, "C:\\provisioning.wbxml" );
+	fs.Connect();
+	CleanupClosePushL(fs);
+	//if( aFile.Open(aFileSession, TmpOutputName(), EFileShareAny|EFileWrite) == KErrNone )
+	file.Replace(fs, TmpOutputName(), EFileShareAny|EFileWrite);
+	CleanupClosePushL(file);
+	TInt pos(0);
+	file.Seek(ESeekEnd, pos);
+//	HBufC8* tmp = HBufC8::NewLC(line.Size());
+//	TPtr8 ptr = tmp->Des();
+//	ptr.Copy(line);
+	TInt result = file.Write(aDes);
+	CleanupStack::PopAndDestroy(2); // file,  fs
+///////////////////////////////////////////////////
+
+//    HexDump(aDes.Ptr(), aDes.Length());
+    }
+
+// ===========================================================================
+#ifdef __WINS__     // File logging for WINS
+// ===========================================================================
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT( KLogFile, "Provisioning.log" );
+_LIT( KLogDirFullName, "c:\\logs\\" );
+_LIT( KLogDir, "Provisioning" );
+
+#define FLOG( a )   { FPrint(a); }
+#define FTRACE( a ) { a; }
+
+// Declare the FPrint function
+//
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    RFileLogger::WriteFormat( KLogDir,
+                              KLogFile,
+                              EFileLoggingModeAppend,
+                              aFmt,
+                              list );
+    }
+
+// ===========================================================================
+#else               // RDebug logging for target HW
+// ===========================================================================
+/*#include <e32svr.h>
+
+#define FLOG( a )   { RDebug::Print( a ); }
+#define FTRACE( a ) { a; }
+
+*/
+
+//////////////MIKA///////////////
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT( KLogFile, "Provisioning.log" );
+_LIT( KLogDirFullName, "c:\\logs\\" );
+_LIT( KLogDir, "Provisioning" );
+
+#define FLOG( a )   { FPrint(a); }
+#define FTRACE( a ) { a; }
+
+// Declare the FPrint function
+//
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    RFileLogger::WriteFormat( KLogDir,
+                              KLogFile,
+                              EFileLoggingModeAppend,
+                              aFmt,
+                              list );
+    }
+
+//////////////MIKA///////////////
+
+
+#endif //__WINS__
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FLOG( a )
+#define FTRACE( a )
+
+#endif // _DEBUG
+
+///////// Kailash ///////////////////////
+inline void LOGX(TInt aSource)
+	{
+		HBufC *iMyBufNumber = HBufC::NewLC(255);
+   		TPtr bufNumberPtr(iMyBufNumber->Des());
+   		bufNumberPtr.FillZ();
+   		bufNumberPtr.AppendFormat(_L("%d"),aSource);
+    	FLOG(iMyBufNumber->Des());
+    	CleanupStack::PopAndDestroy();
+	}
+///////// Kailash ///////////////////////
+	
+#endif      // PROVISIONINGDEBUG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/WPAPAdapter.pan	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,40 @@
+/*
+* 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:    Panic codes for Provisioning accesspoint adapter
+*
+*/
+
+
+
+
+
+#ifndef WPAPADAPTER_PAN
+#define WPAPADAPTER_PAN
+
+enum TWPAPAdapterPanicCodes
+    {
+	EDebugCode = 1000,
+	EIllegalCharacteristic,
+	EIllegalState,
+	EIndexOutOfBounds,
+	ENullPointer,
+	EPreConditionFail,
+	EPostConditionFail, 
+	ESaveOperationAlreadyActive,
+	ENoUniqueNameResolved
+    };
+
+GLDEF_C void Panic( TInt aPanic );
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/WPAPDefs.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,223 @@
+/*
+* 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:     Definitions to WPAPAdapter
+*
+*/
+
+
+
+
+
+#ifndef WPAPDEFS_H
+#define WPAPDEFS_H
+
+#include <e32base.h>
+
+// CONSTANTS
+
+const TUint32 KMaxWEPKeyLength = 29;
+// The maximum WPA Pre-Shared Key length.
+const TUint KMaxWpaPskLength = 63;
+// same as connection name max length in Prov req.
+const TInt KNameMaxLength = 30;
+const TInt KTwoNameServersPerNetworkType = 2;
+// The maximum length of key data
+const TUint KMaxLengthOfKeyData = 58;
+const TUint KMaxLengthOfEapList = 50;
+const TUint KExpandedEapIdLength = 8;
+// Number of keys
+const TUint KMaxNumberofKeys = 4;
+
+const TInt KInitialArraySize = 3;
+
+const TUint KMaxSubKeyLenght = 255;
+
+_LIT(KIPV4, "IPV4");
+_LIT(KIPV6, "IPV6");
+_LIT(KCLWSP, "CL-WSP");
+_LIT(KCOWSP, "CO-WSP");
+_LIT(KCLSECWSP, "CL-SEC-WSP");
+_LIT(KCOSECWSP, "CO-SEC-WSP");
+_LIT(K9200, "9200");
+_LIT(K9201, "9201");
+_LIT(K9202, "9202");
+_LIT(K9203, "9203");
+_LIT(K80, "80");
+_LIT(K8080, "8080");
+_LIT(K443, "443");
+
+_LIT(KGSMGPRS, "GSM-GPRS");
+
+//Characteristic WLAN
+_LIT(KWLAN, "WLAN");
+_LIT(PRISSID, "PRI-SSID");
+_LIT(PRIUSSID, "PRI-U-SSID");
+_LIT(PRIHSSID, "PRI-H-SSID");
+
+//Characteristic WLAN/SEC-SSID
+_LIT(SECSSID, "SEC-SSID");
+_LIT(SSSID, "S-SSID");
+_LIT(SUSSID, "S-U-SSID");
+
+_LIT(NETMODE, "NETMODE");
+_LIT(SECMODE, "SECMODE");
+
+//Characteristic WLAN/EAP
+_LIT(KEAP, "EAP");
+_LIT(EAPTYPE, "EAPTYPE");
+_LIT(EAPUSERNAME, "USERNAME");
+_LIT(EAPPASSWORD, "PASSWORD");
+_LIT(EAPREALM, "REALM");
+_LIT(EAPUSEPSEUD, "USE-PSEUD");
+_LIT(EAPMAXAUTHS, "MAXAUTHS");
+_LIT(EAPENCAPS, "ENCAPS");
+_LIT(EAPVERSERREALM, "VER-SER-REALM");
+_LIT(EAPCLIENTHAUTH, "CLIENTH-AUTH");
+_LIT(EAPSESVALTIME, "SES-VAL-TIME");
+_LIT(EAPCIPSUIT, "CIP-SUIT");
+_LIT(EAPPEAPV0, "PEAP-V0");
+_LIT(EAPPEAPV1, "PEAP-V1");
+_LIT(EAPPEAPV2, "PEAP-V2");
+
+//Characteristic WLAN/EAP/CERT
+_LIT(KCERT, "CERT");
+_LIT(EAPISSNAME, "ISS-NAME");
+_LIT(EAPSUBNAME, "SUB-NAME");
+_LIT(EAPCERTTYPE, "CERT-TYPE");
+_LIT(EAPSERNUM, "SER-NUM");
+_LIT(EAPSUBKEYID, "SUB-KEY-ID");
+_LIT(EAPTHUMBPRINT, "THUMBPRINT");
+
+_LIT(EAPCERTUSER, "USER");
+_LIT(EAPCERTCA, "CA");
+
+_LIT(WPAPRESKEYASC, "WPA-PRES-KEY-ASC");
+_LIT(WPAPRESKEYHEX, "WPA-PRES-KEY-HEX");
+_LIT(DEFAULTWEPIND, "WEPKEYIND");
+_LIT(WEPAUTHMODE, "WEPAUTHMODE");
+
+//Characteristic WLAN/WEPKEY
+_LIT(KWEP, "WEPKEY");
+_LIT(WEPKEYLENGTH, "LENGTH");
+_LIT(WEPKEYINDEX, "INDEX");
+_LIT(WEPKEYDATA, "DATA");
+
+_LIT(KPAP, "PAP");
+_LIT(KCHAP, "CHAP");
+_LIT(KMD5, "MD5");
+_LIT(KANALOGMODEM, "ANALOG-MODEM");
+_LIT(KV110, "V.110");
+_LIT(KV120, "V.120");
+_LIT(KAUTOBAUDING, "AUTOBAUDING");
+_LIT(K9600, "9600");
+_LIT(K14400, "14400");
+_LIT(K19200, "19200");
+_LIT(K28800, "28800");
+_LIT(K38400, "38400");
+_LIT(K43200, "43200");
+_LIT(KIPv6, "IPv6");
+_LIT(KIPv4, "IPv4");
+_LIT(KAddrTypeE164, "E164");
+_LIT(KAddrTypeAPN, "APN");
+
+_LIT(KADHOC, "ADHOC");
+
+_LIT(KWEPSEC, "WEP");
+_LIT(KWPASEC, "WPA");
+_LIT(KWPA2SEC, "WPA2");
+_LIT(K8021XSEC, "8021X");
+_LIT(KWPAPRESSEC, "WPA-PRESHARED-KEY");
+_LIT(KWPA2PRESSEC, "WPA2-PRESHARED-KEY");
+
+
+_LIT(KEAPSIM, "EAP-SIM");
+_LIT(KEAPAKA, "EAP-AKA");
+_LIT(KEAPTLS, "EAP-TLS");
+_LIT(KEAPPEAP, "EAP-PEAP");
+_LIT(KEAPTTLS, "EAP-TTLS");
+_LIT(KEAPLEAP, "EAP-LEAP");
+_LIT(KEAPMSCHAPV2, "EAP-MSCHAPV2");
+_LIT(KEAPGTC, "EAP-GTC");
+_LIT(KEAPFAST, "EAP-FAST");
+
+/*
+_LIT8(KEapNone,"0");
+_LIT8(KEapGtc,"6");
+_LIT8(KEapTls, "13"); 
+_LIT8(KEapLeap,"17");
+_LIT8(KEapSim,"18");
+_LIT8(KEapTtls,"21");
+_LIT8(KEapAka,"23");
+_LIT8(KEapPeap,"25");
+_LIT8(KEapMschapv2,"26");
+_LIT8(KEapSecurid,"32");
+_LIT8(KEapFast,"43");
+*/
+_LIT8(KEapAll,"-017,-018,-023,-013,-025,-021,-043" );
+
+const TUint8 KEapNoneId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+const TUint8 KEapTlsTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d};
+const TUint8 KEapGtcTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06};
+const TUint8 KEapLeapTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11};
+const TUint8 KEapSimTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12};
+const TUint8 KEapTtlsTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15};
+const TUint8 KEapAkaTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17};
+const TUint8 KEapPeapTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19};
+const TUint8 KEapMschapv2TypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A};
+const TUint8 KEapSecuridTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20};
+const TUint8 KEapFastTypeId[] = {0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B};
+
+
+const TUint8 KEapPlus = '+'; 
+
+_LIT(KWEPAUTHMODEOPEN, "OPEN");
+_LIT(KWEPAUTHMODESHARED, "SHARED");
+
+enum TWEPAuthentication
+    {
+    EAuthOpen,              // Open authentication
+    EAuthShared             // Shared authentication
+    };
+    
+// DATA TYPES
+
+/**
+* Data structure for storing a WEP key.
+*/
+struct TWep
+    {
+    /** Specifies which key to add or remove. Range: 0-3 */
+    TUint32 KeyIndex;
+    /** The length of KeyMaterial in bytes. Range: 0-29 */
+    TUint32 KeyLength;
+    /** Array that stores the WEP key. */
+    TUint8 KeyMaterial[KMaxWEPKeyLength];
+    };
+
+/**
+* Data structure for storing a WPA Pre-Shared Key.
+*/
+struct TWpaPsk
+	{
+	/** The length of KeyMaterial in bytes. Range: 0-63 */
+	TUint KeyLength;
+	/** Array of that stores the WPA Pre-Shared Key. */
+	TUint8 KeyMaterial[KMaxWpaPskLength];
+	};
+
+
+
+#endif // WPAPDEFS_H
+
+// End of File.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/WPAPSharedDataKeys.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,46 @@
+/*
+* 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:     Shared data keys for operator AP settings
+*
+*/
+
+
+
+
+
+#ifndef WPAPSHAREDDATAKEYS_H
+#define WPAPSHAREDDATAKEYS_H
+
+// CONSTANTS
+
+// -----------------------------------------------------------------------------
+// AP Operator setting 0x101F466B
+// -----------------------------------------------------------------------------
+
+const TUid KSDUidOperatorSettings = {0x101F466B};
+
+/**
+* Modification of locked APs via OTA allowed 
+*
+* Possible values:
+* 0 (no)
+* 1 (yes)
+*
+* Default value: 0
+**/
+_LIT( KOsOtaModificationAllowed, "A" );
+
+#endif // WPAPSharedDataKeys_H
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Inc/WPAPUtil.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:     Class offers common utility methods.
+*
+*/
+
+
+
+
+
+#ifndef WPAPUTIL_H
+#define WPAPUTIL_H
+
+// INCLUDES
+
+#include <e32std.h>
+
+// CLASS DECLARATION
+
+/**
+ * WPAPUtil offers common helper methods.
+ */ 
+class WPAPUtil
+	{
+	public: // New methods
+
+		/**
+		* Loads a specified resource string from resource file.
+		* @param aResourceId is of a resource string.
+		* @return pointer to loaded descriptor.
+		*/
+		static HBufC* ReadHBufCL( TInt aResourceId );
+
+	};
+
+#endif // WPAPUTIL_H
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/CWPAPAccesspointItem.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,320 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Class stores data for one accesspoint
+*
+*/
+
+
+
+// INCLUDE FILES
+
+#include "CWPAPAccesspointItem.h"		// Own header
+
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+#include <CWPAdapter.h>
+
+
+#include <bldvariant.hrh>
+#include <featmgr.h>					// Feature manager
+#include <CWPAdapter.h>					// Leave code for protected	
+#include "CWPAPItemBase.h"
+#include "CWPAPNapdef.h"
+#include "WPAPAdapter.pan"
+#include "ProvisioningDebug.h"
+#include <cmconnectionmethodext.h>
+#include <cmmanagerext.h>
+#include <cmpluginpacketdatadef.h> 
+#include <cmpluginwlandef.h>
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWPAPAccesspointItem::NewLC
+// -----------------------------------------------------------------------------
+CWPAPAccesspointItem* CWPAPAccesspointItem::NewLC(
+                                            const TDesC& aDefaultName,
+                                            CWPAPItemBase* aLogicalProxy,
+                                            CWPAPItemBase* aPhysicalProxy,
+                                            CWPAPItemBase* aNapdef,
+                                            CWPCharacteristic& aCharacteristic )
+	{
+	CWPAPAccesspointItem* self = 
+                        new(ELeave) CWPAPAccesspointItem( aDefaultName, 
+                                                          aLogicalProxy,
+                                                          aPhysicalProxy,
+                                                          aNapdef,
+                                                          aCharacteristic ); 
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CWPAPAccesspointItem::~CWPAPAccesspointItem()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAccesspointItem::Name
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPAPAccesspointItem::Name() const
+	{
+	if ( iLogicalProxy && iLogicalProxy->Name() != KNullDesC )
+        {
+        return iLogicalProxy->Name();
+		}
+    else if( iPhysicalProxy && iPhysicalProxy->Name() != KNullDesC )
+        {
+        return iPhysicalProxy->Name();
+        }
+    else if( iNapdef && iNapdef->Name() != KNullDesC )
+        {
+        return iNapdef->Name();
+        }
+	else
+		{
+		return iDefaultName;
+		}
+	}
+// -----------------------------------------------------------------------------
+// CWPAPAccesspointItem::NapDef
+// -----------------------------------------------------------------------------
+//
+CWPAPItemBase* CWPAPAccesspointItem::NapDef()
+	{
+	return iNapdef;
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CWPAPAccesspointItem::SetCMManager
+// -----------------------------------------------------------------------------
+//
+void CWPAPAccesspointItem::SetCMManager( RCmManagerExt* aCm )
+	{
+	iCmManager = aCm;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAccesspointItem::Characteristic
+// -----------------------------------------------------------------------------
+//
+TInt CWPAPAccesspointItem::Characteristic()
+	{
+	return iCharacteristic.Type();
+	}
+	
+
+// -----------------------------------------------------------------------------
+// CWPAPAccesspointItem::SaveL
+// -----------------------------------------------------------------------------
+//
+TUint32 CWPAPAccesspointItem::SaveL( CCommsDatabase& aCommsDb )
+	{
+	FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::SaveL:" ) );
+	
+	if ( FeatureManager::FeatureSupported( KFeatureIdSettingsProtection ) )
+		{
+		// This protection check is no longer needed since CMManager 
+		// initiates the transactions to the database
+		/*if( CApProtHandler::IsTableProtectedL( &aCommsDb ) )
+			{
+			// Table protected -> leave with specific code.
+			User::Leave( EWPAccessPointsProtected );
+			}*/	
+		}
+
+	  TUint32 iap = 0;
+    TRAPD( err,iap = StoreL( aCommsDb ) );
+    if( err == KErrLocked )
+        {
+        err = EWPCommsDBLocked;
+        }
+    User::LeaveIfError( err );
+    return iap;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAccesspointItem::StoreL
+// -----------------------------------------------------------------------------
+//
+TUint32 CWPAPAccesspointItem::StoreL( CCommsDatabase& aCommsDb )
+	{
+	FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL:" ) );
+    
+    // CMManager
+    // Create the cmIten, give the bearer as parameter if it is available
+    RCmConnectionMethodExt cmItem;
+    TBool created = EFalse;
+    TUint bearer;
+    TInt err(KErrNone);
+    
+    // If the NapDef object exists and the bearer is defined, then we can
+    // create the connection method using the bearer
+    if ( iNapdef != NULL )
+    	{
+    	bearer = static_cast<CWPAPNapdef*>(iNapdef)->Bearer();
+    	if ( bearer != 0 )
+    		{
+    		cmItem = iCmManager->CreateConnectionMethodL(bearer);
+    		created = ETrue;
+    		}
+    	}
+    	
+    // If the bearer id is not known we will use packet data
+    if ( !created)
+    	{
+    	cmItem = iCmManager->CreateConnectionMethodL(KUidPacketDataBearerType);
+    	}
+    // Create the connection method into the DB
+    TRAP( err,cmItem.UpdateL() );
+    // Leave if the creation fails for some reason
+    if(err!=KErrNone)
+		{
+       	User::Leave(err);
+       	}
+       
+    if( iNapdef )
+        {
+        FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: napdef" ) );
+        
+        // CMManager 
+        TRAP (err, iNapdef->AddDataL( cmItem ));
+       	TRAP ( err,cmItem.UpdateL() );
+       	// Leave if the update of the parameters fails
+    	if(err!=KErrNone)
+			{
+       		User::Leave(err);
+       		}
+        }
+        
+    if( iLogicalProxy )
+        {
+        FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: logicalproxy" ) );
+        // CMManager 
+        iLogicalProxy->AddDataL( cmItem );
+        TRAP( err,cmItem.UpdateL() );
+        // Leave if the update of the parameters fails
+    	if(err!=KErrNone)
+			{
+       		User::Leave(err);
+       		}
+        }
+
+    if( iPhysicalProxy )
+        {
+        FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: physicalproxy" ) );
+        // CMManager 
+        iPhysicalProxy->AddDataL( cmItem );
+        TRAP( err,cmItem.UpdateL() );
+        // Leave if the update of the parameters fails
+    	if(err!=KErrNone)
+			{
+       		User::Leave(err);
+       		}
+        }
+
+    FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: cmItem.UpdateL" ) );
+    
+    // CMManager
+    iUid = cmItem.GetIntAttributeL( CMManager::ECmWapId );
+    
+    TInt test( KErrNone );
+    // Update parameter data to CM
+    TRAP( test,cmItem.UpdateL() );
+    FTRACE(RDebug::Print(_L("[AccessPointAdapter] CWPAPAccesspointItem::StoreL: UpdateL err: %d"), test ));
+    
+    TUint32 cmId = cmItem.GetIntAttributeL( CMManager::ECmId ); 
+    cmItem.Close();
+    
+	if( iNapdef )
+    	{
+		iNapdef->UpdateLingerL(iUid());
+    	}
+       
+
+    FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: SaveWlanDataL" ) );
+    if( iNapdef )
+        { 
+        // Give CMManager pointer and save WLAN data
+		static_cast<CWPAPNapdef*>(iNapdef)->SetCMManager( iCmManager );
+        iNapdef->SaveWlanDataL( cmId, aCommsDb );
+        }
+    
+    
+    TInt i( 0 );
+    TPtrC8 data( iCharacteristic.Data(i) );
+    while( data != KNullDesC8 )
+        {
+        i++;
+        data.Set( iCharacteristic.Data(i) );
+        }
+        
+    iCharacteristic.SetDataL( iUid, i );
+    
+    FLOG( _L( "[AccessPointAdapter] CWPAPAccesspointItem::StoreL: done" ) );
+    return iUid();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPAPAccesspointItem::Uid
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CWPAPAccesspointItem::Uid() const
+	{
+    return iUid;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPAPAccesspointItem::DeleteUidData
+// -----------------------------------------------------------------------------
+//
+void CWPAPAccesspointItem::DeleteUidData() const
+	{
+    iCharacteristic.DeleteAllData();
+    }
+
+// -----------------------------------------------------------------------------
+// CWPAPAccesspointItem::CWPAPAccesspointItem
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPAPAccesspointItem::CWPAPAccesspointItem( const TDesC& aDefaultName,
+                                            CWPAPItemBase* aLogicalProxy,
+                                            CWPAPItemBase* aPhysicalProxy,
+                                            CWPAPItemBase* aNapdef,
+                                            CWPCharacteristic& aCharacteristic )
+                                        : iDefaultName( aDefaultName ),
+                                          iNapdef( aNapdef ),
+                                          iPhysicalProxy( aPhysicalProxy ),
+                                          iLogicalProxy( aLogicalProxy ),
+                                          iCharacteristic( aCharacteristic )
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAccesspointItem::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPAPAccesspointItem::ConstructL()
+	{
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/CWPAPAdapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,452 @@
+/*
+* 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:   Main class for handling provisioning accesspoint data
+*
+*/
+
+
+
+// INCLUDE FILES
+
+#include "CWPAPAdapter.h"			// Own header
+
+#include <CWPCharacteristic.h>
+#include <commdb.h>
+#include <WPAPAdapterResource.rsg>
+#include <featmgr.h>					// Feature manager
+#include "WPAPUtil.h"
+#include "CWPAPAccesspointItem.h"
+#include "CWPAPNapdef.h"
+#include "CWPAPLogicalProxy.h"
+#include "WPAPAdapter.pan"
+#include "CWPLog.h"
+#include "ProvisioningDebug.h"
+#include "WPAPDefs.h"
+#include <cmmanagerext.h>
+#include <cmconnectionmethodext.h>
+#include <WPAdapterUtil.h>
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::CWPAPAdapter
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPAPAdapter::CWPAPAdapter() : CWPAdapter(), 
+                               iLinks( KInitialArraySize ), 
+                               iDataItems( KInitialArraySize ), 
+                               iSaveItems( KInitialArraySize )
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPAPAdapter::ConstructL()
+	{
+	FLOG( _L( "[AccesspointAdapter] CWPAPAdapter::ConstructL:" ) );
+	
+	iTitle = WPAPUtil::ReadHBufCL( R_QTN_SM_WML_ACCESSPOINTS );
+	iDefaultName = WPAPUtil::ReadHBufCL( R_QTN_SM_WAPAP_NAME );
+
+	FeatureManager::InitializeLibL();
+	
+	iCmManager = new RCmManagerExt;
+	iCmManager->OpenL();
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWPAPAdapter* CWPAPAdapter::NewL()
+	{
+	CWPAPAdapter* self = new(ELeave) CWPAPAdapter; 
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CWPAPAdapter::~CWPAPAdapter()
+	{
+	// Contents of iLinks array are not owned
+    iLinks.Close();
+
+    iDataItems.ResetAndDestroy();
+    iDataItems.Close();
+
+    iSaveItems.ResetAndDestroy();
+    iSaveItems.Close();
+    iAPValue.Reset();
+
+	delete iTitle;
+    delete iDefaultName;
+	delete iCommsDb;
+	
+	if ( iCmManager !=  NULL )
+	    {
+	    iCmManager->Close();
+	    delete iCmManager;
+	    }
+	
+    FeatureManager::UnInitializeLib();
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::ItemCount
+// -----------------------------------------------------------------------------
+//
+TInt CWPAPAdapter::ItemCount() const
+	{
+	LOG1("Number of Access points: %d", iSaveItems.Count() );
+	return iSaveItems.Count();
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::SummaryTitle
+// -----------------------------------------------------------------------------
+//
+const TDesC16& CWPAPAdapter::SummaryTitle(TInt aIndex) const
+	{
+	__ASSERT_DEBUG( aIndex >= 0 && aIndex < iSaveItems.Count(), 
+		Panic( EIndexOutOfBounds ));
+	// The title is always the same.
+	return *iTitle;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::SummaryText
+// -----------------------------------------------------------------------------
+//
+const TDesC16& CWPAPAdapter::SummaryText(TInt aIndex) const
+	{
+	__ASSERT_DEBUG( aIndex >= 0 && aIndex < iSaveItems.Count(), 
+		Panic( EIndexOutOfBounds ));
+	return iSaveItems[ aIndex ]->Name();
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::DetailsL
+// -----------------------------------------------------------------------------
+//
+TInt CWPAPAdapter::DetailsL( TInt /*aItem*/, MWPPairVisitor& /*aVisitor*/)
+	{
+	// Detail view is a feature for later release.
+	return KErrNotSupported;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::SaveL
+// -----------------------------------------------------------------------------
+//
+void CWPAPAdapter::SaveL( TInt aItem )
+	{
+    FLOG( _L( "[AccesspointAdapter] CWPAPAdapter::SaveL:" ) );
+
+	__ASSERT_DEBUG(aItem >= 0 &&
+		aItem < iSaveItems.Count(), 
+		Panic( EPreConditionFail ));
+
+    TBool internetparmfound = EFalse;
+    TInt err1;
+
+    for (TInt i = 0; i < iAPValue.Count(); i++)
+        {
+        if (aItem == iAPValue[i])
+            {
+            internetparmfound = ETrue;
+            break;
+            }
+
+        }
+
+	// Create the commsdb when the save is initiated first time.
+	// This stays alive until the adapter is destroyed.
+	if ( !iCommsDb )
+		{
+		iCommsDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
+		}
+
+    if( iAlreadySavedOnce && aItem == 0 )
+        {
+        for( TInt i( 0 ); i < iSaveItems.Count(); i++ )
+            {
+            iSaveItems[i]->DeleteUidData();
+            }
+        }
+    
+    // ********************************************************************************** //            	
+    // ***** check that the napdefs with a certain id are only saved once SKSS-79REKH *** //
+    // ********************************************************************************** //
+    TBool found = EFalse;
+    if (iSaveItems[ aItem ]->Characteristic() == KWPNapDef)
+    	{
+    	
+    	// Get the napdef pointer from the saved items and check that it is not NULL
+    	CWPAPNapdef* napdef = static_cast<CWPAPNapdef*>(iSaveItems[ aItem ]->NapDef());
+
+    	if ( napdef )
+        	{
+        	// Store the id of the NAP that is being saved now
+        	TBufC<KNameMaxLength> napId = napdef->NapId();
+        
+        	// check whether napdef with same id has been already saved.
+        	for ( TInt j( 0 ); j < aItem; j++ )
+        	    {
+        	    // If a napdef is not in question we can move to the next item
+        	    if ( iSaveItems[ j ]->Characteristic() != KWPNapDef)
+        	   		{
+        	    	continue;
+        	    	}
+        	    	
+        	    // Store the pointer to to comparison napdef and make the nap id check if
+        	    // the pointer is other than NULL
+        	    CWPAPNapdef* tmpNap = static_cast<CWPAPNapdef*>(iSaveItems[ j ]->NapDef());
+        	    
+        	    if ( tmpNap != NULL )
+        	        {
+        	        // If the id was found, the napdef with this id is already stored
+        	        if ( tmpNap->NapId() == napId )
+        	        	{
+        	        	found = ETrue;
+        	        	break;
+        	 	       	}
+       	         	}
+        	    }
+        	}
+    	}
+        
+    // if access point is not already stored, then we store it
+    if ( !found )
+        {
+        TUint32 iap = 0;
+        if (internetparmfound)
+            {    
+            // Give pointer to cm manager to access point item
+            iSaveItems[ aItem ]->SetCMManager(iCmManager);
+            TRAPD(err,iap = iSaveItems[ aItem ]->SaveL( *iCommsDb));
+            if(err!=KErrNone)
+			          {
+			          User::LeaveIfError(err);	
+			          }
+			          
+			     TRAP(err1, WPAdapterUtil::SetAPDetailsL(iap));
+			     if (err1 == KErrNone)
+               {
+               iAlreadySavedOnce = ETrue;
+               }
+           }
+			   
+			   if (!internetparmfound || (internetparmfound && err1 != KErrNone))
+             {     
+             // Give pointer to cm manager to access point item
+            iSaveItems[ aItem ]->SetCMManager(iCmManager);
+            TRAPD(err,iap = iSaveItems[ aItem ]->SaveL( *iCommsDb));
+            if(err!=KErrNone)
+			          {
+			          User::LeaveIfError(err);	
+			          }
+			      iAlreadySavedOnce = ETrue;
+            }
+        }
+  FLOG( _L( "[AccesspointAdapter] CWPAPAdapter::SaveL: done" ) );
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::CanSetAsDefault
+// -----------------------------------------------------------------------------
+//
+TBool CWPAPAdapter::CanSetAsDefault( TInt /*aItem*/ ) const
+	{
+	return EFalse;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::SetAsDefault
+// -----------------------------------------------------------------------------
+//
+void CWPAPAdapter::SetAsDefaultL( TInt /*aItem*/ )
+	{
+	// This shouldn't be called because CanSetAsDefault
+	// always returns EFalse.
+	Panic( EPreConditionFail );
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPAPAdapter::VisitL( CWPCharacteristic& aCharacteristic )
+	{
+	FLOG( _L( "[AccesspointAdapter] CWPAPAdapter::VisitL:" ) );
+	
+	TInt type = aCharacteristic.Type();
+
+	if ( type == KWPApplication )
+		{
+		FLOG( _L( "[AccesspointAdapter] CWPAPAdapter::VisitL: KWPApplication" ) );
+		aCharacteristic.AcceptL( *this );
+		}
+	// Check every NAPDEF characteristic. If it contains INTERNET
+	// parameter then new access point is created from NAPDEF data.
+	else if ( type == KWPNapDef && !IsAlreadyLinked( aCharacteristic ) )
+		{
+		FLOG( _L( "[AccesspointAdapter] CWPAPAdapter::VisitL: KWPNapDef" ) );
+        CWPAPNapdef* item = CWPAPNapdef::NewLC( EFalse, 
+            *iDefaultName, 
+            aCharacteristic,
+            aCharacteristic );
+        if( item->AddItemsL( iSaveItems, NULL, NULL ) > 0 )
+            {
+            User::LeaveIfError( iLinks.InsertInAddressOrder( &aCharacteristic ) );
+            }
+        User::LeaveIfError( iDataItems.Append( item ) );
+        
+       
+    TInt val = item->GetInternetIndicator();
+    if (val != -1)
+        {
+        iAPValue.Append(val);
+        }
+    CleanupStack::Pop( item );
+		}
+		FLOG( _L( "[AccesspointAdapter] CWPAPAdapter::VisitL:done" ) );
+
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPAPAdapter::VisitL( CWPParameter& /*aParameter*/ ) 
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::VisitLinkL
+// -----------------------------------------------------------------------------
+//
+void CWPAPAdapter::VisitLinkL( CWPCharacteristic& aCharacteristic )
+	{
+    if( !IsAlreadyLinked( aCharacteristic ) )
+        {
+        switch( aCharacteristic.Type() )
+            {
+            // This is link in APPLICATION characteristic to certain NAPDEF or LOGICAL proxy
+            case KWPPxLogical:
+                {
+                CWPAPLogicalProxy* item = CWPAPLogicalProxy::NewLC( 
+                    *iDefaultName, aCharacteristic );
+                item->AddItemsL( iSaveItems, NULL, NULL );
+                User::LeaveIfError( iLinks.InsertInAddressOrder( &aCharacteristic ) );
+                User::LeaveIfError( iDataItems.Append( item ) );
+                CleanupStack::Pop( item );
+                break;
+                }
+            case KWPNapDef:
+                {
+                CWPAPNapdef* item = CWPAPNapdef::NewLC( ETrue, 
+                    *iDefaultName, 
+                    aCharacteristic,
+                    aCharacteristic );
+                item->AddItemsL( iSaveItems, NULL, NULL );
+                User::LeaveIfError( iLinks.InsertInAddressOrder( &aCharacteristic ) );
+                User::LeaveIfError( iDataItems.Append( item ) );
+                CleanupStack::Pop( item );
+                break;
+                }
+            }
+        }
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::ContextExtension
+// -----------------------------------------------------------------------------
+//
+TInt CWPAPAdapter::ContextExtension( MWPContextExtension*& aContextExtension )
+	{
+	aContextExtension = this;
+	return KErrNone;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::SaveDataL
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CWPAPAdapter::SaveDataL( TInt aIndex ) const
+	{
+	return iSaveItems[ aIndex ]->Uid();
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::DeleteL
+// -----------------------------------------------------------------------------
+//
+void CWPAPAdapter::DeleteL( const TDesC8& aSaveData )
+	{
+	if ( !iCommsDb )
+		{
+		iCommsDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
+		}
+
+    TPckgBuf<TUint32> uid;
+    if( aSaveData.Length() == uid.MaxLength() )
+        {
+        LOG1( "DeleteL: Deleting %08x", uid() );
+        uid.Copy( aSaveData );
+
+        // CMManager
+        TRAPD( err, iCmManager->ConnectionMethodL( uid()).DeleteL() );
+        
+        LOG1( "DeleteL: Result: %d", err );
+        if( err == KErrLocked )
+            {
+            User::Leave( EWPCommsDBLocked );
+            }
+        else if ( err != KErrNone && err != KErrNotFound )
+            {
+            User::Leave( err );
+            }
+        }
+
+	//CleanupStack::PopAndDestroy( dataHandler );
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::Uid
+// -----------------------------------------------------------------------------
+//
+TUint32 CWPAPAdapter::Uid() const
+	{
+    return iDtor_ID_Key.iUid;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPAdapter::IsAlreadyLinked
+// -----------------------------------------------------------------------------
+//
+TBool CWPAPAdapter::IsAlreadyLinked( CWPCharacteristic& aCharacteristic )
+	{
+    return iLinks.FindInAddressOrder( &aCharacteristic ) >= 0;
+	}
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/CWPAPItemBase.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,62 @@
+/*
+* 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:    Defines a base class for all the items in WPAPAdapter
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+
+#include "CWPAPItemBase.h"
+#include "WPAPAdapter.pan"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CWPAPItemBase::~CWPAPItemBase()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// C++ constructor
+// -----------------------------------------------------------------------------
+CWPAPItemBase::CWPAPItemBase( const TDesC& aDefaultName )
+                          : iDefaultName( aDefaultName )
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPItemBase::MarkReceived
+// -----------------------------------------------------------------------------
+//
+void CWPAPItemBase::MarkReceived( TMarkedField aField )
+	{
+	iReceivedFieldsFlags |= aField;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPItemBase::IsReceived
+// -----------------------------------------------------------------------------
+//
+TBool CWPAPItemBase::IsReceived( TMarkedField aField )
+	{
+	return ( iReceivedFieldsFlags & aField );
+	}
+	
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/CWPAPLogicalProxy.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,269 @@
+/*
+* 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:    Defines a class, which holds logical proxy information.
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+
+#include "CWPAPLogicalProxy.h"
+#include <e32svr.h>
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+#include "CWPLog.h"
+#include "CWPAPPhysicalProxy.h"
+#include "CWPAPPort.h"
+#include "WPAPAdapter.pan"
+#include "WPAPDefs.h"
+#include <cmconnectionmethodext.h>
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWPAPLogicalProxy::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWPAPLogicalProxy* CWPAPLogicalProxy::NewLC( 
+                                        const TDesC& aDefaultName, 
+                                        CWPCharacteristic& aCharacteristic )
+	{
+	CWPAPLogicalProxy* self = new(ELeave) CWPAPLogicalProxy( aCharacteristic, 
+                                                             aDefaultName ); 
+	CleanupStack::PushL( self );
+	self->ConstructL();
+    aCharacteristic.AcceptL( *self );
+	return self;
+	}
+	
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CWPAPLogicalProxy::~CWPAPLogicalProxy()
+	{
+	delete iPort;
+	iPhysicalProxies.ResetAndDestroy();
+	iPhysicalProxies.Close();
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPLogicalProxy::ValidateL
+// -----------------------------------------------------------------------------
+//
+TBool CWPAPLogicalProxy::ValidateL()
+	{
+	// Logical proxy is valid if it contains either one or more
+	// physical proxies
+	return iPhysicalProxies.Count() > 0;
+	}
+
+
+
+// -----------------------------------------------------------------------------
+// CWPAPLogicalProxy::AddDataL
+// -----------------------------------------------------------------------------
+//
+void CWPAPLogicalProxy::AddDataL( RCmConnectionMethodExt& aCmItem )
+	{    
+	LOG("--CWPAP CWPAPLogicalProxy::AddDataL begin--");	
+	// This method is called by child physical proxy. 
+
+	// Store name if came along with the document. If missing then access point
+	// name is used.
+	if ( iName )
+		{
+		// CMManager
+		aCmItem.SetStringAttributeL( CMManager::ECmName, iName->Value() );
+		}
+
+	// Store homepage if defined.
+	if ( iHomepage )
+		{
+		// CMManager 
+		TRAPD( err, aCmItem.SetStringAttributeL( CMManager::ECmStartPage, iHomepage->Value() ));
+		
+		LOG2("CWPAP EApWapStartPage, value: %S, err: %d", &iHomepage->Value(), err);
+		User::LeaveIfError( err );
+		}
+
+	// Store port data, which overrides the data stored by child physical proxy.
+
+	if ( iPort )
+		{
+		//CMManager 
+		iPort->AddDataL (aCmItem);
+		
+		}
+	LOG("--CWPAP CWPAPLogicalProxy::AddDataL end--");	
+	}
+
+
+// -----------------------------------------------------------------------------
+// CWPAPLogicalProxy::AddItemsL
+// -----------------------------------------------------------------------------
+//
+TInt CWPAPLogicalProxy::AddItemsL( RPointerArray<CWPAPAccesspointItem>& aItems,
+                                   CWPAPItemBase* /*aLogicalProxy*/,
+                                   CWPAPItemBase* /*aPhysicalProxy*/ ) 
+	{
+    TInt count( 0 );
+    for( TInt i( 0 ); i < iPhysicalProxies.Count(); i++ )
+        {
+        CWPAPPhysicalProxy* pp = iPhysicalProxies[ i ];
+        if( pp->ValidateL() )
+            {
+            count += pp->AddItemsL( aItems, this, NULL );
+            }
+        }
+
+    return count;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPAPLogicalProxy::Name
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPAPLogicalProxy::Name()
+	{
+	if ( iName )
+		{
+		return iName->Value();
+		}
+	else
+		{
+		return KNullDesC;
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPLogicalProxy::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPAPLogicalProxy::VisitL( CWPCharacteristic& aCharacteristic )
+	{
+	TInt type = aCharacteristic.Type();
+
+	// KWPPort
+	
+	// One valid port is enough for us.
+	if ( type == KWPPort && !iPort )
+		{
+        CWPAPPort* port = CWPAPPort::NewLC( aCharacteristic );
+
+		if ( port->ValidateL() )
+			{
+			iPort = port;
+			CleanupStack::Pop( port );
+			}
+		else // Data not valid.
+			{
+			CleanupStack::PopAndDestroy( port );
+			}
+		}
+
+	// KWPPxPhysical
+
+	else if ( type == KWPPxPhysical )
+		{
+		CWPAPPhysicalProxy* physicalProxy = CWPAPPhysicalProxy::NewLC( 
+                                                            iDefaultName, 
+                                                            aCharacteristic,
+                                                            iCharacteristic,
+                                                            iPort );
+
+		if ( physicalProxy->ValidateL() )
+			{
+            User::LeaveIfError( iPhysicalProxies.Append( physicalProxy ) );
+			CleanupStack::Pop( physicalProxy );
+			}
+		else // Data not valid.
+			{
+			CleanupStack::PopAndDestroy( physicalProxy );
+			}
+		}
+	else if ( type == KWPPxAuthInfo )
+		{
+		// Not supported
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPLogicalProxy::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPAPLogicalProxy::VisitL( CWPParameter& aParameter)
+	{
+	TInt id = aParameter.ID();
+	const TDesC& value = aParameter.Value();
+
+	if ( value.Length() == 0 )
+		{
+		// No use process zero length value.
+		return;
+		}
+
+	switch ( id )
+		{
+		case EWPParameterStartPage: // iHomepage
+			{
+			if ( !iHomepage )
+				{
+				iHomepage = &aParameter;
+				}
+			break;
+			}
+		case EWPParameterName:
+			{
+			if ( !iName )
+				{
+				iName = &aParameter;
+				}
+			break;
+			}
+		default:
+			{
+			// Just let through
+			}
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPLogicalProxy::CWPAPLogicalProxy
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPAPLogicalProxy::CWPAPLogicalProxy( CWPCharacteristic& aCharacteristic,
+                                      const TDesC& aDefaultName )
+                                    : CWPAPItemBase( aDefaultName ),
+                                      iPhysicalProxies( KInitialArraySize ),
+                                      iCharacteristic( aCharacteristic )
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPLogicalProxy::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPAPLogicalProxy::ConstructL()
+	{
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/CWPAPNapdef.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,2050 @@
+/*
+* 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:    Class stores data for one accesspoint
+*
+*/
+
+
+
+ 
+// INCLUDE FILES
+
+#include "CWPAPNapdef.h"
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+#include <WPAPAdapterResource.rsg>
+#include <featmgr.h>
+#include <WPAdapterUtil.h>
+#include "CWPAPAccesspointItem.h"
+#include "WPAPAdapter.pan"
+#include <WlanCdbCols.h>
+#include <EapType.h>
+#include <EapSettings.h>
+#include "ProvisioningDebug.h"
+#include <cmconnectionmethodext.h>
+#include <cmpluginpacketdatadef.h>
+#include <cmpluginwlandef.h>
+#include <cmmanagerext.h>
+#include <cmconnectionmethodext.h>
+#include <commdb.h>
+#include <WlanCdbCols.h>
+#include <EapExpandedType.h>
+#include <centralrepository.h>
+#include <pdpcontextmanagerinternalcrkeys.h>
+#include <EapGeneralSettings.h>
+#include <EapTypeDefinitions.h>
+
+const TUint KIapColumn        = 0x00000100;
+const TUint KLingerColumn     = 0x00000200;
+const TUint KColumnMask       = 0xFFFFFF00;
+const TUint KRowMask          = 0x000000FF;
+
+// Delay for comms db begintransaction retry (microseconds)
+const TInt KBeginTransRetryDelay = 1000000; 
+// Maximum number of retries
+const  TInt KBeginTransRetryCount = 7;      
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::NewLC
+// -----------------------------------------------------------------------------
+//
+CWPAPNapdef* CWPAPNapdef::NewLC( TBool aFollowingLink,
+                                 const TDesC& aDefaultName, 
+                                 CWPCharacteristic& aLogicalCharacteristic,
+                                 CWPCharacteristic& aLink )
+	{
+	CWPAPNapdef* self = new(ELeave) CWPAPNapdef( aFollowingLink,
+	                                             aDefaultName,
+                                                 aLogicalCharacteristic ); 
+	CleanupStack::PushL( self );
+	self->ConstructL();
+    aLink.AcceptL( *self );
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CWPAPNapdef::~CWPAPNapdef()
+	{
+	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::~CWPAPNapdef" ) );
+    
+    iEapTypeArray.ResetAndDestroy();
+    iEapTypeArray.Close();
+    iSecSSID.ResetAndDestroy();
+	iSecSSID.Close();
+    iNameServers.Close();
+  
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::ValidateL
+// -----------------------------------------------------------------------------
+//
+TBool CWPAPNapdef::ValidateL()
+	{
+	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ValidateL" ) );
+	
+    TBool result( ETrue );
+
+	if ( iBearer == KUidWlanBearerType )
+	    {	    	
+	    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ValidateL wlan" ) );
+	    if ( iWlanSupported )
+	    	{	    	
+	    	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ValidateL wlan supported" ) );
+	    	return result;
+	    	}
+	    else
+	    	{
+	   		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ValidateL wlan NOT supported" ) );
+	    	return EFalse;
+	    	}
+	    }
+	    
+	// Received unsupported bearer
+	if( iBearerUnsupported )
+	    {
+	    return EFalse;
+	    }
+	    
+	// Didn't receive a bearer value.
+	if ( iBearer == 0 )
+		{
+    // Access point address type can also tell the bearer
+		if( iAccesspointNameType )
+            {
+            TPtrC addrType( iAccesspointNameType->Value() );
+            if( addrType == KAddrTypeAPN )
+                {
+                iBearer =KUidPacketDataBearerType;
+                }
+            }
+        
+        // If still couldn't determine the bearer, default to GPRS
+        if( iBearer == 0 )
+			{
+			iBearer = KUidPacketDataBearerType;
+			}
+		}
+		        
+    // "NAP-ADDRESS" (Access point name) must be defined
+    if( iAccesspointName )
+        {
+        if( iAccesspointName->Value() == KNullDesC )
+            {
+            return EFalse;
+            }
+        }
+    else
+        {
+        return EFalse;
+        }
+
+	/* 
+	Combinations of authentication type, username and password and corressponding
+	value of prompt for password field. AuthType in this table means that provisioning document
+	contained authtype parameter and it was supported by the implementation.
+	Provisioning document names are used in table.
+	x means that value of the specified parameter is received and it was valid.
+	AuthType received & supported 
+	| AuthName 
+	| | AuthSecret 
+	| |	| "Prompt for Password"
+		  no
+	x     no
+      x   no
+	x x   yes
+        x no
+    x   x yes
+      x x no
+    x x	x no
+	*/
+
+	// Set the "prompt password"-value. See the table above. Value is set to true
+	// only if we have supported authentication type and either username or password
+	// is empty.
+	if ( IsReceived( EWPParameterAuthentication_id ) &&
+	     ( ( !iPassword && iUserName ) ||( iPassword && !iUserName ) ) )
+		{
+		iPromptPassword = ETrue;	
+		}
+
+    // IFNETWORKS is a list of possible protocols that a GPRS access points can be 
+    // used for. 
+    if( iBearer == KUidPacketDataBearerType && IsReceived( EWPParameterIfNetworks_id ) )
+        {
+        TLex lex( iIfNetworks->Value() );
+        lex.Mark();
+        do
+            {
+            TChar ch( lex.Get() );
+
+            if( ( !iPdpType && !ch.IsAlphaDigit() ) || ( !iPdpType && lex.Eos() ) )
+                {
+				if(!lex.Eos())
+					{
+					lex.UnGet();
+					}
+                TPtrC value( lex.MarkedToken() );
+				if( !lex.Eos() )
+					{
+					lex.Inc();
+					}
+                
+                if( value == KIPv6 
+                    && FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
+                    {
+                    //iPdpType = EIPv6;
+                    // CMManager
+                    iPdpType = RPacketContext::EPdpTypeIPv6;
+                    result = ETrue;
+                    }
+                else if( value == KIPv6 
+                    && !FeatureManager::FeatureSupported( KFeatureIdIPv6 ) )
+                    {
+                    result = EFalse;
+                    }
+                else if( value == KIPv4 )
+                    {
+                    //iPdpType = EIPv4;
+                    // CMManager
+                    iPdpType = RPacketContext::EPdpTypeIPv4;
+                    result = ETrue;
+                    }
+                }
+            } while( !lex.Eos() );
+        }
+
+	return result;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::AddItemsL
+// -----------------------------------------------------------------------------
+//
+TInt CWPAPNapdef::AddItemsL( RPointerArray<CWPAPAccesspointItem>& aItems,
+                            CWPAPItemBase* aLogicalProxy,
+                            CWPAPItemBase* aPhysicalProxy ) 
+	{
+	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddItemsL" ) );
+	
+    TInt count( 0 );
+
+    if( ( iFollowingLink || IsReceived( EWPParameterInternet_id ) 
+                         || IsReceived( EWPParameterWlan_id ) )
+                         && ValidateL() )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddItemsL append" ) );
+        CWPAPAccesspointItem* item = CWPAPAccesspointItem::NewLC(
+                                                             iDefaultName,
+                                                             aLogicalProxy,
+                                                             aPhysicalProxy,
+                                                             this,
+                                                             iCharacteristic );
+        User::LeaveIfError( aItems.Append( item ) );
+        //Internet Parameter is received
+        if (IsReceived(EWPParameterInternet_id) && !iFollowingLink)
+            {
+            SetInternetIndicator(aItems.Count() - 1);
+            }
+
+        
+        count++;
+        CleanupStack::Pop( item );
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddItemsL append done" ) );
+        }
+    return count;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::SetInternetIndicator
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::SetInternetIndicator(TInt aValue)
+    {
+    iInternetIndicator = aValue;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::GetInternetIndicator
+// -----------------------------------------------------------------------------
+//
+TInt CWPAPNapdef::GetInternetIndicator()
+    {
+    return iInternetIndicator;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::AddDataL
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::AddDataL( /*CApAccessPointItem& aAPItem*/ RCmConnectionMethodExt& aCmItem ) 
+	{
+	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddDataL" ) );
+	
+	TInt err( KErrNone );
+
+    if ( iBearer == KUidWlanBearerType )    
+	    {			    	
+	    	if ( iWlanSupported )
+        	{
+        	// CMManager
+        	AddWlanDataL( aCmItem);
+        	}
+        else
+        	{
+        	// WLAN is disabled (or does not exist) in the device.
+        	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddDataL WLAN disabled." ) );
+        	User::Leave( KErrNotSupported );
+        	}
+	    }
+    else
+        {	    
+    	if ( iConnectionName )
+    		{
+    		// CMManager
+    		aCmItem.SetStringAttributeL( CMManager::ECmName, (iConnectionName->Value().Left( KNameMaxLength ))); 
+    		}
+    	else // Use default name
+    		{
+    		// CMManager
+    		aCmItem.SetStringAttributeL( CMManager::ECmName, iDefaultName );
+    		}
+    	
+    	if ( iAccesspointName )
+    		{
+    		if ( iBearer == KUidPacketDataBearerType )
+    			{
+    			// CMManager
+    			TRAP ( err, aCmItem.SetStringAttributeL( CMManager::EPacketDataAPName, iAccesspointName->Value() ));
+                FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL value: %S, err: %d"),
+                                                                     &iAccesspointName->Value(), err));    			                              
+    			}
+    		else
+    			{
+    			// CMManager
+    			TRAP ( err, aCmItem.SetStringAttributeL( CMManager::EDialDefaultTelNum, iAccesspointName->Value() ));
+                FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::EApIspDefaultTelNumber value: %S, err: %d"),
+                			      &iAccesspointName->Value(), err ) );
+    			}
+    		}
+    		
+    	TRAP ( err, aCmItem.UpdateL() );
+
+    	 if ( iUserName )
+    		{
+    		// CMManager
+    		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::EDialLoginName, iUserName->Value() ));
+    		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL EDialLoginName value: %S, err: %d"),
+    		                    		      &iUserName->Value(), err));
+    		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::EDialIFAuthName, iUserName->Value() ));
+    		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL EDialIFAuthName value: %S, err: %d"),
+    		                    		      &iUserName->Value(), err));
+    		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::ECmIFAuthName, iUserName->Value() ));
+    		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL ECmIFAuthName value: %S, err: %d"),
+    		                    		      &iUserName->Value(), err));
+    		}
+    		
+		// CMManager
+    	TRAP ( err, aCmItem.SetBoolAttributeL( CMManager::ECmIFPromptForAuth, iPromptPassword));
+    	FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL ECmIFPromptForAuth value: %d, err: %d"),
+    	                            	      iPromptPassword, err ));
+
+    	if ( iPassword )
+    		{
+    		// CMManager 
+    		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::EDialLoginPassword, iPassword->Value() ));
+    		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL EDialLoginPassword value: %d, err: %d"),
+    		                		      &iPassword->Value(), err ) );
+    		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::ECmIFAuthPass, iPassword->Value() ));
+    		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL ECmIFAuthPass value: %d, err: %d"),
+    		                		      &iPassword->Value(), err ) );
+    		}	
+
+		// CMManager
+    	TRAP ( err, aCmItem.SetBoolAttributeL( CMManager::ECmDisablePlainTextAuth, iSecureAuthentication ));
+        FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL EApEApIspDisablePlainTextAuth value: %d, err: %d"),    	                         
+                	                        iSecureAuthentication, err ) );
+                	                        
+			
+        // IPv6 APs always have dynamic phone address
+    	//CMManager
+    	if ( iPhoneIPAddress && iPdpType != RPacketContext::EPdpTypeIPv6 )
+    		{
+    		// CMManager IS CORRECT?
+    		//err = aAPItem.WriteTextL( EApIspIPAddr, iPhoneIPAddress->Value() );
+    		TRAP ( err, aCmItem.SetStringAttributeL( CMManager::ECmIPAddress, iPhoneIPAddress->Value() ));
+    		FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddDataL EApIspIPAddr value: %S, err: %d"),
+                        		     &iPhoneIPAddress->Value(), err ) );
+    		}
+
+		TRAP ( err, aCmItem.UpdateL() );
+        for( TInt i( 0 ); i < iNameServers.Count(); i++ )
+            {
+            WriteDNSAddressL( aCmItem, iNameServers[i]->Value() );
+            }
+		TRAP ( err, aCmItem.UpdateL() );
+        if( FeatureManager::FeatureSupported( KFeatureIdIPv6 )
+            && iPdpType )
+            {
+         	// CMManager
+            TRAP ( err, aCmItem.SetIntAttributeL( CMManager::EPacketDataPDPType, iPdpType ));
+            }
+    
+    if ( err ) err = 0; // prevent compiler warning
+        }
+	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddDataL" ) );
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::AddWlanDataL
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::AddWlanDataL( RCmConnectionMethodExt& aCmItem )
+    {
+    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL" ) );
+    
+    if ( !iWlanSupported )
+    	{
+    		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL WLAN NOT supported." ) );
+    		User::Leave( KErrNotSupported);
+    	}
+        
+    TInt err = KErrNone;
+    
+	if ( iConnectionName )
+		{
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL iConnectionName" ) );
+		
+		//Connection name
+		// CMManager
+		aCmItem.SetStringAttributeL( CMManager::ECmName, iConnectionName->Value().Left( KNameMaxLength ) );
+		
+		// CMManager 
+		// Network name
+		aCmItem.SetStringAttributeL( CMManager::EWlanSSID, iConnectionName->Value());
+		
+        FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddWlanDataL iConnectionName err (%d) (%S)"), err, &iConnectionName->Value()));
+				
+		}
+	else // Use default name
+		{
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL iConnectionName default" ) );
+		aCmItem.SetStringAttributeL( CMManager::EWlanSSID, iDefaultName);
+		}
+		   	
+   	//EApWlanNetworkMode Gives network mode, TUint32
+   	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL EApWlanNetworkMode" ) );
+	// CMManager
+   	TRAP ( err, aCmItem.SetIntAttributeL( CMManager::EWlanConnectionMode, iNetMode ));
+   	FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddWlanDataL EApWlanNetworkMode err (%d)"), err));
+        
+    //EApWlanSecurityMode The security mode, TUint32
+    if ( iSecMode == 0 )
+        {
+        // This is needed if Provisioning message does not contain SECMODE parameter
+        // AP does not work if secmode is not set
+        iSecMode = CMManager::EWlanSecModeOpen;
+        }
+        
+    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::AddWlanDataL EApWlanSecurityMode" ) );
+   	// CMManager, securitymode causes error -1, this will be set manually in SaveWlanData
+   	//TRAP ( err, aCmItem.SetIntAttributeL( CMManager::EWlanSecurityMode, iSecMode ));
+    FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::AddWlanDataL EApWlanSecurityMode err (%d)"), err));
+    	
+    if (err)
+        {
+        err = KErrNone;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::WriteDNSAddressL
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::WriteDNSAddressL( /*CApAccessPointItem& aAPItem*/ RCmConnectionMethodExt& aCmItem,
+                                    const TDesC& aValue )
+	{
+    // GPRS access points supports IPv6 only if explicitly stated. 
+    // CMManager
+    TBool apSupportsIPv6( iPdpType == RPacketContext::EPdpTypeIPv6 | iBearer != KUidPacketDataBearerType );
+
+    // If IPv6 is supported, write the DNS address as IPv6 if
+    // bearer supports IPv6 and the address format is IPv6    
+    if( FeatureManager::FeatureSupported( KFeatureIdIPv6 )
+        && apSupportsIPv6
+        && WPAdapterUtil::CheckIPv6( aValue ) )
+        {
+        // Two name servers per network type
+        if( iNumIPv6NameServers < KTwoNameServersPerNetworkType )
+            {
+            // CMManager
+            TRAPD (err, aCmItem.SetStringAttributeL( CMManager::TConnectionMethodCommonAttributes( 
+            													( CMManager::ECmIP6NameServer1 ) + iNumIPv6NameServers ), aValue ) );
+            User::LeaveIfError( err );
+            iNumIPv6NameServers++;
+            }
+        }
+     else if( CheckIPv4values( aValue) )
+        {
+        // Two name servers per network type
+        if( iNumIPv4NameServers < KTwoNameServersPerNetworkType )
+            {
+            // CMManager 
+            TRAPD ( err, aCmItem.SetStringAttributeL( CMManager::TConnectionMethodCommonAttributes( 
+            													( CMManager::ECmIPNameServer1 ) + iNumIPv4NameServers ), aValue ) );
+            User::LeaveIfError( err );
+            aCmItem.SetBoolAttributeL( CMManager::ECmIPDNSAddrFromServer, EFalse);
+            iNumIPv4NameServers++;
+            }
+        }
+	}
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::CheckAddressPart
+// -----------------------------------------------------------------------------
+//
+
+TBool CWPAPNapdef:: CheckAddressPart( TLex& aLex )
+    {
+    TBool result( aLex.Peek().IsDigit() );
+    aLex.Inc();
+    if( aLex.Peek().IsDigit() )
+        {
+        aLex.Inc();
+        if( aLex.Peek().IsDigit() )
+            {
+            aLex.Inc();
+            }
+        }
+
+    return result;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::CheckIPv4values
+// -----------------------------------------------------------------------------
+//
+
+TBool CWPAPNapdef::CheckIPv4values( const TDesC& aValue )
+{
+	
+	TLex aLex( aValue );
+	return CheckAddressPart( aLex ) 
+        && aLex.Get() == '.'
+        && CheckAddressPart( aLex ) 
+        && aLex.Get() == '.'
+        && CheckAddressPart( aLex ) 
+        && aLex.Get() == '.'
+        && CheckAddressPart( aLex )
+        && aLex.Get() == '\0';
+     
+}
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::Name
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPAPNapdef::Name()
+	{
+	if ( iConnectionName )
+		{
+		return iConnectionName->Value();
+		}
+	else
+		{
+		return KNullDesC;
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::VisitL( CWPCharacteristic& aCharacteristic )
+	{
+	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::VisitL(CWPCharacteristic)" ) );
+	
+	TInt type = aCharacteristic.Type();
+    FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::VisitL(CWPCharacteristic) type (%d)"), type));
+	switch ( type )
+		{
+		case KWPNapAuthInfo:
+		case KWPValidity:				
+			{
+			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::VisitL(CWPCharacteristic) normal" ) );
+			aCharacteristic.AcceptL( *this );
+			break;
+			}
+		case KWPWLAN:
+		case KWPWepKey:
+			{
+			if( iWlanSupported )
+				{
+					FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::VisitL(CWPCharacteristic) accept WLAN characteristic" ) );
+					aCharacteristic.AcceptL( *this );
+				}
+			}
+		default:
+			{
+			if ( ( ( ( aCharacteristic.Name().Compare( KWLAN ) ) == 0 )    ||
+			     ( ( aCharacteristic.Name().Compare( SECSSID ) ) == 0 )  ||
+			     ( ( aCharacteristic.Name().Compare( KEAP ) ) == 0 )     ||
+			     ( ( aCharacteristic.Name().Compare( KCERT ) ) == 0 )    ||
+			     ( ( aCharacteristic.Name().Compare( KWEP ) ) == 0 ) ) && iWlanSupported )
+			    {
+			    if(aCharacteristic.Name().Compare( KEAP ) == 0)
+			        {
+                    CEapTypeElement* newEap = new (ELeave) CEapTypeElement;
+                    newEap->iEAPSettings = new (ELeave) EAPSettings;
+               	    newEap->iCertificate = new (ELeave) EapCertificateEntry;
+                    iEapTypeArray.AppendL(newEap);
+			        }
+			    else if(aCharacteristic.Name().Compare( SECSSID ) == 0)
+			        {
+                    SECssID* newsecSSID = new (ELeave) SECssID;
+                    newsecSSID->iSSSID = NULL;
+                    newsecSSID->iSUSSID = NULL;
+                    iSecSSID.AppendL(newsecSSID);
+			        }
+    
+			    aCharacteristic.AcceptL( *this );
+			    }
+			}
+		}
+		
+	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::VisitL(CWPCharacteristic) done" ) );
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::VisitL( CWPParameter& aParameter )
+	{
+	TInt id = aParameter.ID();
+	TPtrC value( aParameter.Value() );
+
+	FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::VisitL(CWPParameter) id: %d value: %S"), id, &value));
+
+	switch ( id )
+		{
+		case EWPParameterName:
+			{
+			if ( !iConnectionName )
+				{
+				iConnectionName = &aParameter;
+				}
+			break;
+			}
+		case EWPParameterBearer:
+			{
+			if ( iBearer != 0 || iBearerUnsupported )
+				{
+				break; // Already received a bearer information
+				}
+
+			if ( value == KGSMGPRS )
+				{
+				iBearer = KUidPacketDataBearerType;
+				}
+			else if ( value == KWLAN && iWlanSupported )
+				{
+				iBearer = KUidWlanBearerType;
+				MarkReceived( EWPParameterWlan_id );
+				}				
+			else
+				{
+				// Unsupported bearer type
+				iBearerUnsupported = ETrue;
+				}
+			break;
+			}
+		case EWPParameterNapAddress:
+			{
+			if ( !iAccesspointName )
+				{
+				iAccesspointName = &aParameter;
+				}
+			break;
+			}
+		case EWPParameterLinger:
+			{
+			iLinger = &aParameter;
+			UdateligerValueL( iLinger );
+			break;
+			}
+		case EWPParameterNapAddrType:
+			{
+			if ( !iAccesspointNameType )
+				{
+				iAccesspointNameType = &aParameter;
+				}
+			break;
+			}
+		case EWPParameterAuthName:
+			{
+			if ( !iUserName )
+				{
+				iUserName = &aParameter;
+				}
+			break;
+			}
+		case EWPParameterAuthSecret:
+			{
+			if ( !iPassword )
+				{
+				iPassword = &aParameter;
+				}
+			break;
+			}
+		case EWPParameterAuthType:
+			{
+			// If already received don't accept
+			if (IsReceived(EWPParameterAuthentication_id))
+				{
+				break;
+				}
+
+			if ( value == KCHAP || value == KMD5 )
+				{
+				iSecureAuthentication = ETrue;
+				MarkReceived( EWPParameterAuthentication_id );
+				}
+			else if ( value == KPAP )
+				{
+				iSecureAuthentication = EFalse;
+				MarkReceived( EWPParameterAuthentication_id );
+				}
+			else
+				{
+				// Not supported...
+				}
+			break;
+			}
+		case EWPParameterLocalAddr: // iPhoneIPAddress
+			{
+			if ( !iPhoneIPAddress )
+				{
+				iPhoneIPAddress = &aParameter;
+				}
+			break;
+			}
+		case EWPParameterDNSAddr:
+			{
+            // All name servers must be stored, as some of them might
+            // be IPv6 and some IPv4
+            User::LeaveIfError( iNameServers.Append( &aParameter ) );
+			break;
+			}
+        case EWPParameterIfNetworks:
+            {
+            if( !iIfNetworks )
+                {
+                iIfNetworks = &aParameter;
+                MarkReceived( EWPParameterIfNetworks_id );
+                }
+            break;
+            }
+        case EWPParameterInternet:
+            {
+            MarkReceived( EWPParameterInternet_id );
+            break;
+            }
+//JMan for WLan
+        case EWPParameterNapID:
+            {
+            if ( !iNapID )
+                {
+                iNapID = &aParameter;
+                }
+            break;
+            }    
+        // Here case 0 are handled the WLAN parameters that are extensions  
+        // to OMA Client Provisioning parameter set.
+        case 0:
+            {
+        if( iWlanSupported )
+        	{
+        	HandleWLanParametersL( aParameter );
+        	}
+        break;
+            }
+//JMan for WLan ends
+		default:
+			{
+			}
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::HandleWLanParametersL
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::HandleWLanParametersL( CWPParameter& aParameter )
+	{
+	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL" ) );
+	
+	if( !iWlanSupported )
+		{
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WLAN not supported." ) );
+		User::Leave( KErrNotSupported );
+		}
+	
+	SECssID* scssid = NULL;
+	if( iSecSSID.Count() )
+	{
+		scssid = iSecSSID[iSecSSID.Count()-1];
+	}
+	
+	TPtrC value( aParameter.Value() );
+    if( ( aParameter.Name().Compare( PRISSID ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL iPriSSID" ) );
+        if ( !iPriSSID )
+            {
+            iPriSSID = &aParameter;
+            }
+        }
+    else if( ( aParameter.Name().Compare( PRIUSSID ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL iPriUSSID" ) );
+        if ( !iPriUSSID )
+            {
+            iPriUSSID = &aParameter;
+            }
+        }// else if
+
+    else if( ( aParameter.Name().Compare( PRIHSSID ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL iPriHSSID" ) );
+        if ( !iPriHSSID )
+            {
+            iPriHSSID = &aParameter;
+            }
+        }// else if
+        
+    else if( ( aParameter.Name().Compare( SSSID ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL iPriHSSID" ) );
+        if(scssid!=NULL)
+        	{
+        	scssid->iSSSID = &aParameter;
+        	}
+			  
+
+        }// else if
+
+    else if( ( aParameter.Name().Compare( SUSSID ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL iPriHSSID" ) );
+			  if(scssid!=NULL)
+        	{
+        	scssid->iSUSSID = &aParameter;
+        	}
+        }// else if
+                        
+    else if( ( aParameter.Name().Compare( NETMODE ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL netmode" ) );
+        if ( value == KADHOC )
+			{
+			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL netmode adhoc" ) );
+			iNetMode = CMManager::EAdhoc;
+			}
+        else // default is INFRA
+            {
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL netmode infra" ) );
+            iNetMode =CMManager::EInfra;
+            }
+        }
+
+    else if( ( aParameter.Name().Compare( SECMODE ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode" ) );
+        if ( value == KWEPSEC )
+			{
+			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWEPSEC" ) );
+			iSecMode = CMManager::EWlanSecModeWep;
+			}
+        else if( value == K8021XSEC )
+            {
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode K8021XSEC" ) );
+			iSecMode = CMManager::EWlanSecMode802_1x;
+            }
+        else if( value == KWPASEC )
+            {
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPASEC" ) );
+
+			iSecMode = CMManager::EWlanSecModeWpa;
+            }
+        else if( value == KWPA2SEC )
+            {
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPA2SEC" ) );
+			iSecMode = CMManager::EWlanSecModeWpa2;
+            }
+        else if( value == KWPAPRESSEC )
+            {
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPAPRESSEC" ) );
+			iSecMode = CMManager::EWlanSecModeWpa;
+            }
+        else if( value == KWPA2PRESSEC )
+            {
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode KWPA2PRESSEC" ) );
+			iSecMode = CMManager::EWlanSecModeWpa2;
+            }          
+        else
+            {
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL secmode open" ) );
+			iSecMode = CMManager::EWlanSecModeOpen;
+            }
+        }
+
+    else if( ( aParameter.Name().Compare( WPAPRESKEYASC ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WPAPRESKEYASC" ) );
+        if ( !iWpaPresKeyAsc )
+            {
+            iWpaPresKeyAsc = &aParameter;
+            }
+        }// else if
+        // indicates the default wepkey index
+    else if( ( aParameter.Name().Compare( DEFAULTWEPIND ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL wepind" ) );
+
+        TLex lex( value );
+        lex.Val( iDefaultWepKeyIndex );
+        if ( iDefaultWepKeyIndex >= 4 )
+            {
+            iDefaultWepKeyIndex = 0;
+            }
+        }// else if
+        
+    else if( ( aParameter.Name().Compare( WEPAUTHMODE ) ) == 0 )
+        {
+        if ( value == KWEPAUTHMODEOPEN )
+			{
+			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL wepauthmode OPEN" ) );
+			iAuthentication = EAuthOpen;
+			}
+		else if ( value == KWEPAUTHMODESHARED )
+		    {
+		    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL wepauthmode SHARED" ) );
+			iAuthentication = EAuthShared;
+		    }
+        }// else if
+        
+    else if( ( aParameter.Name().Compare( WEPKEYLENGTH ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WEPKEYLENGTH" ) );
+        if ( !iWepKeyLength )
+            {
+            iWepKeyLength = &aParameter;
+            }
+        }// else if
+    else if( ( aParameter.Name().Compare( WEPKEYINDEX ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WEPKEYINDEX" ) );
+        TLex lex( value );
+        lex.Val( iWepInd );
+        }// else if 
+    else if( ( aParameter.Name().Compare( WEPKEYDATA ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL WEPKEYDATA" ) );
+
+        if ( iWepInd <  4 )
+            {
+            const TUint8 K40Bits = 5;
+            const TUint8 K104Bits = 13;
+            const TUint8 K232Bits = 29;
+
+            TBuf8<KMaxLengthOfKeyData> buf8;
+            StrCopy( buf8, aParameter.Value() );
+            
+            if(buf8.Length() == K232Bits ||
+                buf8.Length() == K104Bits ||
+                buf8.Length() == K40Bits  )
+                {
+                FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL ASCI Wep Key" ) );
+                HBufC8* buf8Conv = HBufC8::NewLC( KMaxLengthOfKeyData );
+                ConvertAsciiToHex( buf8, buf8Conv );
+                iKeyData[iWepInd] = *buf8Conv;
+                iKeyFormat[iWepInd] = CWPAPNapdef::EAscii;
+                CleanupStack::PopAndDestroy( buf8Conv );
+                }
+            else if( buf8.Length()==K232Bits*2 ||
+                buf8.Length()== K104Bits*2 ||
+                buf8.Length() == K40Bits*2)
+                {
+                FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL HEX Wep Key" ) );
+                iKeyData[iWepInd] = buf8;
+                iKeyFormat[iWepInd] = CWPAPNapdef::EHexadecimal;
+                }
+            }
+        
+        }// else if	
+    
+    // Handle EAP parameter
+    HandleEAPParametersCCL( aParameter );        
+    
+    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleWLanParametersL done" ) );
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::HandleEAPParametersL
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::HandleEAPParametersCCL( CWPParameter& aParameter )
+    {
+	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL" ) );
+   	
+   	CEapTypeElement* eap = NULL;
+   	if ( iEapTypeArray.Count() )
+   	    {
+   	    eap = iEapTypeArray[iEapTypeArray.Count()-1];
+   	    }
+   	if(!eap)
+   	    {
+   	    return;
+   	    }    
+   	
+	TPtrC value( aParameter.Value() );
+	
+    if( ( aParameter.Name().Compare( EAPTYPE ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPTYPE" ) );
+              
+        ConvertEAPStringToIds( value, eap->iEapTypeString, eap->iEAPSettings->iEAPExpandedType );
+        
+        }
+    else if( ( aParameter.Name().Compare( EAPUSERNAME ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPUSERNAME" ) );
+        if ( eap->iEAPSettings->iUsername.Length() == 0 )
+            {
+            eap->iEAPSettings->iUsername = value;
+            eap->iEAPSettings->iUsernamePresent = ETrue;
+            eap->iEAPSettings->iUseAutomaticUsernamePresent = ETrue;
+            eap->iEAPSettings->iUseAutomaticUsername = EFalse;
+            }
+        }// else if 
+    else if( ( aParameter.Name().Compare( EAPPASSWORD ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPASSWORD" ) );
+        if ( eap->iEAPSettings->iPassword.Length() == 0 )
+            {
+            eap->iEAPSettings->iPassword = value;
+            eap->iEAPSettings->iPasswordPresent = ETrue;
+            eap->iEAPSettings-> iShowPassWordPromptPresent = ETrue;
+            eap->iEAPSettings-> iShowPassWordPrompt = EFalse;
+            }
+        }// else if 
+    else if( ( aParameter.Name().Compare( EAPREALM ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPREALM" ) );
+
+        if ( eap->iEAPSettings->iRealm.Length() == 0 )
+            {
+            eap->iEAPSettings->iRealm = value;
+            eap->iEAPSettings->iRealmPresent = ETrue;
+            eap->iEAPSettings->iUseAutomaticRealmPresent = ETrue;
+            eap->iEAPSettings->iUseAutomaticRealm = EFalse;
+            }
+        }// else if 
+    else if( ( aParameter.Name().Compare( EAPUSEPSEUD ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPUSEPSEUD" ) );
+        TInt pseudonyms;
+        TLex lex( value );
+        lex.Val( pseudonyms );
+        
+        eap->iEAPSettings->iUsePseudonymsPresent = ETrue;
+        if ( pseudonyms == 1 )
+            {        
+            eap->iEAPSettings->iUsePseudonyms = ETrue;
+            }
+        else
+            {
+            eap->iEAPSettings->iUsePseudonyms = EFalse;            
+            }
+        }// else if 
+    else if( ( aParameter.Name().Compare( EAPMAXAUTHS ) ) == 0 )
+        {
+        // not supported
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPMAXAUTHS" ) );
+        }// else if 
+    else if( ( aParameter.Name().Compare( EAPENCAPS ) ) == 0 )
+        {
+        
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPENCAPS" ) );
+        
+        TEapExpandedType dummy; 
+        ConvertEAPStringToIds( value, eap->iEncapsulatingExpandedEapId, dummy );
+                     
+        }// else if    
+    else if( ( aParameter.Name().Compare( EAPVERSERREALM ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPVERSERREALM" ) );
+        
+        TInt serverRealm;
+        TLex lex( value );
+        lex.Val( serverRealm );
+        
+        eap->iEAPSettings->iVerifyServerRealmPresent = ETrue;
+        
+        if ( serverRealm == 1 )
+            {        
+            eap->iEAPSettings->iVerifyServerRealm = ETrue;
+            }
+        else
+            {
+            eap->iEAPSettings->iVerifyServerRealm = EFalse;            
+            }
+        }// else if    
+    else if( ( aParameter.Name().Compare( EAPCLIENTHAUTH ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPCLIENTHAUTH" ) );
+        
+        TInt clientAuthentication;
+        TLex lex( value );
+        lex.Val( clientAuthentication );
+        
+        eap->iEAPSettings->iRequireClientAuthenticationPresent = ETrue;
+        
+        if ( clientAuthentication == 1 )
+            {        
+            eap->iEAPSettings->iRequireClientAuthentication = ETrue;
+            }
+        else
+            {
+            eap->iEAPSettings->iRequireClientAuthentication = EFalse;            
+            }
+        }// else if    
+    else if( ( aParameter.Name().Compare( EAPSESVALTIME ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSESVALTIME" ) );
+        
+        TInt sessionValidityTime;
+        TLex lex( value );
+        lex.Val( sessionValidityTime );
+        eap->iEAPSettings->iSessionValidityTime = sessionValidityTime;
+        eap->iEAPSettings->iSessionValidityTimePresent = ETrue;
+
+        }// else if    
+    else if( ( aParameter.Name().Compare( EAPCIPSUIT ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPCIPSUIT" ) );
+        
+        TInt cipherSuites;
+        TLex lex( value );
+        lex.Val( cipherSuites );
+        eap->iEAPSettings->iCipherSuites.Append( cipherSuites );
+        eap->iEAPSettings->iCipherSuitesPresent = ETrue;
+        
+        }// else if
+    else if( ( aParameter.Name().Compare( EAPPEAPV0 ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPEAPV0" ) );
+        
+        TInt peap;
+        TLex lex( value );
+        lex.Val( peap );
+        
+        eap->iEAPSettings->iPEAPVersionsPresent = ETrue;
+        if ( peap == 1 )
+            {        
+            eap->iEAPSettings->iPEAPv0Allowed = ETrue;
+            }
+        else
+            {
+            eap->iEAPSettings->iPEAPv0Allowed = EFalse;            
+            }
+        }// else if     
+    else if( ( aParameter.Name().Compare( EAPPEAPV1 ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPEAPV1" ) );
+        TInt peap;
+        TLex lex( value );
+        lex.Val( peap );
+        eap->iEAPSettings->iPEAPVersionsPresent = ETrue;
+        if ( peap == 1 )
+            {        
+            eap->iEAPSettings->iPEAPv1Allowed = ETrue;
+            }
+        else
+            {
+            eap->iEAPSettings->iPEAPv1Allowed = EFalse;            
+            }
+        }// else if
+    else if( ( aParameter.Name().Compare( EAPPEAPV2 ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPPEAPV2" ) );
+        TInt peap;
+        TLex lex( value );
+        lex.Val( peap );
+        eap->iEAPSettings->iPEAPVersionsPresent = ETrue;
+        if ( peap == 1 )
+            {        
+            eap->iEAPSettings->iPEAPv2Allowed = ETrue;
+            }
+        else
+            {
+            eap->iEAPSettings->iPEAPv2Allowed = EFalse;            
+            }
+        }// else if  
+        
+    else if( ( aParameter.Name().Compare( EAPISSNAME ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPISSNAME" ) );
+        
+        eap->iCertificate->SetSubjectName(value);
+        eap->iCertificate->SetSubjectNamePresent();
+        }// else if        
+        
+    else if( ( aParameter.Name().Compare( EAPSUBNAME ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSUBNAME" ) );
+        
+        eap->iCertificate->SetIssuerName(value);
+        eap->iCertificate->SetIssuerNamePresent();       
+        }// else if        
+        
+    else if( ( aParameter.Name().Compare( EAPCERTTYPE ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPCERTTYPE" ) );
+        if ( value == EAPCERTCA )
+			{
+			FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EEapSim" ) );
+            
+            eap->iCertificate->SetCertType(EapCertificateEntry::ECA);
+            eap->iEAPSettings-> iUseAutomaticCACertificatePresent = ETrue;
+            eap->iEAPSettings-> iUseAutomaticCACertificate = EFalse;
+			}
+		else
+		    {
+		    eap->iCertificate->SetCertType(EapCertificateEntry::EUser);
+		    }
+		// Certificates must be present since this field was added
+		eap->iEAPSettings->iCertificatesPresent = ETrue;
+		eap->iCertificate->SetIsEnabledPresent();
+		eap->iCertificate->SetIsEnabled(ETrue) ;
+        
+        }// else if        
+    else if( ( aParameter.Name().Compare( EAPSERNUM ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSERNUM" ) );
+        
+        eap->iCertificate->SetSerialNumber(value);
+        eap->iCertificate->SetSerialNumberPresent();
+        }// else if
+        
+    else if( ( aParameter.Name().Compare( EAPSUBKEYID ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPSUBKEYID" ) );
+           
+        _LIT(KHexIdLC, "0x");
+       	_LIT(KHexIdUC, "0X");
+       	TBuf<2> HexIdBuf;
+       	TInt keyLen = aParameter.Value().Length();
+       	
+       	// setting the given key to the key buffer
+       	TBuf<KMaxSubKeyLenght> origKey;
+       	origKey.SetLength(keyLen);
+       	origKey = aParameter.Value();
+       	TBuf<KMaxSubKeyLenght> key;
+       	TLex tmpByte;
+       	TInt err(KErrNone);
+       	TUint16 byte;
+       	
+       	// Remove possible spaces from the beginning
+       	origKey.TrimLeft();
+       	
+       	// if the key is over two chars long, then we have to check
+       	// whether there is 0x or 0X in the beginning
+       	if (origKey.Length() >= 2)
+            {
+        	// Copy the two left most characters in to the buffer
+        	HexIdBuf.Copy(origKey.Left(2));
+        	
+        	// If the first characters are 0x or 0X, then they should be ignored
+        	if (HexIdBuf.Compare(KHexIdLC) == 0
+        			|| HexIdBuf.Compare(KHexIdUC) == 0)
+        		{
+        		// delete two characters
+        		origKey.Delete(0, 2);
+        		}
+            }
+        
+       	// looping the subject key through, removing whitespaces
+       	for (TInt i = 0; i < keyLen; i++)
+       		{
+       		// removing white spaces from the left side of the key
+       		origKey.TrimLeft();
+       		// check that there are characters left
+       		if (origKey.Length() >= 2)
+       			{
+       			// pick the two left most bytes from the key
+       			tmpByte = origKey.Left(2);
+       			// convert byte into binary format
+       			err = tmpByte.Val(byte, EHex);
+       			
+       			// delete two characters from the left side of the character array in the buffer
+       			origKey.Delete(0, 2);
+       			
+       			// check whether conversion to decimal went ok
+       			if (err != KErrNone)
+       				{
+       				// if there are problems, then leave the loop
+       				break;
+       				}
+       			
+       			// store the appended byte into the key variable
+       			key.Append(byte);
+       			}
+       			
+       		else if (origKey.Length() == 1)
+       			{
+       			// pick the left most bytes from the key
+       			tmpByte = origKey.Left(1);
+       			// convert byte into binary format
+       			err = tmpByte.Val(byte, EHex);
+       			
+       			// delete two characters from the left side of the character array in the buffer
+       			origKey.Delete(0, 1);
+       			
+       			// check whether conversion to decimal went ok
+       			if (err != KErrNone)
+       				{
+       				// if there are problems, then leave the loop
+       				break;
+       				}
+       			
+       			// store the appended byte into the key variable
+       			key.Append(byte);
+       			}
+       		else
+       			{
+       			break;
+       			}
+       		}
+       	TBuf8<KMaxSubKeyLenght> keyIdentifier;
+       	keyIdentifier.Copy(key);
+       	// store key value only if no errors occurred
+       	if (err == KErrNone) 
+       		{
+       		eap->iCertificate->SetSubjectKeyId(keyIdentifier);
+       		eap->iCertificate->SetSubjectKeyIdPresent();
+       		eap->iEAPSettings->iCertificatesPresent = ETrue; 
+       		}
+       	}
+       	
+        
+    else if( ( aParameter.Name().Compare( EAPTHUMBPRINT ) ) == 0 )
+        {
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::HandleEAPParametersL EAPTHUMBPRINT" ) );
+        eap->iCertificate->SetThumbprintPresent();
+        eap->iCertificate->SetThumbprint(value);
+        }// else if                  
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::CWPAPNapdef
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPAPNapdef::CWPAPNapdef( TBool aFollowingLink,
+                          const TDesC& aDefaultName, 
+                          CWPCharacteristic& aLogicalCharacteristic )
+                        : CWPAPItemBase( aDefaultName ),
+                          iCharacteristic( aLogicalCharacteristic ),
+                          iFollowingLink( aFollowingLink )
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::ConstructL()
+	{
+	iLingerValue = NULL;
+	iLingerFlag = ETrue;
+	iInternetIndicator = -1;
+	//checks if Wlan feature is supported
+  FeatureManager::InitializeLibL();
+  iWlanSupported = FeatureManager::FeatureSupported( KFeatureIdProtocolWlan );
+  FeatureManager::UnInitializeLib();
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::SaveWlanDataL
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::SaveWlanDataL( TUint32 aIapId, CCommsDatabase& aCommsDb )
+    {
+    FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL APid: (%d)"),  aIapId) );
+    
+    if ( iBearer == KUidWlanBearerType )
+	    {
+        CCommsDbTableView* wLanServiceTable;
+        
+        // CMManager
+        // Search the Iap Service Id using the received IapId
+        RCmConnectionMethodExt cm = iCm->ConnectionMethodL( aIapId );
+        TUint32 serviceId = cm.GetIntAttributeL( CMManager::ECmIapServiceId );
+     	
+        // The BeginTransaction might fail if someone else has locked CommsDat
+        TInt dberr = aCommsDb.BeginTransaction();
+        if( dberr == KErrLocked )
+            {
+            // Try BeginTransaction again to get lock
+            TInt retry = KBeginTransRetryCount;            
+            while ( retry > 0 && dberr == KErrLocked )
+                {                   
+                User::After(KBeginTransRetryDelay);
+                dberr = aCommsDb.BeginTransaction();
+                FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL: Database locked. BeginTransaction retry." ) );
+                retry--;
+                }
+            if(dberr != KErrNone)
+                {                            
+                // Could not get lock to CommsDat at all
+                FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL: BeginTransaction failed completely." ) );
+                User::Leave( dberr ); 
+                }           
+            }                             
+        
+        TInt indexToSec = 0;
+        wLanServiceTable = aCommsDb.OpenViewMatchingUintLC( 
+                        TPtrC( WLAN_SERVICE ), TPtrC( WLAN_SERVICE_ID ), serviceId );
+        TInt errorCode = wLanServiceTable->GotoFirstRecord();
+
+        if ( errorCode == KErrNone )
+            {
+            indexToSec = serviceId;
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL updaterecord" ) );
+            wLanServiceTable->UpdateRecord();
+            }
+        else
+            {
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL insertrecord" ) );
+            TUint32 dummyUid( 0 );
+            User::LeaveIfError( wLanServiceTable->InsertRecord( dummyUid ) );
+
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_SERVICE_ID" ) );
+            // Save link to LAN service
+            wLanServiceTable->WriteUintL( TPtrC( WLAN_SERVICE_ID ), aIapId );
+            indexToSec = aIapId;
+            }
+        
+        // Setting the security mode manually, because CMManager does not do that
+        wLanServiceTable->WriteUintL( TPtrC( WLAN_SECURITY_MODE ), iSecMode );
+
+    	if( iSecSSID.Count() )
+			{
+	        CCommsDbTableView* wLanSecserviceTable;
+			wLanSecserviceTable = aCommsDb.OpenTableLC( TPtrC( WLAN_SECONDARY_SSID ) ); 
+			//CleanupStack::Pop(wLanSecserviceTable); // wLanSecserviceTable
+		 	TBuf<4> blank;
+		 	blank.Append(KNullDesC);
+		    
+		    TBool sssid = EFalse;
+	        TBool sussid = EFalse;
+
+	        for(TInt i = 0; i < iSecSSID.Count(); i++ )
+	        	{
+	        	TUint32 id ;
+	        	
+		        
+		        TInt retval = wLanSecserviceTable->InsertRecord(id);
+		        wLanSecserviceTable->WriteUintL(TPtrC(WLAN_SEC_SSID_SERVICE_ID), indexToSec );
+		        wLanSecserviceTable->WriteUintL(TPtrC(WLAN_SEC_SSID_ID), id );
+
+		 	    if( iSecSSID[i]->iSSSID != NULL)
+		 	    sssid = ETrue;
+		 	    if(iSecSSID[i]->iSUSSID != NULL)
+		 	    sussid = ETrue;
+		 	    
+		 	    if((sssid && iSecSSID[i]->iSSSID->Value() != blank) || (sussid && iSecSSID[i]->iSUSSID->Value() != blank ))
+		 	    {
+		 		if( sssid )
+		 		wLanSecserviceTable->WriteTextL(TPtrC(WLAN_SEC_SSID_SCANNED_SSID), iSecSSID[i]->iSSSID->Value());
+			
+				if(sussid)
+				wLanSecserviceTable->WriteTextL(TPtrC(WLAN_SEC_SSID_USED_SSID), iSecSSID[i]->iSUSSID->Value());
+		        
+		 	    }
+		 	    wLanSecserviceTable->PutRecordChanges();
+		 	    sssid = EFalse;
+	            sussid = EFalse;
+	        	}
+	        	CleanupStack::PopAndDestroy( wLanSecserviceTable );
+			}
+			
+			iSecSSID.ResetAndDestroy();
+			iSecSSID.Close();
+        if ( iPriSSID )
+            {
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_SSID" ) );
+            // Save NU_WLAN_SSID
+        	wLanServiceTable->WriteTextL( TPtrC(NU_WLAN_SSID), iPriSSID->Value() );
+            }
+        if ( iPriUSSID )
+            {        
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL WLAN_USED_SSID" ) );
+            // Save WLAN_USED_SSID	
+    	      wLanServiceTable->WriteTextL( TPtrC(WLAN_USED_SSID), iPriUSSID->Value() );
+            }
+        if ( iPriHSSID )
+            {        
+    	    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL WLAN_SCAN_SSID" ) );
+            // Save WLAN_SCAN_SSID
+    	    wLanServiceTable->WriteBoolL( TPtrC(WLAN_SCAN_SSID), ETrue );
+            }
+        else
+            {
+    	    wLanServiceTable->WriteBoolL( TPtrC(WLAN_SCAN_SSID), EFalse );            	
+            }
+
+       	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WEP_INDEX" ) );
+        // Save index of key in use
+        wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_INDEX ), 
+                                      (TUint32&) iDefaultWepKeyIndex );
+        FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WEP_INDEX: (%d)"),  iDefaultWepKeyIndex) );
+
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL NU_WLAN_AUTHENTICATION_MODE" ) );
+        // Open / Shared (0/1)
+        // Save index of key in use
+        wLanServiceTable->WriteUintL( TPtrC( NU_WLAN_AUTHENTICATION_MODE ), 
+                                     ( TUint32& ) iAuthentication );
+        FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL NU_WLAN_AUTHENTICATION_MODE: (%d)"),  iAuthentication) );
+        
+        
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY1" ) );
+        // Save first WEP key
+        wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY1 ), iKeyData[0] );
+        wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY1_FORMAT ), 
+                                 ( TUint32& ) iKeyFormat[0] );
+        FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[0] ) );
+        
+        
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY2" ) );
+        // Save second WEP key
+        wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY2 ), iKeyData[1] );
+        wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY2_FORMAT ), 
+                                 ( TUint32& ) iKeyFormat[1] );
+        FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[1] ) );
+            
+        
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY3" ) );
+        // Save third WEP key
+        wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY3 ), iKeyData[2] );
+        wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY3_FORMAT ), 
+                                 ( TUint32& ) iKeyFormat[2] );
+        FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[2] ) );
+            
+            
+        
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL NU_WLAN_WEP_KEY4" ) );
+        // Save fourth WEP key
+        wLanServiceTable->WriteTextL( TPtrC( NU_WLAN_WEP_KEY4 ), iKeyData[3] );
+        wLanServiceTable->WriteUintL( TPtrC( WLAN_WEP_KEY4_FORMAT ), 
+                                 ( TUint32& ) iKeyFormat[3] );
+        FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL (%S)"), &iKeyData[3] ) );
+            
+        
+        if ( iWpaPresKeyAsc )
+            {     
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL convert WPAKEY to ascii" ) );
+            // convert unicode to 8-bit ascii
+            TBuf8<KMaxWpaPskLength> wpaKey;
+            StrCopy( wpaKey, iWpaPresKeyAsc->Value() );
+            
+            // Enable WPA Pre Shared key mode
+            wLanServiceTable->WriteBoolL( TPtrC( WLAN_ENABLE_WPA_PSK ), ETrue );
+            
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WPA_PRE_SHARED_KEY" ) );
+            // Save PreShared Key
+            wLanServiceTable->WriteTextL( TPtrC( WLAN_WPA_PRE_SHARED_KEY ), 
+                                         wpaKey );
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteUintL WLAN_WPA_KEY_LENGTH" ) ); 
+            // Save PreShared Key Length
+            wLanServiceTable->WriteUintL( TPtrC( WLAN_WPA_KEY_LENGTH ), 
+                                         wpaKey.Length() );                                         
+            }
+
+        TBuf<KMaxLengthOfEapList> eapList;
+        eapList.Copy(KEapAll);
+
+        for (TInt i=0;i<iEapTypeArray.Count();i++)
+            {
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings" ) );
+            CEapTypeElement* eap = iEapTypeArray[i];
+            
+            if ( eap->iEAPSettings->iCertificatesPresent )
+            	{
+            	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL Certificate was present." ) );
+            	eap->iEAPSettings->iCertificates.Append( eap->iCertificate );	
+            	}                  
+
+            // Save EAP list
+            if ( eap->iEapTypeString.Length() > 0  
+            	 && eap->iEncapsulatingExpandedEapId.Length() == 0) // AND method is not encapsulated
+                {
+                FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL WriteTextL WLAN_EAPS" ) );
+                
+                TBuf8<3> buf;
+                _LIT8(KFormat, "%d");
+                // pick the last byte from the array
+                buf.Format(KFormat, eap->iEapTypeString[KExpandedEapIdLength - 1]);
+                // search for the correct offset for the eap type from the KEapAll literal
+                TInt index = KEapAll().Find(buf);
+                
+                const TUint8 offset = 2; //length = f "-0" string
+                // Add '+' to the correct offset, so that the eap is repsesented activated in the list
+                if(index >= offset)
+                    {
+                    eapList[index-offset] = KEapPlus; 
+                    }
+                
+                }
+            // Set iEncapsulatingEapTypes
+                 for ( TInt j = 0; j < iEapTypeArray.Count(); j++ )
+                     {
+                     // Check if any method has this method as the encapsulating method
+                     if ( eap->iEapTypeString == iEapTypeArray[j]->iEncapsulatingExpandedEapId )
+                         {
+                         // Append this method to iEncapsulatedEAPType
+                         eap->iEAPSettings->iEnabledEncapsulatedEAPExpandedTypes.Append( iEapTypeArray[j]->iEAPSettings->iEAPExpandedType );
+                         eap->iEAPSettings->iEnabledEncapsulatedEAPExpandedTypesPresent = ETrue;
+                         }
+                     }
+                 
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings CEapType::NewL" ) );        
+            CEapType* eapType = NULL;
+
+            
+            TRAPD( error, ( eapType = CEapType::NewL( ELan, serviceId, eap->iEAPSettings->iEAPExpandedType ) ) );
+
+            if ( ( error == KErrNone ) && eapType )
+                {
+                CleanupStack::PushL( eapType );
+                
+                // Check if this type is tunneled
+                if ( eap->iEncapsulatingExpandedEapId.Length() > 0 )
+                	{
+                	// It is tunneled. 
+                	eapType->SetTunnelingType( eap->iEncapsulatingExpandedEapId);
+                	
+                	}
+                
+                FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings SetConfigurationL" ) );
+                TRAP_IGNORE( eapType->SetConfigurationL( *eap->iEAPSettings ) );
+                
+                CleanupStack::PopAndDestroy( eapType );
+                
+                }
+            else
+                {
+                FTRACE(RDebug::Print(_L("[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL CEapType::NewL err: %d"), error ) );
+                }
+
+
+            FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL save EAP settings done" ) );
+            }
+            
+            
+	
+	  		// Expanded EAP types in use. Write the eap list to the new columns.
+    		
+    		// generate appropriate entries in the new enabled and disabled list,
+    		// overwriting those values 
+    		
+    		// count the + and - signs to determine the size of enabled and 
+    		// disabled descriptors
+
+    		TLex lex( eapList );
+    		TInt numPlus = 0;
+    		TInt numMinus = 0;
+    		TChar ch;
+    		while ( !lex.Eos() )
+    		    {
+    		    ch = lex.Get();
+    		    if ( ch == '+' ) ++numPlus;
+    		    else if ( ch == '-' ) ++numMinus;
+    		    }
+    		// load general EAP settings If
+    		CEapGeneralSettings* genSettings;
+    		genSettings = CEapGeneralSettings::NewL(ELan, serviceId);
+    		CleanupStack::PushL( genSettings );
+
+    		// get lists of enabled/disabled EAPs for the IAP
+    		
+    		RArray<TEapExpandedType> enabledEapMethods;
+    		RArray<TEapExpandedType> disabledEapMethods;
+
+    		enabledEapMethods.Reset();
+    		disabledEapMethods.Reset();
+   		
+    		
+    		// each entry consumes 8 bytes in binary format
+    		HBufC8* enabledEAPPlugin = HBufC8::NewL( 8 * numPlus );
+    		CleanupStack::PushL( enabledEAPPlugin );
+    		
+    		HBufC8* disabledEAPPlugin = HBufC8::NewL( 8 * numMinus );
+    		CleanupStack::PushL( disabledEAPPlugin );
+    		    
+    		lex.Assign( eapList );
+    		
+    		while ( !lex.Eos() )
+    		    {
+    		    // beginning of implementation UID
+    		    TInt16 implUid = 0;
+    		    
+    		    if ( lex.Val( implUid ) != KErrNone || !implUid )
+    		        {
+    		        // if the old string is corrupted, null out both lists
+    		        enabledEAPPlugin->Des().Zero();
+    		        disabledEAPPlugin->Des().Zero();
+    		        break;
+    		        }
+    		
+    		    // append it to the appropriate list ('+' enabled, '-' disabled)
+    		    _LIT8( KPadding, "\xFE\0\0\0\0\0\0" );
+    		    _LIT8( KMsChapV2Padding, "\xFE\xFF\xFF\xFF\0\0\0");
+    		    const TInt KPlainMsChapV2ImplUid = 99;
+    		    
+    		    if ( implUid > 0 )
+    		        {
+    		        enabledEAPPlugin->Des().Append( 
+    		                            Abs( implUid ) == KPlainMsChapV2ImplUid? 
+    		                                        KMsChapV2Padding: KPadding );
+    		        enabledEAPPlugin->Des().Append( Abs( implUid ) );
+    		        TPtrC8 data(reinterpret_cast<TUint8*>(&implUid), KExpandedEapIdLength);
+    		        TEapExpandedType expandedType;
+					      expandedType.SetValue(enabledEAPPlugin,KEapExpandedTypeLength);
+					      enabledEapMethods.Append(expandedType);
+					      }
+	    
+    		    // swallow the delimiter (',')
+    		    lex.Get();
+    		    }
+    
+    		genSettings->SetEapMethods(enabledEapMethods, disabledEapMethods);  
+    		            
+                	
+	
+    		CleanupStack::PopAndDestroy( disabledEAPPlugin );
+    		CleanupStack::PopAndDestroy( enabledEAPPlugin );
+    		CleanupStack::PopAndDestroy( genSettings );
+    		
+    
+     
+            
+       iEapTypeArray.ResetAndDestroy();
+       wLanServiceTable->PutRecordChanges();
+  
+
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL PutRecordChanges" ) ); 
+        CleanupStack::PopAndDestroy( wLanServiceTable );
+        
+        FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL done" ) );
+	    aCommsDb.CommitTransaction();
+	    }
+	else
+	    {
+	    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::SaveWlanDataL ignored not a WLAN AP" ) );
+	    }
+	    
+    }
+
+//------------------------------------------------------------------------------
+// CWPAPNapdef::ConvertAsciiToHex
+//------------------------------------------------------------------------------
+//
+void CWPAPNapdef::ConvertAsciiToHex( const TDesC8& aSource, HBufC8*& aDest )
+	{
+	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertAsciiToHex" ) );
+	
+	_LIT( hex, "0123456789ABCDEF" );
+	TInt size = aSource.Size();
+	TPtr8 ptr = aDest->Des();
+	for ( TInt ii = 0; ii < size; ii++ )
+		{
+		TText8 ch = aSource[ii];
+		ptr.Append( hex()[(ch/16)&0x0f] );
+		ptr.Append( hex()[ch&0x0f] );
+		}
+    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertAsciiToHex Done" ) );
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::StrCopy
+// String copy with lenght check.
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::StrCopy( TDes8& aTarget, const TDesC& aSource )
+    {
+    FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::StrCopy" ) );
+    
+	TInt len = aTarget.MaxLength();
+    if( len < aSource.Length() ) 
+	    {
+		aTarget.Copy( aSource.Left( len ) );
+		return;
+	    }
+	aTarget.Copy( aSource );
+	
+	FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::StrCopy Done" ) );
+    }
+
+CEapTypeElement::~CEapTypeElement()
+    {
+    delete iEAPSettings;
+    delete iCertificate;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::UpdateLingerL
+// 
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::UpdateLingerL(const TUint32 aIapId)
+{
+		if ( iLinger && ( !iLingerFlag ) )
+		{
+    	AddLingerL( aIapId , iLingerValue );
+		}
+		
+}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::UdateligerValueL
+// 
+// -----------------------------------------------------------------------------
+//
+void CWPAPNapdef::UdateligerValueL(CWPParameter* aLinger)
+{
+		TInt err(KErrNone);
+		const TDesC& value = aLinger->Value();
+		if( !Notalpha(value))
+		{
+		TLex lex( value );
+		TUint Linger = 0;
+		TInt lingerint;
+		err = lex.Val( Linger, EDecimal );
+		if( err == KErrNone )
+		{
+		    lingerint = Linger;
+			if( lingerint >= 0 )
+		    {
+		    	iLingerValue = lingerint;
+		    	iLingerFlag = EFalse;
+		    }
+		}
+		}
+}
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::UdateligerValueL
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CWPAPNapdef::Notalpha(const TDesC& aValue)
+{
+	TBool NotAlpha = EFalse;
+	TChar character;
+	for(TInt i = 0 ; i < aValue.Length(); i++)
+	{
+		character = aValue[i];
+		NotAlpha = character.IsAlpha();
+		if(NotAlpha)
+		break;
+	}
+	
+	return NotAlpha;
+}
+
+
+// ---------------------------------------------------------------------------
+// Adds iapID and linger interval to CentralRepository
+// ---------------------------------------------------------------------------
+//
+void CWPAPNapdef::AddLingerL( const TInt aIapId, const TInt aLingerInterval )
+    {
+    TInt    err( KErrNone );
+    
+    // Open repository
+    CRepository* repository = CRepository::NewLC( KCRUidPDPContextManager );
+    
+    // Find if an entry for "iapId" already exists in CentRep 
+    RArray< TUint32 > foundKeys;
+    foundKeys.Reset();
+    
+    err = repository->FindEqL( KIapColumn,       // partial key
+                               KColumnMask,      // key mask
+                               aIapId,           // value
+                               foundKeys );      // found keys
+    
+    if ( err == KErrNone || err == KErrNotFound )
+        {
+        if ( foundKeys.Count() == 0 )
+            {
+            // Add a new entry
+            TInt arrayCount( 0 );
+            
+            // Get number of iapId&linger entries in Centrep
+            err = repository->Get( KPdpContextManagerLingerArrayCount, 
+                                   arrayCount );
+        
+            if ( err == KErrNone )
+                {
+                arrayCount++;
+                
+                err = repository->Create( ( KIapColumn | arrayCount ), aIapId ); 
+                
+                if ( err == KErrNone )
+                    {
+                    err = repository->Create( ( KLingerColumn | arrayCount ), 
+                                               aLingerInterval );     
+                    }
+                
+                if ( err == KErrNone )
+                    {
+                    // Update number of iapId&linger entries in Centrep
+                    err = repository->Set( KPdpContextManagerLingerArrayCount, 
+                                           arrayCount );
+                    }
+                }
+            }
+        else
+            {
+            // Update existing entry on current row
+            TInt32 row = foundKeys[ 0 ] & KRowMask;
+            
+            err = repository->Set( ( KLingerColumn | row ), aLingerInterval ); 
+            }         
+        }
+        
+    foundKeys.Close();
+    CleanupStack::PopAndDestroy( repository );
+    
+    User::LeaveIfError( err );
+    
+    }
+
+void CWPAPNapdef::ConvertEAPStringToIds( const TDesC& aEAPString, TDes8& aExpandedId, TEapExpandedType& aID)
+	{
+    if ( aEAPString == KEAPSIM )
+		{	
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapSim" ) );
+		aExpandedId.Copy( KEapSimTypeId, KExpandedEapIdLength );
+		aID = *EapExpandedTypeSim.GetType();
+		}
+    else if( aEAPString == KEAPAKA )
+        {
+  		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapAka" ) );
+		aExpandedId.Copy( KEapAkaTypeId, KExpandedEapIdLength );	
+		aID = *EapExpandedTypeAka.GetType();	
+        }
+    else if( aEAPString == KEAPTLS )
+        {
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapTls" ) );
+		aExpandedId.Copy( KEapTlsTypeId, KExpandedEapIdLength );	
+		aID = *EapExpandedTypeTls.GetType();	
+        }
+    else if( aEAPString == KEAPPEAP )
+        {
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapPeap" ) );
+		aExpandedId.Copy( KEapPeapTypeId, KExpandedEapIdLength );	
+		aID = *EapExpandedTypePeap.GetType();	
+        }
+    else if( aEAPString == KEAPTTLS )
+        {
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapTtls" ) );
+		aExpandedId.Copy( KEapTtlsTypeId, KExpandedEapIdLength );		
+		aID = *EapExpandedTypeTtls.GetType();
+        }
+   else if( aEAPString == KEAPLEAP )
+        {
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapLeap" ) );
+		aExpandedId.Copy( KEapLeapTypeId, KExpandedEapIdLength );
+		aID = *EapExpandedTypeLeap.GetType();		
+        }                                    
+   else if( aEAPString == KEAPMSCHAPV2 )
+        {
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapMschapv2" ) );
+		aExpandedId.Copy( KEapMschapv2TypeId, KExpandedEapIdLength );		
+		aID = *EapExpandedTypeMsChapv2.GetType();
+        }     
+   else if( aEAPString == KEAPGTC )
+        {
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapGtc" ) );
+		aExpandedId.Copy( KEapGtcTypeId, KExpandedEapIdLength );
+		aID = *EapExpandedTypeGtc.GetType();
+        }
+   else if( aEAPString == KEAPFAST )
+        {
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapFast" ) );
+		aExpandedId.Copy( KEapFastTypeId, KExpandedEapIdLength );
+		aID = *EapExpandedTypeFast.GetType();
+        }
+
+    else
+        {
+		FLOG( _L( "[AccesspointAdapter] CWPAPNapdef::ConvertEAPStringToIds EEapNone" ) );
+		aExpandedId.Copy( KEapNoneId, KExpandedEapIdLength );
+		aID = *EapExpandedTypeNone.GetType();
+        }
+
+	}
+ 
+// ---------------------------------------------------------------------------
+// Returns the NAP-ID
+// ---------------------------------------------------------------------------
+//
+const TDesC& CWPAPNapdef::NapId()
+    {
+	return iNapID->Value();	
+    }
+
+// ---------------------------------------------------------------------------
+// Returns the bearer value
+// ---------------------------------------------------------------------------
+//    
+TUint CWPAPNapdef::Bearer()
+	{
+	return iBearer;
+	}
+    
+// ---------------------------------------------------------------------------
+// Returns the bearer value
+// ---------------------------------------------------------------------------
+//    
+void CWPAPNapdef::SetCMManager( RCmManagerExt* aCm )
+	{
+	iCm = aCm;
+	}
+    
+    
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/CWPAPPhysicalProxy.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,349 @@
+/*
+* 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:    Defines a class, which holds physical proxy information.
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+
+#include "CWPAPPhysicalProxy.h"				// Own header
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+#include <WPAdapterUtil.h>
+#include <featmgr.h>
+#include "CWPAPLogicalProxy.h"
+#include "CWPAPPort.h"
+#include "CWPAPNapdef.h"
+#include "WPAPAdapter.pan"
+#include "CWPLog.h"
+#include "WPAPDefs.h"
+#include <cmconnectionmethodext.h>
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWPAPPhysicalProxy::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWPAPPhysicalProxy* CWPAPPhysicalProxy::NewLC( 
+                                            const TDesC& aDefaultName, 
+                                            CWPCharacteristic& aCharacteristic, 
+    CWPCharacteristic& aLogicalCharacteristic,
+    CWPAPPort*& aPort )
+	{
+	CWPAPPhysicalProxy* self = new(ELeave) CWPAPPhysicalProxy( 
+	                                                    aDefaultName, 
+                                                        aLogicalCharacteristic,
+                                                        aPort ); 
+	CleanupStack::PushL( self );
+	self->ConstructL();
+    aCharacteristic.AcceptL( *self );
+	return self;
+	}
+	
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CWPAPPhysicalProxy::~CWPAPPhysicalProxy()
+	{
+	delete iPort;
+
+    iNapdefs.ResetAndDestroy();
+    iNapdefs.Close();
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPhysicalProxy::ValidateL
+// -----------------------------------------------------------------------------
+//
+TBool CWPAPPhysicalProxy::ValidateL()
+	{
+	TBool isValid( EFalse );
+
+	// We must have proxy address otherwise this proxy isn't valid.
+	if ( iProxyAddr )
+		{
+		switch ( iPxAddrType )
+			{
+			case EPxAddrTypeIPv4:
+				{
+				isValid = WPAdapterUtil::CheckIPv4( iProxyAddr->Value() );
+				break;
+				}
+            case EPxAddrTypeIPv6:
+                {
+                isValid = FeatureManager::FeatureSupported( KFeatureIdIPv6 )
+                    && WPAdapterUtil::CheckIPv6( iProxyAddr->Value() );
+                break;
+                }
+			case EPxAddrTypeUnsupported:
+				{
+				isValid = EFalse;
+				break;
+				}
+			default: // default value is assumed to be EPxAddrTypeIPv4
+				{
+				isValid = WPAdapterUtil::CheckIPv4( iProxyAddr->Value() );
+				}
+			}
+		}
+	return isValid;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPhysicalProxy::AddDataL
+// -----------------------------------------------------------------------------
+//
+void CWPAPPhysicalProxy::AddDataL( RCmConnectionMethodExt& aCmItem )
+	{  
+	LOG("--CWPAP CWPAPPhysicalProxy::AddDataL begin--");	
+	TInt err(KErrNone);
+	
+	// CMManager
+	aCmItem.SetStringAttributeL( CMManager::ECmWapIPGatewayAddress, iProxyAddr->Value());
+	LOG2("CWPAP EApWapStartPage, value: %S, err: %d",
+	                                             &iProxyAddr->Value(), err);
+
+	//CMManager
+	aCmItem.SetStringAttributeL( CMManager::ECmIPGateway, iProxyAddr->Value());
+	LOG2("CWPAP EApIspIPGateway, value: %S, err: %d",
+	                                             &iProxyAddr->Value(), err);
+
+	//CMManager 
+	aCmItem.SetStringAttributeL( CMManager::ECmProxyServerName, iProxyAddr->Value() );
+	LOG2("CWPAP EApProxyServerAddress, value: %S, err: %d",
+	                                                &iProxyAddr->Value(), err);
+	                                               
+
+	// Store port data
+	if ( iPort )
+        {
+        iPort->AddDataL( aCmItem );
+        }
+    
+    if ( iLogicalPort)
+        {
+        iLogicalPort->AddDataL( aCmItem );
+        }
+    if ( err ) err = 0; // prevent compiler warning
+    
+	LOG("--CWPAP CWPAPPhysicalProxy::AddDataL end--");	
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPhysicalProxy::AddItemsL
+// -----------------------------------------------------------------------------
+//
+TInt CWPAPPhysicalProxy::AddItemsL( RPointerArray<CWPAPAccesspointItem>& aItems,
+                                    CWPAPItemBase* iLogicalProxy, 
+                                    CWPAPItemBase* /*iPhysicalProxy*/ ) 
+	{
+    TInt count( 0 );
+    for( TInt i( 0 ); i < iNapdefs.Count(); i++ )
+        {
+        CWPAPNapdef* pp = iNapdefs[ i ];
+        if( pp->ValidateL() )
+            {
+            count += pp->AddItemsL( aItems, iLogicalProxy, this );
+            }
+        }
+
+    return count;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPAPPhysicalProxy::Name
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPAPPhysicalProxy::Name()
+	{
+    if( iName )
+        {
+        return iName->Value();
+        }
+    else 
+        {
+        return KNullDesC;
+        }
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPhysicalProxy::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPAPPhysicalProxy::VisitL( CWPCharacteristic& aCharacteristic )
+	{
+	TInt type = aCharacteristic.Type();
+	
+	// Accept only KWPPort characteristics
+	// One valid port is enough for us
+	if ( type == KWPPort && !iPort )
+		{
+        CWPAPPort* port = CWPAPPort::NewLC( aCharacteristic );
+
+		if ( port->ValidateL() )
+			{
+			iPort = port;
+			CleanupStack::Pop( port );
+			}
+		else // Data not valid.
+			{
+			CleanupStack::PopAndDestroy( port );
+			}
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPhysicalProxy::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPAPPhysicalProxy::VisitL( CWPParameter& aParameter)
+	{
+	TInt id = aParameter.ID();
+	const TDesC& value = aParameter.Value();
+
+	if ( value.Length() == 0 )
+		{
+		// No use to store zero length value.
+		return;
+		}
+
+	switch ( id )
+		{
+		case EWPParameterPxAddrFQDN: // iGatewayIPAddress
+			{
+			// Implementation comments:
+			// The value of this field is a domain name but we can't 
+			// at the moment resolve this to IP address 
+			// (at least from this adapter).
+			// Therefore this field can't be used. 
+			// EWPParameterPxAddr is supported
+			// and should be used.
+
+			/// Validate the domain name
+			/// Resolve to IP address
+
+			/* // Uncomment if domain name can be validated and IP address resolved
+			// Add only if we haven't already received this field
+			if ( !IsReceived( EWPParameterPxAddrFQDN_id ))
+				{
+				iGatewayIPAddress = &aParameter;
+				MarkReceived( EWPParameterPxAddrFQDN_id );
+				}
+			*/
+			break;
+			}
+		case EWPParameterPxAddr: // iGatewayIPAddress
+			{
+			// Accept only first occurrence of either PxAddr or PxAddrFQDN
+			if ( IsReceived( EWPParameterPxAddrFQDN_id ) ||
+				IsReceived( EWPParameterPxAddr_id ) )
+				{
+				return;
+				}
+			else 
+				{
+				// The max allowed lenght for proxy address is 45 bytes. 
+				// Nothing is stored if max lenght is exceeded
+				if ( aParameter.Value().Length() < 46 )
+					{
+					iProxyAddr = &aParameter;
+					MarkReceived( EWPParameterPxAddr_id );
+					}
+				}
+			break;
+			}
+		case EWPParameterPxAddrType:
+			{
+			if ( !IsReceived( EWPParameterPxAddrType_id ) )
+				{
+				// Only IPv4 addresses are supported.
+				if ( value == KIPV4 )
+					{
+					iPxAddrType = EPxAddrTypeIPv4;
+					}
+                else if( value == KIPV6 )
+                    {
+                    iPxAddrType = EPxAddrTypeIPv6;
+                    }
+				else
+					{
+					iPxAddrType = EPxAddrTypeUnsupported;
+					}
+				MarkReceived( EWPParameterPxAddrType_id );
+				}
+			break;
+			}
+        case EWPParameterName:
+            {
+            if( !iName )
+                {
+                iName = &aParameter;
+                }
+            break;
+            }
+		default:
+			{
+			// Just let through
+			}
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPhysicalProxy::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPAPPhysicalProxy::VisitLinkL( CWPCharacteristic& aLink )
+	{
+    CWPAPNapdef* item = CWPAPNapdef::NewLC( ETrue,
+                                            iDefaultName,
+                                            iLogicalCharacteristic,
+                                            aLink );
+    User::LeaveIfError( iNapdefs.Append( item ) );
+    CleanupStack::Pop( item ); // item
+    }
+
+// -----------------------------------------------------------------------------
+// CWPAPPhysicalProxy::CWPAPPhysicalProxy
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPAPPhysicalProxy::CWPAPPhysicalProxy( 
+                               const TDesC& aDefaultName, 
+                               CWPCharacteristic& aLogicalCharacteristic,
+                               CWPAPPort*& aPort ) 
+	                         : CWPAPItemBase( aDefaultName ), 
+                               iLogicalPort( aPort ),
+                               iNapdefs( KInitialArraySize ),
+                               iLogicalCharacteristic( aLogicalCharacteristic )
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPhysicalProxy::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPAPPhysicalProxy::ConstructL()
+	{
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/CWPAPPort.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,294 @@
+/*
+* 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:    Defines a class, which holds proxy port information.
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+
+#include "CWPAPPort.h"					// Own header
+#include "WPAPAdapter.pan"
+#include "CWPLog.h"
+#include "WPAPDefs.h"
+
+#include <CWPCharacteristic.h>
+#include <CWPParameter.h>
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWPAPPort::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWPAPPort* CWPAPPort::NewLC( CWPCharacteristic& aCharacteristic )
+	{
+	CWPAPPort* self = new(ELeave) CWPAPPort(); 
+	CleanupStack::PushL( self );
+	self->ConstructL();
+    aCharacteristic.AcceptL( *self );
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPort::CWPAPPort
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWPAPPort::CWPAPPort() : CWPAPItemBase( KNullDesC )
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CWPAPPort::~CWPAPPort()
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPort::Validate
+// -----------------------------------------------------------------------------
+//
+TBool CWPAPPort::ValidateL()
+	{
+	// If we got either service or portnumber and 
+	// Those we successfully interpreted the port
+	// information is valid.
+	if ( IsReceived( EWPParameterService_id ) ||
+		IsReceived( EWPParameterPortNbr_id ))
+		{
+		return ETrue;
+		}
+	LOG("CWPAP ERROR! Port not valid");
+	return EFalse; // Nothing received so this is invalid.
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPort::AddData
+// -----------------------------------------------------------------------------
+//
+void CWPAPPort::AddDataL( RCmConnectionMethodExt& aCmItem )
+	{    
+	LOG("--CWPAP CWPAPPort::AddDataL begin--");	
+	TInt err(KErrNone);
+	
+	// CMManager
+	TRAP (err, aCmItem.SetBoolAttributeL( CMManager::ECmWapIPSecurity, iConnectionSecurity ));
+	LOG2("CWPAP EApWapSecurity, value: %d, err: %d", iConnectionSecurity, err);
+
+	// CMManager
+	TRAP (err, aCmItem.SetIntAttributeL( CMManager::ECmWapIPWSPOption, iSessionMode ));
+	LOG2("CWPAP EApWapWspOption, value: %d, err: %d", iSessionMode, err);
+
+	if ( iPortNbr )
+		{
+		const TDesC& value = iPortNbr->Value();
+		TLex lex( value );
+		TUint32 intValue=0;
+		err = lex.Val( intValue, EDecimal );
+		if ( err == KErrNone )
+			{
+			if( intValue > 65535 )
+				{
+				intValue = 0;
+				}
+				
+			// CMManager 
+			TRAP (err, aCmItem.SetIntAttributeL( CMManager::ECmProxyPortNumber, intValue ));
+			LOG2("CWPAP EApProxyPortNumber, value: %d, err: %d",
+			                                                 intValue, err);
+			}
+		}
+	LOG("--CWPAP CWPAPPort::AddDataL end--");	
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPort::Name
+// -----------------------------------------------------------------------------
+//
+const TDesC& CWPAPPort::Name()
+	{
+    return KNullDesC;
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPort::AddItemsL
+// -----------------------------------------------------------------------------
+//
+TInt CWPAPPort::AddItemsL( RPointerArray<CWPAPAccesspointItem>& /*aItems*/,
+                           CWPAPItemBase* /*aLogicalProxy*/,
+                           CWPAPItemBase* /*aPhysicalProxy*/ ) 
+	{
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CWPAPPort::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPAPPort::VisitL( CWPCharacteristic& /*aCharacteristic*/ )
+	{	
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPort::VisitL
+// -----------------------------------------------------------------------------
+//
+void CWPAPPort::VisitL( CWPParameter& aParameter )
+	{
+	TInt id = aParameter.ID();
+	const TDesC& value = aParameter.Value();
+
+	if ( value.Length() == 0 )
+		{
+		// No use of checking the zero legth parameter.
+		return;
+		}
+
+	switch ( id )
+		{
+		case EWPParameterService: // iConnectionSecurity and iSessionMode
+			{
+			// If EWPParameterService value have already received
+			// or service type has been solved from EWPParameterPortNbr value
+			// don't accept this anymore. 
+			if ( IsReceived( EWPParameterService_id ) )
+				{
+				break;
+				}
+
+			if ( value == KCLWSP)
+				{
+				// CMManager
+				SetValues( EFalse, CMManager::ECmWapWspOptionConnectionless, 
+					EWPParameterPortNbr_id );
+				}
+			else if ( value == KCOWSP)
+				{
+				// CMManager
+				SetValues( EFalse, CMManager::ECmWapWspOptionConnectionOriented, 
+					EWPParameterPortNbr_id );
+					
+				}
+			else if ( value == KCLSECWSP)
+				{
+				// CMManager
+				SetValues( ETrue, CMManager::ECmWapWspOptionConnectionless, 
+					EWPParameterPortNbr_id );
+				}
+			else if ( value == KCOSECWSP)
+				{
+				// CMManager
+				SetValues( ETrue, CMManager::ECmWapWspOptionConnectionOriented, 
+					EWPParameterPortNbr_id );
+				}
+			else
+				{
+				// Not supported...
+				}
+			break;
+			}
+		case EWPParameterPortNbr: // iConnectionSecurity and iSessionMode
+			{
+			// If EWPParameterPortNbr value have already handled 
+			// don't accept it anymore.
+			if ( IsReceived( EWPParameterPortNbr_id ) )
+				{
+				break;
+				}
+
+			// Store the pointer to port parameter
+			iPortNbr = &aParameter;
+            MarkReceived( EWPParameterPortNbr_id );
+
+			if ( value == K9200 )
+				{
+				// CMManager
+				SetValues( EFalse, CMManager::ECmWapWspOptionConnectionless, 
+					EWPParameterPortNbr_id );
+					
+				// Type of service identified. 
+				// No need for Service parameter anymore.
+				MarkReceived( EWPParameterService_id );
+				}
+			else if ( value == K9201 || value == K80 ||	value == K8080)
+				{
+				// CMManager
+				SetValues( EFalse, CMManager::ECmWapWspOptionConnectionOriented, 
+					EWPParameterPortNbr_id );
+				MarkReceived( EWPParameterService_id );
+				}
+			else if ( value == K9202 )
+				{
+				// CMManager
+				SetValues( ETrue, CMManager::ECmWapWspOptionConnectionless, 
+					EWPParameterPortNbr_id );
+				MarkReceived( EWPParameterService_id );
+				}
+			else if ( value == K9203 || value == K443 )
+				{
+				// CMManager
+				SetValues( ETrue, CMManager::ECmWapWspOptionConnectionOriented, 
+					EWPParameterPortNbr_id );
+				MarkReceived( EWPParameterService_id );
+				}
+			else
+				{
+				// Not supported...
+				}
+			break;
+			}
+		default:
+			{
+			// Just let through
+			}
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPort::SetValues
+// -----------------------------------------------------------------------------
+//
+void CWPAPPort::SetValues( TBool aConnectionSecurity, 
+                           TInt aSessionMode,
+	                       TMarkedField aReceivedField )
+	{
+	__ASSERT_DEBUG( aReceivedField == EWPParameterService_id || 
+                    aReceivedField == EWPParameterPortNbr_id,
+                    Panic( EPreConditionFail ) );
+
+	iConnectionSecurity = aConnectionSecurity;
+	iSessionMode = aSessionMode;
+
+	MarkReceived( aReceivedField );
+	}
+
+// -----------------------------------------------------------------------------
+// CWPAPPort::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWPAPPort::ConstructL()
+	{
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/CWPLog.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Class offers static utility functions for CWmlBMSubItem.
+*
+*/
+
+
+
+
+// INCLUDE FILES
+
+#include <e32svr.h>
+#include "CWPLog.h"
+
+
+#ifdef ENABLE_LOGGING
+#include <flogger.h>
+
+/// Folder where the WMLBC log resides
+_LIT( KLogFolder, "ringbc" );
+
+/// The name of the log file
+_LIT( KLogFileName, "ringbc.txt" );
+
+/// The format in which the time is formatted in log
+_LIT( KLogTimeFormat, "%02d.%02d:%02d:%06d ");
+
+/// The length of the string produced by KLogTimeFormat
+const TInt KLogTimeFormatLength = 16;
+
+/// How many characters a log line can contain
+const TInt KLogLineLength = 256;
+
+#endif // ENABLE_LOGGING       
+
+// ================= MEMBER FUNCTIONS =======================
+
+#ifdef ENABLE_LOGGING
+// ---------------------------------------------------------
+// Log() 
+//
+// ---------------------------------------------------------
+void Log::DoLog( TRefByValue<const TDesC> aText, ... )
+    {
+    VA_LIST args;
+    VA_START( args, aText );
+
+    TBuf<KLogLineLength> buf;
+    buf.FormatList( aText, args );
+
+#ifdef _DEBUG
+#ifdef LOG_TO_FILE
+	RFileLogger logger;
+	TInt ret = logger.Connect();
+	if (ret==KErrNone)
+		{
+		logger.SetDateAndTime( EFalse,EFalse );
+		logger.CreateLog( KLogFolder, KLogFileName, EFileLoggingModeAppend );		
+		TBuf<KLogTimeFormatLength> timeStamp;
+		TTime now;
+		now.HomeTime();
+		TDateTime dateTime;
+		dateTime = now.DateTime();
+		timeStamp.Format( KLogTimeFormat, 
+            dateTime.Hour(), dateTime.Minute(),
+            dateTime.Second(), dateTime.MicroSecond() );
+		buf.Insert( 0, timeStamp );
+
+		logger.Write(buf);
+		}
+
+	logger.Close();
+
+#else
+    RDebug::Print( buf );
+#endif // LOG_TO_FILE
+#endif // _DEBUG
+    VA_END( args );
+    }
+
+#endif // ENABLE_LOGGING
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/CWPLog.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,79 @@
+/*
+* 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:   Logging class
+*
+*/
+
+
+
+
+
+#ifndef CWPLOG_H
+#define CWPLOG_H
+
+/////////////////////////////////////////////////////////////////////////////
+// #Defines that control printing of additional information to debug stream.
+/////////////////////////////////////////////////////////////////////////////
+
+// INCLUDES
+
+#include "CWPLogDef.h"
+#include <e32std.h>
+
+// DEFINES
+
+#ifdef ENABLE_LOGGING
+#define LOG(s) Log::DoLog(_L(s))
+#define LOG1(s, v) Log::DoLog( _L(s), v )
+#define LOG2(s, v1, v2) Log::DoLog( _L(s), v1, v2 )
+#else
+#define LOG(s)
+#define LOG1(s, v)
+#define LOG2(s, v1, v2)
+#endif // ENABLE_LOGGING
+
+// DATA TYPES
+
+
+// CLASS DECLARATION
+
+/**
+* Class offers logging functionality.
+*/
+class Log
+    {
+
+    public:
+
+        /**
+        * Log the message.
+		* @param aText text to be written to log.
+        */
+        static void DoLog( TRefByValue<const TDesC> aText, ... );
+
+    private: // constructor
+        
+		/// Prohibited default constructor
+		Log();
+
+		/// Prohibited copy constructor
+		Log( const Log& );
+    
+		/// Prohibited assignment operator
+		Log& operator=( const Log& );
+    };
+
+#endif // CWPLOG_H
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/CWPLogDef.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,37 @@
+/*
+* 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:   Logging class definition
+*
+*/
+
+
+
+
+
+#ifndef CWPLOGDEF_H
+#define CWPLOGDEF_H
+
+/////////////////////////////////////////////////////////////////////////////
+// #Defines that control printing of additional information to debug stream.
+/////////////////////////////////////////////////////////////////////////////
+
+// Defining this enables logging
+//#define ENABLE_LOGGING
+
+// Defining this will direct all messages to a log file
+//#define LOG_TO_FILE
+
+#endif // LOGDEF_H
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/WPAPAdapterGroupProxy.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,46 @@
+/*
+* 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:    Table of plugins for ECom
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <implementationproxy.h>
+#include "CWPAPAdapter.h"
+
+// CONSTANTS
+const TImplementationProxy KImplementationTable[] = 
+	{
+	IMPLEMENTATION_PROXY_ENTRY(0x101F84D9, CWPAPAdapter::NewL)
+	};
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(KImplementationTable) / sizeof(TImplementationProxy);
+
+	return KImplementationTable;
+	}
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/WPAPAdapterPanics.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,35 @@
+/*
+* 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:    Panic implementation
+*
+*/
+
+
+
+
+// INCLUDES
+
+#include <e32std.h>             // for GLDEF_C
+#include "WPAPAdapter.pan"
+
+// CONSTANTS
+
+_LIT(KWPAPAdapter, "wpapadapter.dll");
+
+GLDEF_C void Panic( TInt aPanic )
+    {
+    User::Panic( KWPAPAdapter, aPanic );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/Src/WPAPUtil.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Class offers common utility methods.
+*
+*/
+
+
+
+
+// INCLUDE FILES
+
+#include "WPAPUtil.h"			// Own header
+#include <WPAdapterUtil.h>
+
+// CONSTANTS
+// Commented out by JN
+//#if ( defined (__WINS__) || defined (__WINSCW) ) // this different on hw
+    _LIT( KAdapterName, "WPAPAdapterResource" );
+//#else
+//    _LIT( KAdapterName, "WPAPAdapter" );
+//#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// WPAPUtil::ReadHBufCLC
+// -----------------------------------------------------------------------------
+//
+HBufC* WPAPUtil::ReadHBufCL( TInt aResourceId )
+	{
+    TFileName fileName;
+    Dll::FileName( fileName );
+
+    return WPAdapterUtil::ReadHBufCL( fileName, KAdapterName, aResourceId );
+	}
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/group/101F84D8.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,56 @@
+/*
+* 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:   Resource file defining the AccesspointAdapter plugin.
+*
+*/
+
+
+
+
+//  INCLUDES
+#include "registryinfo.rh"
+
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// theInfo
+// Resource defining the ProvisioningAdapter plugin.
+//
+// -----------------------------------------------------------------------------
+//
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = 0x101F84D8;
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x101F84D5;
+			implementations = 
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x101F84D9;
+					version_no = 1;
+					display_name = "WAP AP PA"; // Use short name to save RAM and ROM space
+					default_data = "";
+					opaque_data = "0";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/group/WPAPAdapter.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2002-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:   Project definition file for accesspoint adapter.
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+#include <bldvariant.hrh>
+
+TARGET          WPAPAdapter.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x101F84D8
+
+
+VENDORID        VID_DEFAULT
+CAPABILITY      CAP_ECOM_PLUGIN
+
+SOURCEPATH      ../Src
+SOURCE          CWPAPAdapter.cpp 
+SOURCE          CWPAPItemBase.cpp
+SOURCE          CWPAPAccesspointItem.cpp
+SOURCE          CWPAPNapdef.cpp
+SOURCE          CWPAPLogicalProxy.cpp
+SOURCE          CWPAPPhysicalProxy.cpp
+SOURCE          CWPAPPort.cpp
+SOURCE          WPAPUtil.cpp
+SOURCE          WPAPAdapterPanics.cpp
+SOURCE          WPAPAdapterGroupProxy.cpp
+SOURCE          CWPLog.cpp
+
+SOURCEPATH      ../group
+
+START RESOURCE 101F84D8.rss
+TARGET WPAPAdapter.rsc
+END
+
+START RESOURCE WPAPAdapterResource.rss
+HEADER
+TARGET WPAPAdapterResource.rsc
+TARGETPATH RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END  
+
+
+USERINCLUDE     ../Inc
+USERINCLUDE     ../../bld
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom
+
+LIBRARY         euser.lib
+LIBRARY         ProvisioningEngine.lib
+LIBRARY         commdb.lib
+LIBRARY         FeatMgr.lib
+LIBRARY         ecom.lib
+LIBRARY 		centralrepository.lib
+LIBRARY			cmmanager.lib
+LIBRARY			eapsymbiantools.lib
+LIBRARY			eaptools.lib
+LIBRARY			eaptrace.lib
+DEBUGLIBRARY    flogger.lib     // Only in debug builds
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/group/WPAPAdapterResource.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,35 @@
+/*
+* 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:   Resource file.
+*
+*/
+
+
+
+
+//  INCLUDES
+#include <badef.rh>
+#include <wpapadapter.loc>
+
+// Rich text labels
+
+RESOURCE LBUF r_qtn_sm_wapap_name
+	{ 
+	txt = qtn_sm_wapap_name; 
+	}
+
+RESOURCE LBUF r_qtn_sm_wml_accesspoints
+	{ 
+	txt = qtn_sm_wml_accesspoints; 
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2001-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:   Build information file for AccesspointAdapter CP adapter
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+//../rom/WPAPAdapter.iby	CORE_MW_LAYER_IBY_EXPORT_PATH(WPAPAdapter.iby) 
+//../rom/WPAPAdapterResources.iby	LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(WPAPAdapterResources.iby) 
+
+// export localised loc file
+../loc/WPAPAdapter.loc        MW_LAYER_LOC_EXPORT_PATH(wpapadapter.loc)
+
+PRJ_MMPFILES
+WPAPAdapter.mmp
+
+PRJ_TESTMMPFILES
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/loc/WPAPAdapter.loc	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   This is a localisation file for AccesspointAdapter
+*
+*/
+
+
+
+
+// LOCALISATION STRINGS
+
+//d: Summary text for access points
+//l: popup_info_list_pane_t2/opt1
+//r: 5.0 
+
+#define qtn_sm_wml_accesspoints "Access points:"
+
+//d:This is the default name for new WAP access point. 
+//l:query_popup_data_pane_t1/opt4
+//r: 5.0
+
+#define qtn_sm_wapap_name "WAP access point"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/rom/WPAPAdapter.iby	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,29 @@
+/*
+* 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:   Image description file for project wpapadapter
+*
+*/
+
+
+
+
+#ifndef WPAPADAPTER_IBY
+#define WPAPADAPTER_IBY
+
+#include <data_caging_paths_for_iby.hrh>
+#include <bldvariant.hrh>
+
+ECOM_PLUGIN(WPAPAdapter.dll, WPAPAdapter.rsc)
+
+#endif // WPAPADAPTER_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/accesspointadapter/rom/WPAPAdapterResources.iby	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,29 @@
+/*
+* 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:   Image description file for project wpapadapter
+*
+*/
+
+
+
+
+#ifndef WPAPADAPTERRESOURCES_IBY
+#define WPAPADAPTERRESOURCES_IBY
+
+#include <data_caging_paths_for_iby.hrh>
+#include <bldvariant.hrh>
+
+data=DATAZ_\RESOURCE_FILES_DIR\WPAPAdapterResource.rsc RESOURCE_FILES_DIR\WPAPAdapterResource.rsc
+
+#endif // WPAPADAPTERRESOURCES_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/bld/ProvisioningDebug.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,131 @@
+/*
+* 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 defines logging macros for Provisioning
+*
+*/
+
+
+
+#ifndef PROVISIONINGDEBUG_H
+#define PROVISIONINGDEBUG_H
+
+#include <e32debug.h> 
+
+//Examples
+//FLOG( _L( "[Provisioning] ProvisioningEngine::ConstructL:" ) );
+//FTRACE(RDebug::Print(_L("[Provisioning] ProvisioningEngine::ConstructL: err (%d)"), err));
+#ifdef _DEBUG
+
+const TInt KBTHexDumpWidth=16;
+const TInt KBTLogBufferSize=100;
+const TText KFullStopChar='.';
+
+_LIT(KBTFirstFormatString,"%04x: ");
+_LIT(KBTSecondFormatString,"%02x ");
+_LIT(KBTThirdFormatString,"%c");
+_LIT(KBTThreeSpaces,"   ");
+_LIT(KBTSeparator," ");
+
+inline void HexDump(const TUint8* aPtr, TInt aLen)
+    {
+	if( aPtr != NULL )
+	    {
+    	TBuf<KBTLogBufferSize> line;
+	    TInt i = 0;
+
+    	while (aLen>0)
+    		{
+    		TInt n = (aLen>KBTHexDumpWidth ? KBTHexDumpWidth : aLen);
+    		line.AppendFormat(KBTFirstFormatString,i);
+    		TInt j;
+    		for (j=0; j<n; j++)
+    			line.AppendFormat(KBTSecondFormatString,aPtr[i+j]);
+    		while (j++<KBTHexDumpWidth)
+    			line.Append(KBTThreeSpaces);
+    		line.Append(KBTSeparator);
+    		for (j=0; j<n; j++)
+    			line.AppendFormat(KBTThirdFormatString,(aPtr[i+j]<32 || aPtr[i+j]>126 || aPtr[i+j]==37) ? KFullStopChar : aPtr[i+j]);
+
+    		RDebug::Print(line);
+
+            line.Zero();
+    		aLen-=n;
+    		i+=n;
+    	    }
+        }
+    }
+
+
+// ------------------------------------------
+
+inline void FHex(const TUint8* aPtr, TInt aLen)
+    {
+    HexDump( aPtr, aLen );
+    }
+
+// ------------------------------------------
+
+inline void FHex(const TDesC8& aDes)
+    {
+    HexDump(aDes.Ptr(), aDes.Length());
+    }
+
+// ===========================================================================
+#ifdef __WINS__     // File logging for WINS
+// ===========================================================================
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+
+_LIT( KLogFile, "Provisioning.log" );
+_LIT( KLogDirFullName, "c:\\logs\\" );
+_LIT( KLogDir, "Provisioning" );
+
+#define FLOG( a )   { FPrint(a); }
+#define FTRACE( a ) { a; }
+
+// Declare the FPrint function
+//
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    RFileLogger::WriteFormat( KLogDir,
+                              KLogFile,
+                              EFileLoggingModeAppend,
+                              aFmt,
+                              list );
+    }
+
+// ===========================================================================
+#else               // RDebug logging for target HW
+// ===========================================================================
+#include <e32svr.h>
+
+#define FLOG( a )   { RDebug::Print( a ); }
+#define FTRACE( a ) { a; }
+
+#endif //__WINS__
+
+// ===========================================================================
+#else // // No loggings --> Reduced binary size
+// ===========================================================================
+#define FLOG( a )
+#define FTRACE( a )
+
+#endif // _DEBUG
+
+#endif      // PROVISIONINGDEBUG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/bld/ProvisioningUIDs.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,147 @@
+/*
+* 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:  UIDs for project Provisioning
+*
+*/
+
+
+
+#ifndef PROVISIONINGUID_H
+#define PROVISIONINGUID_H
+
+//  CONSTANTS  
+
+/// ECOM plugin
+#define KECOMUid2 0x10009D8D
+
+/// Normal Symbian OS DLL
+#define KSymbianDLLUid2 0x1000008d
+
+/// UID2 for Provisioning BIO control
+#define KProvisioningBCUid2 0x10005F5F
+
+/// UID3 for Provisioning BIO control
+#define KProvisioningBCUid3 0x101F84D3
+
+/// UID for the Provisioning Message type for BIO database
+#define KProvisioningMessageTypeUid 0x101F84D1
+
+/// UID2 for the handler plugin for WAP Provisioning documents
+#define KProvisioningHandlerUid2 KECOMUid2
+
+/// UID3 for the handler plugin DLL for WAP Provisioning documents
+#define KProvisioningHandlerUid3 0x101F84D2
+
+/// UID for the handler plugin implementation
+#define KProvisioningHandlerImplUid 0x101F84D3
+
+/// UID of the Content Type Handler plugin interface
+#define KProvisioningHandlerInterface 0x101F3E5E
+
+/// UID2 of the Provisioning Parser DLL
+#define KProvisioningParserUid2 KSymbianDLLUid2
+
+/// UID3 of the Provisioning Parser DLL
+#define KProvisioningParserUid3 0x101F84D4
+
+/// UID of the Provisisioning Adapter plugin interface
+#define KProvisioningAdapterInterface 0x101F84D5
+
+/// UID2 of the Provisioning Engine DLL
+#define KProvisioningEngineUid2 KSymbianDLLUid2
+
+/// UID3 of the Provisioning Engine DLL
+#define KProvisioningEngineUid3 0x101F84D6
+
+/// UID for HTTPHeader stream in WAP Provisioning message
+#define KProvisioningMessageStreamUid 0x101F84D7
+
+/// UID2 for the APAdapter DLL
+#define KProvisioningAPAdapterDllUid2 KECOMUid2
+
+/// UID3 for the APAdapter DLL
+#define KProvisioningAPAdapterDllUid3 0x101F84D8
+
+/// UID for the APAdapter
+#define KProvisioningAPAdapterUid 0x101F84D9
+
+/// UID2 for the Browser+MMSAdapter DLL
+#define KProvisioningWAPAdapterDllUid2 KECOMUid2
+
+/// UID3 for the Browser+MMSAdapter DLL
+#define KProvisioningWAPAdapterDllUid3 0x101F84DC
+
+/// UID for the BrowserAdapter
+#define KProvisioningBrowserAdapterUid 0x101F84DB
+
+/// UID for the MMSAdapter
+#define KProvisioningMMSAdapterUid 0x101F84DD
+
+/// UID2 for the DataSyncAdapter DLL
+#define KProvisioningDataSyncAdapterDllUid2 KECOMUid2
+
+/// UID3 for the DataSyncAdapter DLL
+#define KProvisioningDataSyncAdapterDllUid3 0x101F84DE
+
+/// UID for the DataSyncAdapter
+#define KProvisioningDataSyncAdapterUid 0x101F84DF
+
+/// UID2 for the DeviceManagementAdapter DLL
+#define KProvisioningDeviceManagementAdapterDllUid2 KECOMUid2
+
+/// UID3 for the DeviceManagementAdapter DLL
+#define KProvisioningDeviceManagementAdapterDllUid3 0x101F84E0
+
+/// UID for the DeviceManagementAdapter
+#define KProvisioningDeviceManagementAdapterUid 0x101F84E1
+
+/// UID2 for the IMAdapter DLL
+#define KProvisioningIMAdapterDllUid2 KECOMUid2
+
+/// UID3 for the IMAdapter DLL
+#define KProvisioningIMAdapterDllUid3 0x101F84E2
+
+/// UID for the IMAdapter
+#define KProvisioningIMAdapterUid 0x101F84E3
+
+/// UID2 for the StreamingAdapter DLL
+#define KProvisioningStreamingAdapterUid2 KECOMUid2
+
+/// UID3 for the StreamingAdapter DLL
+#define KProvisioningStreamingAdapterDllUid3 0x101F84E6
+
+/// UID for the StreamingAdapter
+#define KProvisioningStreamingAdapterUid 0x101F84E7
+
+/// UID2 for the JavaAdapter DLL
+#define KProvisioningJavaAdapterUid2 KECOMUid2
+
+/// UID3 for the JavaAdapter DLL
+#define KProvisioningJavaAdapterDllUid3 0x101F84E8
+
+/// UID for the JavaAdapter
+#define KProvisioningJavaAdapterUid 0x101F84E9
+
+/// UID2 for Symbian application
+#define KProvisioningCxUID2 0x100039CE
+
+/// UID3 for ProvisioningCx application
+#define KProvisioningCxUID3 0x101F8597
+
+/// UID for the PresenceAdapter
+#define KProvisioningPecAdapterUid 0x102072D3
+
+#endif      //  PROVISIONINGUID_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/bld/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,32 @@
+/*
+* 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:    for building DM adapters
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT   
+PRJ_EXPORTS
+../Rom/ProvisioningAdapter.iby			CORE_APP_LAYER_IBY_EXPORT_PATH(provisioningAdapter.iby)
+../Rom/ProvisioningAdapterResources.iby		LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(provisioningAdapterresources.iby)
+
+../MbxNbrAdapter/loc/MailboxAdapter.loc		MW_LAYER_LOC_EXPORT_PATH(mailboxadapter.loc)
+../accesspointadapter/loc/WPAPAdapter.loc	MW_LAYER_LOC_EXPORT_PATH(WPAPAdapter.loc)
+../StreamingAdapter/loc/StreamingAdapter.loc	MW_LAYER_LOC_EXPORT_PATH(streamingadapter.loc)
+
+
+#include "../accesspointadapter/group/bld.inf"
+#include "../MbxNbrAdapter/Group/bld.inf"
+#include "../StreamingAdapter/Group/bld.inf"
+#include "../WAPAdapter/Group/bld.inf"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/rom/ProvisioningAdapter.iby	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2002-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:  Image description file for the Provisioning
+*
+*/
+
+
+#ifndef __PROVISIONINGADAPTER_IBY__
+#define __PROVISIONINGADAPTER_IBY__
+
+ECOM_PLUGIN(WPWAPAdapter.dll,101F84DC.rsc)
+ECOM_PLUGIN(WPStreamingAdapter.dll,101F85CB.rsc)
+ECOM_PLUGIN(WPAPAdapter.dll, WPAPAdapter.rsc)
+ECOM_PLUGIN(WPMbxNbrAdapter.dll,10207281.rsc)
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omacpadapters/rom/ProvisioningAdapterResources.iby	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2002-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:  Image description file for the Provisioning Resources
+*
+*/
+
+
+#ifndef __PROVISIONINGADAPTERRESOURCES_IBY__
+#define __PROVISIONINGADAPTERRESOURCES_IBY__
+
+
+data=DATAZ_\RESOURCE_FILES_DIR\WPWAPAdapterResource.rsc                        RESOURCE_FILES_DIR\WPWAPAdapter.rsc
+data=DATAZ_\RESOURCE_FILES_DIR\WpstreamingadapterResource.rsc                   RESOURCE_FILES_DIR\Wpstreamingadapter.rsc
+data=DATAZ_\RESOURCE_FILES_DIR\WPMbxNbrAdapterResource.rsc                      RESOURCE_FILES_DIR\WPMbxNbrAdapter.rsc
+data=DATAZ_\RESOURCE_FILES_DIR\WPAPAdapterResource.rsc                          RESOURCE_FILES_DIR\WPAPAdapterResource.rsc
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/extmemctrl/data/2002132B.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource file for ExtMemCtrl Interface Implementation.
+*
+*/
+
+#include "registryinfo.rh"
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+	{
+	// UID for the DLL
+	dll_uid = 0x2002132B;
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of interface that is implemented
+			interface_uid = 0x2001FD40;
+			implementations = 
+				{
+				// Info for ExtMemCtrlDCMOAdapter
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x2002132C;
+					version_no = 1;
+					display_name = "ExtMemCtrlDCMOAdapter";
+					default_data = "text/wml||This is the type of data that this implementation understands. (Can be anything which will allow the resolver to identify this implementation as the correct one at run time. In this case it is a mime type).";
+					opaque_data = "ExternalMemory";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/extmemctrl/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  This file provides building information for FOTACtrl.
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+extmemctrldcmoadapter.mmp
+
+
+// End Of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/extmemctrl/group/extmemctrldcmoadapter.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  ExtMemCtrl plug-in adapter for DCMO
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET extmemctrldcmoadapter.dll
+TARGETTYPE PLUGIN
+
+// ECom Dll recognition UID followed by the unique UID for this dll
+UID 0x10009D8D 0x2002132B
+VENDORID VID_DEFAULT
+CAPABILITY  CAP_ECOM_PLUGIN
+
+SOURCEPATH				../src
+SOURCE						extmemctrldcmoadapter.cpp
+SOURCE						extmemctrldcmoadapterproxy.cpp
+
+USERINCLUDE 			../inc 
+
+APP_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE 		/epoc32/include/ecom
+SYSTEMINCLUDE 	/epoc32/include/mw/hb/hbwidgets
+SYSTEMINCLUDE 	/epoc32/include/mw/hb/hbcore
+
+SOURCEPATH				../data
+start resource 2002132B.rss
+TARGET extmemctrldcmoadapter.rsc
+LANGUAGE_IDS
+end
+
+LIBRARY 			euser.lib ecom.lib efsrv.lib bafl.lib  etul.lib
+LIBRARY       centralrepository.lib
+LIBRARY       platformenv.lib
+LIBRARY 			commonengine.lib               // Series 60 common components library
+LIBRARY       hbcore.lib hbwidgets.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/extmemctrl/inc/extmemctrldcmoadapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ExtMemCtrl plug-in adapter for DCMO
+*
+*/
+
+#ifndef _EXTMEMCTRLDCMOADAPTER__
+#define _EXTMEMCTRLDCMOADAPTER__
+
+#include "dcmointerface.h"
+
+// An implementation of the CDCMOInterface definition
+class CExtMemCtrlDCMOAdapter : public CDCMOInterface
+	{
+public:
+	// Standardised safe construction which leaves nothing the cleanup stack.
+	static CExtMemCtrlDCMOAdapter* NewL(TAny* aInitParams);
+	// Destructor	
+	~CExtMemCtrlDCMOAdapter();
+
+	// Implementation of CDCMOInterface
+	/**
+	 * Get the interger type value
+	 * @param aId
+	 * @param aValue
+	 * @return TDCMOStatus 
+	 */
+	TDCMOStatus  GetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt& aValue);
+	
+	/**
+	 * Get the string type value
+	 * @param aId
+	 * @param aStrValue
+	 * @return TDCMOStatus
+	 */
+	TDCMOStatus  GetDCMOPluginStrAttributeValueL(TDCMONode aId, TDes& aStrValue);
+	
+	 /**
+		* Set the interger type value
+		* @param aId
+		* @param aValue
+		* @return TDCMOStatus
+		*/
+	TDCMOStatus  SetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt aValue);
+	
+	 /**
+		* Set the string type value
+		* @param aId
+		* @param aStrValue
+		* @return TDCMOStatus
+		*/
+	TDCMOStatus  SetDCMOPluginStrAttributeValueL(TDCMONode aId, const TDes& aStrValue);
+	
+	/**
+	 * Get the localized name of this plug-in
+	 * @param aLocName
+	 * @return None
+	 */
+	void GetLocalizedNameL (HBufC*& aLocName);
+	
+private:
+	// Construction
+	CExtMemCtrlDCMOAdapter(TAny* aInitParams);
+	
+	/**
+	 * second phase constructor
+	 */
+	void ConstructL();
+
+private:
+	// Data to pass back from implementation to client
+	HBufC* iProperty;
+	HBufC* iDescription;
+	// Parameters taken from client
+	CDCMOInterface::TDCMOInterfaceInitParams* iInitParams;
+	};  
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/extmemctrl/src/extmemctrldcmoadapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,257 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ExtMemCtrl plug-in adapter for DCMO
+*
+*/
+
+
+#include <f32file.h> 
+#include <driveinfo.h>
+#include <barsread.h> 
+#include <barsc2.h>
+#include <f32file.h> 
+#include <data_caging_path_literals.hrh>
+#include <DevManInternalCRKeys.h>
+#include <centralrepository.h>
+#include "extmemctrldcmoadapter.h"
+#include "hbtextresolversymbian.h"
+
+_LIT( KdcmoResourceFileName, "deviceupdates_" );	
+_LIT( KdcmoResourceFilePath, "z:/resource/qt/translations/" );	
+_LIT( KExtMemCtrlProperty, "ExternalMemory");
+_LIT( KExtMemCtrlDescription, "Used to enable/disable the ExtMem");
+
+
+// Construction and destruction functions
+
+// ----------------------------------------------------------------------------------------
+// CExtMemCtrlDCMOAdapter::NewL
+// ----------------------------------------------------------------------------------------
+CExtMemCtrlDCMOAdapter* CExtMemCtrlDCMOAdapter::NewL(TAny* aParams)
+	{
+		CExtMemCtrlDCMOAdapter* self=new(ELeave) CExtMemCtrlDCMOAdapter(aParams);  
+		CleanupStack::PushL(self);
+		self->ConstructL(); 
+		CleanupStack::Pop();
+		return self;
+	}
+
+// ----------------------------------------------------------------------------------------
+// CExtMemCtrlDCMOAdapter::~CExtMemCtrlDCMOAdapter
+// ----------------------------------------------------------------------------------------
+CExtMemCtrlDCMOAdapter::~CExtMemCtrlDCMOAdapter()
+	{
+		delete iProperty;
+		iProperty = NULL;
+		delete iDescription;
+		iDescription = NULL;
+	}
+
+// ----------------------------------------------------------------------------------------
+// CExtMemCtrlDCMOAdapter::CExtMemCtrlDCMOAdapter
+// ----------------------------------------------------------------------------------------
+CExtMemCtrlDCMOAdapter::CExtMemCtrlDCMOAdapter(TAny* aInitParams)
+:  iInitParams((CDCMOInterface::TDCMOInterfaceInitParams*)aInitParams)
+	{
+	// See ConstructL() for initialisation completion.
+	}
+
+// ----------------------------------------------------------------------------------------
+// CExtMemCtrlDCMOAdapter::ConstructL
+// ----------------------------------------------------------------------------------------
+void CExtMemCtrlDCMOAdapter::ConstructL()
+{	
+	// Safely complete the initialization of the constructed object	
+	if(iInitParams->descriptor)
+		iProperty =  (iInitParams->descriptor)->AllocL();
+	else
+		iProperty = KExtMemCtrlProperty().AllocL();
+	iDescription = KExtMemCtrlDescription().AllocL();
+}
+
+// Implementation of CDCMOInterface
+
+// ----------------------------------------------------------------------------------------
+// CExtMemCtrlDCMOAdapter::GetDCMOPluginIntAttributeValueL
+// Gets the integer attribute value.
+// ----------------------------------------------------------------------------------------
+TDCMOStatus  CExtMemCtrlDCMOAdapter::GetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt& aValue)
+{
+	TDCMOStatus status(EDcmoSuccess);
+	TInt err(KErrNone);
+	
+	switch(aId)
+	{
+		case EGroup: {
+									aValue = EHardware;
+								}
+						break;		
+		case EAttached:	{
+						aValue = 0;
+						RFs fsMemoryCard;
+                  		err = fsMemoryCard.Connect();
+                  		if ( err != KErrNone )
+                  		{
+                  			status = EDcmoFail;
+                  		}
+                  		TDriveInfo dInfo;
+						TVolumeInfo vInfo;
+    					TInt error = fsMemoryCard.Drive( dInfo, EDriveF );
+     					if( error == KErrNone )
+         				{
+         					error = fsMemoryCard.Volume( vInfo, EDriveF );
+         					if( error == KErrNone )
+             				{
+             					aValue = 1;
+             				}
+         				}										
+						fsMemoryCard.Close();  
+						}
+						break;
+		case EEnabled:{
+			            RFs fsMemoryCard;
+                  err = fsMemoryCard.Connect();
+                  if ( err != KErrNone )
+                  {
+                  	status = EDcmoFail;
+                  }
+                      
+                  TDriveInfo  info;
+                  err=fsMemoryCard.Drive(info, EDriveF);
+ //               DBG_ARGS8( _S8("ExtMem err =  %d info.iType = %d"), err, info.iType );
+                                       
+                  if (info.iType == EMediaNotPresent || err != KErrNone ||info.iType == EMediaUnknown )
+                  {
+                    aValue = 0;
+                  }
+                  else
+                  { 
+                    aValue = 1;
+                  }                        
+                  fsMemoryCard.Close();          
+            		  }
+						break;		
+		case EDenyUserEnable:	{
+										aValue = 1;
+									}
+						break;
+		case ENotifyUser:	{
+											aValue = 1;
+											}
+						break;	
+		default :
+						status = 	EDcmoNotFound;		
+	}	
+	return status;
+}
+
+// ----------------------------------------------------------------------------------------
+// CExtMemCtrlDCMOAdapter::GetDCMOPluginStrAttributeValueL
+// Gets the string attribute value.
+// ----------------------------------------------------------------------------------------
+TDCMOStatus  CExtMemCtrlDCMOAdapter::GetDCMOPluginStrAttributeValueL(TDCMONode aId, TDes& aStrValue) 
+{
+	TDCMOStatus status(EDcmoSuccess);		
+	switch(aId)
+	{
+		case EProperty: 	aStrValue = *iProperty;
+							break;		
+		case EDescription:	aStrValue = *iDescription;
+							break;
+		default :	
+						status = EDcmoNotFound;	
+	}
+	return status;
+}
+
+// ----------------------------------------------------------------------------------------
+// CExtMemCtrlDCMOAdapter::SetDCMOPluginIntAttributeValueL
+// Sets the integer attribute value.
+// ----------------------------------------------------------------------------------------
+TDCMOStatus  CExtMemCtrlDCMOAdapter::SetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt aValue)
+{
+	TDCMOStatus status(EDcmoFail);
+	TInt err(KErrNone);
+	
+	switch(aId)
+	{
+		case EDenyUserEnable:
+							break;
+		case ENotifyUser:
+							break;
+		case EEnable:	{
+			        			RFs fsMemoryCard;
+              			err = fsMemoryCard.Connect();
+              			if ( err != KErrNone )
+               			{
+                		  return status ;
+               			}
+               			TBuf<255> fsysname;
+               			fsysname.Zero();
+               			if (!aValue)
+               			{               	
+                			fsMemoryCard.FileSystemName(fsysname,EDriveF);
+                			TRequestStatus stat;
+                			fsMemoryCard.NotifyDismount(EDriveF, stat, EFsDismountForceDismount);
+                			User::WaitForRequest(stat);
+               			 	//err= fsMemoryCard.DismountFileSystem(fsysname, EDriveF);
+                			//if (err == KErrNone)
+                   		status =EDcmoSuccess;                   
+               			}
+               			else
+               			{
+               	 			TInt err(fsMemoryCard.FileSystemName(fsysname,EDriveF));
+               	 			if (err != KErrNone && !fsysname.Length()) 
+               	 			{
+               	 				_LIT( KFmgrFatFSName, "Fat" );
+               	  			err = fsMemoryCard.MountFileSystem( KFmgrFatFSName, EDriveF );
+               	 			} 
+                   		status = EDcmoSuccess;                                 	
+               			} 
+               			fsMemoryCard.Close();
+			          		CRepository *rep = NULL;
+		            		TRAPD( err1, rep = CRepository::NewL( KCRUidDeviceManagementInternalKeys )) ;
+		            		if(!err1) 
+		              		rep->Set( KDevManMemCardCtrl, aValue ); 		              
+		              	delete rep;
+		              	rep = NULL; 							
+		              }
+						break;
+		default :
+							status = EDcmoNotFound;
+	}	
+	return status;
+}
+
+// ----------------------------------------------------------------------------------------
+// CExtMemCtrlDCMOAdapter::SetDCMOPluginStrAttributeValueL
+// Sets the string attribute value.
+// ----------------------------------------------------------------------------------------
+TDCMOStatus  CExtMemCtrlDCMOAdapter::SetDCMOPluginStrAttributeValueL(TDCMONode /* aId */, const TDes& /* aStrValue */)
+{
+	// Nothing to do
+	TDCMOStatus status(EDcmoNotSupported);	
+	return status;	
+}
+
+// ----------------------------------------------------------------------------------------
+// CExtMemCtrlDCMOAdapter::GetLocalizedNameL
+// returns the localized plug-in name.
+// ----------------------------------------------------------------------------------------
+void CExtMemCtrlDCMOAdapter::GetLocalizedNameL (HBufC*& aLocName)
+{	
+	TBool result = HbTextResolverSymbian::Init(KdcmoResourceFileName, KdcmoResourceFilePath );					
+	_LIT(KTextExtMemory, "txt_device_update_info_external_memory_card");
+	aLocName = HbTextResolverSymbian::LoadL(KTextExtMemory);	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/extmemctrl/src/extmemctrldcmoadapterproxy.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  ExtMemCtrl plug-in adapter for DCMO
+*
+*/
+
+#include <e32std.h>
+#include <implementationproxy.h>
+
+#include "extmemctrldcmoadapter.h"
+
+
+// Map the interface UIDs to implementation factory functions
+const TImplementationProxy ImplementationTable[] = 
+	{
+		IMPLEMENTATION_PROXY_ENTRY(0x2002132C,	CExtMemCtrlDCMOAdapter::NewL),
+	};
+
+// 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/omadcmoadapters/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  This file provides building information for DCMO plug-in adapters.
+*
+*/
+
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+../rom/omadcmoadapters.iby			CORE_APP_LAYER_IBY_EXPORT_PATH(omadcmoadapters.iby)
+
+PRJ_MMPFILES
+
+#include "../extmemctrl/group/bld.inf"
+#include "../wlanctrl/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/rom/omadcmoadapters.iby	Tue Jul 13 04:01:20 2010 +0530
@@ -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:   Image description file for project dcmo
+*
+*/
+
+#ifndef _OMADCMOADAPTERS_IBY_
+#define _OMADCMOADAPTERS_IBY_
+
+#ifdef FF_RUNTIME_DEVICE_CAPABILITY_CONFIGURATION
+ECOM_PLUGIN(extmemctrldcmoadapter.dll,extmemctrldcmoadapter.rsc)
+ECOM_PLUGIN(wlanctrldcmoadapter.dll,wlanctrldcmoadapter.rsc)
+#endif
+
+#endif // _OMADCMOADAPTERS_IBY_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/wlanctrl/data/wlanctrldcmoadapter.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,49 @@
+/*
+ * ==============================================================================
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ * 
+ * Description:
+ * 
+ * ==============================================================================
+ */
+
+#include "registryinfo.rh"
+
+// Declares info for two implementations
+RESOURCE REGISTRY_INFO theInfo
+	{
+	// UID for the DLL
+	dll_uid = 0x20022FB5;
+	// Declare array of interface info
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			// UID of interface that is implemented
+			interface_uid = 0x2001FD40;
+			implementations = 
+				{
+				// Info for WlanCtrlDCMOAdapter
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x20022FB4;
+					version_no = 1;
+					display_name = "WlanCtrlDCMOAdapter";
+					default_data = "text/wml||Allow/Disallow Wifi.";
+					opaque_data = "WLAN";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/wlanctrl/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -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:
+ * 
+ * ==============================================================================
+ */
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+PRJ_EXPORTS
+
+
+PRJ_MMPFILES
+wlanctrldcmoadapter.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/wlanctrl/group/wlanctrldcmoadapter.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,49 @@
+/*
+ * ==============================================================================
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ * 
+ * Description:
+ * 
+ * ==============================================================================
+ */
+
+#include <platform_paths.hrh>
+
+//CAPABILITY  	CAP_ECOM_PLUGIN
+CAPABILITY  	CAP_GENERAL_DLL
+TARGET 			wlanctrldcmoadapter.dll
+TARGETTYPE 		PLUGIN
+UID 			0x10009D8D 0x20022FB5
+VENDORID 		VID_DEFAULT
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom 
+SYSTEMINCLUDE 	/epoc32/include/mw/hb/hbwidgets
+SYSTEMINCLUDE 	/epoc32/include/mw/hb/hbcore
+
+USERINCLUDE 	../inc 
+
+SOURCEPATH	../data
+START RESOURCE wlanctrldcmoadapter.rss
+TARGET wlanctrldcmoadapter.rsc
+LANGUAGE_IDS
+END
+
+LIBRARY 		euser.lib ECom.lib featmgr.lib
+LIBRARY			commonengine.lib
+LIBRARY     hbcore.lib hbwidgets.lib
+
+SOURCEPATH ../src
+SOURCE wlanctrldcmoadapterproxy.cpp wlanctrldcmoadapter.cpp
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/wlanctrl/inc/wlanctrldcmoadapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,60 @@
+//
+/*
+ * ==============================================================================
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ * 
+ * Description:
+ * 
+ * ==============================================================================
+ */
+
+#ifndef _WlanCtrlDCMOAdapter__
+#define _WlanCtrlDCMOAdapter__
+
+#include "dcmointerface.h"
+#include "dcmoconst.h"
+
+// An implementation of the CDCMOInterface definition
+class CWLanCtrlDCMOAdapter : public CDCMOInterface
+	{
+public:
+	// Standardised safe construction which leaves nothing the cleanup stack.
+	static CWLanCtrlDCMOAdapter* NewL(TAny* aInitParams);
+
+	// Destructor	
+	~CWLanCtrlDCMOAdapter();
+
+	// Implementation of CDCMOInterface
+    virtual TDCMOStatus  GetDCMOPluginIntAttributeValueL( TDCMONode aId, TInt& aValue); 
+    virtual TDCMOStatus  GetDCMOPluginStrAttributeValueL( TDCMONode aId, TDes& aStrValue);
+    virtual TDCMOStatus  SetDCMOPluginIntAttributeValueL( TDCMONode aId, TInt aValue);
+    virtual TDCMOStatus  SetDCMOPluginStrAttributeValueL( TDCMONode aId, const TDes& aStrValue);
+    virtual void GetLocalizedNameL( HBufC*& aLocName );
+	
+private:
+	// Construction
+	CWLanCtrlDCMOAdapter(TAny* aInitParams);
+	void ConstructL();
+	TDCMOStatus MapFeatureControlError( TInt aErrorCode );
+
+private:
+	// Data to pass back from implementation to client
+	HBufC* iProperty;
+	HBufC* iDescription;
+	// Parameters taken from client
+	CDCMOInterface::TDCMOInterfaceInitParams* iInitParams;
+	
+	
+	};  
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/wlanctrl/src/wlanctrldcmoadapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,200 @@
+/*
+ * ==============================================================================
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ * 
+ * Description:
+ * 
+ * ==============================================================================
+ */
+
+#include <featurecontrol.h>
+#include <featmgr.h>
+#include <data_caging_path_literals.hrh> 
+#include <bautils.h>
+#include "wlanctrldcmoadapter.h"
+#include "hbtextresolversymbian.h"
+
+_LIT( KdcmoResourceFileName, "deviceupdates_" );	
+_LIT( KdcmoResourceFilePath, "z:/resource/qt/translations/" );	
+_LIT( KWlanCtrlProperty, "WLAN" );
+_LIT( KDisableWlanDescription, "Used to enable/disable the WLAN connectivity." ); // Description
+
+
+TDCMOStatus CWLanCtrlDCMOAdapter::MapFeatureControlError( TInt aErrorCode )
+    {
+    TDCMOStatus status( EDcmoFail );
+    
+    switch ( aErrorCode )
+        {
+        case KErrNone:
+            status = EDcmoSuccess;
+            break;
+        case KErrPermissionDenied:
+        case KErrAccessDenied:
+            status = EDcmoAccessDenied;
+            break;
+        case KErrNotFound:
+            status = EDcmoNotFound;
+            break;
+        default:
+            break;
+        }
+    return status;
+    }
+
+// Construction and destruction functions
+
+CWLanCtrlDCMOAdapter* CWLanCtrlDCMOAdapter::NewL( TAny* aParams )
+	{
+	CWLanCtrlDCMOAdapter* self = new ( ELeave ) CWLanCtrlDCMOAdapter( aParams );  
+	CleanupStack::PushL( self );
+	self->ConstructL(); 
+	CleanupStack::Pop();
+	return self;
+	}
+
+CWLanCtrlDCMOAdapter::~CWLanCtrlDCMOAdapter()
+	{	
+	FeatureManager::UnInitializeLib();
+	
+	delete iProperty;
+	delete iDescription;
+	}
+
+CWLanCtrlDCMOAdapter::CWLanCtrlDCMOAdapter( TAny* aInitParams )
+:  iInitParams( ( CDCMOInterface::TDCMOInterfaceInitParams* ) aInitParams )
+	{
+	// See ConstructL() for initialisation completion.
+	}
+
+void CWLanCtrlDCMOAdapter::ConstructL()
+	{	
+	// Set up the data to pass back
+	iProperty = KWlanCtrlProperty().AllocL();
+	iDescription = KDisableWlanDescription().AllocL();
+	
+    FeatureManager::InitializeLibL();
+
+	}
+
+
+// Implementation of CDCMOInterface
+TDCMOStatus CWLanCtrlDCMOAdapter::SetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt aValue)
+{
+	TDCMOStatus status(EDcmoFail);
+	TInt err( KErrNone );
+	
+	switch( aId )
+	{
+		case EDenyUserEnable:
+		    status = EDcmoNotSupported;
+		    break;
+		case ENotifyUser:
+		    status = EDcmoNotSupported;
+			break;
+		case EEnable:	
+		    {
+            RFeatureControl featureControl;
+            TUid wlanUid( TUid::Uid( KFeatureIdProtocolWlan ) ); 
+            err = featureControl.Connect();
+            
+            if ( err == KErrNone )
+                {
+                if( aValue == 0 )
+                    {
+                    // Disable WLAN
+                    err = featureControl.DisableFeature( wlanUid );
+		            }
+                else if ( aValue == 1 )
+                    {
+                    // Enable WLAN
+                    err = featureControl.EnableFeature( wlanUid );
+                    }
+                status = MapFeatureControlError( err );
+                featureControl.Close();
+                }
+            
+		    }
+		    break;
+		default:
+		    break;
+	}
+	
+	return status;
+}
+
+TDCMOStatus CWLanCtrlDCMOAdapter::GetDCMOPluginIntAttributeValueL(TDCMONode aId, TInt& aValue)
+{
+	TDCMOStatus status( EDcmoSuccess );
+	
+	switch(aId)
+	{
+		case EGroup: 
+		    aValue = EConnectivity;
+		    break;
+		case EAttached:
+		    aValue = EFalse;
+		    break;
+		case EEnabled:	
+		    aValue = FeatureManager::FeatureSupported( KFeatureIdProtocolWlan );		    
+		    break;    
+		case EDenyUserEnable:
+		    aValue = EFalse;
+		    break; 
+		case ENotifyUser:
+		    aValue = ETrue;
+		    break;
+		case EEnable:
+		    status = EDcmoAccessDenied;
+		    break;
+		default:
+		    break;
+	}
+	
+	return status;
+}
+
+TDCMOStatus CWLanCtrlDCMOAdapter::SetDCMOPluginStrAttributeValueL( TDCMONode   /* aId */, 
+                                                                   const TDes& /* aStrValue */ )
+{
+	// Nothing to do
+	TDCMOStatus status( EDcmoFail );
+	
+	return status;	
+}
+
+TDCMOStatus CWLanCtrlDCMOAdapter::GetDCMOPluginStrAttributeValueL( TDCMONode aId, TDes& aStrValue ) 
+{
+	TDCMOStatus status( EDcmoSuccess );
+	switch( aId )
+	{
+		case EProperty: 	
+		    aStrValue = *iProperty;
+		    break;
+		case EDescription:	
+		    aStrValue = *iDescription;
+		    break;
+		default:			
+		    status = EDcmoNotFound;
+		    break;
+	}
+		
+	return status;
+}
+
+void CWLanCtrlDCMOAdapter::GetLocalizedNameL( HBufC*& aLocName )
+    {
+    	TBool result = HbTextResolverSymbian::Init(KdcmoResourceFileName, KdcmoResourceFilePath );					
+			_LIT(KTextWLAN, "txt_device_update_info_wlan");
+			aLocName = HbTextResolverSymbian::LoadL(KTextWLAN);	
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadcmoadapters/wlanctrl/src/wlanctrldcmoadapterproxy.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -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:
+ * 
+ * ==============================================================================
+ */
+
+#include <e32std.h>
+#include <implementationproxy.h>
+
+#include "wlanctrldcmoadapter.h"
+
+#ifndef IMPLEMENTATION_PROXY_ENTRY
+#define IMPLEMENTATION_PROXY_ENTRY( aUid, aFuncPtr )  {{aUid},(aFuncPtr)}
+#endif
+
+
+// Map the interface UIDs to implementation factory functions
+const TImplementationProxy ImplementationTable[] = 
+	{
+		IMPLEMENTATION_PROXY_ENTRY(0x20022FB4, CWLanCtrlDCMOAdapter::NewL),
+	};
+
+// Exported proxy for instantiation method resolution
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+	return ImplementationTable;
+	}
+
--- a/omadmadapters/bld/bld.inf	Tue Jul 13 03:51:25 2010 +0530
+++ b/omadmadapters/bld/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -28,7 +28,7 @@
 #include "../streamingadapter/bld/bld.inf"
 
 #include "../globalwlansettings/group/bld.inf"
-//#include "../nsmldminternet/group/bld.inf"
+#include "../nsmldminternet/group/bld.inf"
 #include "../nsmldmalwaysonadapter/group/bld.inf"
 #include "../nsmldmbmadapter/group/bld.inf"
 #include "../connmoadapter/group/bld.inf"
@@ -46,11 +46,11 @@
 #endif
 
 #ifdef __SYNCML_DM_FOTA
-//#include "../fota/bld/bld.inf"
+#include "../fota/bld/bld.inf"
 #endif
 
 #ifdef __SYNCML_DM_IMPS
 //#include "../imps/bld/bld.inf"
 #endif
 
-//#include "../dcmodmadapter/group/bld.inf"
+#include "../dcmodmadapter/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/dcmodmadapter/data/dcmodmadapter.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  Resource file for DCMO DM Adapter.
+*
+*/
+
+// INCLUDES
+#include <registryinfo.rh>
+#include <nsmldmconstants.h>
+
+// CONSTANTS  
+
+// MACROS  
+
+// RESOURCE DEFINITIONS 
+
+//-----------------------------------------------------------------------------
+//   
+//    theInfo
+//    -
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE REGISTRY_INFO theRegistryInfo
+    {
+    dll_uid = 0x2001FD3E; // The DLL's 3rd UID.
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = KNSmlDMInterfaceUid; // DM interface UID
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x2001FD3F;
+                    version_no = 1;
+                    display_name = "DCMO DM Adapter";
+                    default_data = "";
+                    opaque_data = "";
+                    }
+                };
+            }
+        };
+    }
+
+// End Of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/dcmodmadapter/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  This file provides building information for DCMO DM Adapter.
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+dcmodmadapter.mmp
+
+// End Of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/dcmodmadapter/group/dcmodmadapter.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -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:  DCMO DM Adapter
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET          dcmodmadapter.dll
+TARGETTYPE      PLUGIN
+CAPABILITY      CAP_ECOM_PLUGIN
+
+UID             0x10009D8D 0x2001FD3E
+VENDORID        VID_DEFAULT
+LANG            SC
+
+SOURCEPATH      ../src
+SOURCE          dcmodmadapter.cpp
+SOURCE          dcmodmadaptermain.cpp
+
+APP_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc
+
+SYSTEMINCLUDE 	/epoc32/include/ecom
+
+
+START RESOURCE  ../data/dcmodmadapter.rss
+TARGET          dcmodmadapter.rsc
+LANGUAGE_IDS
+END
+
+LIBRARY         euser.lib
+LIBRARY         ecom.lib
+LIBRARY         centralrepository.lib
+LIBRARY         dmutil.lib
+LIBRARY         charconv.lib
+LIBRARY					dcmoclient.lib
+LIBRARY					policyengine.lib
+LIBRARY					nsmldebug.lib
+
+
+SMPSAFE
+// End Of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/dcmodmadapter/inc/dcmodmadapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,528 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DCMO DM Adapter
+*
+*/
+
+#ifndef __DCMODMADAPTER_H
+#define __DCMODMADAPTER_H
+
+// INCLUDES
+#include <e32base.h>
+#include <smldmadapter.h>
+#include <centralrepository.h>
+#include "dcmoclient.h"
+#include "dcmoconst.h"
+
+const TUid KCRUidDCMOServer={0x2001FE47};
+const TInt KDCMOKeyMaxNumber = 16;
+const TInt KDCMOPropertyNumber = 1;
+
+_LIT8( KMimeType, "text/plain" );
+_LIT8( KNSmlDCMOAdapterTitle,       "DCMO DM Adapter" );
+_LIT8( KNSmlTrue,						"True" );
+_LIT8( KNSmlFalse,					"False" );
+
+_LIT8( KNSmlHardware,				"Hardware" );
+_LIT8( KNSmlIO,							"IO" );
+_LIT8( KNSmlConnectivity,		"Connectivity" );
+_LIT8( KNSmlSoftware,				"Software" );
+_LIT8( KNSmlService,				"Service" );
+
+//DDF accepted DM-fieldnames
+_LIT8( KNSmlDdfProperty,				"Property" );
+_LIT8( KNSmlDdfGroup,						"Group" );
+_LIT8( KNSmlDdfDescription,			"Description" );
+_LIT8( KNSmlDdfAttached,				"Attached" );
+_LIT8( KNSmlDdfEnabled,					"Enabled" );
+_LIT8( KNSmlDdfDCMOConfig,			"DCMOConfig" );
+_LIT8( KNSmlDdfDenyUserEnable,	"DenyUserEnable" );
+_LIT8( KNSmlDdfNotifyUser,			"NotifyUser" );
+_LIT8( KNSmlDdfOperations,			"Operations" );
+_LIT8( KNSmlDdfEnable,					"Enable" );
+_LIT8( KNSmlDdfDisable,					"Disable" );
+_LIT8( KNSmlDdfOpExt,						"Ext" ); 
+_LIT8( KNSmlDdfExt,							"Ext" );
+_LIT8( KNSmlDdfOpExtSemiEnable,	"SemiEnable" );
+
+//DDF DM-field descriptions
+_LIT8( KDCMOCapabilityDescription,				"DCMO capability node");
+_LIT8( KNSmlDdfPropertyDescription,				"Property of DCMO" );
+_LIT8( KNSmlDdfGroupDescription,					"Group of DCMO" );
+_LIT8( KNSmlDdfDescDescription,						"The Description node" );
+_LIT8( KNSmlDdfAttachedDescription,				"Attached" );
+_LIT8( KNSmlDdfEnabledDescription,				"Enabled" );
+_LIT8( KNSmlDdfDCMOConfigDescription,			"The DCMO Configuration node" );
+_LIT8( KNSmlDdfDenyUserEnableDescription,	"DenyUserEnable" );
+_LIT8( KNSmlDdfNotifyUserDescription,			"NotifyUser" );
+_LIT8( KNSmlDdfOperationsDescription ,    "Operations node " );
+_LIT8( KNSmlDdfEnableDescription ,       	"Enable Operation " );
+_LIT8( KNSmlDdfDisableDescription ,       "Disable Operation " );
+_LIT8( KNSmlDdfOpExtDescription ,       	"Extra Operations " );
+_LIT8( KNSmlDdfExtDescription,						"Extra" );
+_LIT8( KNSmlDdfOpExtSemiEnableDescription,	"Semi Enable Operation" );
+
+_LIT8( KDcmoMatch, 											"DCMO" );
+_LIT8( KDcmoMatch2, 										"DCMO/*" );
+_LIT8( KDcmoMatch3, 										"DCMO/*/*" );
+_LIT8( KDcmoConfigMatch, 								"DCMO/*/DCMOConfig");
+_LIT8( KSegmDcmo,												"Property/Group/Description/Attached/Enabled/DCMOConfig/Operations/Ext");
+_LIT8( KSegmDcmoConfig,									"DenyUserEnable/NotifyUser");
+_LIT8( KSegmDcmoOperations,							"Enable/Disable/Ext");
+_LIT8( KDcmoConfigDenyUserEnableMatch, 	"DCMO/*/DCMOConfig/DenyUserEnable");
+_LIT8( KDcmoConfigNotifyUserMatch, 			"DCMO/*/DCMOConfig/NotifyUser");
+_LIT8( KDcmoOperationsMatch, 						"DCMO/*/Operations");
+_LIT8( KDcmoOperationsExtMatch, 				"DCMO/*/Operations/Ext");
+
+
+_LIT8( KNSmlBluetooth,									"Bluetooth" );
+
+// CLASS DECLARATION
+
+/**
+* Adapter class
+* Provides DM adapter interface
+*/
+class CDcmoDMAdapter : public CSmlDmAdapter
+    {
+    
+    public: // Constructors, destructor
+        /**
+        * Create instance of CDcmoDMAdapter
+        * @param aDmCallBack
+        * @return Instance of CDcmoDMAdapter
+        */    
+        static CDcmoDMAdapter* NewL( MSmlDmCallback* aDmCallback );
+
+        /**
+        * Create instance of CDcmoDMAdapter
+        * @param aDmCallBack
+        * @return Instance of CDcmoDMAdapter
+        */   
+        static CDcmoDMAdapter* NewLC( MSmlDmCallback* aDmCallback );
+
+        /**
+        * C++ Destructor
+        */
+        virtual ~CDcmoDMAdapter();
+
+    public:
+	    /**
+	    * The function returns current version of the DDF.
+	    * By asking current DDF versions from adapters DM Module can control
+	    * possible changes in the data structure and send the changed DDF
+	    * description to a management server.
+	    * This function is always called after DDFStructureL.
+        * @param aVersion DDF version of the adapter. (filled by the adapter)
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void DDFVersionL( CBufBase& aVersion );
+	
+	    /**
+	    * The function for filling the DDF structure of the adapter
+	    * This function is only called once, immediately after the adapter is created.
+	    * @param aDDFObject	Reference to root object. A DM adapter starts filling
+		         the data structure by calling AddChildObjectL to the root object and
+				 so describes the DDF of the adapter. 
+	    * @publishedPartner
+	    * @prototype
+	    */
+        void DDFStructureL( MSmlDmDDFObject& aDDF );
+	
+	    /**
+	    * The function creates new leaf objects, or replaces data in existing leaf
+	    * objects. The information about the success of the command should be
+	    * returned by calling SetStatusL function of MSmlDmCallback callback
+	    * interface. This makes it possible to buffer the commands. However, all
+	    * the status codes for buffered commands must be returned at the latest when
+	    * the adapter's CompleteOutstandingCmdsL() is called.
+	    * @param aURI			URI of the object
+	    * @param aLUID		LUID of the object (if the adapter has earlier returned a
+	 	     				LUID to the DM Module). For new objects, this is the LUID
+ 			    			inherited through the parent node.
+ 	    * @param aObject		Data of the object. 
+	    * @param aType		MIME type of the object
+	    * @param aStatusRef	Reference to correct command, i.e. this reference
+	 					must be used when calling the SetStatusL of this command
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void UpdateLeafObjectL( const TDesC8& aURI, 
+	                            const TDesC8& aLUID,
+			                    const TDesC8& aObject, 
+			 				    const TDesC8& aType,
+							    TInt aStatusRef 
+							  );
+		
+        /**
+	    * The function creates new leaf objects, or replaces data in existing leaf
+	    * objects, in the case where data is large enough to be streamed. The
+	    * information about the success of the command should be returned by calling
+	    * SetStatusL function of MSmlDmCallback callback interface. This makes it
+	    * possible to buffer the commands.  However, all the status codes for buffered
+	    * commands must be returned at the latest when the CompleteOutstandingCmdsL()
+	    * of adapter is called.
+	    * @param aURI		URI of the object
+	    * @param aLUID		LUID of the object (if the adapter has earlier returned a
+    						LUID to the DM Module). For new objects, this is the LUID
+	    					inherited through the parent node.
+	    * @param aStream	Data of the object. Adapter should create write stream
+		    				and return, when data is written to stream by DM agent,
+			    			StreamCommittedL() is called by DM engine
+	    * @param aType		MIME type of the object
+	    * @param aStatusRef	Reference to correct command, i.e. this reference
+    						must be used when calling the SetStatusL of this
+		    				command.
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void UpdateLeafObjectL( const TDesC8& aURI, 
+	                            const TDesC8& aLUID,
+								RWriteStream*& aStream, 
+								const TDesC8& aType,
+		 						TInt aStatusRef 
+		 				      );
+	
+	    /**
+	    * The function deletes an object and its child objects. The SetStatusL
+	    * should be used as described in UpdateLeafObjectL()
+	    * @param aURI		URI of the object
+	    * @param aLUID		LUID of the object (if the adapter have earlier returned
+    						LUID to the DM Module).
+	    * @param aStatusRef	Reference to correct command, i.e. this reference must
+						be used when calling the SetStatusL of this command.
+        * @publishedPartner
+	    * @prototype
+	    */
+	    void DeleteObjectL( const TDesC8& aURI, 
+	                        const TDesC8& aLUID,
+							TInt aStatusRef 
+					      );
+	
+	    /**
+	    * The function fetches data of a leaf object. The SetStatusL should be used
+	    * as described in UpdateLeafObjectL(). The data is returned by using the
+	    * SetResultsL function of MSmlCallback callback interface, and may be streamed.
+	    * @param aURI			URI of the object
+	    * @param aLUID			LUID of the object (if the adapter have earlier
+    							returned LUID to the DM Module).   
+	    * @param aType 			MIME type of the object
+	    * @param aResultsRef	Reference to correct results, i.e. this reference
+    							must be used when returning the result by calling
+	    						the SetResultsL.
+	    * @param aStatusRef		Reference to correct command, i.e. this reference
+		    					must be used when calling the SetStatusL of this
+    							command.
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void FetchLeafObjectL( const TDesC8& aURI, 
+	                           const TDesC8& aLUID,
+							   const TDesC8& aType, 
+							   TInt aResultsRef,
+							   TInt aStatusRef 
+							 );
+	
+	    /**
+	    * The function fetches the size of the data of a leaf object. The size is
+	    * in bytes, and must reflect the number of bytes that will be transferred
+	    * when the framework calls FetchLeafObjectL. The SetStatusL should be used
+	    * as described in FetchLeafObjectL(). The size value is returned by using
+	    * the SetResultsL function of MSmlCallback callback interface, and must be
+	    * a decimal integer expressed as a string, eg. "1234".
+	    * Results from this call MUST NOT be streamed.
+	    * @param aURI			URI of the object
+	    * @param aLUID			LUID of the object (if the adapter have earlier
+    							returned LUID to the DM Module).   
+	    * @param aType 			MIME type of the object
+	    * @param aResultsRef	Reference to correct results, i.e. this reference
+    							must be used when returning the result by calling
+	    						the SetResultsL.
+	    * @param aStatusRef		Reference to correct command, i.e. this reference
+     							must be used when calling the SetStatusL of this
+	    						command.
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void FetchLeafObjectSizeL( const TDesC8& aURI, 
+	                               const TDesC8& aLUID,
+								   const TDesC8& aType, 
+								   TInt aResultsRef,
+								   TInt aStatusRef 
+								 );
+	    /**
+	    * The function fetches URI list. An adapter returns the list of URI segments
+	    * under the given URI be separated by slash ("/"). The URI segment names for
+	    * new objects must be given by the adapter.
+	    * The list is returned by calling the SetResultsL function of MSmlCallback
+	    * callback interface.	Results from this call MUST NOT be streamed.
+	    * @param aParentURI					URI of the parent object
+	    * @param aParentLUID				LUID of the parent object (if the
+    										adapter have earlier returned LUID to
+		    								the DM Module).   
+	    * @param aPreviousURISegmentList	URI list with mapping LUID information,
+			    							which is known by DM engine. An adapter
+				    						can use this information when verifying
+					    					if old objects still exists. An adapter
+						    				also knows what objects are new to DM
+							    			engine and can provide LUID mapping for
+								    		them. aPreviousURISegmentList parameter
+									    	(see above) helps to recognise new
+    										objects.
+	    * @param aResultsRef				Reference to correct results, i.e. this
+    										reference must be used when returning
+	    									the result by calling the SetResultsL.
+	    * @param aStatusRef					Reference to correct command, i.e. this
+		    								reference must be used when calling the
+			    							SetStatusL of this command.
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void ChildURIListL( const TDesC8& aURI, 
+	                        const TDesC8& aLUID,
+					        const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
+					        TInt aResultsRef, 
+					        TInt aStatusRef 
+					      );
+	
+        /**
+	    * The function adds node object. In some cases an implementation of the
+	    * function may be empty function, if the node object does not need concrete
+	    * database update. Still this function may be helpful to an adapter, i.e. in
+	    * passing mapping LUID of the node to DM Module. The SetStatusL should be
+	    * used as described in UpdateLeafObjectL()
+	    * @param aURI			URI of the object
+	    * @param aParentLUID	LUID of the parent object (if the adapter have
+     							earlier returned LUID to the DM Module).   
+	    * @param aStatusRef		Reference to correct command, i.e. this reference
+		    					must be used when calling the SetStatusL of this
+			    				command.
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void AddNodeObjectL( const TDesC8& aURI, 
+	                         const TDesC8& aParentLUID,
+		  					 TInt aStatusRef 
+		  				   );
+
+	    /**
+	    * The function implements execute command. The information about the success
+	    * of the command should be returned by calling SetStatusL function of
+	    * MSmlDmCallback callback interface. This makes it possible to buffer the
+	    * commands.
+	    * However, all the status codes for buffered commands must be returned at
+	    * the latest when the CompleteOutstandingCmdsL() of adapter is called.
+	    * @param aURI			URI of the command
+	    * @param aLUID			LUID of the object (if the adapter have earlier
+    							returned LUID to the DM Module).   
+	    * @param aArgument		Argument for the command
+	    * @param aType			MIME type of the object 
+	    * @param aStatusRef		Reference to correct command, i.e. this reference
+    							must be used when calling the SetStatusL of this
+	    						command.
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void ExecuteCommandL( const TDesC8& aURI, 
+	                          const TDesC8& aLUID,
+							  const TDesC8& aArgument, 
+							  const TDesC8& aType,
+							  TInt aStatusRef 
+							);
+
+	    /**
+	    * The function implements execute command. The information about the
+	    * success of the command should be returned by calling SetStatusL function
+	    * of MSmlDmCallback callback interface. This makes it possible to buffer the
+	    * commands.
+	    * However, all the status codes for buffered commands must be returned at
+	    * the latest when the CompleteOutstandingCmdsL() of adapter is called.
+	    * @param aURI			URI of the command
+	    * @param aLUID			LUID of the object (if the adapter have earlier
+    							returned LUID to the DM Module).   
+	    * @param aStream		Argument for the command. Adapter should create
+		    					write stream and return, when data is written to
+			    				stream by DM agent, StreamCommittedL() is called by
+				    			DM engine
+	    * @param aType			MIME type of the object 
+	    * @param aStatusRef		Reference to correct command, i.e. this reference
+    							must be used when calling the SetStatusL of this
+	    						command.
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void ExecuteCommandL( const TDesC8& aURI, 
+	                          const TDesC8& aLUID,
+							  RWriteStream*& aStream, 
+							  const TDesC8& aType,
+							  TInt aStatusRef 
+							);
+
+	    /**
+	    * The function implements copy command. The information about the success of
+	    * the command should be returned by calling SetStatusL function of
+	    * MSmlDmCallback callback interface. This makes it possible to buffer the
+	    * commands.
+	    * However, all the status codes for buffered commands must be returned at
+	    * the latest when the CompleteOutstandingCmdsL() of adapter is called.
+	    * @param aTargetURI		Target URI for the command
+	    * @param aSourceLUID	LUID of the target object (if one exists, and if the adapter
+    							has	earlier returned a LUID to the DM Module).   
+	    * @param aSourceURI		Source URI for the command
+	    * @param aSourceLUID	LUID of the source object (if the adapter has
+    							earlier returned a LUID to the DM Module).   
+	    * @param aType			MIME type of the objects
+	    * @param aStatusRef		Reference to correct command, i.e. this reference
+    							must be used when calling the SetStatusL of this
+	    						command.
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void CopyCommandL( const TDesC8& aTargetURI, 
+	                       const TDesC8& aTargetLUID,
+						   const TDesC8& aSourceURI, 
+						   const TDesC8& aSourceLUID,
+						   const TDesC8& aType, 
+						   TInt aStatusRef 
+						 );
+
+	    /**
+	    * The function indicates start of Atomic command.
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void StartAtomicL();
+	
+	    /**
+	    * The function indicates successful end of Atomic command. The adapter
+	    * should commit all changes issued between StartAtomicL() and
+	    * CommitAtomicL()
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void CommitAtomicL();
+	
+	    /**
+	    * The function indicates unsuccessful end of Atomic command. The adapter
+	    * should rollback all changes issued between StartAtomicL() and
+	    * RollbackAtomicL(). If rollback fails for a command, adapter should use
+	    * SetStatusL() to indicate it.
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void RollbackAtomicL();
+	
+	    /**
+        * Returns ETrue if adapter supports streaming otherwise EFalse.
+	    * @param aItemSize size limit for stream usage
+        * @return TBool ETrue for streaming support
+	    * @publishedPartner
+	    * @prototype
+        */
+	    TBool StreamingSupport( TInt& aItemSize );
+	
+	    /**
+        * Called when stream returned from UpdateLeafObjectL or ExecuteCommandL has
+	    * been written to and committed. Not called when fetching item.
+	    * @publishedPartner
+	    * @prototype
+        */	
+	    void StreamCommittedL();
+	
+	    /**
+	    * The function tells the adapter that all the commands of the message that
+	    * can be passed to the adapter have now been passed.  This indicates that
+	    * the adapter must supply status codes and results to any buffered commands.
+	    * This must be done at latest by the time this function returns.
+	    * This function is used at the end of SyncML messages, and during processing
+	    * of Atomic.   In the case of Atomic processing, the function will be
+	    * followed by a call to CommitAtomicL or RollbackAtomicL.
+	    * @publishedPartner
+	    * @prototype
+	    */
+	    void CompleteOutstandingCmdsL();
+
+    private: // New methods
+    	
+    	/**
+	    * The function fills the adapter node with the details
+	    * @publishedPartner
+	    * @prototype
+	    */
+        void FillNodeInfoL( MSmlDmDDFObject& aDDFObject, 
+                                            TSmlDmAccessTypes& aAccessTypes, 
+                                            MSmlDmDDFObject::TScope aScope,
+                                            MSmlDmDDFObject::TDFFormat aFormat, 
+                                            MSmlDmDDFObject::TOccurence aOccurence,
+                                            const TDesC8& aDescription,
+                                            const TDesC8& aMIMEType );
+       
+      /**
+	    * This function loads all the DCMO plug-in adapters 
+	    * @publishedPartner
+	    * @prototype
+	    */
+        void DDFDCMOAdaptersL(MSmlDmDDFObject& rootdcmo);
+        
+     /**
+	    * This function constructs the DDFnode with the details 
+	    * @publishedPartner
+	    * @prototype
+	    */ 
+        void FillDCMODDFL(MSmlDmDDFObject& aDDF);  
+        
+          
+      /**
+	    * This function returns the Category of the plug-in 
+	    * adapter from the aURI.
+	    * @param aURI
+	    * @return TPtrC8 category
+	    */    
+        
+        TPtrC8 GetCategoryFromUriL(const TDesC8& aURI )  ;    
+                            
+      /**
+    	* Maps a system wide error code to a TError.
+    	* @param aError A system wide error code.
+    	* @return A TError value depending on aError.
+    	*/
+    		CSmlDmAdapter::TError MapErrorToStatus( TInt aError ) const;     
+    	
+    	/**
+	    * This function returns the dcmo enforcement 
+	    * @param None
+	    * @return TBool true if dcmo enforcement or false
+	    */        	
+    	TBool CheckEnforcementL();
+                                
+    private: // Constructor
+        /**
+        * Symbian 2nd phase constructor
+        */
+        void ConstructL();
+
+        /**
+        * C++ Constructor
+        */    
+        CDcmoDMAdapter( TAny* aEcomArguments );
+                                                                                 
+    private: // Data
+        RDCMOClient* idcmoClient;
+        TBool iExtOpNode;
+    };
+
+#endif // __DCMODMADAPTER_H
+
+// End Of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/dcmodmadapter/src/dcmodmadapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,926 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DCMO DM Adapter implementation
+*
+*/
+
+// INCLUDE
+#include <implementationproxy.h>
+#include <smldmadapter.h>
+#include <data_caging_path_literals.hrh>
+#include <centralrepository.h>
+#include <e32base.h>
+#include <ecom.h>
+#include <utf.h>
+#include <SettingEnforcementInfo.h> // DCMO Enforcement
+#include "nsmldebug.h"
+#include "dcmodmadapter.h"
+#include "dcmointerface.h"
+
+// CONSTANTS
+
+#define MAXBUFLEN 255
+
+_LIT8( KTextType,"text/plain" ); // Leaf inputs
+_LIT8( KDCMODMAdapterVersion, "1.0" ); // Adapter version
+_LIT8( KDCMORootNode, "DCMO" ); // root URI
+
+
+// ============================= MEMBER FUNCTIONS =============================
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::NewL
+// Symbian 1st phase contructor
+// (static, may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+CDcmoDMAdapter* CDcmoDMAdapter::NewL( MSmlDmCallback* aCallback )
+    {
+    CDcmoDMAdapter* self = NewLC( aCallback );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::NewLC
+// Symbian 1st phase contructor. Push object to cleanup-stack
+// (static, may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+CDcmoDMAdapter* CDcmoDMAdapter::NewLC( MSmlDmCallback* aCallback )
+    {
+    	_DBG_FILE( "CDcmoDMAdapter NewLC : begin"  );
+    	CDcmoDMAdapter* self = new ( ELeave ) CDcmoDMAdapter( aCallback );
+    	CleanupStack::PushL( self );
+    	self->ConstructL();
+    	_DBG_FILE( "CDcmoDMAdapter NewLC : end"  );
+    	return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::CDcmoDMAdapter()
+// C++ Constructor
+// Status : Draft
+// ----------------------------------------------------------------------------
+CDcmoDMAdapter::CDcmoDMAdapter( TAny* aEcomArguments )
+    : CSmlDmAdapter::CSmlDmAdapter( aEcomArguments )
+    {
+    	_DBG_FILE( "CDcmoDMAdapter Constructor"  );
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::ConstructL
+// 2nd phase contructor
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::ConstructL()
+    {
+    	_DBG_FILE( "CDcmoDMAdapter::ConstructL"  );
+    	idcmoClient = RDCMOClient::NewL();
+    	iExtOpNode = EFalse;	
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::~CDcmoDMAdapter()
+// C++ Destructor
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+CDcmoDMAdapter::~CDcmoDMAdapter()
+    {
+    	_DBG_FILE( "CDcmoDMAdapter Destructor"  );
+    	if( idcmoClient )
+    		{
+    			idcmoClient->Close();
+    			delete idcmoClient;
+    		}
+    	idcmoClient = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::DDFVersionL
+// Return DM plug-in version
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::DDFVersionL( CBufBase& aDDFVersion )
+    {
+    // Insert version information
+    _DBG_FILE( "CDcmoDMAdapter::DDFVersionL" );
+    aDDFVersion.InsertL( 0, KDCMODMAdapterVersion );
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::DDFStructureL
+// Return DM plug-in structure
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
+    {
+    // Declare accesses
+    _DBG_FILE( "CDcmoDMAdapter::DDFStructureL begin" );
+    TSmlDmAccessTypes accessTypes;
+    accessTypes.SetGet();    
+    
+    // Create root node 
+    MSmlDmDDFObject& root = aDDF.AddChildObjectL( KDCMORootNode );
+    FillNodeInfoL( root,
+                   accessTypes,
+                   MSmlDmDDFObject::EPermanent,
+                   MSmlDmDDFObject::ENode,
+                   MSmlDmDDFObject::EOne,
+                   KNullDesC8(),
+                   KTextType );
+                   
+   	root.SetDFTitleL( KNSmlDCMOAdapterTitle );
+                   
+   	DDFDCMOAdaptersL(root);
+   	_DBG_FILE( "CDcmoDMAdapter::DDFStructureL end" );
+
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::StreamingSupport
+// Return streaming support status, set supported item size
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+TBool CDcmoDMAdapter::StreamingSupport( TInt& /* aItemSize */ )
+    {
+    // Not supported
+    _DBG_FILE( "CDcmoDMAdapter::StreamingSupport"  );
+    return EFalse;
+    }
+    
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::StreamCommittedL
+// Commit stream buffer
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::StreamCommittedL()
+    {        
+    _DBG_FILE("CDcmoDMAdapter::StreamCommitted"  );
+    // Intentionally left empty 
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::CompleteOutstandingCmdsL
+// Complete outstanding commands
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::CompleteOutstandingCmdsL()
+    {
+    _DBG_FILE( "CDcmoDMAdapter::CompleteOutstandingCmdsL"  );
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::FillNodeInfoL
+// Fill node info
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::FillNodeInfoL( MSmlDmDDFObject& aDDFObject, 
+                                     TSmlDmAccessTypes& aAccessTypes, 
+                                     MSmlDmDDFObject::TScope aScope,
+                                     MSmlDmDDFObject::TDFFormat aFormat, 
+                                     MSmlDmDDFObject::TOccurence aOccurence,
+                                     const TDesC8& aDescription,
+                                     const TDesC8& aMIMEType )
+    {
+    _DBG_FILE( "CDcmoDMAdapter::FillNodeInfoL - begin"  );
+    aDDFObject.SetAccessTypesL( aAccessTypes );
+    aDDFObject.SetScopeL( aScope );
+    aDDFObject.SetOccurenceL( aOccurence );
+    aDDFObject.SetDFFormatL( aFormat );
+    aDDFObject.SetDescriptionL( aDescription );
+    if ( aFormat != MSmlDmDDFObject::ENode )
+        {
+        aDDFObject.AddDFTypeMimeTypeL( aMIMEType );
+        }
+    _DBG_FILE( "CDcmoDMAdapter::FillNodeInfoL - end"  );    
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::CopyCommandL
+// Copy object
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/, 
+                                    const TDesC8& /*aTargetLUID*/,
+                                    const TDesC8& /*aSourceURI*/, 
+                                    const TDesC8& /*aSourceLUID*/,
+                                    const TDesC8& /*aType*/, 
+                                    TInt aStatusRef )
+    {
+    // Not supported
+    _DBG_FILE( "CDcmoDMAdapter::CopyCommandL"  );
+    Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    }
+
+// ----------------------------------------------------------------------------
+// DeleteObjectL
+// Delete object
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::DeleteObjectL( const TDesC8& /* aURI */, 
+                                     const TDesC8& /* aLUID */,
+                                     TInt aStatusRef )
+
+    {
+    // Not supported
+    _DBG_FILE( "CDcmoDMAdapter::DeleteObjectL"  );
+    Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    }
+    
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::FetchLeafObjectL
+// Fetch leaf
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::FetchLeafObjectL( const TDesC8& aURI, 
+                                        const TDesC8& /* aLUID */,
+								        const TDesC8& aType, 
+								        TInt aResultsRef,
+								        TInt aStatusRef )
+    {
+    _DBG_FILE( "CDcmoDMAdapter::FetchLeafObjectL - begin"  );
+    MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk; 
+		TDCMOStatus err (EDcmoFail);
+		
+    TBool dcmoEnforce=EFalse;
+	  TRAPD(eError, dcmoEnforce =CheckEnforcementL())
+	  if(!(eError==KErrNone && dcmoEnforce))
+	  {
+	  	 // Respond
+	  	retValue = CSmlDmAdapter::ENotAllowed;
+  		Callback().SetStatusL( aStatusRef, retValue );
+  		return;
+	  }
+    
+		TBuf<MAXBUFLEN> iName;
+		
+		TPtrC8 category = GetCategoryFromUriL( aURI );
+		iName.Copy ( category );
+
+		CBufBase *lObject = CBufFlat::NewL( 128 );
+    CleanupStack::PushL( lObject );
+    lObject->Reset();
+    TBool value;
+    TInt group;
+    	
+		if(aURI.Find(KNSmlDdfProperty)!= KErrNotFound)
+		{
+			 _DBG_FILE( "CDcmoDMAdapter::FetchLeafObjectL - In Property"  );
+			TBuf<KDCMOMaxStringSize> property;
+			err = idcmoClient->GetDCMOStrAttributeValue(iName, EProperty,property); 
+			lObject->Reset();
+			TBuf8<KDCMOMaxStringSize> tmp;
+			tmp.Copy(property);
+			lObject->InsertL(lObject->Size(),tmp);
+		}
+			
+		else if(aURI.Find(KNSmlDdfGroup)!= KErrNotFound)
+		{
+			 _DBG_FILE( "CDcmoDMAdapter::FetchLeafObjectL - In Group"  );
+			err = idcmoClient->GetDCMOIntAttributeValue(iName, EGroup, group); 
+			switch(group)
+			{
+				case EHardware			: 	lObject->InsertL(lObject->Size(),KNSmlHardware);
+										break;
+				case EIO						:	lObject->InsertL(lObject->Size(),KNSmlIO);
+										break;
+				case EConnectivity	:	lObject->InsertL(lObject->Size(),KNSmlConnectivity);
+										break;
+				case ESoftware			:	lObject->InsertL(lObject->Size(),KNSmlSoftware);
+										break;
+				case EService				:	lObject->InsertL(lObject->Size(),KNSmlService);
+										break;	
+				default : retValue = CSmlDmAdapter::ENotFound;
+									
+			}
+		}			
+		else if(aURI.Find(KNSmlDdfDescription)!= KErrNotFound)
+		{
+			 _DBG_FILE( "CDcmoDMAdapter::FetchLeafObjectL - In Description"  );
+			TBuf<KDCMOMaxStringSize> description;
+			err = idcmoClient->GetDCMOStrAttributeValue(iName, EDescription, description); 
+			lObject->Reset();
+			TBuf8<KDCMOMaxStringSize> tmp;
+			tmp.Copy(description);
+			lObject->InsertL(lObject->Size(),tmp);
+		}
+			
+		else if(aURI.Find(KNSmlDdfAttached)!= KErrNotFound)
+		{
+			 _DBG_FILE( "CDcmoDMAdapter::FetchLeafObjectL - In Attached"  );
+			err = idcmoClient->GetDCMOIntAttributeValue(iName, EAttached, value); 
+			if(value)
+				lObject->InsertL(lObject->Size(),KNSmlTrue);
+			else
+				lObject->InsertL(lObject->Size(),KNSmlFalse);
+		}
+		
+		else if(aURI.Find(KNSmlDdfEnabled)!= KErrNotFound) 
+		{
+			 _DBG_FILE( "CDcmoDMAdapter::FetchLeafObjectL - In Enabled"  );
+			err = idcmoClient->GetDCMOIntAttributeValue(iName, EEnabled, value); 
+			if(value)
+				lObject->InsertL(lObject->Size(),KNSmlTrue);
+			else
+				lObject->InsertL(lObject->Size(),KNSmlFalse);			
+		}
+			
+		else if(aURI.Find(KNSmlDdfDenyUserEnable)!= KErrNotFound)
+		{
+			 _DBG_FILE( "CDcmoDMAdapter::FetchLeafObjectL - In DenyUserEnable"  );
+			err = idcmoClient->GetDCMOIntAttributeValue(iName, EDenyUserEnable, value); 
+			if(value)
+				lObject->InsertL(lObject->Size(),KNSmlTrue);
+			else
+				lObject->InsertL(lObject->Size(),KNSmlFalse);
+		}
+			
+		else if(aURI.Find(KNSmlDdfNotifyUser)!= KErrNotFound)
+		{
+			 _DBG_FILE( "CDcmoDMAdapter::FetchLeafObjectL - In NotifyUser"  );
+			err = idcmoClient->GetDCMOIntAttributeValue(iName, ENotifyUser, value); 
+			if(value)
+				lObject->InsertL(lObject->Size(),KNSmlTrue);
+			else
+				lObject->InsertL(lObject->Size(),KNSmlFalse);
+		}
+		
+		else if(aURI.Find(KNSmlDdfExt)!= KErrNotFound)
+		{
+			_DBG_FILE( "CDcmoDMAdapter::FetchLeafObjectL - In Ext"  );
+			lObject->Reset();
+			lObject->InsertL(lObject->Size(), KNullDesC8);
+			err = EDcmoSuccess;
+		}
+			
+		else
+			retValue = CSmlDmAdapter::ENotFound;
+		
+		if(retValue == CSmlDmAdapter::EOk)
+    {
+			switch(err)
+			{
+				case EDcmoSuccess 		:	Callback().SetResultsL( aResultsRef, *lObject, aType );
+											break;
+				case EDcmoNotSupported	:	retValue = CSmlDmAdapter::EError;
+											break;
+				case EDcmoAccessDenied	:	retValue = CSmlDmAdapter::ENotAllowed;
+											break;
+				default :
+											retValue = CSmlDmAdapter::EError;						
+			}
+				
+  	}
+    	
+    CleanupStack::PopAndDestroy(); //lObject	
+
+    // Respond
+  Callback().SetStatusL( aStatusRef, retValue );
+   _DBG_FILE( "CDcmoDMAdapter::FetchLeafObjectL - end"  );
+    }    
+    
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::FetchLeafObjectSizeL
+// Calculate leaf object size
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::FetchLeafObjectSizeL( const TDesC8& /* aURI */, 
+                                            const TDesC8& /* aLUID */,
+									        const TDesC8& /* aType */, 
+									        TInt /* aResultsRef */,
+									        TInt aStatusRef )
+    {
+    _DBG_FILE( "CDcmoDMAdapter::FetchLeafObjectSizeL"  );
+    MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
+    // Respond
+    Callback().SetStatusL( aStatusRef, retValue );
+    }    
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::ChildURIListL
+// Create child URI list
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::ChildURIListL( const TDesC8& aURI, 
+                                     const TDesC8& /* aLUID */,
+					                 const CArrayFix<TSmlDmMappingInfo>& /* aPreviousURISegmentList */,
+            					     TInt aResultsRef, 
+            					     TInt aStatusRef )
+    {
+    _DBG_FILE( "CDcmoDMAdapter::ChildURIListL - begin"  );
+    MSmlDmAdapter::TError retValue = CSmlDmAdapter::EOk;
+    CBufBase *currentURISegmentList = CBufFlat::NewL( 128 );
+		CleanupStack::PushL( currentURISegmentList );	
+
+ 		if(( aURI.Match( KDcmoMatch2 ) != KErrNotFound ) &&
+		 (aURI.Match( KDcmoMatch3 ) == KErrNotFound ))
+		{	
+            currentURISegmentList->InsertL( currentURISegmentList->Size(), KSegmDcmo );
+			Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EOk );
+		    Callback().SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 );
+            CleanupStack::PopAndDestroy(  ); // currentURISegmentList
+       		_DBG_FILE( "CDcmoDMAdapter::ChildURIListL(): end" );
+			return;
+		}
+    else if(( aURI.Match( KDcmoMatch ) != KErrNotFound ) &&
+              (aURI.Match( KDcmoMatch2 ) == KErrNotFound ))
+        {
+        //    
+        }
+    // DCMOConfig subtree
+    else if( ( aURI.Match( KDcmoConfigMatch ) != KErrNotFound ))
+        {
+          currentURISegmentList->InsertL( currentURISegmentList->Size(), KSegmDcmoConfig );
+        }
+    // Operations    
+    else if(( aURI.Match( KDcmoOperationsMatch ) != KErrNotFound ))
+        {
+          currentURISegmentList->InsertL( currentURISegmentList->Size(), KSegmDcmoOperations );
+        } 
+    // Ext    
+    else if(( aURI.Match(KNSmlBluetooth) != KErrNotFound) && ( aURI.Match(KDcmoOperationsExtMatch)!= KErrNotFound ))
+        {
+          currentURISegmentList->InsertL( currentURISegmentList->Size(), KNSmlDdfOpExtSemiEnable );
+        }        
+    else
+        {
+        retValue = CSmlDmAdapter::ENotFound;
+        }
+
+    // Respond
+    Callback().SetStatusL( aStatusRef, retValue );
+    CleanupStack::PopAndDestroy(); // currentURISegmentList
+    _DBG_FILE( "CDcmoDMAdapter::ChildURIListL - end"  );
+    }    
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::AddNodeObjectL
+// Add node
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::AddNodeObjectL( const TDesC8& /* aURI */,
+                                     const TDesC8& /* aParentLUID */,
+								     TInt aStatusRef )
+    {
+    // Not supported
+    _DBG_FILE( "CDcmoDMAdapter::AddNodeObjectL - begin"  );
+    Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    _DBG_FILE( "CDcmoDMAdapter::AddNodeObjectL - end"  );
+    }    
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::ExecuteCommandL
+// Execute command
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::ExecuteCommandL( const TDesC8&  aURI , 
+                                      const TDesC8& /* aLUID */,
+							          const TDesC8& /* aArgument */, 
+							          const TDesC8& /* aType */,
+								      TInt aStatusRef )
+    {
+    _DBG_FILE( "CDcmoDMAdapter::ExecuteCommandL - begin"  );
+   	MSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
+    TInt err (EDcmoFail);
+    
+    TBool dcmoEnforce=EFalse;
+	  TRAPD(eError, dcmoEnforce =CheckEnforcementL())
+	  if(!(eError==KErrNone && dcmoEnforce))
+	  {
+	  	 // Respond
+	  	status = CSmlDmAdapter::ENotAllowed;
+  		Callback().SetStatusL( aStatusRef, status );
+  		return;
+	  }
+	  
+		TBuf<MAXBUFLEN> iName;
+		TPtrC8 category = GetCategoryFromUriL( aURI );
+		iName.Copy ( category );		
+		
+		if((category.Compare( KNSmlBluetooth ) == KErrNone ) && (aURI.Find( KNSmlDdfOpExtSemiEnable ) != KErrNotFound ))
+			err = idcmoClient->SetDCMOIntAttributeValue(iName, EEnable, 2); 
+		else if(aURI.Find( KNSmlDdfEnable ) != KErrNotFound ) 
+			err = idcmoClient->SetDCMOIntAttributeValue(iName, EEnable, 1); 
+		else if(aURI.Find( KNSmlDdfDisable ) != KErrNotFound ) 
+			err = idcmoClient->SetDCMOIntAttributeValue(iName, EEnable, 0); 		
+		else	
+			err = EDcmoNotFound;				
+			// map error	
+		status = MapErrorToStatus( err );
+								
+    Callback().SetStatusL( aStatusRef, status );
+    _DBG_FILE( "CDcmoDMAdapter::ExecuteCommandL - end"  );
+    }    
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::ExecuteCommandL
+// Execute command, streaming enabled
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::ExecuteCommandL( const TDesC8& /* aURI */, 
+                                      const TDesC8& /* aLUID */,
+								      RWriteStream*& /* aStream */,
+								      const TDesC8& /* aType */,
+								      TInt aStatusRef )
+    {
+    // Not supported
+    Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    }    
+    
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::UpdateLeafObjectL
+// Update leaf object
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::UpdateLeafObjectL( const TDesC8& /* aURI */, 
+                                        const TDesC8& /* aLUID */,
+                                        const TDesC8& /* aObject */,
+                                        const TDesC8& /* aType */,
+                                        TInt aStatusRef )
+    {
+      _DBG_FILE( "CDcmoDMAdapter::UpdateLeafObjectL - begin"  );
+ 		// Not supported
+    Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+   _DBG_FILE( "CDcmoDMAdapter::UpdateLeafObjectL - end"  );
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::UpdateLeafObjectL
+// Update leaf object, streaming enabled
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::UpdateLeafObjectL( const TDesC8& /* aURI */, 
+                                         const TDesC8& /* aLUID */,
+									     RWriteStream*& /* aStream */, 
+									     const TDesC8& /* aType */,
+		 							     TInt aStatusRef )
+    {
+    // Not supported
+    Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    }
+    
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::StartAtomicL
+// Start atomic
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::StartAtomicL()
+    {
+    }
+    
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::CommitAtomicL
+// Commit atomic commands
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::CommitAtomicL()
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::RollbackAtomicL
+// Lose all modifications after 'StartAtomicL' command
+// (may leave)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::RollbackAtomicL()
+    {
+    }    
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::MapStatusToError()
+// Returns a status code corresponding to the system error code given 
+// as parameter.
+// ---------------------------------------------------------------------------
+//
+CSmlDmAdapter::TError CDcmoDMAdapter::MapErrorToStatus( TInt aError ) const
+ {
+    CSmlDmAdapter::TError err = CSmlDmAdapter::EError;
+    
+    switch( aError )
+        {
+        case EDcmoSuccess:
+            err = CSmlDmAdapter::EExecSuccess;
+            break;
+        case EDcmoFail:
+            err = CSmlDmAdapter::EExecClientError;
+            break;    
+        case EDcmoNotFound:
+            err = CSmlDmAdapter::EExecDownloadFailed;
+            break;
+        case EDcmoNotSupported:
+            err = CSmlDmAdapter::EExecClientError;
+            break;
+        case EDcmoAccessDenied:
+            err = CSmlDmAdapter::EExecClientError;
+            break;            
+        default :
+        		err = CSmlDmAdapter::EExecClientError;        
+        }
+    
+    return err;
+ }
+      
+// ========================= OTHER EXPORTED FUNCTIONS =========================
+
+void CleanupEComArray(TAny* aArray)
+	{
+	(static_cast<RImplInfoPtrArray*> (aArray))->ResetAndDestroy();
+	(static_cast<RImplInfoPtrArray*> (aArray))->Close();
+	}
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::DDFDCMOAdaptersL
+// This function loads all the DCMO plug-in adapters
+// ----------------------------------------------------------------------------
+//
+void CDcmoDMAdapter::DDFDCMOAdaptersL(MSmlDmDDFObject& rootdcmo)
+{
+		_DBG_FILE("CDcmoDMAdapter::DDFDCMOAdaptersL(): begin");	
+			TBuf8<MAXBUFLEN> buf;
+      TSmlDmAccessTypes accessTypes;
+    	accessTypes.SetGet();
+    	
+			CRepository* centrep = NULL;
+			TInt err(KErrNone);
+			TRAP(err, centrep = CRepository::NewL( KCRUidDCMOServer ));
+			if(err == KErrNone)
+			{
+				TUint32 centrepKey = 0;
+				TInt count(0);
+				TInt reterr = centrep->Get( centrepKey, count );	
+				if(reterr == KErrNone)
+				{		
+					TBuf<MAXBUFLEN> buffer;
+					for(TInt i=0; i<count; i++)
+					{   
+        		centrepKey = KDCMOKeyMaxNumber*i + KDCMOPropertyNumber ;
+        		reterr = centrep->Get( centrepKey, buffer );
+	    			if( reterr== KErrNone )
+        		{        			
+        			buf.Copy ( buffer );
+        			MSmlDmDDFObject& entityNode = rootdcmo.AddChildObjectL( buf );
+    					FillNodeInfoL( entityNode,
+                   accessTypes,
+                   MSmlDmDDFObject::EDynamic,
+                   MSmlDmDDFObject::ENode,
+                   MSmlDmDDFObject::EZeroOrOne,                   
+                   KDCMOCapabilityDescription,
+                   KMimeType ); 
+                                       
+							FillDCMODDFL(entityNode);
+							buf.Zero();
+        		}
+					}
+				}	
+				delete centrep;
+				centrep = NULL;
+			}
+			
+			// Read info about all implementations into infoArray
+			RImplInfoPtrArray infoArray;
+			// Note that a special cleanup function is required to reset and destroy
+			// all items in the array, and then close it.
+			TCleanupItem cleanup(CleanupEComArray, &infoArray);
+			CleanupStack::PushL(cleanup);
+			REComSession::ListImplementationsL(KDCMOInterfaceUid, infoArray);
+
+			// Loop through each info for each implementation
+			// and create and use each in turn
+			CDCMOInterface* ex;			
+
+			for (TInt i=0; i< infoArray.Count(); i++)
+				{
+
+				TUid impluid = infoArray[i]->ImplementationUid();
+				// Create object of type and call its function
+				
+				buf = infoArray[i]->OpaqueData();
+				
+				CDCMOInterface::TDCMOInterfaceInitParams initParms;
+				initParms.uid = impluid;
+				TBuf<MAXBUFLEN> categoryName;
+				categoryName.Copy(buf);
+				initParms.descriptor = categoryName.AllocL(); 
+				ex = CDCMOInterface::NewL(initParms);
+				CleanupStack::PushL(ex);
+				if( buf.Compare(KNSmlBluetooth)== KErrNone )
+				{
+					iExtOpNode = ETrue;
+				}	
+    			MSmlDmDDFObject& entityNode = rootdcmo.AddChildObjectL( buf );
+    			FillNodeInfoL( entityNode,
+                   accessTypes,
+                   MSmlDmDDFObject::EDynamic,
+                   MSmlDmDDFObject::ENode,
+                   MSmlDmDDFObject::EZeroOrOne,                   
+                   KDCMOCapabilityDescription,
+                   KMimeType ); 
+                                       
+				FillDCMODDFL(entityNode);
+				ex = NULL;
+				buf.Zero();
+				CleanupStack::PopAndDestroy(); //ex
+				}
+
+			// Clean up
+			CleanupStack::PopAndDestroy(); //infoArray, results in a call to CleanupEComArray
+	_DBG_FILE("CDcmoDMAdapter::DDFDCMOAdaptersL(): end");	
+}
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::FillDCMODDFL
+// This function constructs the DDFnode with the details
+// ----------------------------------------------------------------------------
+//	
+void CDcmoDMAdapter::FillDCMODDFL(MSmlDmDDFObject& aDDF)
+{
+	_DBG_FILE("CDcmoDMAdapter::FillDCMPDDFL(): begin");
+		
+	  TSmlDmAccessTypes accessTypesG;
+    accessTypesG.SetGet();
+    
+    MSmlDmDDFObject& nPropertyDDF = aDDF.AddChildObjectL( KNSmlDdfProperty );			// Property
+    FillNodeInfoL( nPropertyDDF, accessTypesG,  
+                    MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::EChr, MSmlDmDDFObject::EOne,
+                    KNSmlDdfPropertyDescription, KMimeType );
+
+    //Group 
+    MSmlDmDDFObject& nGroupDDF = aDDF.AddChildObjectL( KNSmlDdfGroup );					// Group
+    FillNodeInfoL( nGroupDDF, accessTypesG,  
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, MSmlDmDDFObject::EOne,
+                    KNSmlDdfGroupDescription, KMimeType );           
+                    
+    // Description node 
+    MSmlDmDDFObject& nDescriptionDDF = aDDF.AddChildObjectL( KNSmlDdfDescription );		// Description
+    FillNodeInfoL( nDescriptionDDF, accessTypesG, 
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, MSmlDmDDFObject::EOne, 
+                    KNSmlDdfDescDescription, KMimeType );
+
+    MSmlDmDDFObject& nAttachedDDF = aDDF.AddChildObjectL( KNSmlDdfAttached );			// Attached
+    FillNodeInfoL( nAttachedDDF, accessTypesG, 
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, MSmlDmDDFObject::EOne,
+                    KNSmlDdfAttachedDescription, KMimeType );
+
+		MSmlDmDDFObject& nEnabledDDF = aDDF.AddChildObjectL( KNSmlDdfEnabled );			// Enabled
+    FillNodeInfoL( nEnabledDDF, accessTypesG,  
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, MSmlDmDDFObject::EOne,
+                    KNSmlDdfEnabledDescription, KMimeType );
+
+		MSmlDmDDFObject& nDCMOConfigDDF = aDDF.AddChildObjectL( KNSmlDdfDCMOConfig );	// DCMOConfig
+    FillNodeInfoL( nDCMOConfigDDF, accessTypesG,  
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, MSmlDmDDFObject::EOne,
+                    KNSmlDdfDCMOConfigDescription, KMimeType );
+    
+    MSmlDmDDFObject& nDenyUserEnableDDF = nDCMOConfigDDF.AddChildObjectL( KNSmlDdfDenyUserEnable );	// DenyUserEnable
+    FillNodeInfoL( nDenyUserEnableDDF, accessTypesG,  
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, MSmlDmDDFObject::EZeroOrOne,
+                    KNSmlDdfDenyUserEnableDescription, KMimeType );
+                    
+
+    MSmlDmDDFObject& nNotifyUserDDF = nDCMOConfigDDF.AddChildObjectL( KNSmlDdfNotifyUser );	// NotifyUser
+    FillNodeInfoL( nNotifyUserDDF, accessTypesG,  
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, MSmlDmDDFObject::EOne,
+                    KNSmlDdfNotifyUserDescription, KMimeType );                     
+    //Operations 
+   
+  	MSmlDmDDFObject& nOperationsDDF = aDDF.AddChildObjectL( KNSmlDdfOperations );		// Operations
+    FillNodeInfoL( nOperationsDDF, accessTypesG,  
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, MSmlDmDDFObject::EOne,
+                    KNSmlDdfOperationsDescription, KMimeType ); 
+                    
+   	
+   	TSmlDmAccessTypes accessTypesE;   
+    accessTypesE.SetExec();
+    
+   	MSmlDmDDFObject& nEnableDDF = nOperationsDDF.AddChildObjectL( KNSmlDdfEnable );		// Enable
+    FillNodeInfoL( nEnableDDF, accessTypesE,  
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, MSmlDmDDFObject::EOne,
+                    KNSmlDdfEnableDescription, KMimeType );
+                    
+    
+   	MSmlDmDDFObject& nDisableDDF = nOperationsDDF.AddChildObjectL( KNSmlDdfDisable );	// Disable
+    FillNodeInfoL( nDisableDDF, accessTypesE,  
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, MSmlDmDDFObject::EOne,
+                    KNSmlDdfDisableDescription, KMimeType );
+                    
+
+   	MSmlDmDDFObject& nOpExtDDF = nOperationsDDF.AddChildObjectL( KNSmlDdfOpExt );		// Operations/Ext
+    FillNodeInfoL( nOpExtDDF, accessTypesG,  
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, MSmlDmDDFObject::EOne,
+                    KNSmlDdfOpExtDescription, KMimeType );
+    
+    if( iExtOpNode )
+    {	
+    	MSmlDmDDFObject& nOpExtSemiEnableDDF = nOpExtDDF.AddChildObjectL( KNSmlDdfOpExtSemiEnable );		// Operations/Ext/SemiEnable
+    	FillNodeInfoL( nOpExtSemiEnableDDF, accessTypesE,  
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, MSmlDmDDFObject::EOne,
+                    KNSmlDdfOpExtSemiEnableDescription, KMimeType );                    
+    	iExtOpNode = EFalse;
+  	}               
+
+   	MSmlDmDDFObject& nExtDDF = aDDF.AddChildObjectL( KNSmlDdfExt );						// Ext
+    FillNodeInfoL( nExtDDF, accessTypesG, 
+                    MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, MSmlDmDDFObject::EOne, 
+                    KNSmlDdfExtDescription, KMimeType ); 
+
+
+	_DBG_FILE("CDcmoDMAdapter::FillDCMPDDFL(): end");
+}    
+
+// ----------------------------------------------------------------------------
+// CDcmoDMAdapter::GetCategoryFromUriL
+// This function returns the implementation UID if the plug-in
+// ----------------------------------------------------------------------------
+//	
+TPtrC8 CDcmoDMAdapter::GetCategoryFromUriL(const TDesC8& aURI )
+{
+	_DBG_FILE("CDcmoDMAdapter::GetDCMOAdapterUidL(): begin");
+	
+	TInt length = aURI.Length ();
+	TInt count = 0;
+	TInt flag = 0;
+	for (count=0; count<length; count++)
+		{
+		if ( aURI[count]=='/')
+			{
+				if ( flag )
+					break;
+				flag = count;			
+			}
+		}
+		
+	_DBG_FILE("CDcmoDMAdapter::GetDCMOAdapterUidL(): end");	
+	return ( aURI.Mid ( flag+1 , count-(flag+1) ));	
+
+
+}
+
+//----------------------------------------------------------------------
+// TBool CDcmoDMAdapter::CheckEnforcementL()
+// If DCMO policy is enforced true is returned else false
+//----------------------------------------------------------------------
+TBool CDcmoDMAdapter::CheckEnforcementL()
+{
+    CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL();
+    CleanupStack::PushL(info);
+    TBool enforceActive ( EFalse );
+    User::LeaveIfError(info->EnforcementActive(EDCMOEnforcement, enforceActive));
+    CleanupStack::PopAndDestroy(info);
+    return enforceActive;
+}
+    
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/dcmodmadapter/src/dcmodmadaptermain.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DCMO DM Adapter implementation
+*
+*/
+
+// INCLUDE
+#include <implementationproxy.h>
+#include "dcmodmadapter.h"
+
+// ----------------------------------------------------------------------------
+// ImplementationTable
+// Ecom plug-in implementation table
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] = 
+    {
+	IMPLEMENTATION_PROXY_ENTRY( 0x2001FD3F, CDcmoDMAdapter::NewL )
+    };
+
+// ----------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Instance of implementation proxy
+// (exported)
+// Status : Draft
+// ----------------------------------------------------------------------------
+//
+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/omadmadapters/fota/bld/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    build info file for Fota adapter
+*
+*/
+
+
+
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+
+// Generic configuration interface for component cenrep settings  
+../conf/fotaadapter.confml                    APP_LAYER_CONFML(fotaadapter.confml)
+../conf/fotaadapter_101F9A08.crml 	        APP_LAYER_CRML(fotaadapter_101F9A08.crml)
+
+// ARMv5 udeb
+../src/101F9A02.SPD        /epoc32/release/armv5/udeb/z/private/100012a5/policy/101f9a02.spd
+
+// ARMv5 urel
+../src/101F9A02.SPD        /epoc32/release/armv5/urel/z/private/100012a5/policy/101f9a02.spd
+
+// WINSCW udeb
+../src/101F9A02.SPD        /epoc32/release/winscw/udeb/z/private/100012a5/policy/101f9a02.spd
+
+// WINSCW urel
+../src/101F9A02.SPD        /epoc32/release/winscw/urel/z/private/100012a5/policy/101f9a02.spd
+
+
+
+PRJ_MMPFILES
+./nsmldmfotaadapter.mmp
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/fota/bld/nsmldmfotaadapter.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    DM Fota Adapter
+*
+*/
+
+
+
+
+#include "defaultcaps.hrh"
+#include  <platform_paths.hrh>
+
+CAPABILITY		CAP_GENERAL_DLL
+TARGET          nsmldmfotaadapter.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x101F9A08
+VENDORID        VID_DEFAULT
+
+//Default system include paths for app layer modules.
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom
+
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+
+SOURCEPATH      ../src
+SOURCE          nsmldmfotaadapter.cpp
+SOURCE          nsmldmfotaadapterdb.cpp
+
+START RESOURCE nsmldmfotaadapter.rss
+LANGUAGE_IDS
+END
+
+
+
+LIBRARY        	euser.lib ecom.lib nsmldebug.lib
+LIBRARY         efsrv.lib edbms.lib estor.lib
+LIBRARY         sysutil.lib bafl.lib
+LIBRARY			fotaengine.lib
+LIBRARY			syncmlclientapi.lib
+LIBRARY			nsmlprivateapi.lib
+LIBRARY         centralrepository.lib
+LIBRARY     	nsmldmtreedbclient.lib
+LIBRARY			flogger.lib
+SMPSAFE
Binary file omadmadapters/fota/conf/fotaadapter.confml has changed
Binary file omadmadapters/fota/conf/fotaadapter_101F9A08.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/fota/inc/FotaSrvDebug.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,73 @@
+/*
+* 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 defines logging macros 
+*
+*/
+
+
+
+#ifndef FOTADEBUG_H
+#define FOTADEBUG_H
+
+    // IMPORT_C static TInt Print(TRefByValue<const TDesC> aFmt,...);
+#if defined (__WINS__)
+    #define _FOTA_DEBUG
+  //  #define _FOTA_DEBUG_RDEBUG
+#else
+    #define _FOTA_DEBUG
+#endif
+    //#endif
+    #ifdef _FOTA_DEBUG
+
+
+        #include <e32std.h>
+        #include <f32file.h>
+        #include <flogger.h>
+        #include <e32svr.h>
+
+        _LIT( KLogFile, "fumo.log" );
+        _LIT( KLogDir, "fota" );
+
+        inline void FWrite (TRefByValue<const TDesC> aFmt,...)
+            {
+            VA_LIST list;
+            VA_START( list, aFmt );
+            RFileLogger::WriteFormat( KLogDir,KLogFile,EFileLoggingModeAppend ,TPtrC(aFmt) ,list );
+            }
+
+        #ifdef _FOTA_DEBUG_RDEBUG 
+            #ifndef __GNUC__          
+                #define FLOG            RDebug::Print
+            #else   // __GNUC__       
+                #define FLOG(arg...)    RDebug::Print(arg);
+            #endif // __GNUC__        
+        #else // _FOTA_DEBUG_RDEBUG
+            #ifndef __GNUC__          
+                #define FLOG            FWrite
+            #else   // __GNUC__       
+                #define FLOG(arg...)    FWrite(arg);
+            #endif // __GNUC__        
+        #endif // _FOTA_DEBUG_RDEBUG
+
+    #else   // _FOTA_DEBUG    
+        #ifndef __GNUC__
+            #define FLOG
+        #else
+            #define FLOG(arg...)
+        #endif // __GNUC__
+    #endif // _FOTA_DEBUG
+
+#endif      // FOTADEBUG_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/fota/inc/fotaadapterCRKeys.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,35 @@
+/*
+* 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:    FotaAdapter private CenRep key definitions
+*
+*/
+
+
+
+
+#ifndef FOTAADAPTERCRKEYS_H
+#define FOTAADAPTERCRKEYS_H
+
+// CONSTANTS
+
+// key uid
+const TUid KCRUidFotaAdapter = {0x101F9A08};
+
+// Fota adapter is loaded iff key is on
+const TUint32 KCRFotaAdapterEnabled = 0x00000001;
+
+
+#endif // FOTAADAPTERCRKEYS_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/fota/inc/nsmldmfotaadapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,565 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    DM Fota Adapter
+*
+*/
+
+
+
+
+#ifndef __NSMLDMFOTAADAPTER_H__
+#define __NSMLDMFOTAADAPTER_H__
+
+//  INCLUDES
+#include <e32base.h>
+#include <smldmadapter.h>
+#include <fotaengine.h>
+#include <fotaConst.h>
+
+#include "nsmldmfotaadapterdb.h"
+
+
+// CONSTANTS
+
+const TInt KNSmlDMFotaResultBufferExpandSize = 64;
+const TInt KNSmlDMFotaStreamingTreshold = 4096;
+const TInt KNSmlDMFotaNullPkgId = -1;
+
+// final result values
+const TInt KNSmlDMFotaUndefinedError = 410;
+const TInt KNSmlDMFotaSuccessfullDownload = 202;
+const TInt KNSmlDMFotaBadUrl = 502;
+
+// P&S keys defined & owned by FotaServer for OMA DM large object
+// sets the OMA DM large object download status
+const TUint32 KFotaLrgObjDl = 0x00000005;
+// sets the profile id used for OMA DM large object download
+const TUint32 KFotaLrgObjProfileId = 0x00000006;
+// literals for DDF structure
+_LIT8( KNSmlDMFotaNode,                     "FUMO" );
+_LIT8( KNSmlDMFotaNodeName,                 "PkgName" );
+_LIT8( KNSmlDMFotaNodeVersion,              "PkgVersion" );
+_LIT8( KNSmlDMFotaNodeDownload,             "Download" );
+_LIT8( KNSmlDMFotaNodeDownloadUrl,          "PkgURL" );
+_LIT8( KNSmlDMFotaNodeDownloadAndUpdate,    "DownloadAndUpdate" );
+_LIT8( KNSmlDMFotaNodeDownloadAndUpdateUrl, "PkgURL" );
+_LIT8( KNSmlDMFotaNodeState,                "State" );
+
+// descriptions for DDF nodes
+_LIT8( KNSmlDMFotaNodeDescription,
+"Placeholder for all firmware management objects" );
+
+_LIT8( KNSmlDMFotaRunTimeNodeDescription,
+"Placeholder for a single firmware management object" );
+
+_LIT8( KNSmlDMFotaNodeNameDescription,
+"Name of a firmware update package" );
+
+_LIT8( KNSmlDMFotaNodeVersionDescription,
+"Version of a firmware update package" );
+
+_LIT8( KNSmlDMFotaNodeDownloadDescription,
+"Execution target for firmware update package download" );
+
+_LIT8( KNSmlDMFotaNodeDownloadUrlDescription,
+"Url to a location containing binary firmare update package" );
+
+_LIT8( KNSmlDMFotaNodeUpdateDescription,
+"Execution target for installing update package to device" );
+
+_LIT8( KNSmlDMFotaNodeUpdateDataDescription,
+"Binary data used in installation" );
+
+_LIT8( KNSmlDMFotaNodeDownloadAndUpdateDescription,
+"Execution target for downloading firmware update package and installing it" );
+
+_LIT8( KNSmlDMFotaNodeDownloadAndUpdateUrlDescription,
+"Url to a location containing binary firmare update package" );
+
+_LIT8( KNSmlDMFotaNodeStateDescription,
+"Current state of firmware update" );
+
+// mime types etc
+_LIT8( KNSmlDMFotaRunTimeMimeType,
+"org.openmobilealliance/1.0/FirmwareUpdateManagementObject" );
+
+_LIT8( KNSmlDMFotaTextPlain,    "text/plain" );
+_LIT8( KNSmlDMFotaDDFVersion,   "1.0" ); 
+
+_LIT8( KNSmlDMFotaUpdateMetaType,
+"org.openmobilealliance.dm.firmwareupdate.update" );
+
+_LIT8( KNSmlDMFotaDownloadMetaType,
+"org.openmobilealliance.dm.firmwareupdate.download" );
+
+_LIT8( KNSmlDMFotaDownloadAndUpdateMetaType,
+"org.openmobilealliance.dm.firmwareupdate.downloadandupdate" );
+
+_LIT8( KNSmlDMFotaMetaFormat, "text/plain" );
+
+_LIT8( KNSmlDMFotaRunTimeChildren,
+"PkgName/PkgVersion/Download/DownloadAndUpdate/State" );
+
+// uri related
+_LIT8( KNSmlDMFotaSeparatorDes, "/" );
+_LIT8( KNSmlDMFotaRuntimeMatch, "*FUMO/*" );
+_LIT8( KNSmlDMFotaRootMatch,    "*FUMO" );
+
+
+/**
+*  CNSmlDmFotaAdapter, the main adapter class of Fota. Provides methods 
+*  to access and modify FUMO objects.
+*  
+*  @lib nsmldmfotaadapter.lib
+*  
+*/
+class CNSmlDmFotaAdapter : public CSmlDmAdapter
+    {
+
+public:
+
+    /**
+    * Two-phased constructor.
+    * @param aDmCallback A pointer to DM Callback, which is used to 
+    * set statuses and results of commands.
+    * @return A pointer to the newly created adapter.
+    */
+    static CNSmlDmFotaAdapter* NewL( MSmlDmCallback* aDmCallback );
+    
+    /**
+    * Two-phased constructor. Pushes the pointer onto the CleanupStack.
+    * @param aDmCallback A pointer to DM Callback, which is used to 
+    * set statuses and results of commands.
+    * @return A pointer to the newly created adapter.
+    */
+    static CNSmlDmFotaAdapter* NewLC( MSmlDmCallback* aDmCallback );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CNSmlDmFotaAdapter();
+    
+public: 
+    
+    // from CSmlDmAdapter
+    
+    /**
+    * Sets current version of Fota adapter's DDF structure to aDDFVersion.
+    * @param aVersion Buffer which on return contains the version.
+    */
+    void DDFVersionL( CBufBase& aDDFVersion );
+    
+    /**
+    * Fills the DDF structure of firmware management object using the given 
+    * reference as the root of DDF. Also checks if there are any Generic 
+    * Alerts to be sent to current remote DM server. If there are, delegates 
+    * the alerts to SOS Server using Private API.
+    * @param aDDFObject Reference to root DDF node.
+    */
+    void DDFStructureL( MSmlDmDDFObject& aDDF );
+    
+    /**
+    * Updates a leaf object in FUMO. Sets ENotFound as status to DM Framework,
+    * if aURI and/or aLUID is not valid.
+    * @param aURI Uri which spesifies the leaf to be updated in a firmware 
+    * object.
+    * @param aLUID Identifier used to identify in which firmware object 
+    * the leaf should be updated.
+    * @param aObject Data used in the update.
+    * @param aType Mime type of the data. Ignored in Fota adapter.
+    * @param aStatusRef Identifier that is used when setting the completion
+    * status to DM Framework.
+    */
+    void UpdateLeafObjectL( const TDesC8& aURI,
+                            const TDesC8& aLUID, 
+                            const TDesC8& aObject, 
+                            const TDesC8& aType, 
+                            TInt aStatusRef );
+    
+    /**
+    * Deletes a firmware object from Fota DB. If aURI does not point to a 
+    * runtime node and/or aLUIDis invalid, ENotFound is set as status for 
+    * this command.
+    * @param aURI Uri which spesifies a firmware object.
+    * @param aLUID Identifier used to identify in which firmware object 
+    * should be deleted.
+    * @param aStatusRef Identifier that is used when setting the completion 
+    * status to DM Framework.
+    */
+    void DeleteObjectL( const TDesC8& aURI,
+                        const TDesC8& aLUID, 
+                        const TInt aStatusRef ); 
+    
+    /**
+    * Fetches a leaf object in FUMO. Sets ENotFound as status to DM Framework,
+    * if aURI and/or aLUID is not valid.
+    * @param aURI Uri which spesifies the leaf to be fetched.
+    * @param aLUID Identifier used to identify from which firmware object the 
+    * leaf should be fetched.
+    * @param aType Mime type that server wishes to be used in the returned data.
+    * Ignored in Fota adapter (but used when setting the result).
+    * @param aResultRef Identifier that is used when setting the result 
+    * (fetched data) to DM Framework.
+    * @param aStatusRef Identifier that is used when setting the completion
+    * status to DM Framework.
+    */
+    void FetchLeafObjectL( const TDesC8& aURI, 
+                           const TDesC8& aLUID, 
+                           const TDesC8& aType, 
+                           const TInt aResultsRef, 
+                           const TInt aStatusRef ); 
+    
+    /**
+    * Forms a list of children of given node (aURI) and sets the list to 
+    * DM Framework as result.
+    * @param aURI Uri which spesifies the node whose children should be 
+    * listed. In Fota this should point to either to the ./FUMO or ./FUMO/<x>.
+    * In the first case aPreviousURISegmentList is trusted and the list is 
+    * formed entirely based on it. In the latter case, a hard coded list of 
+    * run time node's children is returned.
+    * @param aLUID Identifier of aURI. Ignored in Fota adapter.
+    * @param aPreviousURISegmentList A List of aURI's children formed by 
+    * DM Framework.
+    * @param aResultRef Identifier that is used when setting the result 
+    * (fetched data) to DM Framework.
+    * @param aStatusRef Identifier that is used when setting the completion
+    * status to DM Framework.
+    */
+    void ChildURIListL( const TDesC8& aURI, 
+                        const TDesC8& aLUID, 
+                        const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, 
+                        const TInt aResultsRef, 
+                        const TInt aStatusRef );
+    
+    /**
+    * Adds a firmware object to Fota DB. If aURI does not point to a runtime 
+    * node and/or aLUID is invalid, ENotFound is set as status for this 
+    * command.
+    * @param aURI Uri which spesifies the firmware object.
+    * @param aParentLUID Identifier of aURI. If this is a valid ID, then 
+    * the object has already been added and EAlreadyExists is set as status 
+    * for this command.
+    * @param aStatusRef Identifier that is used when setting the completion 
+    * status to DM Framework.
+    */
+    void AddNodeObjectL( const TDesC8& aURI, 
+                         const TDesC8& aParentLUID, 
+                         const TInt aStatusRef );
+    
+    /**
+    * This method is used to update PkgData, which is the only large object 
+    * data in FUMO. Adapter opens a stream to a data (using Fota Engine) 
+    * and sets this stream to aStream after which this method returns. DM Host
+    * Server then writes the data to the stream piece by piece and finally 
+    * calls StreamCommittedL() when all data is written.
+    * @param aURI Uri which spesifies the leaf to be updated in a firmware 
+    * object. If this does not point to ./FUMO/<x>/Update/PkgData, ENotFound 
+    * is set as status for this command.
+    * @param aLUID Identifier used to identify in which firmware object the 
+    * data should be updated.
+    * @param aStream Pointer to a stream, where the opened stream is set.
+    * @param aType Mime type of the data. Ignored in Fota adapter.
+    * @param aStatusRef Identifier that is used when setting the completion 
+    * status to DM Framework.
+    */
+    void UpdateLeafObjectL( const TDesC8& aURI,
+                            const TDesC8& aLUID, 
+                            RWriteStream*& aStream, 
+                            const TDesC8& aType, 
+                            const TInt aStatusRef );
+    
+    /**
+    * Fetches the size of leaf object's data in bytes. Sets ENotFound as 
+    * status to DM Framework, if aURI and/or aLUID is not valid.
+    * @param aURI Uri which spesifies the leaf whose data is measured.
+    * @param aLUID Identifier used to identify from which firmware object 
+    * the leaf size should be counted.
+    * @param aType Mime type that server wishes to be used in the returned 
+    * data. Ignored in Fota adapter (but used when setting the result)
+    * @param aResultRef Identifier that is used when setting the result 
+    * (fetched data) to DM Framework.
+    * @param aStatusRef Identifier that is used when setting the completion 
+    * status to DM Framework.
+    */
+    void FetchLeafObjectSizeL( const TDesC8& aURI,
+                               const TDesC8& aLUID, 
+                               const TDesC8& aType, 
+                               const TInt aResultsRef, 
+                               const TInt aStatusRef );
+    
+    /**
+    * Executes command targeting Download, DownloadAndUpdate or Update. In any
+    * other case, ENotFound is set as status for this command. Saves all 
+    * the data needed when reporting the final result of this command in 
+    * the beginning of next DM session, fetches needed data for the command 
+    * and delegates the command to Fota Engine.
+    * @param aURI Uri which spesifies the target node for the exec command.
+    * @param aLUID Identifier used to identify the firmware object where the 
+    * target node lies.
+    * @param aArgument The argument data of the exec command. In Fota this is 
+    * an overloaded feature, and this parameter contains the Correlator of 
+    * the exec command.
+    * @param aType Mime type of aArgument. Ignored in Fota adapter.
+    * @param aStatusRef Identifier that is used when setting the completion 
+    * status to DM Framework.
+    */
+    void ExecuteCommandL( const TDesC8& aURI, 
+                          const TDesC8& aLUID,
+                          const TDesC8& aArgument, 
+                          const TDesC8& aType, 
+                          const TInt aStatusRef );
+    
+    /**
+    * Not supported.
+    */
+    void ExecuteCommandL( const TDesC8& aURI, 
+                          const TDesC8& aLUID, 
+                          RWriteStream*& aStream, 
+                          const TDesC8& aType, 
+                          const TInt aStatusRef );
+    
+    /**
+    * Not supported.
+    */
+    void CopyCommandL( const TDesC8& aTargetURI, 
+                       const TDesC8& aTargetLUID, 
+                       const TDesC8& aSourceURI, 
+                       const TDesC8& aSourceLUID, 
+                       const TDesC8& aType, 
+                       TInt aStatusRef );
+    
+    /**
+    * Not supported.
+    */
+    void StartAtomicL();
+    
+    /**
+    * Not supported.
+    */
+    void CommitAtomicL();
+    
+    /**
+    * Not supported.
+    */
+    void RollbackAtomicL();
+    
+    /**
+    * Returns whether or not streaming is supported in this adapter. In Fota
+    * this method is also used to enquire whether or not a large object 
+    * whose size is given in aItemSize fits to disk (OOD check using Fota 
+    * Engine), and to acknowledge that Generic Alerts have been successfully 
+    * sent. If aItemSize is larger that 0, OOD check feature is executed. If 
+    * aItemSize equals KNSmlDMResetGenAlerts, Generic Alerts are marked sent.
+    * Otherwise aItemSize is set to a treshold value, which is used by DM 
+    * Host Server to determine if streaming should be used (large object) 
+    * or not.
+    * @param aItemSize If this parameter is larger than zero in the beginning,
+    * on return it equals KErrNone if the data fits to disk, and KErrNoMemory 
+    * if not. If in the beginning this param equals KNSmlDMResetGenAlerts, 
+    * Generic Alerts are marked sent. Otherwise if in the beginning this param
+    * is less or equal to zero, on return it equals to the treshold value 
+    * mentioned above.
+    * @return Whether or not streaming is supported in this adapter 
+    * (ETrue always).
+    */
+    TBool StreamingSupport( TInt& aItemSize );
+    
+    /**
+    * DM Host Server notifies Fota adapter using this method, when all data 
+    * has been written to the stream opened for streaming in UpdateLeafObjectL 
+    * targeting PkgData. Fota adapter forwards this notification to Fota 
+    * Engine.
+    */
+    void StreamCommittedL();
+    
+    /**
+    * Not supported.
+    */
+    void CompleteOutstandingCmdsL();
+    
+private:
+
+    /**
+    * Check if fota table exists
+    * @param aLUID    ID of the node
+    * @return  whether table exists
+    */
+    TBool TableExistsL(const TDesC8& aLUID) const;
+
+    /**
+    * Default constructor.
+    * @param aEcomArguments A pointer to MSmlDmCallback which is received 
+    * through ECom. The pointer is passed on to base class.
+    */
+    CNSmlDmFotaAdapter( TAny* aEcomArguments );
+    
+    /**
+    * Second phase construction.
+    */
+    void ConstructL();
+    
+    /**
+    * Fetches the data in firmware object identified by aLUID (object) and 
+    * aURI (leaf).
+    * @param aURI Identifies the leaf whose data should be fetched.
+    * @param aLUID Identifies the FW object in which the leaf object is.
+    * @param aObject Reference to CBufBase to which the fetched data is 
+    * written.
+    * @return Status code according to the success of the fetch.
+    */
+    CSmlDmAdapter::TError DoFetchObjectL( const TDesC8& aURI, 
+                                          const TDesC8& aLUID, 
+                                          CBufBase& aObject );
+    
+    /**
+    * Gets data needed for Update execution from Fota DB and notifies 
+    * Fota Engine. Note: this method does not wait for Fota Engine to 
+    * execute the command, but immediately returns when Fota Engine has been 
+    * notified.
+    * @param aLUID The id of the firmware object to which this exec is 
+    * targeted.
+    * @param aProfile The profile id of the currently running DM session.
+    * @return Status code according to the success of the method.
+    */
+    CSmlDmAdapter::TError DoExecUpdateL( const TNSmlDmFwObjectId aLUID, 
+                                         const TSmlProfileId aProfile );
+    
+    /**
+    * Gets data needed for Download or DownloadAndUpdate execution from 
+    * Fota DB and notifies Fota Engine. Note: this method does not wait 
+    * for Fota Engine to execute the command, but immediately returns when 
+    * Fota Engine has been notified.
+    * @param aLUID The id of the firmware object to which this exec is 
+    * targeted.
+    * @param aProfile The profile id of the currently running DM session.
+    * @param aUpdate If set ETrue, executes DownloadAndUpdate. Otherwise 
+    * executes Download.
+    * @return Status code according to the success of the method.
+    */
+    CSmlDmAdapter::TError DoExecDownloadL( const TNSmlDmFwObjectId aLUID, 
+                                           const TSmlProfileId aProfile,
+                                           TBool aUpdate );
+    
+    /**
+    * Saves all the data needed to save before any exec command and returns 
+    * the id of the profile of currently running DM session.
+    * @param aURI Management uri, which is the target of the exec command.
+    * @param aLUID Identifies the firm3ware object that is the target of the 
+    * exec command.
+    * @param aCorrelator Correlator received as an argument in the exec 
+    * command.
+    * @return Profile id of the currently running DM session.
+    */
+    TSmlProfileId SaveExecInfoL( const TDesC8& aURI, 
+                                 const TNSmlDmFwObjectId aLUID,
+                                 const TDesC8& aCorrelator );
+    
+    /**
+    * Fetches profile id and server id of the currently running DM session 
+    * using Client API.
+    * @param aProfId Reference which on succesful return contains the 
+    * profile id.
+    * @param aServerId Reference which on successful return contains 
+    * the server id.
+    */
+    void GetServerInfoL( TSmlProfileId& aProfId, HBufC8*& aServerId ) const;
+    
+    /**
+    * Checks if there are any firmware objects that have empty final results. 
+    * If there are, checks if any their final result should be reported to 
+    * currently running DM session's remote server using Generic Alert. 
+    * I.e. if the remote server is the same as with any of those firmware 
+    * object's whose execution's final result has not been reported yet, 
+    * uses Private API to generate Generic Alert about them.
+    */
+    void MakeGenericAlertsL();
+    
+    /***
+    * Checks existance of predefined node under FUMO and adds it to 
+    * DM Tree 
+    **/
+    
+    void CheckAndAddPredefinedNodeL();
+    /***
+    * Gets predefined node name to be created under FUMO from cenrep 
+    * 
+    **/
+    
+    void GetPredefinedNodeL(TDes8& aNode);
+    /**
+    * Sets final result to all those FW objects that are associated with 
+    * current DM session's remote server, have been a target to an exec 
+    * command and that exec command has been finished. I.e. Generic Alert 
+    * has been successfully sent reporting these final results, and is not 
+    * needed to be sent anymore in next DM session.
+    */
+    void MarkGenericAlertsSentL();
+    
+    /**
+    * Returns correct meta/type acoording to the execution target aURI.
+    * @param aURI The target for exec command, e.g. ./FUMO/<X>/Update
+    * @return The meta/type
+    */
+    TPtrC8 GetMetaType( const TDesC8& aURI ) const;
+    
+    /**
+    * Maps a system wide error code to a TError.
+    * @param aError A system wide error code.
+    * @return A TError value depending on aError.
+    */
+    CSmlDmAdapter::TError MapErrorToStatus( TInt aError ) const;
+    
+    /**
+    * Parses a numeric value from aLUID.
+    * @param aLUID A string representation of a signed integer.
+    * @return TInt value.
+    */
+    TInt DesToInt( const TDesC8& aLUID ) const;
+    
+    /**
+    * Return the last uri segment of the given uri. E.g. in 
+    * ./FUMO/<x>/Download last uri segment is "Download"
+    * @param aURI the uri to be parsed.
+    * @return The last segment.
+    */
+    TPtrC8 LastURISeg( const TDesC8& aURI ) const;
+    
+    /**
+    * Fills the given information to a DDF Object node.
+    * @param aNode The node whose data is filled.
+    * @param aAccTypes The access types of the node.
+    * @param aOccurance Occurance of the node.
+    * @param aScope The scope of the node.
+    * @param aFormat The format of the node's data, i.e. node/chr/bin/...
+    * @param aDescription Informal description of the node.
+    */
+    void FillNodeInfoL( MSmlDmDDFObject& aNode, 
+                        const TSmlDmAccessTypes& aAccTypes, 
+                        MSmlDmDDFObject::TOccurence aOccurrence, 
+                        MSmlDmDDFObject::TScope aScope, 
+                        MSmlDmDDFObject::TDFFormat aFormat,
+                        const TDesC8& aDescription ) const;
+    
+    RFotaEngineSession& FotaEngineL();
+
+private:
+
+    CNSmlDmFotaAdapterDb* iFotaDb;
+    RFotaEngineSession iFotaEngine;
+    
+    TInt iPkgId;
+    
+    };
+
+#endif // __NSMLDMFOTAADAPTER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/fota/inc/nsmldmfotaadapterdb.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,458 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Fota adapter's DB header file
+*
+*/
+
+
+
+
+
+#ifndef __NSMLDMFOTAADAPTERDB_H
+#define __NSMLDMFOTAADAPTERDB_H
+
+// INCLUDE FILES
+
+#include <e32std.h>
+#include <e32base.h>
+#include <d32dbms.h>
+#include <f32file.h>
+#include <SyncMLDef.h>
+#include <fotaengine.h>
+#include <fotaConst.h>
+
+// CONSTANTS
+
+// null final result value
+const TInt KNSmlFotaNullResult = 0;
+
+// Database name & location
+const TInt KNSmlFotaAdapterDbDrive = EDriveC;
+_LIT( KNSmlFotaAdapterDbName, "c:nsmldmfotaadapter.db" );
+
+// Table and column names
+_LIT( KNSmlTableFwMgmtObject,       "FwMgmtObject" );
+_LIT( KNSmlFwMgmtObjectId,          "PkgId" );
+_LIT( KNSmlFwMgmtObjectName,        "PkgName" );
+_LIT( KNSmlFwMgmtObjectVersion,     "PkgVersion" );
+_LIT( KNSmlFwMgmtObjectUrl,         "PkgURL" );
+_LIT( KNSmlFwMgmtObjectMgmtUri,     "MgmtURI" );
+_LIT( KNSmlFwMgmtObjectProfileId,   "ProfileId" );
+_LIT( KNSmlFwMgmtObjectServerId,    "ServerId" );
+_LIT( KNSmlFwMgmtObjectResult,      "FinalResult" );
+_LIT( KNSmlFwMgmtObjectCorrelator,  "Correlator" );
+
+// SQL statements
+_LIT( KNSmlCreateFwMgmtObjectTable, "CREATE TABLE FwMgmtObject ( PkgId \
+COUNTER NOT NULL, PkgName CHAR(%d), PkgVersion CHAR(%d), PkgURL LONG VARCHAR, \
+MgmtURI CHAR(%d), ProfileId INTEGER, ServerId CHAR(%d), FinalResult INTEGER, \
+Correlator CHAR(%d) )" );
+
+_LIT( KNSmlGetFwMgmtObject, "SELECT * FROM FwMgmtObject WHERE PkgId = %d" );
+
+_LIT( KNSmlGetUnfinishedFwMgmtObjects, "SELECT * FROM FwMgmtObject \
+WHERE FinalResult = %d" );
+
+_LIT( KNSmlGetUnfinishedFwMgmtObjectByServerId, "SELECT * FROM FwMgmtObject \
+WHERE FinalResult = %d AND ServerId = '%S' AND NOT (MgmtURI = '')" );
+
+_LIT( KNSmlDeleteFwMgmtObject,"DELETE FROM FwMgmtObject WHERE PkgId = %d");
+
+// Max. lengths of string fields in FwMgmtObject
+const TInt KNSmlMaxMgmtUriLength = 60;
+const TInt KNSmlMaxServerIdLength = 150;
+const TInt KNSmlMaxCorrelatorLength = 150;
+
+// Estimate of url size used in max row size (OOD checks)
+const TInt KNSmlPkgURLLengthEstimate = 350;
+
+// space needed for above integers in buffer
+const TInt KNSmlFwMgmtObjectIntLength = 4;
+
+// space needed for an integer in buffer
+const TInt KNSmlFwMgmtObjectIntegerLength = 10;
+
+// Size of empty Fota database in bytes (+ additional treshold)
+const TInt KNSmlFotaAdapterEmptyDbSize = 350;
+
+// Estimated maximum size of FwMgmtObject table row (+ additional treshold)
+const TInt KNSmlMaxFwMgmtObjectRowSize = KFotaMaxPkgNameLength + 
+                                         KFotaMaxPkgVersionLength + 
+                                         KNSmlPkgURLLengthEstimate + 
+                                         KNSmlMaxMgmtUriLength + 
+                                         KNSmlMaxServerIdLength + 
+                                         KNSmlMaxCorrelatorLength + 115;
+
+// TYPEDEFS
+typedef TInt TNSmlDmFwObjectId;
+typedef RArray<TNSmlDmFwObjectId> RNSmlDmFwObjectArray;
+
+
+
+// CLASS DECLARATION
+
+/**
+*  CNSmlDmFotaAdapterDb provides an interface for accessing Fota database.
+*  
+*  @lib nsmldmfotaadapter.lib
+*  
+*/
+class CNSmlDmFotaAdapterDb : public CBase
+    {
+
+public:
+        
+    /**
+    * Two-phased constructor.
+    * @return A pointer to the newly created instance.
+    */
+    static CNSmlDmFotaAdapterDb* NewL();    
+
+    /**
+    * Two-phased constructor. Pushes the pointer onto the CleanupStack.
+    * @return A pointer to the newly created instance.
+    */
+    static CNSmlDmFotaAdapterDb* NewLC();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CNSmlDmFotaAdapterDb();
+
+    /**
+    * Adds a new row (i.e. firmware object) to the FwMgmtObject table.
+    * The values in each column are left NULL, except FinalResult to 
+    * KNSmlFotaNullResult. 
+    * Leaves with KErrDiskFull, if OOD check fails.
+    * @return The id of the new fw object in Fota database.
+    */
+    TNSmlDmFwObjectId AddFwObjectL();
+    
+    /**
+    * Deletes a firmware object from FwMgmtObject table.
+    * @param aId The identifier of the object to be deleted.
+    * @return KErrNone if the object was successfully deleted, KErrNotFound if 
+    * the object was not found from database.
+    */
+    TInt DeleteFwObjectL( const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Finds all the firmware objects that have null final result and sets
+    * the ids of those objetcs to aArray.
+    * @param aArray that on return contains the ids.
+    */
+    void GetEmptyFinalResultsL( RNSmlDmFwObjectArray& aArray );
+    
+    /**
+    * Finds all the firmware objects that have null final result, server id 
+    * equals to given server id and mgmt uri is not empty. Sets the ids of 
+    * those objetcs to aArray.
+    * @param aArray Array that on return contains the ids.
+    * @param aServerId The id of the server whose empty final result values 
+    * are listed.
+    */
+    void GetEmptyFinalResultsL( RNSmlDmFwObjectArray& aArray, 
+                                const TDesC8& aServerId );
+    
+    /**
+    * Fetches the PkgName field of a firmware object from database.
+    * @param aId The identifier of the object, whose data should be fetched.
+    * @return The value in PkgName field of the object, if object was found.
+    * NULL otherwise.
+    */
+    HBufC8* PkgNameL( const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Fetches the PkgVersion field of a firmware object from database.
+    * @param aId The identifier of the object, whose data should be fetched.
+    * @return The value in PkgVersion field of the object, if object was found.
+    * NULL otherwise.
+    */
+    HBufC8* PkgVersionL( const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Fetches the PkgURL field of a firmware object from database.
+    * @param aId The identifier of the object, whose data should be fetched.
+    * @return The value in PkgURL field of the object, if object was found.
+    * NULL otherwise.
+    */
+    HBufC8* PkgUrlL( const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Fetches the MgmtURI field of a firmware object from database.
+    * @param aId The identifier of the object, whose data should be fetched.
+    * @return The value in MgmtURI field of the object, if object was found.
+    * NULL otherwise.
+    */
+    HBufC8* MgmtUriL( const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Fetches the ProfileId field of a firmware object from database.
+    * @param aId The identifier of the object, whose data should be fetched.
+    * @return The value in ProfileId field of the object, if object was found.
+    * KErrNotFound otherwise.
+    */
+    TSmlProfileId ProfileIdL( const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Fetches the ServerId field of a firmware object from database.
+    * @param aId The identifier of the object, whose data should be fetched.
+    * @return The value in ServerId field of the object, if object was found.
+    * NULL otherwise.
+    */
+    HBufC8* ServerIdL( const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Fetches the FinalResult field of a firmware object from database.
+    * @param aId The identifier of the object, whose data should be fetched.
+    * @return The value in FinalResult field of the object, if object was 
+    * found. KErrNotFound otherwise.
+    */
+    TInt FinalResultL( const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Fetches the Correlator field of a firmware object from database.
+    * @param aId The identifier of the object, whose data should be fetched.
+    * @return The value in Correlator field of the object, if object was 
+    * found. NULL otherwise.
+    */
+    HBufC8* CorrelatorL( const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Sets the value of PkgName field of a firmware object.
+    * @param aName The new value for the field.
+    * @param aId The identifier of the object, whose data should be updated.
+    * @return KErrNone, if the update was successful. KErrNotFound, if the 
+    * object was not found. KErrOverflow, if given name is too large for the 
+    * database.
+    */
+    TInt SetPkgNameL( const TDesC8& aName, const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Sets the value of PkgVersion field of a firmware object.
+    * @param aVersion The new value for the field.
+    * @param aId The identifier of the object, whose data should be updated.
+    * @return KErrNone, if the update was successful. KErrNotFound, if the 
+    * object was not found. KErrOverflow, if given version is too large 
+    * for the database.
+    */
+    TInt SetPkgVersionL( const TDesC8& aVersion, const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Sets the value of PkgURL field of a firmware object.
+    * @param aUrl The new value for the field.
+    * @param aId The identifier of the object, whose data should be updated.
+    * @return KErrNone, if the update was successful. KErrNotFound, if the 
+    * object was not found. KErrOverflow, if given url is too large for the 
+    * database.
+    */
+    TInt SetPkgUrlL( const TDesC8& aUrl, const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Sets the value of MgmtURI field of a firmware object.
+    * @param aUri The new value for the field.
+    * @param aId The identifier of the object, whose data should be updated.
+    * @return KErrNone, if the update was successful. KErrNotFound, if the 
+    * object was not found. KErrOverflow, if given uri is too large for the 
+    * database.
+    */
+    TInt SetMgmtUriL( const TDesC8& aUri, const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Sets the values of ProfileId and ServerId fields of a firmware object.
+    * @param aProfile The new value for the ProfileId.
+    * @param aServerId The new value for the ServerId.
+    * @param aId The identifier of the object, whose data should be updated.
+    * @return KErrNone, if the update was successful. KErrNotFound, if the 
+    * object was not found. KErrOverflow, if given server id is too large 
+    * for the database.
+    */
+    TInt SetServerInfoL( const TSmlProfileId aProfile, 
+                         const TDesC8& aServerId,
+                         const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Sets the value of FinalResult field of a firmware object.
+    * @param aResult The new value for the field.
+    * @param aId The identifier of the object, whose data should be updated.
+    * @return KErrNone, if the update was successful. KErrNotFound, if the 
+    * object was not found.
+    */
+    TInt SetFinalResultL( const TInt aResult, const TNSmlDmFwObjectId aId );
+    
+    /**
+    * Sets the value of Correlator field of a firmware object.
+    * @param aCorrelator The new value for the field.
+    * @param aId The identifier of the object, whose data should be updated.
+    * @return KErrNone, if the update was successful. KErrNotFound, if the 
+    * object was not found. KErrOverflow, if given correlator is too large 
+    * for the database.
+    */
+    TInt SetCorrelatorL( const TDesC8& aCorrelator, 
+                         const TNSmlDmFwObjectId aId );
+
+private:
+
+    /**
+    * Creates Fota database.
+    * @param aFullName Name and path of database.
+    */
+    void CreateDatabaseL( const TDesC& aFullName );
+
+    /**
+    * Sets new value to a text field in a firmware object. This method is used 
+    * by the public descriptor setters.
+    * @param aColumn The name of the field to be updated.
+    * @param aValue The new value for the field.
+    * @param aObject The identifier of the object, whose data should be 
+    * updated.
+    * @return KErrNone, if the update was successful. KErrNotFound, if the 
+    * object was not found.
+    */
+    TInt SetStrValueL( const TDesC& aColumn, 
+                       const TDesC8& aValue, 
+                       const TNSmlDmFwObjectId aObject );
+
+    /**
+    * Writes using Db streams the new value to a long text field in a 
+    * firmware object. This method is used by the public descriptor 
+    * setters (PkgURL).
+    * @param aColumn The name of the field to be updated.
+    * @param aValue The new value for the field.
+    * @param aObject The identifier of the object, whose data should 
+    * be updated.
+    * @return KErrNone, if the update was successful. KErrNotFound, if 
+    * the object was not found.
+    */
+    TInt SetLongStrValueL( const TDesC& aColumn,
+                           const TDesC8& aValue, 
+                           const TNSmlDmFwObjectId aObject );
+
+    /**
+    * Sets new value to a integer field in a firmware object. This method 
+    * is used by the public integer setters.
+    * @param aColumn The name of the field to be updated.
+    * @param aValue The new value for the field.
+    * @param aObject The identifier of the object, whose data should be 
+    * updated.
+    * @return KErrNone, if the update was successful. KErrNotFound, if the 
+    * object was not found.
+    */
+    TInt SetIntValueL( const TDesC& aColumn,
+                       const TInt aValue, 
+                       const TNSmlDmFwObjectId aObject );
+
+    /**
+    * Fetches the value in a text field of a firmware object. This method is 
+    * used by the public descriptor getters.
+    * @param aColumn The name of the field where the data should be fetched.
+    * @param aObject The identifier of the object, whose data should be 
+    * fetched.
+    * @return The value in the field, if object was found. NULL otherwise.
+    */
+    HBufC8* StrValueL( const TDesC& aColumn, const TNSmlDmFwObjectId aObject );
+
+    /**
+    * Fetches the value in a long text field of a firmware object using Db 
+    * streams. This method is used by the public descriptor getters (PkgURL).
+    * @param aColumn The name of the field where the data should be fetched.
+    * @param aObject The identifier of the object, whose data should be 
+    * fetched.
+    * @return The value in the field, if object was found. NULL otherwise.
+    */
+    HBufC8* LongStrValueL( const TDesC& aColumn, 
+                           const TNSmlDmFwObjectId aObject );
+
+    /**
+    * Fetches the value in a integer field of a firmware object. This method 
+    * is used by the public integer getters.
+    * @param aColumn The name of the field where the data should be fetched.
+    * @param aObject The identifier of the object, whose data should be 
+    * fetched.
+    * @return The value in the field, if object was found. KErrNotFound 
+    * otherwise.
+    */
+    TInt IntValueL( const TDesC& aColumn, const TNSmlDmFwObjectId aObject );
+
+    /**
+    * Prepares iView with read-only access rights to a single firmware object.
+    * @param aObject The identifier of the object, whose data is about 
+    * to be read.
+    */
+    void FetchRowL( const TNSmlDmFwObjectId aObject );
+    
+    /**
+    * Prepares iView with update access rights to a single firmware object. 
+    * @param aObject The identifier of the object, whose data is about to 
+    * be updated.
+    * @return KErrNone, if there were no errors and iView was successfully
+    * prepared. 
+    * KErrNotFound, if the firmware object was not found.
+    */
+    TInt UpdateRowL( const TNSmlDmFwObjectId aObject );
+    
+    /**
+    * Makes an SQL query string for getting a row from FwMgmtObject table.
+    * @param aId The identifier of the object, which is used in the SQL query.
+    * @return A string containing the formatted SQL query.
+    */
+    HBufC* FwMgmtObjectRowSqlLC( TNSmlDmFwObjectId aId ) const;
+
+    /**
+    * Closes the view and then prepares it with the given values.
+    * @param aSql SQL statement defining the view, which is prepared by 
+    * this method.
+    * @param aAccess Permitted operations for the view.
+    */
+    void PrepareViewL( const TDesC& aSql, RDbRowSet::TAccess aAccess );
+
+    /**
+    * Commits update and compacts the database.
+    */
+    void CommitAndCompact();
+
+    /**
+    * Converts a 8-bit descriptor to a 16-bit descriptor, which is allocated 
+    * from heap and pushed onto the CleanupStack.
+    * @param aDes Descriptor to be converted.
+    * @return A pointer to the newly allocated copy.
+    */
+    HBufC* ConvertTo16BitLC( const TDesC8& aDes ) const;
+
+    /**
+    * Second phase construction.
+    */
+    void ConstructL();
+
+    /**
+    * Constructor.
+    */
+    CNSmlDmFotaAdapterDb();
+
+private:
+
+    RDbNamedDatabase iDatabase;
+    RFs iFsSession;
+    RDbs iRdbSession;
+
+    RDbTable iFwObjectTable;
+    CDbColSet* iColSet;
+    RDbView iView;
+
+    };
+
+
+#endif // __NSMLDMFOTAADAPTERDB_H   
+            
+// End of File
Binary file omadmadapters/fota/src/101F9A02.SPD has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/fota/src/nsmldmfotaadapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,1605 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    DM Fota Adapter
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <implementationproxy.h> // For TImplementationProxy definition
+//#ifdef RD_OMADMAPPUI_UI_EVOLUTION
+#include <DevManInternalCRKeys.h>
+//#endif
+#include <SyncMLClient.h>
+#include <SyncMLClientDM.h>
+#include <e32property.h>
+#include <centralrepository.h>
+#include "fotaadapterCRKeys.h"
+#include "NSmlPrivateAPI.h"
+#include "nsmldmimpluids.h"
+#include "nsmldmfotaadapter.h"
+#include "nsmldmconst.h"
+#include "nsmldebug.h"
+#include "FotaSrvDebug.h"
+#include "nsmldmtreedbclient.h"
+#include <nsmldmconst.h>
+
+// =========================== MEMBER FUNCTIONS ==============================
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter* CNSmlDmFotaAdapter::NewL()
+// Creates new instance of CNSmlDmFotaEngine and returns a pointer to it.
+// ---------------------------------------------------------------------------
+//
+CNSmlDmFotaAdapter* CNSmlDmFotaAdapter::NewL( MSmlDmCallback* aDmCallback )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::NewL(): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::NewL >>"));
+    CNSmlDmFotaAdapter* self = NewLC( aDmCallback );
+    CleanupStack::Pop( self );
+    _DBG_FILE("CNSmlDmFotaAdapter::NewL(): end");
+    FLOG(_L("CNSmlDmFotaAdapter::NewL <<"));
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter* CNSmlDmFotaAdapter::NewLC()
+// Creates new instance of CNSmlDmFotaEngine and returns a pointer to it. 
+// Leaves the pointer onto the CleanupStack.
+// ---------------------------------------------------------------------------
+//
+CNSmlDmFotaAdapter* CNSmlDmFotaAdapter::NewLC( MSmlDmCallback* aDmCallback )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::NewLC(): begin");
+    CNSmlDmFotaAdapter* self = new (ELeave) CNSmlDmFotaAdapter( aDmCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    _DBG_FILE("CNSmlDmFotaAdapter::NewLC(): end");
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::CNSmlDmFotaAdapter()
+// Constructor.
+// ---------------------------------------------------------------------------
+//
+CNSmlDmFotaAdapter::CNSmlDmFotaAdapter( TAny* aEcomArguments )
+    : CSmlDmAdapter( aEcomArguments ), iPkgId( KNSmlDMFotaNullPkgId )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::CNSmlDmFotaAdapter(): begin");
+    _DBG_FILE("CNSmlDmFotaAdapter::CNSmlDmFotaAdapter(): end");
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::ConstructL()
+// Second phase construction.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::ConstructL()
+    {
+    // Check if Fota feature is defined
+    TInt value( 0 );
+    CRepository * rep = CRepository::NewLC( KCRUidFotaAdapter );
+	TInt err = rep->Get( KCRFotaAdapterEnabled, value );
+	CleanupStack::PopAndDestroy( rep );
+	
+	if ( err != KErrNone || value == 0 )
+    	{
+    	User::Leave( KErrNotSupported );
+    	}    
+    	
+    iFotaDb = CNSmlDmFotaAdapterDb::NewL();
+    }
+    
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter()
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter(): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter >>"));
+    
+    if (iFotaEngine.Handle())
+        iFotaEngine.Close();
+
+    delete iFotaDb;
+    FLOG(_L("CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter <<"));
+    _DBG_FILE("CNSmlDmFotaAdapter::~CNSmlDmFotaAdapter(): end");
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapter::DDFVersionL()
+//  Returns the DDF version of the adapter.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::DDFVersionL( CBufBase& aDDFVersion )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::DDFVersionL(TDes& aDDFVersion): begin");
+
+    aDDFVersion.InsertL( 0, KNSmlDMFotaDDFVersion );
+
+    _DBG_FILE("CNSmlDmFotaAdapter::DDFVersionL(TDes& aDDFVersion): end");
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapter::DDFStructureL()
+//  Builds the DDF structure of adapter.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::DDFStructureL(): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::DDFStructureL >>"));
+    TSmlDmAccessTypes accessTypes;
+    
+    // fota root
+    MSmlDmDDFObject& FUMO = aDDF.AddChildObjectL( KNSmlDMFotaNode );
+    accessTypes.SetAdd();
+    accessTypes.SetGet();
+    FillNodeInfoL(  FUMO, 
+                    accessTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EPermanent,
+                    MSmlDmDDFObject::ENode,
+                    KNSmlDMFotaNodeDescription );
+
+    accessTypes.Reset();
+
+    // run time node <X>
+    MSmlDmDDFObject& rtPkg = FUMO.AddChildObjectGroupL();
+    rtPkg.AddDFTypeMimeTypeL( KNSmlDMFotaRunTimeMimeType );
+    accessTypes.SetAdd();
+    accessTypes.SetDelete();
+    accessTypes.SetGet();
+    //accessTypes.SetReplace();
+    FillNodeInfoL(  rtPkg, 
+                    accessTypes,
+                    MSmlDmDDFObject::EZeroOrMore, 
+                    MSmlDmDDFObject::EDynamic, 
+                    MSmlDmDDFObject::ENode, 
+                    KNSmlDMFotaRunTimeNodeDescription );
+
+    accessTypes.Reset();
+
+    // <X>/PkgName
+    MSmlDmDDFObject& name = rtPkg.AddChildObjectL( KNSmlDMFotaNodeName );
+    accessTypes.SetAdd();
+    accessTypes.SetGet();
+    accessTypes.SetReplace();
+    FillNodeInfoL(  name,
+                    accessTypes,
+                    MSmlDmDDFObject::EZeroOrOne,
+                    MSmlDmDDFObject::EDynamic,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMFotaNodeNameDescription );
+
+    // <X>/PkgVersion
+    MSmlDmDDFObject& version = rtPkg.AddChildObjectL( KNSmlDMFotaNodeVersion );
+    FillNodeInfoL(  version,
+                    accessTypes,
+                    MSmlDmDDFObject::EZeroOrOne,
+                    MSmlDmDDFObject::EDynamic,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMFotaNodeVersionDescription );
+
+    accessTypes.Reset();
+
+    // <X>/Download
+    MSmlDmDDFObject& download = 
+    rtPkg.AddChildObjectL( KNSmlDMFotaNodeDownload );
+
+    accessTypes.SetGet();
+    accessTypes.SetExec();
+    FillNodeInfoL(  download,
+                    accessTypes,
+                    MSmlDmDDFObject::EZeroOrOne,
+                    MSmlDmDDFObject::EDynamic,
+                    MSmlDmDDFObject::ENode,
+                    KNSmlDMFotaNodeDownloadDescription );
+
+    accessTypes.Reset();
+
+    // <X>/Download/PkgURL
+    MSmlDmDDFObject& dlUrl = 
+    download.AddChildObjectL( KNSmlDMFotaNodeDownloadUrl );
+
+    accessTypes.SetGet();
+    accessTypes.SetReplace();
+    FillNodeInfoL(  dlUrl,
+                    accessTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EDynamic,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMFotaNodeDownloadUrlDescription );
+
+    accessTypes.Reset();
+
+
+    // <X>/DownloadAndUpdate
+    MSmlDmDDFObject& dlAndUpdate = 
+    rtPkg.AddChildObjectL( KNSmlDMFotaNodeDownloadAndUpdate );
+
+    accessTypes.SetGet();
+    accessTypes.SetExec();
+    FillNodeInfoL(  dlAndUpdate,
+                    accessTypes,
+                    MSmlDmDDFObject::EZeroOrOne,
+                    MSmlDmDDFObject::EDynamic,
+                    MSmlDmDDFObject::ENode,
+                    KNSmlDMFotaNodeDownloadAndUpdateDescription );
+
+    accessTypes.Reset();
+
+    // <X>/DownloadAndUpdate/PkgURL
+    MSmlDmDDFObject& dlAndUpdateUrl = 
+    dlAndUpdate.AddChildObjectL( KNSmlDMFotaNodeDownloadAndUpdateUrl );
+
+    accessTypes.SetGet();
+    accessTypes.SetReplace();
+    FillNodeInfoL(  dlAndUpdateUrl,
+                    accessTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EDynamic,
+                    MSmlDmDDFObject::EChr,
+                    KNSmlDMFotaNodeDownloadAndUpdateUrlDescription );
+
+    accessTypes.Reset();
+
+    // <X>/State
+    MSmlDmDDFObject& state = rtPkg.AddChildObjectL( KNSmlDMFotaNodeState );
+    accessTypes.SetGet();
+    FillNodeInfoL(  state,
+                    accessTypes,
+                    MSmlDmDDFObject::EOne,
+                    MSmlDmDDFObject::EDynamic,
+                    MSmlDmDDFObject::EInt,
+                    KNSmlDMFotaNodeStateDescription );
+
+    
+    
+    //Check cenrep for predefined node and add if its not in DB
+    CheckAndAddPredefinedNodeL();
+    
+    // check if there is need to make generic alert(s), 
+    // and generate them if there are
+    MakeGenericAlertsL();
+
+
+    // Set ACL for fota root, if not yet set
+    RNSmlDMCallbackSession session;
+    User::LeaveIfError( session.Connect() );
+    CleanupClosePushL(session);
+
+    CBufBase* acl=CBufFlat::NewL(10);
+    CleanupStack::PushL( acl );
+    session.GetAclL( KNSmlDMFotaNode,*acl,EFalse );
+
+    if( acl->Size() == 0 )
+        {
+        _LIT8(KACLForAll, "Add=*&Get=*&Delete=*&Exec=*&Replace=*");
+        session.UpdateAclL( KNSmlDMFotaNode, KACLForAll);
+        }
+    CleanupStack::PopAndDestroy( acl );
+    CleanupStack::PopAndDestroy( &session );
+
+    _DBG_FILE("CNSmlDmFotaAdapter::DDFStructureL(): end");
+    FLOG(_L("CNSmlDmFotaAdapter::DDFStructureL <<"));
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::UpdateLeafObjectL()
+// Updates value of leaf object.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::UpdateLeafObjectL( const TDesC8& aURI, 
+                                            const TDesC8& aLUID, 
+                                            const TDesC8& aObject, 
+                                            const TDesC8& /*aType*/, 
+                                            const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::UpdateLeafObjectL(): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::UpdateLeafObjectL >>"));
+    CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
+    
+    if ( aLUID.Length() > 0 )
+        {
+        TInt res = KErrNotFound;
+        TNSmlDmFwObjectId id = DesToInt( aLUID );
+        
+        TPtrC8 lastSeg = LastURISeg( aURI );
+        if ( lastSeg == KNSmlDMFotaNodeName )
+            {
+            res = iFotaDb->SetPkgNameL( aObject, id );
+            }
+        else if ( lastSeg == KNSmlDMFotaNodeVersion )
+            {
+            res = iFotaDb->SetPkgVersionL( aObject, id );
+            }
+        else if ( lastSeg == KNSmlDMFotaNodeDownloadUrl || 
+                  lastSeg == KNSmlDMFotaNodeDownloadAndUpdateUrl )
+            {
+            TInt configFlags( KErrNone );        
+            CRepository* centrep = NULL;
+            TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ) );    	
+            if ( err == KErrNone && centrep ) 
+                {
+                configFlags = 2; //means fota operation
+                centrep->Set( KDevManSessionType, configFlags );
+                delete centrep;
+                centrep = NULL;
+                }
+            else
+                {
+                User::Leave( err );
+                }
+            res = iFotaDb->SetPkgUrlL( aObject, id );
+            }
+        // map error
+        status = MapErrorToStatus( res );
+        }
+    else
+        {
+        // cannot update, object unknown
+        status = CSmlDmAdapter::ENotFound;
+        }
+#ifdef __WINS__
+TInt pos=-1;
+pos = aURI.Find(KNSmlDMFotaNodeDownload);
+
+if (status == CSmlDmAdapter::EOk && pos != KErrNotFound)
+	{
+	if ( aURI.Find(KNSmlDMFotaNodeDownloadAndUpdate) !=KErrNotFound)
+		ExecuteCommandL(_L8("./FUMO/FWUpdate/DownloadAndUpdate"),aLUID,aObject,_L8(""),status);
+	else
+		ExecuteCommandL(_L8("./FUMO/FWUpdate/Download"),aLUID,aObject,_L8(""),status);
+	}
+#endif    
+    
+    Callback().SetStatusL( aStatusRef, status );
+    
+    _DBG_FILE("CNSmlDmFotaAdapter::UpdateLeafObjectL(): end");
+    FLOG(_L("CNSmlDmFotaAdapter::UpdateLeafObjectL <<"));
+    }
+    
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::DeleteObjectL()
+// Deletes a firmware object from Fota database.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::DeleteObjectL( const TDesC8& aURI, 
+                                        const TDesC8& aLUID, 
+                                        const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::DeleteLeafObjectL( ): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::DeleteObjectL >>"));
+    
+    CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
+    
+    if ( ( aURI.Match( KNSmlDMFotaRuntimeMatch ) != KErrNotFound ) && 
+         ( aLUID.Length() > 0 ) )
+        {
+		TBuf8<KMaxFullName> temp;
+		GetPredefinedNodeL(temp);
+		TBuf8<KMaxName> node[4];
+    	TInt location = temp.LocateReverse(',');
+    	node[0].Copy(temp.Mid(location+1));
+    	TInt newLocation = (temp.Left(location-1)).LocateReverse(',');
+    	node[1].Copy(temp.Mid(newLocation+1,location-(newLocation+1)));
+    	location = newLocation;
+    	newLocation = (temp.Left(location-1)).LocateReverse(',');
+    	node[2].Copy(temp.Mid(newLocation+1,location-(newLocation+1)));
+    	node[3].Copy(temp.Mid(0,newLocation ));
+    	for(TInt i =0 ; i<4; i++)
+    	{    		
+    		if (node[i].Length() && aURI.Find( node[i] ) != KErrNotFound)
+            {
+            status = CSmlDmAdapter::ENotAllowed;
+            Callback().SetStatusL( aStatusRef, status );
+            return;
+            }
+    	}
+        // delete object identified by aLUID
+        TNSmlDmFwObjectId id = DesToInt( aLUID );
+        TInt res = iFotaDb->DeleteFwObjectL( id );
+
+        if ( res == KErrNone )
+            {
+            // deletion was successful, delete also from Fota Engine
+            FotaEngineL().DeleteUpdatePackage( id );
+            }
+        else
+            {
+            status = MapErrorToStatus( res );
+            }
+        }
+    else
+        {
+        // object unknown
+        status = CSmlDmAdapter::ENotFound;
+        }
+    
+    Callback().SetStatusL( aStatusRef, status );
+    
+    _DBG_FILE("CNSmlDmFotaAdapter::DeleteLeafObjectL( ): end");
+    FLOG(_L("CNSmlDmFotaAdapter::DeleteObjectL <<"));
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapter::FetchLeafObjectL()
+//  Fetches the values of leaf objects.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::FetchLeafObjectL( const TDesC8& aURI, 
+                                           const TDesC8& aLUID,
+                                           const TDesC8& aType,
+                                           const TInt aResultsRef,
+                                           const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::FetchLeafObjectL(): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::FetchLeafObjectL >>"));
+    // buffer for result
+    CBufBase* result = CBufFlat::NewL( KNSmlDMFotaResultBufferExpandSize );
+    CleanupStack::PushL( result );
+    
+    // fetch data
+    CSmlDmAdapter::TError status = DoFetchObjectL( aURI, aLUID, *result );
+    if ( status == CSmlDmAdapter::EOk )
+        {
+        Callback().SetResultsL( aResultsRef, *result, aType );
+        }
+    
+    CleanupStack::PopAndDestroy( result );
+    
+    Callback().SetStatusL( aStatusRef, status );
+    
+    _DBG_FILE("CNSmlDmFotaAdapter::FetchLeafObjectL(): end");
+    FLOG(_L("CNSmlDmFotaAdapter::FetchLeafObjectL <<"));
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapter::ChildURIListL()
+//  Returns the list of children of a node.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::ChildURIListL( const TDesC8& aURI,
+                                        const TDesC8& aLUID, 
+                                        const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, 
+                                        const TInt aResultsRef, 
+                                        const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::ChildURIListL(): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::ChildURIListL >>"));
+    
+    CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
+    TPtrC8 mimeType( KNullDesC8 );
+    
+    // buffer for result
+    CBufBase* result = CBufFlat::NewL( KNSmlDMFotaResultBufferExpandSize );
+    CleanupStack::PushL( result );
+    
+    TPtrC8 lastSeg = LastURISeg( aURI );
+    if ( lastSeg == KNSmlDMFotaNodeDownload && aLUID.Length() > 0 )
+        {
+        // target is ./FUMO/<x>/Download
+        result->InsertL( 0, KNSmlDMFotaNodeDownloadUrl );
+        }
+    else if ( lastSeg == KNSmlDMFotaNodeDownloadAndUpdate && aLUID.Length() > 0 )
+        {
+        // target is ./FUMO/<x>/DownloadAndUpdate
+        result->InsertL( 0, KNSmlDMFotaNodeDownloadAndUpdateUrl );
+        }
+    else if ( ( aURI.Match( KNSmlDMFotaRuntimeMatch ) != KErrNotFound ) 
+        && ( TableExistsL( aLUID ) ) )
+        {
+        // target is ./FUMO/<x>
+        result->InsertL( 0, KNSmlDMFotaRunTimeChildren );
+        mimeType.Set( KNSmlDMFotaRunTimeMimeType );
+        }
+    else if ( aURI.Match( KNSmlDMFotaRootMatch ) != KErrNotFound )
+        {
+        // target is ./FUMO
+        
+        // return the children listed in aPreviousURISegmentList
+        TInt childCount = aPreviousURISegmentList.Count();
+        for ( TInt i = 0; i < childCount - 1; ++i )
+            {
+            result->InsertL( result->Size(), aPreviousURISegmentList[i].iURISeg );
+            result->InsertL( result->Size(), KNSmlDMFotaSeparatorDes );
+            }
+        
+        if ( childCount )
+            {
+            // insert last child without separator
+            result->InsertL( result->Size(), 
+                aPreviousURISegmentList[ childCount - 1 ].iURISeg );
+            }
+        
+        }
+    else
+        {
+        // invalid target
+        status = CSmlDmAdapter::ENotFound;
+        }
+    
+    // set result, if it was found
+    if ( status == CSmlDmAdapter::EOk )
+        {
+        Callback().SetResultsL( aResultsRef, *result, mimeType );
+        }
+    
+    Callback().SetStatusL( aStatusRef, status );
+    
+    CleanupStack::PopAndDestroy( result );
+    
+    _DBG_FILE("CNSmlDmFotaAdapter::ChildURIListL(): end");
+    FLOG(_L("CNSmlDmFotaAdapter::ChildURIListL <<"));
+    }
+    
+
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::TableExistsL(const TDesC8& aLUID) const
+// Checks if table exists
+// ---------------------------------------------------------------------------
+//
+TBool CNSmlDmFotaAdapter::TableExistsL(const TDesC8& aLUID) const
+    {
+    TBool ret = EFalse;
+    if(aLUID.Length()>0)
+        {
+        TNSmlDmFwObjectId luid = DesToInt( aLUID );
+        TSmlProfileId profileId = iFotaDb->ProfileIdL(luid);
+        if (profileId!=KErrNotFound)
+            {
+            ret = ETrue;
+            }
+        }
+    return ret;
+    }
+
+//
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::AddNodeObjectL()
+// Adds new row to firmware object table in Fota database.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::AddNodeObjectL( const TDesC8& aURI, 
+                                         const TDesC8& aParentLUID, 
+                                         const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::AddNodeObjectL(): begin");
+    
+    CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
+    
+     // Luid specified and it's a valid luid => already exists
+    if ( TableExistsL( aParentLUID ) )
+        {
+        // the object has already been created and mapping set to DM Framework
+        status = CSmlDmAdapter::EAlreadyExists;
+        }
+    else if ( aURI.Match( KNSmlDMFotaRuntimeMatch ) != KErrNotFound )
+        {
+        TInt configFlags( KErrNone );        
+        CRepository* centrep = NULL;
+        TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ) );     
+        if ( err == KErrNone && centrep ) 
+            {
+            configFlags = 2; //means fota operation
+            centrep->Set( KDevManSessionType, configFlags );
+            delete centrep;
+            centrep = NULL;
+            }
+        else
+            {
+            User::Leave( err );
+            }
+            
+    
+        // add new FW object to db
+        TNSmlDmFwObjectId newId = KErrNotFound;
+        TRAP( err, newId = iFotaDb->AddFwObjectL() );
+        
+        if ( err == KErrNone )
+            {
+            // added ok
+            TBuf8<KNSmlFwMgmtObjectIntegerLength> newLUID;
+            newLUID.AppendNum( newId );
+            
+            Callback().SetMappingL( aURI, newLUID );
+            }
+        else
+            {
+            status = MapErrorToStatus( err );
+            }
+
+        }
+    else
+        {
+        // error, invalid uri
+        status = CSmlDmAdapter::ENotFound;
+        }
+    
+    Callback().SetStatusL( aStatusRef, status );
+//    if(status==CSmlDmAdapter::EOk)
+//        {
+//        TSmlProfileId profId = KErrNotFound;
+//        HBufC8* serverId = NULL;
+//        
+//        GetServerInfoL( profId, serverId );
+//        
+//        if(serverId)
+//            {
+//            CleanupStack::PushL( serverId );
+//            
+//            _LIT( KFotaAclAdd, "Add=");
+//            _LIT( KFotaAclGet, "Get=");
+//            _LIT( KFotaAclReplace, "Replace=");
+//            _LIT( KFotaAclDelete, "Delete=");
+//            _LIT( KFotaAclExec, "Exec=");
+//            _LIT( KFotaAclSeparator, "&");
+//            _LIT( KFotaAclForAll, "*");
+//            
+//            const TUint length = KFotaAclAdd().Length() +
+//                                 KFotaAclGet().Length() +
+//                                 KFotaAclReplace().Length() +
+//                                 KFotaAclDelete().Length() +
+//                                 KFotaAclExec().Length() +
+//                                 serverId->Length()*4 +
+//                                 5; /* 4*'&'+ ''*' */
+//                                 
+//            HBufC8* acl = HBufC8::NewLC(length);
+//            TPtr8 acltPtr = acl->Des();
+//            acltPtr.Append(KFotaAclAdd);
+//            acltPtr.Append(*serverId);
+//            acltPtr.Append(KFotaAclSeparator);
+//
+//            acltPtr.Append(KFotaAclGet);
+//            acltPtr.Append(*serverId);
+//            acltPtr.Append(KFotaAclSeparator);
+//
+//            acltPtr.Append(KFotaAclReplace);
+//            acltPtr.Append(*serverId);
+//            acltPtr.Append(KFotaAclSeparator);
+//
+//            acltPtr.Append(KFotaAclDelete);
+//            acltPtr.Append(KFotaAclForAll);
+//            acltPtr.Append(KFotaAclSeparator);
+//
+//            acltPtr.Append(KFotaAclExec);
+//            acltPtr.Append(*serverId);
+//            
+//            RNSmlDMCallbackSession session;
+//            User::LeaveIfError( session.Connect() );
+//            CleanupClosePushL(session);
+//            session.UpdateAclL(aURI,*acl);
+//            CleanupStack::PopAndDestroy( &session );
+//            CleanupStack::PopAndDestroy( acl );
+//            CleanupStack::PopAndDestroy( serverId );
+//            }
+//        }
+    
+    _DBG_FILE("CNSmlDmFotaAdapter::AddNodeObjectL(): end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::UpdateLeafObjectL()
+// Updates a leaf object using streaming. In Fota adapter this method is used 
+// only to update PkgData of a firmware object.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::UpdateLeafObjectL( const TDesC8& aURI, 
+                                            const TDesC8& aLUID, 
+                                            RWriteStream*& aStream, 
+                                            const TDesC8& /*aType*/, 
+                                            const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::UpdateLeafObjectL(stream): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::UpdateLeafObjectL >>"));
+    CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound;
+    
+            
+    Callback().SetStatusL( aStatusRef, status );
+    
+    _DBG_FILE("CNSmlDmFotaAdapter::UpdateLeafObjectL(stream): end");
+    FLOG(_L("CNSmlDmFotaAdapter::UpdateLeafObjectL <<"));
+    }
+
+// ---------------------------------------------------------------------------
+// void CNSmlDmFotaAdapter::FetchLeafObjectSizeL()
+// Fetches data object and returns its size.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, 
+                                               const TDesC8& aLUID, 
+                                               const TDesC8& aType, 
+                                               const TInt aResultsRef, 
+                                               const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::FetchLeafObjectSizeL(): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::FetchLeafObjectSizeL >>"));
+    // buffer for result
+    CBufBase* result = CBufFlat::NewL( KNSmlDMFotaResultBufferExpandSize );
+    CleanupStack::PushL( result );
+    
+    // fetch data
+    CSmlDmAdapter::TError status = DoFetchObjectL( aURI, aLUID, *result );
+    if ( status == CSmlDmAdapter::EOk )
+        {
+        // get size and form a string representation
+        TInt size = result->Size();
+        TBuf8<KNSmlFwMgmtObjectIntegerLength> sizeStr;
+        sizeStr.AppendNum( size );
+        
+        // insert size to result
+        result->Reset();
+        result->InsertL( 0, sizeStr );
+        
+        Callback().SetResultsL( aResultsRef, *result, aType );
+        }
+    
+    CleanupStack::PopAndDestroy( result );
+    
+    Callback().SetStatusL( aStatusRef, status );
+    
+    _DBG_FILE("CNSmlDmFotaAdapter::FetchLeafObjectSizeL(): end");
+    FLOG(_L("CNSmlDmFotaAdapter::FetchLeafObjectSizeL <<"));
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::ExecuteCommandL()
+// Executes Update, Download or DownloadAndUpdate command depending on aURI. 
+// If aURI does not match to any of these, ENotFound is set as status.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::ExecuteCommandL( const TDesC8& aURI, 
+                                          const TDesC8& aLUID, 
+                                          const TDesC8& aArgument, 
+                                          const TDesC8& /*aType*/, 
+                                          const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::ExecuteCommandL(): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::ExecuteCommandL >>"));
+    //#ifdef RD_OMADMAPPUI_UI_EVOLUTION
+    TInt configFlags( 0 );        
+    CRepository* centrep = NULL;
+    TRAPD( err, centrep = CRepository::NewL( KCRUidDeviceManagementInternalKeys ) );
+    if ( centrep )
+        {
+        centrep->Get( KDevManSessionType, configFlags );            
+        }
+    if ( err != KErrNone ) 
+        {
+        User::Leave( err );
+        }
+    else
+        {
+        configFlags = 1;
+        centrep->Set( KDevManSessionType, configFlags );
+        }
+    if( centrep )    
+       {
+        delete centrep;
+       }        
+    //#endif   
+    CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound;
+    
+    if ( aLUID.Length() > 0 )
+        {
+        TNSmlDmFwObjectId id = DesToInt( aLUID );
+        
+        // uri should target Update, Download or DownloadAndUpdate
+        TPtrC8 lastSeg = LastURISeg( aURI );
+        if ( lastSeg == KNSmlDMFotaNodeDownload ||
+             lastSeg == KNSmlDMFotaNodeDownloadAndUpdate )
+            {
+            
+            // save information about the execution and get profile id of 
+            // currently running DM session
+            TSmlProfileId profId = 0;
+            TRAPD( err, profId = SaveExecInfoL( aURI, id, aArgument ) );
+            
+            if ( err == KErrNone )
+                {
+                if ( lastSeg == KNSmlDMFotaNodeDownload )
+                    {
+                    // download
+                    status = DoExecDownloadL( id, profId, EFalse );
+                    }
+                else if ( lastSeg == KNSmlDMFotaNodeDownloadAndUpdate )
+                    {
+                    // download and update
+                    status = DoExecDownloadL( id, profId, ETrue );
+                    }
+                
+                }
+            else
+                {
+                status = MapErrorToStatus( err );
+                }
+            }
+        
+        }
+#ifndef __WINS__ 
+    Callback().SetStatusL( aStatusRef, status );
+#endif    
+    _DBG_FILE("CNSmlDmFotaAdapter::ExecuteCommandL(): end");
+    FLOG(_L("CNSmlDmFotaAdapter::ExecuteCommandL <<"));
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::ExecuteCommandL()
+// Not supported.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::ExecuteCommandL( const TDesC8& /*aURI*/, 
+                                          const TDesC8& /*aLUID*/, 
+                                          RWriteStream*& /*aStream*/, 
+                                          const TDesC8& /*aType*/, 
+                                          const TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::ExecuteCommandL(): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::ExecuteCommandL >>"));
+    Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    FLOG(_L("CNSmlDmFotaAdapter::ExecuteCommandL <<"));
+    _DBG_FILE("CNSmlDmFotaAdapter::ExecuteCommandL(): end");
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::CopyCommandL()
+// Not supported.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::CopyCommandL( const TDesC8& /*aTargetURI*/, 
+                                       const TDesC8& /*aTargetLUID*/, 
+                                       const TDesC8& /*aSourceURI*/,
+                                       const TDesC8& /*aSourceLUID*/, 
+                                       const TDesC8& /*aType*/, 
+                                       TInt aStatusRef )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::CopyCommandL(): begin");
+    
+    Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
+    
+    _DBG_FILE("CNSmlDmFotaAdapter::CopyCommandL(): end");
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::StartAtomicL()
+// Not supported.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::StartAtomicL()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::StartAtomicL(): begin");
+    _DBG_FILE("CNSmlDmFotaAdapter::StartAtomicL(): end");
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::CommitAtomicL()
+// Not supported.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::CommitAtomicL()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::CommitAtomicL(): begin");
+    _DBG_FILE("CNSmlDmFotaAdapter::CommitAtomicL(): end");
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::RollbackAtomicL()
+// Not supported.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::RollbackAtomicL()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::RollbackAtomicL(): begin");
+    _DBG_FILE("CNSmlDmFotaAdapter::RollbackAtomicL(): end");
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::StreamingSupport()
+// Returns whether or not streaming is supported in this adapter.
+// In Fota this method is also used to enquire whether or not a large object
+// whose size is given in aItemSize fits to disk (OOD check using Fota Engine),
+// and to acknowledge that Generic Alerts have been sent succesfully to remote 
+// server. If aItemSize is larger that 0, OOD check feature is executed. 
+// If aItemSize equals to KNSmlDMResetGenAlerts, Generic Alerts are marked 
+// sent. Otherwise aItemSize is set to a treshold value, which is used by 
+// DM Host Server to determineif streaming should be used (large object) 
+// or not.
+// ---------------------------------------------------------------------------
+//
+TBool CNSmlDmFotaAdapter::StreamingSupport( TInt& aItemSize )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::StreamingSupport(): begin");
+    FLOG(_L("CNSmlDmFotaAdapter::StreamingSupport, ITEM = %d >>"), aItemSize);
+    TBool ret (EFalse);
+    if ( aItemSize == KNSmlDMResetGenAlerts )
+        {
+        // generic alerts have been sent successfully to this server
+        TRAPD( err, MarkGenericAlertsSentL() );
+        if(err)
+            {
+        	_DBG_FILE("CNSmlDmFotaAdapter::StreamingSupport(): error in MarkGenricAlertSentL()");
+            }
+        ret = ETrue;
+        }
+        
+    _DBG_FILE("CNSmlDmFotaAdapter::StreamingSupport(): end");
+    FLOG(_L("CNSmlDmFotaAdapter::StreamingSupport <<"));
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::StreamCommittedL()
+// Notification method used by DM Host Server. All data has been written to 
+// stream successfully and stream has been committed and closed.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::StreamCommittedL()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::StreamCommittedL(): begin");
+   
+    _DBG_FILE("CNSmlDmFotaAdapter::StreamCommittedL(): end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::CompleteOutstandingCmdsL()
+// Not supported.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::CompleteOutstandingCmdsL()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapter::CompleteOutstandingCmdsL(): begin");
+    _DBG_FILE("CNSmlDmFotaAdapter::CompleteOutstandingCmdsL(): end");
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::DoFetchObjectL()
+// Fetches the data identified by aURI in FW object aLUID. Writes the data 
+// to aObject and returns status code according to the success of the fetch.
+// ---------------------------------------------------------------------------
+//
+CSmlDmAdapter::TError CNSmlDmFotaAdapter::DoFetchObjectL( const TDesC8& aURI,
+                                                          const TDesC8& aLUID,
+                                                          CBufBase& aObject )
+    {
+    CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound;
+    
+    if ( aLUID.Length() > 0 )
+        {
+        HBufC8* data = NULL;
+        TNSmlDmFwObjectId id = DesToInt( aLUID );
+        
+        // get correct data according to the last segment of the uri
+        TPtrC8 lastSeg = LastURISeg( aURI );
+        if ( lastSeg == KNSmlDMFotaNodeName )
+            {
+            data = iFotaDb->PkgNameL( id );
+            }
+        else if ( lastSeg == KNSmlDMFotaNodeVersion )
+            {
+            data = iFotaDb->PkgVersionL( id );
+            }
+        else if ( lastSeg == KNSmlDMFotaNodeDownloadUrl || 
+                  lastSeg == KNSmlDMFotaNodeDownloadAndUpdateUrl )
+            {
+            data = iFotaDb->PkgUrlL( id );
+            }
+        else if ( lastSeg == KNSmlDMFotaNodeState )
+            {
+            // state is fetched from fota engine
+            RFotaEngineSession::TState state = FotaEngineL().GetState( id );
+            data = HBufC8::NewL( KNSmlFwMgmtObjectIntegerLength );
+            data->Des().AppendNum( state );
+            }
+        
+        // if data is fetched ok, set results
+        if ( data )
+            {
+            CleanupStack::PushL( data );
+            
+            aObject.InsertL( 0, *data );
+            status = CSmlDmAdapter::EOk;
+            
+            CleanupStack::PopAndDestroy( data );
+            }
+        }
+    
+    return status;
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::DoExecUpdateL()
+// Gets needed data for Update from Fota DB and notifies Fota Engine that 
+// Update should be executed. Returns status according to the success of 
+// the method.
+// ---------------------------------------------------------------------------
+//
+CSmlDmAdapter::TError CNSmlDmFotaAdapter::DoExecUpdateL( 
+                                                const TNSmlDmFwObjectId aLUID, 
+                                                const TSmlProfileId aProfile )
+    {
+    CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
+    
+    // get needed data from db for fota engine
+    HBufC8* pkgName = iFotaDb->PkgNameL( aLUID );
+    CleanupStack::PushL( pkgName );
+    
+    HBufC8* pkgVersion = iFotaDb->PkgVersionL( aLUID );
+    CleanupStack::PushL( pkgVersion );
+    
+    TInt error = KErrNone;
+
+    if ( pkgName && pkgVersion )
+        {
+        // notify fota engine to start update
+        error = FotaEngineL().Update( aLUID, aProfile, *pkgName, *pkgVersion );
+        
+        // if immediate error occured, set final result to corresponding 
+        // value so that generic alert is not sent
+        if ( error == KErrNotFound )
+            {
+            // binary update package has not been downloaded yet -> not 
+            // possible to update
+            status = CSmlDmAdapter::ENotFound;
+            iFotaDb->SetFinalResultL( KNSmlDMFotaUndefinedError, aLUID  );
+            }
+        else if ( error != KErrNone )
+            {
+            // other error
+            status = CSmlDmAdapter::EError;
+            iFotaDb->SetFinalResultL( KNSmlDMFotaUndefinedError, aLUID );
+            }
+        }
+    else
+        {
+        // fw object was not found
+        status = CSmlDmAdapter::ENotFound;
+        }
+    
+    CleanupStack::PopAndDestroy( pkgVersion );
+    CleanupStack::PopAndDestroy( pkgName );
+
+    return status;
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::DoExecDownloadL()
+// Gets needed data for Download or DownloadAndUpdate from Fota DB and 
+// notifies Fota Engine that Download or DownloadAndUpdate should be executed.
+// Returns status according to the success of the method.
+// ---------------------------------------------------------------------------
+//
+CSmlDmAdapter::TError CNSmlDmFotaAdapter::DoExecDownloadL( 
+                                                const TNSmlDmFwObjectId aLUID,
+                                                const TSmlProfileId aProfile,
+                                                TBool aUpdate )
+    {
+    CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
+    
+    // get needed data from db for fota engine
+    HBufC8* url = iFotaDb->PkgUrlL( aLUID );
+    CleanupStack::PushL( url );
+    
+    HBufC8* pkgName = iFotaDb->PkgNameL( aLUID );
+    CleanupStack::PushL( pkgName );
+    
+    HBufC8* pkgVersion = iFotaDb->PkgVersionL( aLUID );
+    CleanupStack::PushL( pkgVersion );
+    
+    TInt error = KErrNone;
+    
+    if ( url && pkgName && pkgVersion )
+        {
+        TBool silent (EFalse);
+        TInt value (ENonSilent);
+        RProperty::Get(KPSUidNSmlSOSServerKey, KNSmlDMSilentJob, value);
+        
+        if (value == ESilent)
+            {
+            silent = ETrue;
+            FLOG(_L("Session type is silent"));
+            }
+        if ( aUpdate )
+            {
+            // notify fota engine to start download and update
+            error = FotaEngineL().DownloadAndUpdate( aLUID, *url, aProfile, *pkgName, *pkgVersion,silent );
+            }
+        else
+            {
+            // notify fota engine to start download
+            error = FotaEngineL().Download( aLUID, *url, aProfile, *pkgName, *pkgVersion, silent );
+            }
+        
+        // if immediate error occured, set final result to corresponding value so that 
+        // generic alert is not sent
+        if ( error == KErrArgument )
+            {
+            // url incorrectly formed
+            status = CSmlDmAdapter::EInvalidObject;
+            iFotaDb->SetFinalResultL( KNSmlDMFotaBadUrl, aLUID );
+            }
+        else if ( error != KErrNone )
+            {
+            // other error
+            status = CSmlDmAdapter::EError;
+            iFotaDb->SetFinalResultL( KNSmlDMFotaUndefinedError, aLUID );
+            }
+        }
+    else
+        {
+        // fw object was not found
+        status = CSmlDmAdapter::ENotFound;
+        }
+    
+    CleanupStack::PopAndDestroy( pkgVersion );
+    CleanupStack::PopAndDestroy( pkgName );
+    CleanupStack::PopAndDestroy( url );
+
+    return status;
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::SaveExecInfoL()
+// Saves the values needed when starting an exec command. Returns the saved 
+// profile id.
+// ---------------------------------------------------------------------------
+//
+TSmlProfileId CNSmlDmFotaAdapter::SaveExecInfoL( const TDesC8& aURI, 
+                                                 const TNSmlDmFwObjectId aLUID,
+                                                 const TDesC8& aCorrelator )
+    {
+    // set final result (null), uri and correlator to fota db
+    User::LeaveIfError( iFotaDb->SetFinalResultL( KNSmlFotaNullResult, aLUID ) );
+    User::LeaveIfError( iFotaDb->SetMgmtUriL( aURI, aLUID ) );
+    User::LeaveIfError( iFotaDb->SetCorrelatorL( aCorrelator, aLUID ) );
+    
+    // fetch profile id and server id of the currently running dm session
+    TSmlProfileId profId = KErrNotFound;
+    HBufC8* serverId = NULL;
+    
+    GetServerInfoL( profId, serverId );
+    CleanupStack::PushL( serverId );
+    
+    // save profile id and server id to fota db
+    User::LeaveIfError( iFotaDb->SetServerInfoL( profId, *serverId, aLUID ) );
+    
+    CleanupStack::PopAndDestroy( serverId );
+    
+    return profId;
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::GetServerInfoL()
+// Fetches profile id and server id of the currently running dm session. 
+// Data is fetched using Client API and set to the references given as 
+// parameters. Reallocates server id to aServerId.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::GetServerInfoL( TSmlProfileId& aProfId, 
+                                         HBufC8*& aServerId ) const
+    {
+    // Open session
+    RSyncMLSession session;
+    session.OpenL();
+    CleanupClosePushL( session );
+    
+    // get current job's id (and usage type)
+    TSmlJobId jobId = KErrNotFound;
+    TSmlUsageType type = ESmlDevMan;
+    session.CurrentJobL( jobId, type );
+    
+    // open currently running job
+    RSyncMLDevManJob dmJob;
+    dmJob.OpenL( session, jobId );
+    CleanupClosePushL( dmJob );
+    
+    // get job's profile id
+    aProfId = dmJob.Profile();
+    
+    // open profile using id in read-only mode
+    RSyncMLDevManProfile dmProf;
+    dmProf.OpenL( session, aProfId, ESmlOpenRead );
+    CleanupClosePushL( dmProf );
+    
+    // get profile's server id
+    aServerId = dmProf.ServerId().AllocL();
+    
+    // close handles
+    CleanupStack::PopAndDestroy( &dmProf );
+    CleanupStack::PopAndDestroy( &dmJob );
+    CleanupStack::PopAndDestroy( &session );
+    }
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::CheckAndAddPredefinedNodeL()
+// Checks if predefined node for FUMO is in tree if not add to the tree 
+// ---------------------------------------------------------------------------
+//    
+void CNSmlDmFotaAdapter::CheckAndAddPredefinedNodeL()
+    {
+    
+	TBuf8<KMaxFullName> temp;
+	GetPredefinedNodeL(temp);
+	if (temp.Length())
+		{
+    	RNSmlDMCallbackSession session;
+    	User::LeaveIfError( session.Connect() );
+    	CleanupClosePushL(session);
+	TBuf8<KMaxName> node[4];
+    TInt location = temp.LocateReverse(',');
+    node[0].Copy(temp.Mid(location+1));
+    TInt newLocation = (temp.Left(location-1)).LocateReverse(',');
+    node[1].Copy(temp.Mid(newLocation+1,location-(newLocation+1)));
+    location = newLocation;
+    newLocation = (temp.Left(location-1)).LocateReverse(',');
+    node[2].Copy(temp.Mid(newLocation+1,location-(newLocation+1)));
+    node[3].Copy(temp.Mid(0,newLocation ));
+	for(TInt i=0; i<4; i++)
+	{	
+		TBuf8<KMaxFullName> temp1;
+		temp1.Zero();
+		temp1.Copy(KNSmlDMFotaNode);
+		temp1.Append(KNSmlDMFotaSeparatorDes);
+		temp1.Append(node[i]);
+   		HBufC8* luid = session.GetLuidAllocL( KNSmlDMFotaAdapterImplUid,temp1);
+		CleanupStack::PushL(luid);
+    	if ( luid->Length() > 0 )
+			{
+			CleanupStack::PopAndDestroy( luid );
+    		CleanupStack::PopAndDestroy( &session );
+			return;			
+			}
+   		else
+    		{
+      		// Add the mapping 
+			TNSmlDmFwObjectId newId = KErrNotFound;
+        	TRAPD( err, newId = iFotaDb->AddFwObjectL() );
+
+	        if ( err == KErrNone )
+				{
+            	// added ok
+            	TBuf8<KNSmlFwMgmtObjectIntegerLength> newLUID;
+            	newLUID.AppendNum( newId );
+      			session.AddMappingInfoL(KNSmlDMFotaAdapterImplUid, temp1, newLUID );
+            	}
+    		}
+		CleanupStack::PopAndDestroy( luid );
+	}
+		CleanupStack::PopAndDestroy( &session );
+    	}
+    }
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::GetPredefinedNodeL()
+// Gets  predefined node for FUMO from cenrep 
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::GetPredefinedNodeL(TDes8& aNode)
+	{
+    CRepository* centrep( NULL);
+	aNode.Zero();
+   	centrep = CRepository::NewLC( TUid::Uid(0x101F9A0A) );
+
+    if ( centrep )
+	    {
+    	TFullName temp;
+		
+    	if (centrep->Get( KDevManFUMOPredefinedNodes, temp )==KErrNone && temp.Length() )
+			{
+			temp.Trim();
+			aNode.Copy(temp);
+			}
+		CleanupStack::PopAndDestroy(centrep);
+	    }
+	}
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::MakeGenericAlertsL()
+// Checks whether or not there are fw objects whose final result should be 
+// sent to the remote server which is involved with the current DM session.
+// If there are such objects, notifies private api using the data needed for
+// generic alert generation.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::MakeGenericAlertsL()
+    {
+    FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL >>"));
+    // search for fw objects that have empty final result
+    RNSmlDmFwObjectArray ids;
+    CleanupClosePushL( ids );
+    
+    iFotaDb->GetEmptyFinalResultsL( ids );
+    if ( ids.Count() == 0 )
+        {
+        // none found, no need for generic alerts
+        CleanupStack::PopAndDestroy( &ids );
+        FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 1"));
+        return;
+        }
+    
+    // get information of the remote DM server
+    TSmlProfileId profId = 0;
+    HBufC8* serverId = NULL;
+    GetServerInfoL( profId, serverId );
+    CleanupStack::PushL( serverId );
+    
+    // open handle to private api
+    RNSmlPrivateAPI privateAPI;
+    FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 2"));
+    privateAPI.OpenL();
+    CleanupClosePushL( privateAPI );
+    
+    // go through all objects in ids
+    for ( TInt i = 0; i < ids.Count(); ++i )
+        {
+        // check that server ids match. if not, move to next entry
+    FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 3"));
+        HBufC8* fwServerId = iFotaDb->ServerIdL( ids[i] );
+        CleanupStack::PushL( fwServerId );
+        FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 4"));
+        if ( *serverId == *fwServerId )
+            {
+            // check that mgmt uri is not empty string. if it is, 
+            // move to next entry
+            HBufC8* fwMgmtUri = iFotaDb->MgmtUriL( ids[i] );
+            FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 5"));
+            CleanupStack::PushL( fwMgmtUri );
+            
+            if ( *fwMgmtUri != KNullDesC8 )
+                {
+                // check that update has reached its final result
+            FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 6"));
+                TInt finalResult = FotaEngineL().GetResult( ids[i] );
+                
+                RFotaEngineSession::TState finalState = FotaEngineL().GetState( ids[i] );
+                
+                if ( finalResult != KErrNotFound && finalState != RFotaEngineSession::EStartingUpdate)
+                    {
+                    // get fw object's correlator
+                    HBufC8* fwCorrelator = iFotaDb->CorrelatorL( ids[i] );
+                    CleanupStack::PushL( fwCorrelator );
+                    
+                    // add generic alert to dm message
+                    TPtrC8 metaType = GetMetaType( *fwMgmtUri );
+                    FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 7"));
+                    privateAPI.AddDMGenericAlertRequestL( *fwMgmtUri, metaType, KNSmlDMFotaMetaFormat, finalResult, *fwCorrelator );
+                    FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL 8"));
+                    CleanupStack::PopAndDestroy( fwCorrelator );
+                    }
+                }
+            
+            CleanupStack::PopAndDestroy( fwMgmtUri );
+            }
+        
+        CleanupStack::PopAndDestroy( fwServerId );
+        }
+    
+    CleanupStack::PopAndDestroy( &privateAPI );
+    CleanupStack::PopAndDestroy( serverId );
+    CleanupStack::PopAndDestroy( &ids );
+    FLOG(_L("CNSmlDmFotaAdapter::MakeGenericAlertsL <<"));
+    
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::MarkGenericAlertsSentL()
+// Puts a final result value to those fw objects, that are 
+// associated with current DM session's remote server, have 
+// been a target to an exec command and the exec command has 
+// finished. I.e. Generic Alert has been sent to remote server
+// reporting the results of these exec commands --> not needed to 
+// send Generic Alert anymore in next DM session.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::MarkGenericAlertsSentL()
+    {
+    
+    FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL >>"));
+    
+    // search for fw objects that have empty final result
+    RNSmlDmFwObjectArray ids;
+    CleanupClosePushL( ids );
+    
+    // get information of the remote DM server
+    TSmlProfileId profId = 0;
+    HBufC8* serverId = NULL;
+    GetServerInfoL( profId, serverId );
+    CleanupStack::PushL( serverId );
+    
+    FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL 1"));
+    iFotaDb->GetEmptyFinalResultsL( ids, *serverId );
+    
+    // go through all objects in ids
+    for ( TInt i = 0; i < ids.Count(); ++i )
+        {
+        // check that update has reached its final result
+    FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL 2"));
+        TInt finalResult = FotaEngineL().GetResult( ids[i] );
+        if ( finalResult != KErrNotFound )
+            {
+            // set final result thus setting generic alert sent
+        FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL 3"));
+            iFotaDb->SetFinalResultL( finalResult, ids[i] );
+            
+            // also notify fota engine, that generic alert has been
+            // successfully sent, thus enabling possible cleanup
+            FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL, %d"), ids[i]);
+            FotaEngineL().GenericAlertSentL( ids[i] );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( serverId );
+    CleanupStack::PopAndDestroy( &ids );
+    FLOG(_L("CNSmlDmFotaAdapter::MarkGenericAlertsSentL <<"));
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::GetMetaType()
+// Determines by the given uri which meta/type should be used in generic 
+// alert.Returns the correct type, or KNullDesC8 if uri does not match to 
+// exec targets.
+// ---------------------------------------------------------------------------
+//
+TPtrC8 CNSmlDmFotaAdapter::GetMetaType( const TDesC8& aURI ) const
+    {
+    TPtrC8 lastSeg = LastURISeg( aURI );
+    
+    if ( lastSeg == KNSmlDMFotaNodeDownload )
+        {
+        return KNSmlDMFotaDownloadMetaType();
+        }
+    else if ( lastSeg == KNSmlDMFotaNodeDownloadAndUpdate )
+        {
+        return KNSmlDMFotaDownloadAndUpdateMetaType();
+        }
+
+    return KNullDesC8();
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::MapStatusToError()
+// Returns a status code corresponding to the system error code given 
+// as parameter.
+// ---------------------------------------------------------------------------
+//
+CSmlDmAdapter::TError CNSmlDmFotaAdapter::MapErrorToStatus( TInt aError ) const
+    {
+    CSmlDmAdapter::TError err = CSmlDmAdapter::EError;
+    
+    switch( aError )
+        {
+        case KErrNone:
+            err = CSmlDmAdapter::EOk;
+            break;
+        case KErrNotFound:
+            err = CSmlDmAdapter::ENotFound;
+            break;
+        case KErrDiskFull:
+            err = CSmlDmAdapter::EDiskFull;
+            break;
+        case KErrOverflow:
+            err = CSmlDmAdapter::ETooLargeObject;
+            break;
+        default:
+            break;
+        }
+    
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::DesToInt()
+// Converts a 8 bit descriptor to an integer.
+// ---------------------------------------------------------------------------
+//
+TInt CNSmlDmFotaAdapter::DesToInt( const TDesC8& aLUID ) const
+    {
+    TLex8 lex( aLUID );
+    TInt value = KErrNotFound;
+    lex.Val( value );
+    
+    return value;
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::LastURISeg()
+// Returns the last segment of the given uri.
+// ---------------------------------------------------------------------------
+//
+TPtrC8 CNSmlDmFotaAdapter::LastURISeg( const TDesC8& aURI ) const
+    {
+    TInt pos = aURI.LocateReverse( KNSmlDMFotaSeparatorDes()[0] );
+    if( pos == KErrNotFound )
+        {
+        return aURI;
+        }
+    else
+        {
+        return aURI.Mid( pos + 1 );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CNSmlDmFotaAdapter::FillNodeInfoL()
+// Fills the DDF node info.
+// ---------------------------------------------------------------------------
+//
+void CNSmlDmFotaAdapter::FillNodeInfoL( MSmlDmDDFObject& aNode, 
+                                        const TSmlDmAccessTypes& aAccTypes, 
+                                        MSmlDmDDFObject::TOccurence aOccurrence, 
+                                        MSmlDmDDFObject::TScope aScope, 
+                                        MSmlDmDDFObject::TDFFormat aFormat, 
+                                        const TDesC8& aDescription ) const
+    {
+    aNode.SetAccessTypesL( aAccTypes );
+    aNode.SetOccurenceL( aOccurrence );
+    aNode.SetScopeL( aScope );
+    aNode.SetDFFormatL( aFormat );
+    
+    if( aFormat != MSmlDmDDFObject::ENode )
+        {
+        aNode.AddDFTypeMimeTypeL( KNSmlDMFotaTextPlain );
+        }
+    
+    aNode.SetDescriptionL( aDescription );
+    }
+
+RFotaEngineSession& CNSmlDmFotaAdapter::FotaEngineL()
+    {
+    FLOG(_L("CNSmlDmFotaAdapter::FotaEngineL >>"));
+    if (!iFotaEngine.Handle())
+        {
+        FLOG(_L("Opening fota engine..."));
+        iFotaEngine.OpenL();
+        }
+    
+    FLOG(_L("CNSmlDmFotaAdapter::FotaEngineL <<"));
+    return iFotaEngine;
+    }
+// ---------------------------------------------------------------------------
+// TImplementationProxy ImplementationTable[]
+// Needed because of ECOM architecture.
+// ---------------------------------------------------------------------------
+//
+#ifndef IMPLEMENTATION_PROXY_ENTRY
+#define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr)  {{aUid},(aFuncPtr)}
+#endif
+
+const TImplementationProxy ImplementationTable[] = 
+    {
+    IMPLEMENTATION_PROXY_ENTRY(KNSmlDMFotaAdapterImplUid, CNSmlDmFotaAdapter::NewL)
+    };
+
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// ---------------------------------------------------------------------------
+// ImplementationGroupProxy()
+// Needed because of ECOM architecture.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    _DBG_FILE("ImplementationGroupProxy() for CNSmlDmFotaAdapter: begin");
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+    _DBG_FILE("ImplementationGroupProxy() for CNSmlDmFotaAdapter: end");
+    return ImplementationTable;
+    }
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/fota/src/nsmldmfotaadapter.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,46 @@
+CHARACTER_SET UTF8/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Resource data for Fota adapter
+*
+*/
+
+
+
+
+
+#include <registryinfo.rh>
+#include "nsmldmconstants.h"
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x101F9A08; //The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = KNSmlDMInterfaceUid; // DM interface UID
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x101F9A09; // DM FOTA implementation UID
+                version_no = 1; 
+                display_name = "";
+                default_data = "";
+                opaque_data = "";
+                }
+            };
+          }
+      };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/fota/src/nsmldmfotaadapterdb.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,881 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Fota adapter's DB implementation file
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+#include <sysutil.h>
+#include <bautils.h>
+
+#include "nsmldmfotaadapterdb.h"
+#include "nsmlconstants.h"
+#include "nsmldebug.h"
+
+#ifndef __WINS__
+                                    // This lowers the unnecessary compiler warning (armv5) to remark.
+                                    // "Warning: #174-D: expression has no effect..." is caused by 
+                                    // DBG_ARGS8 macro in no-debug builds.
+#pragma diag_remark 174
+#endif
+
+// ============================ MEMBER FUNCTIONS =============================
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::NewL()
+//  Creates a new instance of CNSmlDmFotaAdapterDb object.
+// ---------------------------------------------------------------------------
+// 
+CNSmlDmFotaAdapterDb* CNSmlDmFotaAdapterDb::NewL()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::NewL(): begin");
+    
+    CNSmlDmFotaAdapterDb* self = CNSmlDmFotaAdapterDb::NewLC(); 
+    CleanupStack::Pop( self );
+
+    _DBG_FILE("CNSmlDmFotaAdapterDb::NewL(): end");
+    
+    return self;
+    }   
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::NewLC()
+//  Creates a new instance of CNSmlDmFotaAdapterDb object. 
+//  Pushes and leaves new instance onto CleanupStack.
+// ---------------------------------------------------------------------------
+// 
+CNSmlDmFotaAdapterDb* CNSmlDmFotaAdapterDb::NewLC()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::NewLC(): begin");
+    
+    CNSmlDmFotaAdapterDb* self = new( ELeave ) CNSmlDmFotaAdapterDb();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::NewLC(): end");
+    
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::ConstructL()
+//  Second phase constructor.
+// ---------------------------------------------------------------------------
+// 
+void CNSmlDmFotaAdapterDb::ConstructL()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::ConstructL(): begin");
+    
+    User::LeaveIfError( iFsSession.Connect() );
+    User::LeaveIfError( iRdbSession.Connect() );
+    iFsSession.SetSessionToPrivate( KNSmlFotaAdapterDbDrive );
+
+    TParse name;
+
+#ifdef SYMBIAN_SECURE_DBMS
+	name.Set( KNSmlFotaAdapterDbName(), NULL, NULL );
+#else
+    name.Set( KNSmlFotaAdapterDbName(), KNSmlDatabasesNonSecurePath, NULL );
+#endif
+
+	TInt err = iDatabase.Open( iRdbSession,
+	                           name.FullName(),
+	                           KNSmlDBMSSecureMDHostOneID );
+    if ( err == KErrNotFound )
+        {
+        CreateDatabaseL( name.FullName() );
+        err = iDatabase.Open( iRdbSession,
+                              name.FullName(),
+                              KNSmlDBMSSecureMDHostOneID );
+        User::LeaveIfError( err );
+        }
+    else
+        {
+        
+        if ( ( err == KErrEof ) || ( err == KErrCorrupt ) || 
+             ( err == KErrArgument ) )
+            {
+            // something seriously wrong with the db, delete it and try 
+            // to create new
+            iRdbSession.DeleteDatabase( name.FullName(),
+                                        KNSmlDMHostOnePolicyUID );
+            CreateDatabaseL( name.FullName() );
+            err = iDatabase.Open( iRdbSession,
+                                  name.FullName(),
+                                  KNSmlDBMSSecureMDHostOneID );
+            }
+        
+        User::LeaveIfError( err );
+        }
+
+    User::LeaveIfError( iFwObjectTable.Open( iDatabase,
+                                             KNSmlTableFwMgmtObject ) );
+    iColSet = iFwObjectTable.ColSetL();
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::ConstructL(): end");
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::CNSmlDmFotaAdapterDb()
+//  Constructor.
+// ---------------------------------------------------------------------------
+// 
+CNSmlDmFotaAdapterDb::CNSmlDmFotaAdapterDb()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::CNSmlDmFotaAdapterDb(): begin");
+    _DBG_FILE("CNSmlDmFotaAdapterDb::CNSmlDmFotaAdapterDb(): end");
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::~CNSmlDmFotaAdapterDb()
+//  Destructor.
+// ---------------------------------------------------------------------------
+// 
+CNSmlDmFotaAdapterDb::~CNSmlDmFotaAdapterDb()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::~CNSmlDmFotaAdapterDb(): begin");
+
+    iView.Close();
+    
+    delete iColSet;
+    iFwObjectTable.Close();
+        
+    iDatabase.Close();
+    iFsSession.Close();
+    iRdbSession.Close();
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::~CNSmlDmFotaAdapterDb(): ends");
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::AddFwObjectL()
+//  Inserts new uninitialized row to FwMgmtObject table and returns its id.
+// ---------------------------------------------------------------------------
+// 
+TNSmlDmFwObjectId CNSmlDmFotaAdapterDb::AddFwObjectL()
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::AddFwObjectL(): begin");
+    
+    // Check OOD before inserting new row into FwMgmtObject table
+    if ( SysUtil::FFSSpaceBelowCriticalLevelL( &iFsSession, 
+                                               KNSmlMaxFwMgmtObjectRowSize ) )
+        {
+        User::Leave( KErrDiskFull );
+        }
+    
+    iDatabase.Begin();
+    
+    // Insert new row, and set finalt result to its null value
+    iFwObjectTable.InsertL();
+    iFwObjectTable.SetColL( iColSet->ColNo( KNSmlFwMgmtObjectResult ), 
+                            KNSmlFotaNullResult );
+    iFwObjectTable.PutL();
+    
+    CommitAndCompact();
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::AddFwObjectL(): end");
+    
+    return iFwObjectTable.ColUint( iColSet->ColNo( KNSmlFwMgmtObjectId ) );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::DeleteFwObjectL()
+//  Deletes a row from FwMgmtObject table identified by aId. If such row is 
+//  not found, returns KErrNotFound, KErrNone otherwise.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::DeleteFwObjectL( const TNSmlDmFwObjectId aId )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::DeleteFwObjectL(): begin");
+    
+    HBufC* sql = HBufC::NewL( KNSmlDeleteFwMgmtObject().Length() + 
+                              KNSmlFwMgmtObjectIntegerLength );
+    sql->Des().Format( KNSmlDeleteFwMgmtObject, aId );
+    
+    iDatabase.Begin();
+    TInt result = iDatabase.Execute( *sql );
+    CommitAndCompact();
+    
+    delete sql;
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::DeleteFwObjectL(): end");
+    
+    return ( result == 0 ) ? KErrNotFound : KErrNone;
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::GetEmptyFinalResultsL()
+//  Finds all the rows in FwMgmtObject table that have null final result and
+//  puts the PkgIds of those rows to aArray.
+// ---------------------------------------------------------------------------
+// 
+void CNSmlDmFotaAdapterDb::GetEmptyFinalResultsL( RNSmlDmFwObjectArray& aArray )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::GetEmptyFinalResultsL(): begin");
+    
+    aArray.Reset();
+    
+    HBufC* sql = HBufC::NewLC( KNSmlGetUnfinishedFwMgmtObjects().Length() + 
+                               KNSmlFwMgmtObjectIntLength );
+    sql->Des().Format( KNSmlGetUnfinishedFwMgmtObjects, KNSmlFotaNullResult );
+    
+    PrepareViewL( *sql, iView.EReadOnly );
+
+    CleanupStack::PopAndDestroy( sql );
+    
+    while ( iView.NextL() )
+        {
+        // get final result and append it to aArray
+        iView.GetL();
+        aArray.AppendL( iView.ColUint( 
+                        iColSet->ColNo( KNSmlFwMgmtObjectId ) ) );
+        }
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::GetEmptyFinalResultsL(): end");
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::GetEmptyFinalResultsL()
+//  Finds all the rows in FwMgmtObject table that have null final result, 
+//  server id equals to aServerId and management uri is not an empty string.
+//  Puts the PkgIds of those rows to aArray.
+// ---------------------------------------------------------------------------
+// 
+void CNSmlDmFotaAdapterDb::GetEmptyFinalResultsL( RNSmlDmFwObjectArray& aArray, 
+                                                  const TDesC8& aServerId )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::GetEmptyFinalResultsL(serverid): begin");
+    
+    aArray.Reset();
+    
+    HBufC* serverId = ConvertTo16BitLC( aServerId );
+    
+    HBufC* sql = HBufC::NewLC( 
+                        KNSmlGetUnfinishedFwMgmtObjectByServerId().Length() + 
+                        KNSmlFwMgmtObjectIntLength + 
+                        serverId->Length() );
+    
+    sql->Des().Format( KNSmlGetUnfinishedFwMgmtObjectByServerId, 
+                       KNSmlFotaNullResult, 
+                       serverId );
+    
+    PrepareViewL( *sql, iView.EReadOnly );
+
+    CleanupStack::PopAndDestroy( sql );
+    CleanupStack::PopAndDestroy( serverId );
+    
+    while ( iView.NextL() )
+        {
+        // get final result and append it to aArray
+        iView.GetL();
+        aArray.AppendL( iView.ColUint( 
+                        iColSet->ColNo( KNSmlFwMgmtObjectId ) ) );
+        }
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::GetEmptyFinalResultsL( serverid ): end");
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::PkgNameL()
+//  Returns the PkgName field from FW object identified by aId. If no such 
+//  object is found, returns NULL.
+// ---------------------------------------------------------------------------
+// 
+HBufC8* CNSmlDmFotaAdapterDb::PkgNameL( const TNSmlDmFwObjectId aId )
+    {
+    return StrValueL( KNSmlFwMgmtObjectName, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::PkgVersionL()
+//  Returns the PkgVersion field from FW object identified by aId. If no such 
+//  object is found, returns NULL.
+// ---------------------------------------------------------------------------
+// 
+HBufC8* CNSmlDmFotaAdapterDb::PkgVersionL( const TNSmlDmFwObjectId aId )
+    {
+    return StrValueL( KNSmlFwMgmtObjectVersion, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::PkgUrlL()
+//  Returns the PkgUrl field from FW object identified by aId. If no such 
+//  object is found, returns NULL.
+// ---------------------------------------------------------------------------
+// 
+HBufC8* CNSmlDmFotaAdapterDb::PkgUrlL( const TNSmlDmFwObjectId aId )
+    {
+    return LongStrValueL( KNSmlFwMgmtObjectUrl, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::MgmtUriL()
+//  Returns the MgmtUri field from FW object identified by aId. If no such 
+//  object is found, returns NULL.
+// ---------------------------------------------------------------------------
+// 
+HBufC8* CNSmlDmFotaAdapterDb::MgmtUriL( const TNSmlDmFwObjectId aId )
+    {
+    return StrValueL( KNSmlFwMgmtObjectMgmtUri, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::ProfileIdL()
+//  Returns the ProfileId field from FW object identified by aId. If no such 
+//  object is found, returns KErrNotFound.
+// ---------------------------------------------------------------------------
+// 
+TSmlProfileId CNSmlDmFotaAdapterDb::ProfileIdL( const TNSmlDmFwObjectId aId )
+    {
+    return IntValueL( KNSmlFwMgmtObjectProfileId, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::ServerIdL()
+//  Returns the ServerId field from FW object identified by aId. If no such 
+//  object is found, returns NULL.
+// ---------------------------------------------------------------------------
+// 
+HBufC8* CNSmlDmFotaAdapterDb::ServerIdL( const TNSmlDmFwObjectId aId )
+    {
+    return StrValueL( KNSmlFwMgmtObjectServerId, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::FinalResultL()
+//  Returns the FinalResult field from FW object identified by aId. If no such 
+//  object is found, returns KErrNotFound.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::FinalResultL( const TNSmlDmFwObjectId aId )
+    {
+    return IntValueL( KNSmlFwMgmtObjectResult, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::CorrelatorL()
+//  Returns the Correlator field from FW object identified by aId. If no such 
+//  object is found, returns NULL.
+// ---------------------------------------------------------------------------
+// 
+HBufC8* CNSmlDmFotaAdapterDb::CorrelatorL( const TNSmlDmFwObjectId aId )
+    {
+    return StrValueL( KNSmlFwMgmtObjectCorrelator, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::SetPkgNameL()
+//  Sets aName as the value of PkgName in FW object identified by aId. If no 
+//  such object is found, returns KErrNotFound. If name is too large for the 
+//  database, returns KErrOverflow.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::SetPkgNameL( const TDesC8& aName, 
+                                        const TNSmlDmFwObjectId aId )
+    {
+    if ( aName.Length() > KFotaMaxPkgNameLength )
+        {
+        return KErrOverflow;
+        }
+    
+    return SetStrValueL( KNSmlFwMgmtObjectName, aName, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::SetPkgVersionL()
+//  Sets aVersion as the value of PkgVersion in FW object identified by aId.
+//  If no such object is found, returns KErrNotFound. If version is too 
+//  large for the database, returns KErrOverflow.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::SetPkgVersionL( const TDesC8& aVersion, 
+                                           const TNSmlDmFwObjectId aId )
+    {
+    if ( aVersion.Length() > KFotaMaxPkgVersionLength )
+        {
+        return KErrOverflow;
+        }
+    
+    return SetStrValueL( KNSmlFwMgmtObjectVersion, aVersion, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::SetPkgUrlL()
+//  Sets aUrl as the value of PkgURL in FW object identified by aId. If no 
+//  such object is found, returns KErrNotFound. If url is too large for the 
+//  database, returns KErrOverflow.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::SetPkgUrlL( const TDesC8& aUrl, 
+                                       const TNSmlDmFwObjectId aId )
+    {
+    if ( aUrl.Length() > KFotaMaxPkgURLLength )
+        {
+        return KErrOverflow;
+        }
+    
+    return SetLongStrValueL( KNSmlFwMgmtObjectUrl, aUrl, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::SetMgmtUriL()
+//  Sets aUri as the value of MgmtURI in FW object identified by aId. If no 
+//  such object is found, returns KErrNotFound. If uri is too large for the 
+//  database, returns KErrOverflow.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::SetMgmtUriL( const TDesC8& aUri, 
+                                        const TNSmlDmFwObjectId aId )
+    {
+    if ( aUri.Length() > KNSmlMaxMgmtUriLength )
+        {
+        return KErrOverflow;
+        }
+    
+    return SetStrValueL( KNSmlFwMgmtObjectMgmtUri, aUri, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::SetServerInfoL()
+//  Sets aProfileId as the value of ProfileId and aServerId as the value of 
+//  ServerId in FW object identified by aId. If no such object is found, 
+//  returns KErrNotFound. If server id is too large for the database, 
+//  returns KErrOverflow.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::SetServerInfoL( const TSmlProfileId aProfile, 
+                                           const TDesC8& aServerId, 
+                                           const TNSmlDmFwObjectId aId )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::SetServerInfoL(): begin");
+    
+    if ( aServerId.Length() > KNSmlMaxServerIdLength )
+        {
+        return KErrOverflow;
+        }
+    
+    HBufC* serverId = ConvertTo16BitLC( aServerId );
+    TInt ret = UpdateRowL( aId );
+    
+    if ( ret == KErrNone )
+        {
+        // do update
+        iView.SetColL( iColSet->ColNo( KNSmlFwMgmtObjectProfileId ), 
+                       aProfile );
+        iView.SetColL( iColSet->ColNo( KNSmlFwMgmtObjectServerId ), 
+                       *serverId );
+        iView.PutL();
+        }
+    
+    CommitAndCompact();
+    
+    CleanupStack::PopAndDestroy( serverId );
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::SetServerInfoL(): end");
+    
+    return ret;
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::SetFinalResultL()
+//  Sets aResult as the value of FinalResult in FW object identified by aId.
+//  If no such object is found, returns KErrNotFound.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::SetFinalResultL( const TInt aResult, 
+                                            const TNSmlDmFwObjectId aId )
+    {
+    return SetIntValueL( KNSmlFwMgmtObjectResult, aResult, aId );
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::SetCorrelatorL()
+//  Sets aCorrealtor as the value of Correlator in FW object identified by aId.
+//  If no such object is found, returns KErrNotFound. If given correlator is 
+//  too large for the database, returns KErrOverflow.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::SetCorrelatorL( const TDesC8& aCorrelator, 
+                                           const TNSmlDmFwObjectId aId )
+    {
+    if ( aCorrelator.Length() > KNSmlMaxCorrelatorLength )
+        {
+        return KErrOverflow;
+        }
+    
+    return SetStrValueL( KNSmlFwMgmtObjectCorrelator, aCorrelator, aId );
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::CreateDatabaseL()
+//  Creates Fota database.
+// ---------------------------------------------------------------------------
+// 
+void CNSmlDmFotaAdapterDb::CreateDatabaseL( const TDesC& aFullName )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::CreateDatabaseL(): begin");
+
+    // Check OOD before creating new Fota DB
+    if ( SysUtil::FFSSpaceBelowCriticalLevelL( &iFsSession, 
+                                               KNSmlFotaAdapterEmptyDbSize ) )
+        {
+        User::Leave( KErrDiskFull );
+        }
+
+    // create sql query string, 5 = amount of length integers used in Format()
+    HBufC* createFwMgmtTable = HBufC::NewLC( 
+                                    KNSmlCreateFwMgmtObjectTable().Length() + 
+                                    KNSmlFwMgmtObjectIntLength*5 );
+    
+    createFwMgmtTable->Des().Format( KNSmlCreateFwMgmtObjectTable, 
+                                     KFotaMaxPkgNameLength,
+                                     KFotaMaxPkgVersionLength,
+                                     KNSmlMaxMgmtUriLength,
+                                     KNSmlMaxServerIdLength,
+                                     KNSmlMaxCorrelatorLength );
+
+    User::LeaveIfError( iDatabase.Create( iRdbSession,
+	                                      aFullName,
+	                                      KNSmlDBMSSecureMDHostOneID ) );
+    iDatabase.Begin();
+    iDatabase.Execute( *createFwMgmtTable );
+
+    CommitAndCompact();
+    iDatabase.Close();
+    
+    CleanupStack::PopAndDestroy( createFwMgmtTable );
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::CreateDatabaseL(): end");
+    }   
+
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::SetStrValueL()
+//  Sets aValue as the value of aColumn in FW object identified by aObject.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::SetStrValueL( const TDesC& aColumn, 
+                                         const TDesC8& aValue,
+                                         const TNSmlDmFwObjectId aObject )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::SetStrValueL(): begin");
+    
+    HBufC* value = ConvertTo16BitLC( aValue );
+    
+    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::SetStrValueL(): ('%S', '%S', %d)"), 
+              &aColumn, value, aObject );
+    
+    TInt ret = UpdateRowL( aObject );
+    
+    if ( ret == KErrNone )
+        {
+        // do update
+        iView.SetColL( iColSet->ColNo( aColumn ), *value );
+        iView.PutL();
+        }
+    
+    CommitAndCompact();
+    
+    CleanupStack::PopAndDestroy( value );
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::SetStrValueL(): end");
+    
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::SetLongStrValueL()
+//  Streams aValue and its length as the value of aColumn in FW object 
+//  identified by aObject.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::SetLongStrValueL( const TDesC& aColumn, 
+                                             const TDesC8& aValue, 
+                                             const TNSmlDmFwObjectId aObject )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::SetLongStrValueL(): begin");
+    
+    HBufC* value = ConvertTo16BitLC( aValue );
+    
+    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::SetStrValueL(): ('%S', '%S', %d)"),
+              &aColumn, value, aObject );
+    
+    TInt ret = UpdateRowL( aObject );
+    
+    if ( ret == KErrNone )
+        {
+        // do update
+        
+        RDbColWriteStream wStream;
+        wStream.OpenL( iView, iColSet->ColNo( aColumn ) );
+        CleanupClosePushL( wStream );
+        
+        wStream.WriteInt32L( value->Length() );
+        wStream.WriteL( *value, value->Length() );
+        
+        CleanupStack::PopAndDestroy( &wStream );
+        
+        iView.PutL();
+        }
+    
+    CommitAndCompact();
+    
+    CleanupStack::PopAndDestroy( value );
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::SetLongStrValueL(): end");
+    
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::SetIntValueL()
+//  Sets aValue as the value of aColumn in FW object identified by aObject.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::SetIntValueL( const TDesC& aColumn, 
+                                         const TInt aValue, 
+                                         const TNSmlDmFwObjectId aObject )
+    {
+    _DBG_FILE("CNSmlDmFotaAdapterDb::SetIntValueL(): begin");
+    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::SetIntValueL(): ('%S', %d, %d)"), 
+              &aColumn, aValue, aObject );
+    
+    TInt ret = UpdateRowL( aObject );
+    
+    if ( ret == KErrNone )
+        {
+        // do update
+        iView.SetColL( iColSet->ColNo( aColumn ), aValue );
+        iView.PutL();
+        }
+    
+    CommitAndCompact();
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::SetIntValueL(): end");
+    
+    return ret;
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::UpdateRowL()
+//  Prepares iView when setting a value to one of the rows in DB table. 
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::UpdateRowL( const TNSmlDmFwObjectId aObject )
+    {
+    TInt ret = KErrNone;
+    
+    HBufC* sql = FwMgmtObjectRowSqlLC( aObject );
+    PrepareViewL( *sql, iView.EUpdatable );
+    iDatabase.Begin();
+
+    CleanupStack::PopAndDestroy( sql );
+    
+    if ( iView.FirstL() )
+        {
+        // fw object exists
+        // Get current row for accessing and initiate update
+        iView.GetL();
+        iView.UpdateL();
+        }
+    else
+        {
+        // fw object does not exists, cannot update
+        ret = KErrNotFound;
+        }
+    
+    return ret;
+    }
+    
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::StrValueL()
+//  Returns the value in FW object identified by aObject in column aColumn.
+// ---------------------------------------------------------------------------
+// 
+HBufC8* CNSmlDmFotaAdapterDb::StrValueL( const TDesC& aColumn, 
+                                         const TNSmlDmFwObjectId aObject )
+    {
+    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::StrValueL('%S', %d): begin"), 
+              &aColumn, aObject );
+    
+    HBufC8* value = NULL;
+    
+    FetchRowL( aObject );
+    
+    if ( iView.FirstL() )
+        {
+        // get value
+        iView.GetL();
+        TPtrC res = iView.ColDes( iColSet->ColNo( aColumn ) );
+        
+        // convert to 8-bit
+        value = HBufC8::NewL( res.Length() );
+        value->Des().Copy( res );
+        }
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::StrValueL(): end");
+    
+    return value;
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::LongStrValueL()
+//  Returns the value in FW object identified by aObject in column aColumn.
+// ---------------------------------------------------------------------------
+// 
+HBufC8* CNSmlDmFotaAdapterDb::LongStrValueL( const TDesC& aColumn, 
+                                             const TNSmlDmFwObjectId aObject )
+    {
+    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::LongStrValueL('%S', %d): begin"), 
+              &aColumn, aObject );
+    
+    HBufC8* value = NULL;
+    
+    FetchRowL( aObject );
+    
+    if ( iView.FirstL() )
+        {
+        // get value
+        iView.GetL();
+        
+        RDbColReadStream rStream;
+        rStream.OpenL( iView, iColSet->ColNo( aColumn ) );
+        CleanupClosePushL( rStream );
+        
+        TInt length = 0;
+        TRAPD( err, length = rStream.ReadInt32L() );
+        
+        HBufC* buf = HBufC::NewLC( length );
+        TPtr bufPtr = buf->Des();
+        
+        if ( err == KErrNone )
+            {
+            rStream.ReadL( bufPtr, length );
+            }
+        
+        // convert to 8-bit
+        value = HBufC8::NewL( bufPtr.Length() );
+        value->Des().Copy( bufPtr );
+        
+        CleanupStack::PopAndDestroy( buf );
+        CleanupStack::PopAndDestroy( &rStream );
+        }
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::LongStrValueL(): end");
+    
+    return value;
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::IntValueL()
+//  Returns the value in FW object identified by aObject in column aColumn.
+// ---------------------------------------------------------------------------
+// 
+TInt CNSmlDmFotaAdapterDb::IntValueL( const TDesC& aColumn,
+                                      const TNSmlDmFwObjectId aObject )
+    {
+    DBG_ARGS( _S16("CNSmlDmFotaAdapterDb::IntValueL('%S', %d): begin"), 
+              &aColumn, aObject );
+    
+    TInt value = KErrNotFound;
+    
+    FetchRowL( aObject );
+    
+    if ( iView.FirstL() )
+        {
+        iView.GetL();
+        value = iView.ColInt( iColSet->ColNo( aColumn ) );
+        }
+    
+    _DBG_FILE("CNSmlDmFotaAdapterDb::IntValueL(): end");
+    
+    return value;
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::FetchRowL()
+//  Prepares iView when getting a single row from DB.
+// ---------------------------------------------------------------------------
+// 
+void CNSmlDmFotaAdapterDb::FetchRowL( const TNSmlDmFwObjectId aObject )
+    {
+    HBufC* sql = FwMgmtObjectRowSqlLC( aObject );
+    
+    PrepareViewL( *sql, iView.EReadOnly );
+
+    CleanupStack::PopAndDestroy( sql );
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::FwMgmtObjectRowSqlLC()
+//  Returns a buffer containing formatted SQL statement for getting a FW object 
+//  identified by aId.
+// ---------------------------------------------------------------------------
+// 
+HBufC* CNSmlDmFotaAdapterDb::FwMgmtObjectRowSqlLC( TNSmlDmFwObjectId aId ) const
+    {
+    HBufC* sql = HBufC::NewLC( KNSmlGetFwMgmtObject().Length() + 
+                               KNSmlFwMgmtObjectIntegerLength );
+    
+    TPtr sqlPtr = sql->Des();
+    sqlPtr.Format( KNSmlGetFwMgmtObject, aId );
+    return sql;
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::PrepareViewL()
+//  Closes and prepares the view
+// ---------------------------------------------------------------------------
+// 
+void CNSmlDmFotaAdapterDb::PrepareViewL( const TDesC& aSql, 
+                                         RDbRowSet::TAccess aAccess )
+    {
+    iView.Close();
+    User::LeaveIfError( iView.Prepare( iDatabase, TDbQuery(aSql), aAccess ) );
+    
+    if ( iView.Unevaluated() )
+        {
+        User::LeaveIfError( iView.EvaluateAll() );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::CommitAndCompact()
+//  Commits update and compacts the database
+// ---------------------------------------------------------------------------
+// 
+void CNSmlDmFotaAdapterDb::CommitAndCompact() 
+    {
+    iDatabase.Commit();
+    iDatabase.Compact();
+    }
+
+// ---------------------------------------------------------------------------
+//  CNSmlDmFotaAdapterDb::ConvertTo16BitLC()
+//  Returns a pointer to a unicode copy of the given 8-bit descriptor.
+//  The pointer to the copy is allocated from heap and pushed on the 
+//  CleanupStack.
+// ---------------------------------------------------------------------------
+// 
+HBufC* CNSmlDmFotaAdapterDb::ConvertTo16BitLC( const TDesC8& aDes ) const
+    {
+    HBufC* buf = HBufC::NewLC( aDes.Length() );
+    buf->Des().Copy( aDes );
+    
+    return buf;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldminternet/group/bld.inf	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,30 @@
+/*
+* 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:   build info file for internet settings adapter
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+./nsmlinternetadapter.mmp
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldminternet/group/nsmlinternetadapter.mmp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2004-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:   InternetAdapter 
+*
+*/
+
+
+
+#include "defaultcaps.hrh"
+#include  <platform_paths.hrh>
+
+CAPABILITY      CAP_ECOM_PLUGIN
+TARGET	      	nsmlinternetadapter.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x101F6DEA
+VENDORID        VID_DEFAULT
+
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE 	/epoc32/include/ecom 
+
+SOURCEPATH      ../src
+USERINCLUDE     ../inc
+
+SOURCE          NSmlInternetAdapter.cpp
+
+SOURCE		NSmlWLanAdapter.cpp
+SOURCE		NSmlWlanSettings.cpp
+
+START RESOURCE	NSmlInternetAdapter.rss
+END
+
+LANG	sc
+
+LIBRARY		charconv.lib commdb.lib efsrv.lib ecom.lib euser.lib nsmldmclientserverutils.lib
+LIBRARY		nsmldebug.lib sysutil.lib
+LIBRARY		inetprotutil.lib
+LIBRARY 	commsdat.lib
+LIBRARY 	cmmanager.lib
+LIBRARY 	cmmanagerdatabase.lib
+LIBRARY 	centralrepository.lib FeatMgr.lib
+LIBRARY		policyengine.lib
+LIBRARY		nsmldmtreedbclient.lib
+LIBRARY		eaptools.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldminternet/inc/NSmlInternetAdapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,533 @@
+/*
+ * 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:   Internet-settings 
+ *
+ */
+
+#ifndef __NSMLINTERNETADAPTER_H__
+#define __NSMLINTERNETADAPTER_H__
+
+// SyncML device management LoginScript
+//#define __SYNCML_DM_LSCRIPT 1
+//#define __SYNCML_DM_WLAN 1
+// ------------------------------------------------------------------------------------------------
+// Includes
+// ------------------------------------------------------------------------------------------------
+#include <utf.h>
+#include <bldvariant.hrh>
+#include <commdb.h>
+#include <metadatabase.h>
+#include "smldmadapter.h"
+#include "nsmlconstants.h"
+
+#include "NSmlWLanAdapter.h"
+#include "NSmlWlanSettings.h"
+
+const TInt KNSmlInternetAdapterFatMinSize = 512;
+const TInt KNSmlIncompleteAP = -1;
+// Buffering Stuff
+const TInt KNSmlAPGranularity = 4;
+const TUint8 KNSmlDMUriSeparator = 0x2f;
+
+const TUint8 KNSmlDMDot = 0x2e;
+const TUint8 KNSmlDMAsciiIntStart = 0x30;
+const TUint8 KNSmlDMAsciiIntEnd = 0x39;
+// Other constants
+const TInt KNSmlApDnsLuidUpperBase = 300000;
+const TInt KNSmlAp3gpppsLowerBase = 50000;
+const TInt KNSmlApProxyLowerBase = 100000;
+const TInt KNSmlApProxyUpperBase = 200000;
+const TInt KNSmlApWapLowerBase = 9200;
+const TInt KNSmlApWapUpperBase = 9203;
+
+//DDF version number
+_LIT8( KNSmlInternetAdapterDDFversion, "1.1");
+
+//DDF accepted AP-fieldnames
+_LIT8( KNSmlDdfAP, "AP" );
+
+_LIT8( KNSmlDdfPx, "Px" );
+_LIT8( KNSmlDdfPxName, "Name" );
+_LIT8( KNSmlDdfPxId, "PxID" );
+_LIT8( KNSmlDdfPxPW, "PxPW" );
+_LIT8( KNSmlDdfPPGAuthTy, "PPGAuthTy" );
+_LIT8( KNSmlDdfDomain, "Domain" );
+_LIT8( KNSmlDdfDomainL, "DomainL" );
+_LIT8( KNSmlDdfPxAddr, "PxAddr" );
+_LIT8( KNSmlDdfToNAPID, "ToNAPID" );
+_LIT8( KNSmlDdfToNAPIDL, "ToNAPIDL" );
+_LIT8( KNSmlDdfStartpg, "Startpg" );
+_LIT8( KNSmlDdfBasAuthId, "BasAuthId" );
+_LIT8( KNSmlDdfBasAuthPW, "BasAuthPW" );
+_LIT8( KNSmlDdfPort, "Port" );
+_LIT8( KNSmlDdfPortNbr, "PortNbr" );
+_LIT8( KNSmlDdfPxAuthTy, "PxAuthTy" );
+_LIT8( KNSmlDdfService, "Service" );
+_LIT8( KNSmlDdfServiceL, "ServiceL" );
+_LIT8( KNSmlDdfUsePTxtLog, "UsePTxtLog" );
+
+_LIT8( KNSmlDdfGPRSPDP, "GPRSPDP" );
+_LIT8( KNSmlDdfDefGW, "DefGW" );
+_LIT8( KNSmlDdfNetworkMask, "NetworkMask" );
+
+_LIT8( KNSmlDdfPPPComp, "PPPComp" );
+
+_LIT8( KNSmlDdfNAPDef, "NAPDef" );
+_LIT8( KNSmlDdfNAPName, "Name" );
+_LIT8( KNSmlDdfNAPLinger, "Linger" );
+_LIT8( KNSmlDdfNAPID, "NAPID" );
+_LIT8( KNSmlDdfBearer, "Bearer" );
+_LIT8( KNSmlDdfBearerL, "BearerL" );
+_LIT8( KNSmlDdfDirection, "Direction" );
+_LIT8( KNSmlDdfInternet, "Internet" );
+_LIT8( KNSmlDdfNAPAddr, "NAPAddr" );
+_LIT8( KNSmlDdfNAPAddrTy, "NAPAddrTy" );
+_LIT8( KNSmlDdfDNSAddr, "DNSAddr" );
+_LIT8( KNSmlDdfDNSAddrL, "DNSAddrL" );
+_LIT8( KNSmlDdfDNSAddrTy, "DNSAddrTy" );
+_LIT8( KNSmlDdfDNSPriority, "DNSPriority" );
+_LIT8( KNSmlDdfNAPAuthInf, "NAPAuthInf" );
+_LIT8( KNSmlDdfAuthName, "AuthName" );
+_LIT8( KNSmlDdfAuthSecr, "AuthSecr" );
+_LIT8( KNSmlDdfPxAuthInf, "PxAuthInf" );
+_LIT8( KNSmlDdfPxAuthId, "PxAuthID" );
+_LIT8( KNSmlDdfPxAuthPW, "PxAuthPW" );
+
+_LIT8( KNSmlDdfIPAddrFromServer,"IPAddrFromServer" );
+_LIT8( KNSmlDdfIPAddr, "IPAddr" );
+_LIT8( KNSmlDdfDNSAddrFromServer,"IPDNSAddrFromServer" );
+_LIT8( KNSmlDdfIPv6DNSAddrFromServer,"IPv6DNSAddrFromServer" );
+_LIT8( KNSmlDdfIfNetworks, "IfNetworks" );
+_LIT8( KNSmlDdfIAPService, "IAPService" );
+_LIT8( KNSmlDdfLANService, "LANService" );
+
+_LIT8( KNSmlDdfIAPSeamlessness, "Seamlessness" );
+_LIT8( KNSmlDdfIAPMetaData, "MetaData" );
+
+_LIT8( KNSmlDdfNoPxFor, "NoPxFor" );
+_LIT8( KNSmlDdfNoPxForL, "NoPxForL" );
+
+_LIT8( KNSmlDdfNetworks, "Networks" );
+_LIT8( KNSmlDdfNetworkName, "Name" );
+_LIT8( KNSmlDdfNetworkID, "ID" );
+
+//DDF AP-field descriptions
+_LIT8( KNSmlDdfAPDesc, "AP (Access Point) node" );
+
+_LIT8( KNSmlDdfPxDesc, "Px (Proxy) node" );
+_LIT8( KNSmlDdfPxNameDesc, "Px name description" );
+_LIT8( KNSmlDdfNameDesc, "Displayable name for the Proxy" );
+_LIT8( KNSmlDdfPxIdDesc, "Define one Proxy entity" );
+_LIT8( KNSmlDdfPxPWDesc, "Password for one Proxy entity" );
+_LIT8( KNSmlDdfPPGAuthTyDesc, "Link PxID and PxPW to an authentication method" );
+_LIT8( KNSmlDdfPxAddrDesc, "Proxy-Address" );
+_LIT8( KNSmlDdfToNAPIDDesc, "Parent to all Network Access Point link objects" );
+_LIT8( KNSmlDdfToNAPIDLDesc, "NAPID end" );
+_LIT8( KNSmlDdfStartpgDesc, "The WAP homepage or start page" );
+_LIT8( KNSmlDdfBasAuthIdDesc, "Basic authentication identifier" );
+_LIT8( KNSmlDdfBasAuthPWDesc, "Basic authentication password" );
+_LIT8( KNSmlDdfPortDesc, "Port node" );
+_LIT8( KNSmlDdfPortNbrDesc, "Value of the port number" );
+_LIT8( KNSmlDdfServiceDesc, "Service node" );
+_LIT8( KNSmlDdfServiceLDesc, "ServiceL" );
+_LIT8( KNSmlDdfUsePTxtLogDesc, "Plain Text Login is used or not" );
+
+_LIT8( KNSmlDdfGPRSPDPDesc, "GPRS PDP-type" );
+_LIT8( KNSmlDdfDefGWDesc, "Default Gateway" );
+_LIT8( KNSmlDdfNetworkMaskDesc, "Network/Subnet mask" );
+
+_LIT8( KNSmlDdfPPPCompDesc, "PPP Compression" );
+
+_LIT8( KNSmlDdfNAPDefDesc, "Network Access Point Definition objects parent" );
+_LIT8( KNSmlDdfNAPNameDesc, "Displayable name for the NAP" );
+_LIT8( KNSmlDdfNAPIDDesc, "Used by TO-NAPID link of the Proxy" );
+_LIT8( KNSmlDdfNAPLingerDesc, "Linger value" );
+_LIT8( KNSmlDdfBearerDesc, "Bearer node" );
+_LIT8( KNSmlDdfBearerLDesc, "Bearer valid" );
+_LIT8( KNSmlDdfDirectionDesc, "Direction for network type" );
+_LIT8( KNSmlDdfInternetDesc, "IP-routable network segment" );
+_LIT8( KNSmlDdfNAPAddrDesc, "NAP-Address" );
+_LIT8( KNSmlDdfNAPAddrTyDesc, "NAP-Address-Type" );
+_LIT8( KNSmlDdfDNSAddrDesc, "DNSAddr node" );
+_LIT8( KNSmlDdfDNSAddrLDesc, "Address of a DNS server" );
+_LIT8( KNSmlDdfDNSAddrTyDesc, "Type of DNS address" );
+_LIT8( KNSmlDdfDNSPriorityDesc, "Rank of DNS server" );
+_LIT8( KNSmlDdfNAPAuthInfDesc, "Authentication Info" );
+_LIT8( KNSmlDdfAuthNameDesc, "Loginname" );
+_LIT8( KNSmlDdfAuthSecrDesc, "Loginpassword" );
+_LIT8( KNSmlDdfPxAuthInfDesc, "Proxy Authentication Info" );
+_LIT8( KNSmlDdfPxAuthIdDesc, "Proxy Loginname" );
+_LIT8( KNSmlDdfPxAuthPWDesc, "Proxy Loginpassword" );
+
+_LIT8( KNSmlDdfIPAddrFromServerDesc,"Get IP addresses from server?" );
+_LIT8( KNSmlDdfIPAddrDesc, "IP-address" );
+_LIT8( KNSmlDdfDNSAddrFromServerDesc,"Get DNS addresses from server?" );
+_LIT8( KNSmlDdfIPv6DNSAddrFromServerDesc,"Get IPv6 addresses from server?" );
+_LIT8( KNSmlDdfIfNetworksDesc, "Comma separated list of network protocols, e.g. PPP" );
+_LIT8( KNSmlDdfIAPServiceDesc, "IAP service" );
+
+_LIT8( KNSmlDdfIAPSeamlessnessDesc, "IAP seamlessness value" );
+_LIT8( KNSmlDdfIAPMetaDataDesc, "IAP meta data value" );
+
+_LIT8( KNSmlDdfDomainDesc, "Domain desc" );
+_LIT8( KNSmlDdfDomainLDesc, "Domain, for which the Proxy is responsible" );
+
+_LIT8( KNSmlDdfNoPxForDesc, "No proxy for listed AP:s" );
+_LIT8( KNSmlDdfNoPxForLDesc, "No proxy for this AP" );
+
+_LIT8( KNSmlDdfNetworksDesc, "Networks" );
+_LIT8( KNSmlDdfNetworkNameDesc, "Network Name" );
+_LIT8( KNSmlDdfNetworkIDDesc, "Network ID" );
+
+//Other 
+_LIT8( KNSmlDNS1, "/DNS1" );
+_LIT8( KNSmlDNS2, "/DNS2" );
+_LIT8( KNSmlDNS3, "/DNS3" );
+_LIT8( KNSmlDNS4, "/DNS4" );
+
+_LIT8(KNSmlAPnode, "NAPDef/Px");
+
+_LIT8(KNSmlNAPDefGPRSnode, "Name/NAPID/Startpg/Bearer/IPAddr/IPAddrFromServer/IfNetworks/NAPAddr/NAPAddrTy/IPDNSAddrFromServer/IPv6DNSAddrFromServer/DNSAddr/NAPAuthInf/DefGW/NetworkMask/PPPComp/UsePTxtLog/GPRSPDP/Networks/IAPService/Seamlessness/MetaData/Linger");
+
+//_LIT8(KNSmlNAPDefCSDnode, "Name/NAPID/Bearer/IPAddr/IPAddrFromServer/IfNetworks/NAPAddr/NAPAddrTy/CallTy/IPDNSAddrFromServer/IPv6DNSAddrFromServer/DNSAddr/NAPAuthInf/LnkSpeed/DefGW/NetworkMask/PPPComp/UseCB/CBTy/CBNbr/UsePTxtLog/ModemInit/Networks/IAPService");
+
+//_LIT8(KNSmlNAPDefGPRSnode, "Name/NAPID/Bearer/IPAddr/IPAddrFromServer/IfNetworks/NAPAddr/NAPAddrTy/CallTy/IPDNSAddrFromServer/IPv6DNSAddrFromServer/DNSAddr/NAPAuthInf/LnkSpeed/DefGW/NetworkMask/PPPComp/UsePTxtLog/GPRSPDP/Networks/IAPService");
+
+_LIT8(KNSmlPxnode, "Name/PxID/PxAddr/Port/ToNAPID/Startpg/Domain/PxAuthInf/NoPxFor");
+
+#ifdef __SYNCML_DM_LSCRIPT
+_LIT8(KNSmlLoginscriptnode, "/LoginTW/LoginScriptData");
+#endif
+
+_LIT8(KNSmlDNSAddrNode, "DNSAddrL/DNSAddrTy/DNSPriority" );
+
+_LIT8(KNSmlWLannode, "/WLAN/SSID/UsedSSID/SSIDHidden/UseWPAPSK/NetworkMode/SecurityMode/WEPAuthMode/WPAPreSharedKey/WLANEAPList/WEPKeyIndex/WEPKey/Data/Length/WEPKeyID/Username/Password/EAPType/Realm/UsePseudonym/Encapsulation/VerifyCertRealm/RequireClientAuthentication/SessionValidityTime/CipherSuite/AllowPEAPv0/AllowPEAPv1/AllowPEAPv2/IssuerName/SubjectName/CertType/SerialNumber/SubjectKeyId/Fingerprint");
+
+//Default data values
+_LIT( KNSmlDefName, "APAdapterIns" );
+_LIT( KNSmlDefAP, "AP" );
+_LIT8( KNSmlFirstDNSPri, "1" );
+_LIT8( KNSmlSecondDNSPri, "2" );
+_LIT8( KNSmlDNSIp, "IP" );
+_LIT8( KNSmlDNSIp6, "IP6" );
+_LIT8( KNSmlEmptyIpv4Address8, "0.0.0.0");
+_LIT( KNSmlEmptyIpv4Address, "0.0.0.0");
+_LIT8( KNSmlMimeTypeTextPlain, "text/plain" );
+
+_LIT8( KNSmlDmApValOutgoing, "Outgoing" );
+_LIT8( KNSmlDmApValIncoming, "Incoming" );
+_LIT8( KNSmlDmApVal3Gppps, "3GPPPS" );
+_LIT8( KNSmlDmApValGsmCsd, "GSM-CSD" );
+_LIT8( KNSmlDmApValGsmGprs, "GSM-GPRS" );
+_LIT8( KNSmlDmApValGsmHscsd, "GSM-HSCSD" );
+_LIT8( KNSmlDmApValVpn, "VPN" );
+_LIT8( KNSmlDmApValWlan, "WLAN" );
+_LIT8( KNSmlDmApValFSlash, "/" );
+_LIT8( KNSmlDmApValAnalog, "ANALOG-MODEM" );
+_LIT8( KNSmlDmApValV110, "V.110" );
+_LIT8( KNSmlDmApValV120, "V.120" );
+
+_LIT8( KNSmlDmApValAuto, "Auto" );
+_LIT8( KNSmlDmApVal2400, "2400" );
+_LIT8( KNSmlDmApVal4800, "4800" );
+_LIT8( KNSmlDmApVal9600, "9600" );
+_LIT8( KNSmlDmApVal14400, "14400" );
+_LIT8( KNSmlDmApVal19200, "19200" );
+_LIT8( KNSmlDmApVal28800, "28800" );
+_LIT8( KNSmlDmApVal32000, "32000" );
+_LIT8( KNSmlDmApVal33600, "33600" );
+_LIT8( KNSmlDmApVal38400, "38400" );
+_LIT8( KNSmlDmApVal43200, "43200" );
+_LIT8( KNSmlDmApVal48000, "48000" );
+_LIT8( KNSmlDmApVal56000, "56000" );
+_LIT8( KNSmlDmApVal57600, "57600" );
+_LIT8( KNSmlDmApVal64000, "64000" );
+_LIT8( KNSmlDmApValExtended, "Extended" );
+_LIT8( KNSmlDmApValIpv4, "IPv4" );
+_LIT8( KNSmlDmApValIpv6, "IPv6" );
+_LIT8( KNSmlDmApValTrue, "True" );
+_LIT8( KNSmlDmApValFalse, "False" );
+
+//class forwards
+class CNSmlWLanAdapter;
+
+struct TNSmlAPAddElement
+    {
+    HBufC8 *iUri;
+    HBufC8 *iData;
+    TInt iStatusRef;
+    HBufC8* iLuid;
+    TBool iLeaf;
+    TBool iDone;
+    };
+
+enum TNSmlAPLeafType
+    {
+    EDMUpdate, EDMAdd, EDMDelete, EDMUnset
+    };
+
+struct TNSmlAPBufferElement
+    {
+    CArrayFixFlat<TNSmlAPAddElement> *iNodeBuf;
+    CArrayFixFlat<TNSmlAPAddElement> *iWlanNodeBuf;
+    HBufC8* iMappingName;
+    HBufC8* iName;
+    TBool iExecuted;
+    TInt iLuid;
+    TBool iBearer;
+    TBool iDirection;
+    TBool iNameReceived;
+    TBool iDnsUpdateBuf;
+    };
+//
+// ------------------------------------------------------------------------------------------------
+// CNSmlInternetAdapter 
+// ------------------------------------------------------------------------------------------------
+class CNSmlInternetAdapter : public CSmlDmAdapter
+    {
+public:
+
+    enum TNSmlAPFieldType
+        {
+        EStr, EInt, EBin, EBool, ESpec, EWap, EWrong
+        };
+    static CNSmlInternetAdapter* NewL(MSmlDmCallback* aDmCallback);
+    static CNSmlInternetAdapter* NewLC(MSmlDmCallback* aDmCallback);
+
+    virtual ~CNSmlInternetAdapter();
+
+    // Adapter interface
+    void DDFVersionL(CBufBase& aDDFVersion);
+    void DDFStructureL(MSmlDmDDFObject& aDDF);
+    void
+            AddLeafObjectL(const TDesC8& aURI, const TDesC8& aParentLUID,
+                    const TDesC8& aObject, const TDesC8& aType,
+                    const TInt aStatusRef);
+    void
+            UpdateLeafObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+                    const TDesC8& aObject, const TDesC8& aType,
+                    const TInt aStatusRef);
+    void UpdateLeafObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+            RWriteStream*& aStream, const TDesC8& aType, TInt aStatusRef);
+    void DeleteObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+            const TInt aStatusRef);
+    void FetchLeafObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+            const TDesC8& aType, const TInt aResultsRef,
+            const TInt aStatusRef);
+    void FetchLeafObjectSizeL(const TDesC8& aURI, const TDesC8& aLUID,
+            const TDesC8& aType, TInt aResultsRef, TInt aStatusRef);
+    void ChildURIListL(const TDesC8& aURI, const TDesC8& aLUID,
+            const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
+            const TInt aResultsRef, const TInt aStatusRef);
+    void AddNodeObjectL(const TDesC8& aURI, const TDesC8& aParentLUID,
+            const TInt aStatusRef);
+    void ExecuteCommandL(const TDesC8& aURI, const TDesC8& aLUID,
+            const TDesC8& aArgument, const TDesC8& aType, TInt aStatusRef);
+    void ExecuteCommandL(const TDesC8& aURI, const TDesC8& aLUID,
+            RWriteStream*& aStream, const TDesC8& aType, TInt aStatusRef);
+    void CopyCommandL(const TDesC8& aTargetURI, const TDesC8& aTargetLUID,
+            const TDesC8& aSourceURI, const TDesC8& aSourceLUID,
+            const TDesC8& aType, TInt aStatusRef);
+    void StartAtomicL();
+    void CommitAtomicL();
+    void RollbackAtomicL();
+    TBool StreamingSupport(TInt& aItemSize);
+    void StreamCommittedL();
+    void CompleteOutstandingCmdsL();
+
+private:
+    void ConstructL();
+    CNSmlInternetAdapter(TAny* aEcomArguments);
+    TDesC8& SetIntObjectLC(const TInt& aObject);
+    TInt SetField(const TDesC8& aSource);
+    TInt GetIntObject8(const TDesC8& aObject);
+    TInt IntLUID(const TDesC8& aLUID);
+
+    void AddNodeBufferL(const TDesC8& aURI, const TDesC8& aParentLUID,
+            const TInt aStatusRef, const TBool aDontAppend,
+            const TBool aWlan = EFalse);
+
+    void AddLeafBufferL(const TDesC8& aURI, const TDesC8& aParentLUID,
+            const TDesC8& aObject, const TDesC8& aType,
+            const TInt aStatusRef, const TBool aWlan = EFalse);
+
+    CSmlDmAdapter::TError FetchLeafObjectL(const TDesC8& aURI,
+            const TDesC8& aLUID, const TDesC8& aType, CBufBase& aObject);
+    TPtrC8 LastURISeg(const TDesC8& aURI);
+    TPtrC8 FirstURISeg(const TDesC8& aURI);
+    TPtrC8 GetDynamicAPNodeUri(const TDesC8& aURI);
+    void ExecuteBufferL(const TDesC8& aURI, const TBool aCompleting = EFalse);
+    TPtrC8 GetAddURISeg(const TDesC8& aURI, const TDesC8& aName);
+
+    CNSmlInternetAdapter::TNSmlAPFieldType
+            GetAPFieldType(const TDesC8& aURI) const;
+    TBool GetAPField(TPtrC& aTableName, TPtrC& aColumn) const;
+    TBool NotValidStrLenght(const TDesC& aSource);
+
+    TDesC8& ConvertTo8LC(const TDesC& aSource);
+    TDesC16& ConvertTo16LC(const TDesC8& aSource);
+
+    TInt InitializeGPRSL(CCommsDbTableView* aTable);
+    TInt InitializeProxyL(CCommsDbTableView* aTable);
+
+    TInt InitializeWAPIAPL(CCommsDbTableView* aTable, const TDesC8& aName);
+    TInt InitializeWAPL(CCommsDbTableView* aTable);
+    TInt InitializeLANServiceL(CCommsDbTableView* aTable);
+    TInt InitializeVPNServiceL(CCommsDbTableView* aTable);
+    TBool IsValidNameL(const TDesC8& aName);
+    TBool IsValidIPv4AddressL(const TDesC8& aNapAddr);
+    void NextAPNameL(const TDesC8& aName);
+
+    TUint32 GetIAPSeamlessnessL(TUint32 aId);
+    TUint32 GetIAPMetaDataL(TUint32 aId);
+    void
+            SetIAPSeamlessnessL(TUint32 apMetaID, TUint32 aSeam,
+                    TInt aStatusRef);
+    void SetIAPMetaDataL(TUint32 apMetaID, TUint32 aMeta, TInt aStatusRef);
+
+    TBool CheckEnforcementL();
+    TBool CheckWLANEnforcementL();
+    TInt UnprotectWLANAPItemL(TUint32 aId);
+    TInt DoProtectWAPTablesL(TBool aProtect);
+    void DoLockIAPTablesL(TBool aLock);
+
+    TBool IsIAPRecordLockedL(TUint32 aRecord);
+    TInt DoProtectIAPRecordL(TUint32 aRecord, TBool aProtect);
+    TBool IsProxyRecordLockedL(TUint32 aRecord);
+    TInt DoProtectProxyRecordL(TUint32 aRecord, TBool aProtect);
+    TBool IsServiceRecordLockedL(TUint32 aRecord);
+    TInt DoProtectServiceRecordL(TUint32 aRecord, TBool aProtect);
+    TBool IsWAPAccessPointRecordLockedL(TUint32 aRecord);
+    TInt DoProtectWAPAccessRecordL(TUint32 aRecord, TBool aProtect);
+
+    TBool IsWLANfield(const TDesC8& aURI);
+    TBool IsWlanL(const TDesC8& aURI);
+    TBool GetLanBearerL(TUint32& aId);
+
+    void SaveIAPDataL(const TDesC8& aURI);
+    TBool GetModemBearerL(TUint32& aId);
+    TBool IsInsertAllowedL();
+    TUint32 GetMaxIdL();
+    TBool GetProxyIdL(const TDesC8& aURI);
+
+    TBool APExistsL(TUint32 aId);
+    TBool NAPDefExistsL(TUint32 aId);
+    TBool PxExistsL(TUint32 aId);
+    TBool WapAPExistsL(TUint32 aId);
+    TBool NetworkExistsL(TUint32 aId);
+    TBool NetworkNameExistsL(TUint32& aId, const TDesC8& aObject);
+    TBool AddNetworkL(TUint32& aId, const TDesC8& aObject);
+
+    TBool DeleteAPL(TUint32 aId);
+    TBool DeleteNAPDefL(TUint32 aId);
+    TBool DeleteProxyL(TUint32 aId);
+    TBool DeleteWapAPL(TUint32 aId);
+
+    TUint32 GetAPIdFromURIL(const TDesC8& aURI);
+    void IsWapPort(const TDesC8& aObject);
+    void FillNodeInfoL(MSmlDmDDFObject& aNode, TSmlDmAccessTypes aAccTypes,
+            MSmlDmDDFObject::TOccurence aOccurrence,
+            MSmlDmDDFObject::TScope aScope,
+            MSmlDmDDFObject::TDFFormat aFormat, const TDesC8& aDescription);
+
+    TInt UpdateIAPnameL(TUint32 aId, const TDesC8& aObject);
+    TUint32 GetLocationL();
+
+    TBool
+            InitializeDNSParamsFromBuffL(const TPtrC8 aParentUri,
+                    TInt& aDnsPri);
+    TInt
+            DnsToLuid(const UriUtils::TUriHostType aType,
+                    const TInt aPriority) const;
+    TInt LuidToDns(UriUtils::TUriHostType& aType, TInt& aPriority,
+            const TInt aLuid) const;
+    TPtrC8 RemoveLastSeg(const TDesC8& aURI) const;
+
+    void ClearBuffer(CArrayFixFlat<TNSmlAPAddElement>* aBuffer);
+    void LingerValueL(const TDesC8& aObject);
+    void AddLingerL(const TInt aIapId, const TInt aLingerInterval);
+    void UpdateLingerL(const TInt aIapId, const TInt aLingerInterval);
+    void GetLingerL(const TInt aIapId, TInt& aLingerInterval);
+    void DeleteLingerL(const TInt aIapId);
+    TBool Notalpha(const TDesC& aValue);
+    TUint32 ConstructTreeL(const TDesC8& aURI);
+    TBool IsAPUriFormatMatchPredefined(const TDesC8 & aURI);
+
+private:
+    MSmlDmCallback* iCallBack;
+
+    CNSmlWLanAdapter* iWlanAdapter;
+
+    TInt iLUID;
+    TInt iParentLUID;
+    TInt iObject;
+    TBool iWapPort;
+    TInt iDirection;
+    TBool iStaleMapUpdate;
+    HBufC8* iField;
+    TNSmlAPLeafType iLeafType;
+
+    TBuf8<KCommsDbSvrMaxFieldLength> iWAPAccessPoint;
+    TUint32 iWapId;
+    TBuf<KCommsDbSvrMaxFieldLength> iWapBearer;
+    TBuf8<KCommsDbSvrMaxFieldLength> iWapName;
+    TBuf8<KCommsDbSvrMaxFieldLength> iWapUserName;
+    TBuf8<KCommsDbSvrMaxFieldLength> iWapPassword;
+
+    CArrayFixFlat<TNSmlAPBufferElement> *iBuffer;
+    TBool i3GPPPS;
+
+private:
+    // data
+    CCommsDatabase* iDatabase;
+
+    TBool iIAPExists;
+
+    TInt iDnsIpv4Pri; // 1 or 2 
+    TInt iDnsIpv6Pri;
+    TInt iExecutionIndex;
+    TBool iExecutingBuffer;
+    TBool iDnsUpdate;
+
+    TBuf8<KCommsDbSvrMaxFieldLength> iIAPName;
+
+    TUint32 iIAPId;
+
+    TUint32 iISPId;
+
+    TUint32 iProxyId;
+    TUint32 iProxyISP;
+
+    TBuf<KCommsDbSvrMaxFieldLength> iProxyServiceType;
+    TBuf8<KCommsDbSvrMaxFieldLength> iProxyServerName;
+
+    HBufC8* iPrevURI;
+    TInt iPrevLUID;
+
+    TBuf<KCommsDbSvrMaxFieldLength> iBearer;
+
+    TUint32 iBearerType;
+    TInt iNetworkId;
+    TInt iLingerValue;
+    TBool iLingerFlag;
+    TBool iTransactionCommitted;
+    TBool iWAPRelock;
+    RArray<TPtrC> iLockTableList;
+
+    TBool iWlanSupported;
+    TBool isAdd;
+    };
+
+#endif // __NSMLINTERNETADAPTER_H__
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldminternet/inc/NSmlWLanAdapter.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,397 @@
+/*
+ * 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:   Wlan adapter
+ *
+ */
+
+#ifndef __NSMLWLANADAPTER_H__
+#define __NSMLWLANADAPTER_H__
+
+// -----------------------------------------------------------------------------------------------
+// Includes
+// -----------------------------------------------------------------------------------------------
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <commsdat_partner.h>
+#endif
+#include <utf.h>
+#include <commdb.h>
+#include <EapSettings.h>
+#include "smldmadapter.h"
+#include "nsmlconstants.h"
+#include "NSmlWlanSettings.h"
+
+// -----------------------------------------------------------------------------------------------
+// Constants
+// -----------------------------------------------------------------------------------------------
+const TInt KNSmlWepKeyGranularity = 4;
+const TInt KNSmlMaxURISegLen = 32;
+const TInt KExpandedEAPIdLength = 8;
+const TInt KNsmlSubjectKeyIdLength = 255;
+const TInt KIdentifierLength = 20;
+const TUint KMaxLengthOfEapList = 50;
+
+_LIT8( KNSmlWLanAdapterDDFversion, "1.0" );
+_LIT16( KNSmlWLanServiceTable, "WLANServiceTable" );
+_LIT8( KNSmlWLanId, "Id" );
+_LIT8( KNSmlWLanName, "Name" );
+_LIT8( KNSmlWLanHidden, "Hidden" );
+_LIT8( KNSmlWLanReadOnly, "ReadOnly" );
+_LIT8( KNSmlWLanServiceId, "ServiceID" );
+_LIT8( KNSmlWLanNetworkMode, "NetworkMode" );
+_LIT8( KNSmlWLanConnectionMode, "WlanConnectionMode" );
+_LIT8( KNSmlWLanSsid, "SSID" );
+_LIT8( KNSmlWLanUsedSsid, "UsedSSID" );
+_LIT8( KNSmlWLanSsidHidden, "SSIDHidden" );
+_LIT8( KNSmlWLanUseWPAPSK, "UseWPAPSK" );
+_LIT8( KNSmlWLanEnablePSK, "EnablePSK" );
+_LIT8( KNSmlWLanWepKey1, "WEPKey1InHex" );
+_LIT8( KNSmlWLanWepKey2, "WEPKey2InHex" );
+_LIT8( KNSmlWLanWepKey3, "WEPKey3InHex" );
+_LIT8( KNSmlWLanWepKey4, "WEPKey4InHex" );
+_LIT8( KNSmlWLanWepIndex, "WEPKeyIndex" );
+_LIT8( KNSmlWLanWepKey, "WEPKey" );
+_LIT8( KNSmlWLanSecurityMode, "SecurityMode" );
+_LIT8( KNSmlWLanWpaAuthMode, "WPAAuthMode" );
+_LIT8( KNSmlWLanWpaPreSharedKey, "WPAPreSharedKey" );
+_LIT8( KNSmlWLanEapList, "WLANEAPList" );
+_LIT8( KNSmlWLanAuthMode, "WEPAuthMode" );
+_LIT8( KNSmlWLanWepKeyId, "WEPKeyID" );
+_LIT8( KNSmlWLanWepKeyData, "Data" );
+_LIT8( KNSmlWLanNodeName, "WLAN" );
+
+_LIT8( KNSmlEmpty, "" );
+#define  KNSmlWLanDefaultSSID _S("Net1")
+
+_LIT8( KNSmlWLan, "/WLAN" );
+_LIT8( KNSmlNAPDefWlanNode,"Name/NAPID/Bearer/IPAddrFromServer/IfNetworks/NAPAddr/NAPAddrTy/IPDNSAddrFromServer/DNSAddr/DefGW/NetworkMask/Networks/IAPService");
+
+_LIT8( KNSmlWLanListOfLeafs, "SSID/UsedSSID/SSIDHidden/NetworkMode/SecurityMode/WPAPreSharedKey/UseWPAPSK/WEPKey/WEPKeyIndex/WLANEAPList/WEPAuthMode/EAP/SecondarySSID" );
+
+_LIT8( KNSmlWLanListOfSecondaryLeafs, "SSID/UsedSSID" );
+_LIT8( KNSmlWLanListOfWepKeys, "1/2/3/4" );
+_LIT8( KNSmlWLanListOfWepKeyLeafs, "WEPKeyID/Data" );
+_LIT8( KNSmlWLanAllowUnsecure8, "allow unsecure" );
+_LIT8( KNSmlWLanWep8, "WEP" );
+_LIT8( KNSmlWLan8021x8, "802.1X" );
+_LIT8( KNSmlWLanWpa8, "WPA" );
+_LIT8( KNSmlWLanWpa28, "WPA2" );
+_LIT8( KNSmlWLanWpaPreSharedKey8, "WPA pre-shared key" );
+_LIT8( KNSmlWLanAdHoc8, "ADHOC" );
+_LIT8( KNSmlWLanInfrastructure8, "Infrastructure" );
+_LIT8( KNSmlMimeType, "text/plain" );
+
+#ifdef FF_WLAN_EXTENSIONS
+_LIT8( KNSmlWLanListOfEAPLeafs, "EAPType/Username/Password/Realm/UsePseudonym/VerifyCertRealm/RequireClientAuthentication/SessionValidityTime/CipherSuite/AllowPEAPv0/AllowPEAPv1/AllowPEAPv2/Certificate/AuthProvMode/UnauthProvMode/PACGroupRef/WarnADHPNoPAC/WarnADHPNoMatchPAC/WarnNotDefaultSrv" );
+#else
+_LIT8( KNSmlWLanListOfEAPLeafs, "EAPType/Username/Password/Realm/UsePseudonym/VerifyCertRealm/RequireClientAuthentication/SessionValidityTime/CipherSuite/AllowPEAPv0/AllowPEAPv1/AllowPEAPv2/Certificate" );
+#endif
+
+_LIT8( KNSmlWLanListOfCertificateLeafs, "IssuerName/SubjectName/CertType/SerialNumber/SubjectKeyId/Fingerprint" );
+
+_LIT8( KNSmlWLanSecSsid, "SecondarySSID" );
+_LIT8( KNSmlWLanEap, "EAP" );
+_LIT8( KNSmlWLanEapType, "EAPType" );
+_LIT8( KNSmlWLanUsername, "Username" );
+_LIT8( KNSmlWLanPassword, "Password" );
+_LIT8( KNSmlWLanRealm, "Realm" );
+_LIT8( KNSmlWLanUsePseudonym, "UsePseudonym" );
+_LIT8( KNSmlWLanEncapsulation, "Encapsulation" );
+_LIT8( KNSmlWLanVerifyCertRealm, "VerifyCertRealm" );
+_LIT8( KNSmlWLanRequireClientAuthentication, "RequireClientAuthentication" );
+_LIT8( KNSmlWLanSessionValidityTime, "SessionValidityTime" );
+_LIT8( KNSmlWLanCipherSuite, "CipherSuite" );
+_LIT8( KNSmlWLanAllowPEAPv0, "AllowPEAPv0" );
+_LIT8( KNSmlWLanAllowPEAPv1, "AllowPEAPv1" );
+_LIT8( KNSmlWLanAllowPEAPv2, "AllowPEAPv2" );
+#ifdef FF_WLAN_EXTENSIONS 
+_LIT8( KNSmlWLanAuthProvMode, "AuthProvMode" );
+_LIT8( KNSmlWLanUnauthProvMode, "UnauthProvMode" );
+_LIT8( KNSmlWLanPACGroupRef, "PACGroupRef" );
+_LIT8( KNSmlWLanWarnADHPNoPAC, "WarnADHPNoPAC" );
+_LIT8( KNSmlWLanWarnADHPNoMatchPAC, "WarnADHPNoMatchPAC" );
+_LIT8( KNSmlWLanWarnNotDefaultSrv, "WarnNotDefaultSrv" );
+#endif
+_LIT8( KNSmlWLanCertificate, "Certificate" );
+_LIT8( KNSmlWLanIssuerName, "IssuerName" );
+_LIT8( KNSmlWLanSubjectName, "SubjectName" );
+_LIT8( KNSmlWLanCertType, "CertType" );
+_LIT8( KNSmlWLanSerialNumber, "SerialNumber" );
+_LIT8( KNSmlWLanSubjectKeyId, "SubjectKeyId" );
+_LIT8( KNSmlWLanFingerprint, "Fingerprint" );
+
+_LIT8(KTrue, "True");
+_LIT8(KFalse, "False");
+_LIT8(KTtrue, "true");
+_LIT8(KFfalse, "false");
+_LIT8(KSlash, "/");
+_LIT8(KDash, "-");
+_LIT8(KNSmlWLanEapId, "EAPId" );
+
+_LIT8(KSuitesDefault, "-010,-022,-019,-047,-050,-051,-004,-005");
+
+const TUint RSA_3DES_SHA = 10;
+const TUint DHE_RSA_3DES_SHA = 22;
+const TUint DHE_DSS_3DES_SHA = 19;
+const TUint RSA_AES_SHA = 47; // ?
+const TUint DHE_RSA_AES_SHA = 50; // ?
+const TUint DHE_DSS_AES_SHA = 51; // ?
+const TUint RSA_RC4_MD5 = 4;
+const TUint RSA_RC4_SHA = 5;
+const TUint NUMBER_OF_CIPHERSUITES = 8;
+const TUint KExpandedEapIdLength = 8;
+const TUint8 KEapPlus = '+';
+
+_LIT8(KEAPSIM, "EAP-SIM");
+_LIT8(KEAPAKA, "EAP-AKA");
+_LIT8(KEAPTLS, "EAP-TLS");
+_LIT8(KEAPPEAP, "EAP-PEAP");
+_LIT8(KEAPTTLS, "EAP-TTLS");
+_LIT8(KEAPLEAP, "EAP-LEAP");
+_LIT8(KEAPMSCHAPV2, "EAP-MSCHAPV2");
+_LIT8(KMSCHAPV2, "MSCHAPV2");
+_LIT8(KEAPGTC, "EAP-GTC");
+_LIT8(KEAPFAST, "EAP-FAST");
+_LIT8(KEAPTTLSPAP, "EAP-TTLSPAP");
+
+_LIT8(KEapAll,"-017,-018,-023,-013,-025,-021,-043" );
+
+const TUint8 KEapNoneId[] =
+    {
+    0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+    };
+const TUint8 KEapTlsTypeId[] =
+    {
+    0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d
+    };
+const TUint8 KEapGtcTypeId[] =
+    {
+    0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06
+    };
+const TUint8 KEapLeapTypeId[] =
+    {
+    0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11
+    };
+const TUint8 KEapSimTypeId[] =
+    {
+    0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12
+    };
+const TUint8 KEapTtlsTypeId[] =
+    {
+    0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15
+    };
+const TUint8 KEapAkaTypeId[] =
+    {
+    0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17
+    };
+const TUint8 KEapPeapTypeId[] =
+    {
+    0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19
+    };
+const TUint8 KEapMschapv2TypeId[] =
+    {
+    0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A
+    };
+const TUint8 KEapSecuridTypeId[] =
+    {
+    0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20
+    };
+const TUint8 KEapFastTypeId[] =
+    {
+    0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2B
+    };
+const TUint8 KMschapv2TypeId[] =
+    {
+    0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x63
+    };
+const TUint8 KTtlspapTypeId[] =
+    {
+    0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x62
+    };
+const TUint8 KNotInsidePEAP = 0x04;
+const TUint8 KNotOutsidePEAP = 0x08;
+const TUint8 KNotInsideTTLS = 0x10;
+
+//Forward Declarations
+class TEapExpandedType;
+
+// -----------------------------------------------------------------------------------------------
+// Structures
+// -----------------------------------------------------------------------------------------------
+struct TNSmlWepKeyBufferElement
+    {
+    HBufC8* iUri;
+    HBufC8* iData;
+    TInt iWepKeyId;
+    TInt iIdStatusRef;
+    //TInt iUseWPAPSK;
+    TInt iDataStatusRef;
+    TInt iNodeStatusRef;
+    TInt iLengthStatusRef;
+    TBool iExecuted;
+    TBool iDataSet;
+    TInt iLuid;
+    };
+
+struct TNSmlSecondarySSIDBufferElement
+    {
+    HBufC8* iUri;
+    TBuf<KMaxTextLength> ScannedId;
+    TBuf<KMaxTextLength> UsedId;
+    TInt wlanLuid;
+    TBool iExecuted;
+    };
+
+struct TNSmlEAPBufferElement
+    {
+    EAPSettings* iEAPSettings;
+    TEapExpandedType iEncapsulatingExpandedEapId;
+    RArray<TInt> iStatusRefArray;
+    TInt iWLANServiceId;
+    TBuf8<KExpandedEapIdLength> iEapTypeString;
+    TBuf8<KExpandedEapIdLength> iEncapsulatingString;
+    };
+
+// -----------------------------------------------------------------------------------------------
+// Enumerations
+// -----------------------------------------------------------------------------------------------
+enum TConnectionMode
+    {
+    EAdhoc = 0, EInfrastructure = 1
+    };
+
+enum TWLanSecurityMode
+    {
+    EAllowUnsecure = 1, EWep = 2, EWlan8021x = 4, EWpa = 8, EWpa2 = 16
+    };
+
+enum TWepAuthenticationMode
+    {
+    EOpen = 0, EShared = 1
+    };
+
+enum TNsmlWLANAdapterEapType
+    {
+    EEapNone = 0,
+    EEapGtc = 6,
+    EEapTls = 13,
+    EEapLeap = 17,
+    EEapSim = 18,
+    EEapTtls = 21,
+    EEapAka = 23,
+    EEapPeap = 25,
+    EEapMschapv2 = 26,
+    EEapSecurid = 32,
+    EEapFast = 43,
+    ETtlsPlainPap = 98,
+    EPlainMschapv2 = 99
+    };
+// ------------------------------------------------------------------------------------------------
+// CNSmlWLanAdapter 
+// ------------------------------------------------------------------------------------------------
+class CNSmlWLanAdapter : public CSmlDmAdapter
+    {
+public:
+    static CNSmlWLanAdapter* NewL(MSmlDmCallback* aDmCallback,
+            CCommsDatabase& aDatabase);
+    static CNSmlWLanAdapter* NewLC(MSmlDmCallback* aDmCallback,
+            CCommsDatabase& aDatabase);
+    void ConstructL(CCommsDatabase& aDatabase);
+    virtual ~CNSmlWLanAdapter();
+
+    // Adapter interface
+    void DDFVersionL(CBufBase& aDDFVersion);
+    void DDFStructureL(MSmlDmDDFObject& aDDF);
+    void
+            AddLeafObjectL(const TDesC8& aURI, const TDesC8& aParentLUID,
+                    const TDesC8& aObject, const TDesC8& aType,
+                    const TInt aStatusRef);
+    void
+            UpdateLeafObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+                    const TDesC8& aObject, const TDesC8& aType,
+                    const TInt aStatusRef);
+    void UpdateLeafObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+            RWriteStream*& aStream, const TDesC8& aType, TInt aStatusRef);
+    void DeleteObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+            const TInt aStatusRef);
+    void FetchLeafObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+            const TDesC8& aType, const TInt aResultsRef,
+            const TInt aStatusRef);
+    void FetchLeafObjectSizeL(const TDesC8& aURI, const TDesC8& aLUID,
+            const TDesC8& aType, TInt aResultsRef, TInt aStatusRef);
+
+    void ChildURIListL(const TDesC8& aURI, const TDesC8& aLUID,
+            const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
+            const TInt aResultsRef, const TInt aStatusRef);
+    void AddNodeObjectL(const TDesC8& aURI, const TDesC8& aParentLUID,
+            const TInt aStatusRef);
+    void ExecuteCommandL(const TDesC8& aURI, const TDesC8& aLUID,
+            const TDesC8& aArgument, const TDesC8& aType, TInt aStatusRef);
+    void ExecuteCommandL(const TDesC8& aURI, const TDesC8& aLUID,
+            RWriteStream*& aStream, const TDesC8& aType, TInt aStatusRef);
+    void CopyCommandL(const TDesC8& aTargetURI, const TDesC8& aTargetLUID,
+            const TDesC8& aSourceURI, const TDesC8& aSourceLUID,
+            const TDesC8& aType, TInt aStatusRef);
+    void StartAtomicL();
+    void CommitAtomicL();
+    void RollbackAtomicL();
+    TBool StreamingSupport(TInt& aItemSize);
+    void StreamCommittedL();
+    void CompleteOutstandingCmdsL();
+    CSmlDmAdapter::TError FetchLeafObjectL(const TDesC8& aURI,
+            const TDesC8& aLUID, const TDesC8& aType, CBufBase& aObject);
+
+private:
+    CNSmlWLanAdapter(TAny* aEcomArguments, CCommsDatabase& aDatabase);
+    void FillNodeInfoL(MSmlDmDDFObject& aNode, TSmlDmAccessTypes aAccTypes,
+            MSmlDmDDFObject::TOccurence aOccurrence,
+            MSmlDmDDFObject::TScope aScope,
+            MSmlDmDDFObject::TDFFormat aFormat, const TDesC8& aDescription);
+    HBufC* IntToDesLC(const TInt aLuid);
+    HBufC8* IntToDes8LC(const TInt aLuid);
+    TInt DesToInt(const TDesC8& aLuid);
+    TInt GetIdFromLuid(const TDesC8& aLuid);
+    TUint32 GetSecSSIDFromUriL(const TDesC8& aUri);
+    TInt GetEAPIdFromUri(const TDesC8& aUri);
+    TInt GetCertificateIdFromUri(const TDesC8& aUri);
+    TInt GetWepKeyIdFromLuid(const TDesC8& aLuid);
+    TInt GetWepKeyIdFromUri(const TDesC8& aUri);
+    TInt NumOfUriSegs(const TDesC8& aUri);
+    TPtrC8 GetLastUriSeg(const TDesC8& aURI);
+    TPtrC8 RemoveLastUriSeg(const TDesC8& aURI);
+    void ExecuteBufferL(TBool aFinal = EFalse);
+    TDesC8& ConvertTo8LC(const TDesC& aSource);
+    TDesC16& ConvertTo16LC(const TDesC8& aSource);
+    void DesToBufferL(CBufBase& aTo, const TDesC& aFrom);
+    void FillCipherSuiteBufferL(CBufBase& aBuffer);
+    void FillCipherSuitesL(const TDesC8& aObject, const TInt aLuid);
+    void ConvertEAPStringToIds(TDes8& aEAPString, TEapExpandedType& aId);
+    TInt GetServiceIdFromUriL(const TDesC8& aURI);
+    TInt GetEncapsEAPIdFromUri(const TDesC8& aUri);
+    void ResetEAPStructL();
+    void DeleteEAPStructL();
+    void GetExpandedType(const TInt aEapType, const TInt aTunnelingType,
+            TEapExpandedType& aExpanedId, TEapExpandedType& aExpanedEncapsId);
+
+    MSmlDmCallback* iCallBack;
+    CWlanSettings* iWlanSettings;
+    CArrayFixFlat<TNSmlWepKeyBufferElement> *iBuffer;
+    TWlanSettings *iSettings;
+    EAPSettings* iEAPSettings;
+    RPointerArray<TNSmlSecondarySSIDBufferElement> iSecondaryBuffer;
+    RPointerArray<TNSmlEAPBufferElement> iEAPBuffer;
+    CCommsDatabase& iDatabase;
+
+    };
+
+#endif __NSMLWLANADAPTER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldminternet/inc/NSmlWlanSettings.h	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,133 @@
+/*
+ * 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:   Wlan Adapter commsDB handler
+ *
+ */
+
+#ifndef __NSMLWLANSETTINGS_H__
+#define __NSMLWLANSETTINGS_H__
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <commsdat_partner.h>
+#endif
+#include <commdb.h>
+#include <commsdattypesv1_1.h>
+#include <EapType.h>
+
+const TInt KMaxPSKLength = 63;
+const TInt KMinPSKLength = 8;
+
+// ==========================================================================
+// Class forwards
+// ==========================================================================
+//
+class CWlanSettings;
+
+class TWlanSettings
+    {
+public:
+    TBuf<KMaxTextLength> Name;
+    TUint32 Id;
+    TUint32 ServiceID;
+    TUint32 ConnectionMode; // Infrastructure / adhoc
+    TBuf<KMaxTextLength> SSID;
+    TBuf8<KMaxTextLength> WepKey1;
+    TBuf8<KMaxTextLength> WepKey2;
+    TBuf8<KMaxTextLength> WepKey3;
+    TBuf8<KMaxTextLength> WepKey4;
+    TUint32 WepIndex;
+    TUint32 SecurityMode; // SecurityMode (Allow unsecure, wep, 802.1xs, wpa) enum EWlanSecurityMode
+    TUint32 WPAMode; // enum EWpaMode
+    TUint32 UseWPAPSK; // CR ID: TMVI-5Y49AS
+    TBuf8<KMaxPSKLength> WPAPreSharedKey;
+    TUint32 AuthMode;
+    TBuf<KMaxTextLength> UsedSSID;
+    TUint32 ScanSSID;
+    TBuf<KMaxLongTextLength> EapList;
+    TBool SecondarySSIDsExisting;
+    //    TBuf<KMaxTextLength>        SecondarySSID;
+    //    TBuf<KMaxTextLength>        UsedSecondarySSID;
+
+    };
+
+class TSecondarySSID
+    {
+public:
+    TUint32 Id;
+    TBuf<KMaxTextLength> ScannedId;
+    TBuf<KMaxTextLength> UsedId;
+    };
+
+// -----------------------------------------------------------------------------------------------
+// Defines
+// -----------------------------------------------------------------------------------------------
+
+class CWlanSettings : public CBase
+    {
+public:
+    static CWlanSettings* NewL(CCommsDatabase& aDatabase);
+    void ConstructL();
+    ~CWlanSettings();
+
+    TInt GetWlanSettings(TUint32 aLuid, TWlanSettings& aWlanSettings);
+    TInt DeleteWlanSettings(TUint32 aLuid);
+    TInt WriteWlanSettings(TWlanSettings& aWlanSettings);
+    void ConnectToDatabaseL();
+    TInt RecordExists(TUint32 aLuid);
+    TInt PerformLockWLANTablesL(TBool aProtect);
+    TBool CheckEnforcementL();
+    TBool CheckAPEnforcementL();
+    TBool iWLANRelock;
+
+    TInt GetEAPSettings(const TInt aId, TEapExpandedType& aExpandedId,
+            TEapExpandedType& aEncapsId, EAPSettings& aEapSettings);
+    TInt DeleteEAPSettings(TInt aId);
+    void DeleteWlanEapSettingsL(TInt aWlanId);
+    TInt DeleteSecondarySSIDsL(TUint32 aWLANId);
+    TInt DeleteOneSecondarySSIDL(TUint32 aWLANId, TUint32 asecId);
+    TInt WriteEAPSettings(EAPSettings& aEapSettings);
+    TInt WriteSecondarySSIDL(TUint32 aWlanID, TSecondarySSID& aSettings,
+            TBool aNew);
+    void GetSecondarySSIDListL(TUint32 aLuid,
+            RArray<TSecondarySSID>& aSecondarySSIDs);
+    void GetEAPInterfaceL(const TInt aId, TEapExpandedType& aEncapsId,
+            TEapExpandedType& aExpandedId);
+    TInt InstalledEAPsL(CBufBase& aEAPList);
+
+private:
+
+    CWlanSettings(CCommsDatabase& aDatabase);
+    TInt GoToRecord(TUint32 aId);
+    void GetDataFromRecordL(TWlanSettings* aWlanSettings);
+    void WriteDataToRecordL(TWlanSettings* aWlanSettings);
+    void InitialiseRecordL();
+    void SetSecondaryViewToRecordL(TUint32 aId);
+
+    TDesC8& ConvertTo8LC(const TDesC& aSource);
+    TDesC16& ConvertTo16LC(const TDesC8& aSource);
+    TBool IsDisallowedInsideTTLS(const CImplementationInformation& aImplInfo);
+    TBool IsDisallowedInsidePEAP(const CImplementationInformation& aImplInfo);
+    TBool
+            IsDisallowedOutsidePEAP(
+                    const CImplementationInformation& aImplInfo);
+
+    CCommsDatabase& iDatabase;
+    CCommsDbTableView* iTableView;
+    CCommsDbTableView* iSecondaryView;
+    CEapType* iEapType;
+    TUint32 iServiceID;
+    TBool iExpandedEAPTypeFieldsUsed;
+    };
+
+#endif __NSMLWLANSETTINGS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldminternet/rom/nsmlinternetadapter.iby	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,36 @@
+/*
+* 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:   Image description file for project InternetAdapter
+*
+*/
+
+
+
+REM SyncML Device Management internet adapter
+
+#include <bldvariant.hrh>
+
+#ifndef __NSMLINTERNETADAPTER_IBY__
+#define __NSMLINTERNETADAPTER_IBY__
+
+#ifdef __SYNCML_DM // nothing should be installed from this .iby file if __SYNCML_DM feature is not selected
+#ifndef FF_DM_CONNMO_ADAPTER // nothing should be installed from this .iby file if this flag is specified.
+														 // ConnMO is used in that case for access point provisioning.
+
+ECOM_PLUGIN(nsmlinternetadapter.dll,nsmlinternetadapter.rsc)
+
+#endif // FF_DM_CONNMO_ADAPTER
+#endif //__SYNCML_DM
+
+#endif //__NSMLINTERNETADAPTER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldminternet/src/NSmlInternetAdapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,9651 @@
+/*
+ * 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:   Internet-settings 
+ *
+ */
+
+#include <commdb.h>
+#include <cdbstore.h>
+#include <cdbcols.h>             // CommsDB columname defs
+#include <implementationproxy.h> // For TImplementationProxy definition
+#include <cdbpreftable.h>
+#include <etelpckt.h>   // ISP enumerations
+#include <etelmm.h>     // GPRS ProtocolType
+#include <nifvar.h>     // CallbackType
+#include <etelqos.h>    // GPRS enumeration
+#include <wappdef.h>    // WAP  enumeration
+#include <sysutil.h>    // OOD checking
+#include <uriutils.h>   // ipv4 + ipv6 checking
+#include <featmgr.h>
+#include "NSmlInternetAdapter.h"
+#include "NSmlWLanAdapter.h"
+#include "nsmldebug.h"
+#include "nsmldmtreedbclient.h"
+#include <comms-infras/commdb/protection/protectdb.h>
+#include <utf.h>
+
+#include <metadatabase.h>
+#include <cmmanagerext.h>
+#include <cmconnectionmethoddef.h>
+#include <cmconnectionmethodext.h>
+#include  <cmpluginbaseeng.h>
+#include <centralrepository.h>
+#include <pdpcontextmanagerinternalcrkeys.h>
+
+const TUint KNSmlInternetAdapterImplUid = 0x101F6DE2;
+
+const TUint KIapColumn = 0x00000100;
+const TUint KLingerColumn = 0x00000200;
+const TUint KColumnMask = 0xFFFFFF00;
+const TUint KRowMask = 0x000000FF;
+
+#include <SettingEnforcementInfo.h> // VSettingEnforcementInfo
+class CNSmlWLanAdapter;
+
+_LIT( KDaemonManagerName, "NetCfgExtnDhcp" );
+_LIT( KConfigDaemonName, "!DhcpServ" );
+
+#ifndef __WINS__
+// This lowers the unnecessary compiler warning (armv5) to remark.
+// "Warning:  #174-D: expression has no effect..." is caused by 
+// DBG_ARGS8 macro in no-debug builds.
+#pragma diag_remark 174
+#endif
+
+const TInt KBeginTransRetryDelay = 1000000; // Delay for comms db begintransaction retry (microseconds)
+const TInt KBeginTransRetryCount = 7; // Maximum number of retries
+//-----------------------------------------------------------------------------
+// CSmlInternetAdapter* CSmlInternetAdapter::NewL( )
+//-----------------------------------------------------------------------------
+
+CNSmlInternetAdapter* CNSmlInternetAdapter::NewL(MSmlDmCallback* aDmCallback)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::NewL(): begin");
+
+    CNSmlInternetAdapter* self = NewLC(aDmCallback);
+    CleanupStack::Pop();
+
+    _DBG_FILE("CNSmlInternetAdapter::NewL(): end");
+    return self;
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter* CNSmlInternetAdapter::NewLC( )
+//------------------------------------------------------------------------------
+CNSmlInternetAdapter* CNSmlInternetAdapter::NewLC(MSmlDmCallback* aDmCallback)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::NewLC(): begin");
+    CNSmlInternetAdapter* self = new (ELeave) CNSmlInternetAdapter(
+            aDmCallback);
+    CleanupStack::PushL(self);
+
+    self->iCallBack = aDmCallback;
+    self->ConstructL();
+
+    _DBG_FILE("CNSmlInternetAdapter::NewLC(): end");
+    return self;
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::CNSmlInternetAdapter()
+//------------------------------------------------------------------------------
+CNSmlInternetAdapter::CNSmlInternetAdapter(TAny* aEcomArguments) :
+    CSmlDmAdapter(aEcomArguments)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::CNSmlInternetAdapter(): begin");
+    _DBG_FILE("CNSmlInternetAdapter::CNSmlInternetAdapter(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::~CNSmlInternetAdapter(TAny* aEcomArguments)
+//------------------------------------------------------------------------------
+CNSmlInternetAdapter::~CNSmlInternetAdapter()
+    {
+    _DBG_FILE("CNSmlInternetAdapter::~CNSmlInternetAdapter(): begin");
+
+    delete iField;
+
+    delete iPrevURI;
+
+    // Command buffer cleaning if leave happend
+    if (iBuffer)
+        {
+        for (TInt i = 0; i < iBuffer->Count(); i++)
+            {
+            delete iBuffer->At(i).iMappingName;
+            delete iBuffer->At(i).iName;
+
+            ClearBuffer(iBuffer->At(iExecutionIndex).iNodeBuf);
+            delete iBuffer->At(i).iNodeBuf;
+
+            ClearBuffer(iBuffer->At(iExecutionIndex).iWlanNodeBuf);
+            delete iBuffer->At(i).iWlanNodeBuf;
+            }
+
+        iBuffer->Reset();
+        delete iBuffer;
+        }
+
+    if (iWlanSupported)
+        {
+        delete iWlanAdapter;
+        }
+
+    delete iDatabase;
+    FeatureManager::UnInitializeLib();
+    _DBG_FILE("CNSmlInternetAdapter::~CNSmlInternetAdapter(): end");
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::ConstructL()
+//      Second phase constructor.
+//=============================================
+void CNSmlInternetAdapter::ConstructL()
+    {
+    FeatureManager::InitializeLibL();
+    iField = HBufC8::NewL(KNSmlMaxURLLength);
+
+    iPrevURI = HBufC8::NewL(KNSmlMaxURLLength);
+
+    iDatabase = CCommsDatabase::NewL();
+    // iDatabase->BeginTransaction(); //+++
+    iTransactionCommitted = ETrue;
+    i3GPPPS = EFalse;
+
+    iLeafType = EDMUnset; // Default for leaf handling
+
+    //  Reset identification data
+
+    iDirection = ECommDbConnectionDirectionUnknown;
+
+    //
+    //  Command buffering used for AddNode + AddLeaf
+    //
+    iBuffer = new (ELeave) CArrayFixFlat<TNSmlAPBufferElement> (
+            KNSmlAPGranularity);
+
+    // checks if Wlan feature is supported
+    iWlanSupported = FeatureManager::FeatureSupported(KFeatureIdProtocolWlan);
+
+    // WlanAdapter 
+    //  
+    if (iWlanSupported)
+        {
+        iWlanAdapter = CNSmlWLanAdapter::NewL(iCallBack, *iDatabase);
+        }
+
+    iNetworkId = KErrNotFound;
+    iLingerValue = NULL;
+    iLingerFlag = ETrue;
+    isAdd = EFalse;
+    }
+
+//------------------------------------------------------------------------------
+// void CNSmlInternetAdapter::DDFVersionL()
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::DDFVersionL(CBufBase& aDDFVersion)
+    {
+    aDDFVersion.InsertL(0, KNSmlInternetAdapterDDFversion);
+    }
+//------------------------------------------------------------------------------
+//  void CNSmlInternetAdapter::DDFStructureL()
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::DDFStructureL(MSmlDmDDFObject& aDDF)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::DDFStructureL(): begin");
+
+    //
+    // Set rest acceptable operations for data itself
+    //
+
+    TSmlDmAccessTypes aclTypesAddGetDel;
+    aclTypesAddGetDel.SetGet();
+    aclTypesAddGetDel.SetAdd();
+    aclTypesAddGetDel.SetDelete();
+
+    TSmlDmAccessTypes aclTypesAddGet;
+    aclTypesAddGet.SetGet();
+    aclTypesAddGet.SetAdd();
+
+    TSmlDmAccessTypes aclTypesNoDelete;
+    aclTypesNoDelete.SetGet();
+    aclTypesNoDelete.SetReplace();
+    aclTypesNoDelete.SetAdd();
+
+    TSmlDmAccessTypes aclTypesNoGet;
+    aclTypesNoGet.SetReplace();
+    aclTypesNoGet.SetAdd();
+    aclTypesNoGet.SetDelete();
+
+    TSmlDmAccessTypes aclTypesAddReplace;
+    aclTypesAddReplace.SetReplace();
+    aclTypesAddReplace.SetAdd();
+
+    TSmlDmAccessTypes aclTypesOnlyGet;
+    aclTypesOnlyGet.SetGet();
+
+    TSmlDmAccessTypes aclTypesAll;
+    aclTypesAll.SetGet();
+    aclTypesAll.SetReplace();
+    aclTypesAll.SetAdd();
+    aclTypesAll.SetDelete();
+
+    MSmlDmDDFObject* ddfRoot = &aDDF;
+    MSmlDmDDFObject& ddf = ddfRoot->AddChildObjectL(KNSmlDdfAP);
+
+    _LIT8(KDescription, "AP-Settings DDF description");
+    _LIT8(KDFTitle, "AP-settings title");
+
+    FillNodeInfoL(ddf, aclTypesOnlyGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EPermanent, MSmlDmDDFObject::ENode, KDescription);
+
+    ddf.SetDFTitleL(KDFTitle);
+    ddf.SetDefaultValueL(KNullDesC8);
+
+    MSmlDmDDFObject& nApDDF = ddf.AddChildObjectGroupL(); // For AP/<X>
+
+    FillNodeInfoL(nApDDF, aclTypesAll, MSmlDmDDFObject::EZeroOrMore,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nNAPDefRootDDF = nApDDF.AddChildObjectL(KNSmlDdfNAPDef); // NAPDef
+    FillNodeInfoL(nNAPDefRootDDF, aclTypesAddGet,
+            MSmlDmDDFObject::EZeroOrOne, // EZeroOrMore
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nNAPDefDDF = nNAPDefRootDDF.AddChildObjectGroupL(); // For NAPDef<x>
+    FillNodeInfoL(nNAPDefDDF, aclTypesAddGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nPxRootDDF = nApDDF.AddChildObjectL(KNSmlDdfPx); // Px
+    FillNodeInfoL(nPxRootDDF, aclTypesAddGet, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nPxDDF = nPxRootDDF.AddChildObjectGroupL(); // For Px<x>
+    FillNodeInfoL(nPxDDF,
+            aclTypesAddGetDel,//aclTypesAddGet
+            MSmlDmDDFObject::EOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNullDesC8);
+    //
+    //  NAPDef-node fields
+    //
+    MSmlDmDDFObject& nNameDDF = nNAPDefDDF.AddChildObjectL(KNSmlDdfNAPName); // Name
+    FillNodeInfoL(nNameDDF, aclTypesNoDelete, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfNAPNameDesc);
+
+    MSmlDmDDFObject& nNAPIDDDF = nNAPDefDDF.AddChildObjectL(KNSmlDdfNAPID); // NAPID
+    FillNodeInfoL(nNAPIDDDF, aclTypesOnlyGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfNAPIDDesc);
+
+    MSmlDmDDFObject& nNAPLingerDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfNAPLinger); // Linger
+    FillNodeInfoL(nNAPLingerDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EInt, KNSmlDdfNAPLingerDesc);
+
+    MSmlDmDDFObject& nNAPStartpgDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfStartpg); // Startpg
+    FillNodeInfoL(nNAPStartpgDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlDdfStartpgDesc);
+
+    MSmlDmDDFObject& nBearerRootDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfBearer); // Bearer 
+    FillNodeInfoL(nBearerRootDDF, aclTypesAddGet,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nBearerDDF = nBearerRootDDF.AddChildObjectGroupL(); // Bearer/<x>
+    FillNodeInfoL(nBearerDDF, aclTypesAddGet, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nBearerLDDF =
+            nBearerDDF.AddChildObjectL(KNSmlDdfBearerL); // BearerL
+    FillNodeInfoL(nBearerLDDF, aclTypesAddGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfBearerLDesc);
+
+    MSmlDmDDFObject& nDirectionDDF = nBearerDDF.AddChildObjectL(
+            KNSmlDdfDirection); // Direction
+    FillNodeInfoL(nDirectionDDF, aclTypesAddGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfDirectionDesc);
+
+    MSmlDmDDFObject& nNAPAddrDDF =
+            nNAPDefDDF.AddChildObjectL(KNSmlDdfNAPAddr); // NAPAddr
+    FillNodeInfoL(nNAPAddrDDF, aclTypesNoDelete, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfNAPAddrDesc);
+
+    MSmlDmDDFObject& nNAPAddrTyDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfNAPAddrTy); // NAPAddrTy
+    FillNodeInfoL(nNAPAddrTyDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlDdfNAPAddrTyDesc);
+
+    MSmlDmDDFObject& nDNSAddrRootDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfDNSAddr); // DNSAddr
+    FillNodeInfoL(nDNSAddrRootDDF, aclTypesAddGet,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nDNSAddrDDF = nDNSAddrRootDDF.AddChildObjectGroupL(); // DNSAddr/<x>
+    FillNodeInfoL(nDNSAddrDDF, aclTypesAddGet, MSmlDmDDFObject::EOneOrMore,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nDNSAddrLDDF = nDNSAddrDDF.AddChildObjectL(
+            KNSmlDdfDNSAddrL); // DNSAddrL
+    FillNodeInfoL(nDNSAddrLDDF, aclTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfDNSAddrLDesc);
+
+    MSmlDmDDFObject& nDNSAddrTyDDF = nDNSAddrDDF.AddChildObjectL(
+            KNSmlDdfDNSAddrTy); // DNSAddrTy
+    FillNodeInfoL(nDNSAddrTyDDF, aclTypesOnlyGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfDNSAddrTyDesc);
+
+    MSmlDmDDFObject& nDNSPriorityDDF = nDNSAddrDDF.AddChildObjectL(
+            KNSmlDdfDNSPriority); // DNSAddrPriority
+    FillNodeInfoL(nDNSPriorityDDF, aclTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfDNSPriorityDesc);
+
+    MSmlDmDDFObject& nNAPAuthInfRootDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfNAPAuthInf); // NAPAuthInf 
+    FillNodeInfoL(nNAPAuthInfRootDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nNAPAuthInfDDF =
+            nNAPAuthInfRootDDF.AddChildObjectGroupL(); // NAPAuthInf/<x>
+    FillNodeInfoL(nNAPAuthInfDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nAuthNameDDF = nNAPAuthInfDDF.AddChildObjectL(
+            KNSmlDdfAuthName); // AuthName
+    FillNodeInfoL(nAuthNameDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlDdfAuthNameDesc);
+
+    MSmlDmDDFObject& nAuthSecrDDF = nNAPAuthInfDDF.AddChildObjectL(
+            KNSmlDdfAuthSecr); // AuthSecr
+    FillNodeInfoL(nAuthSecrDDF, aclTypesAddReplace,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlDdfAuthSecrDesc);
+
+    MSmlDmDDFObject& nDefGWDDF = nNAPDefDDF.AddChildObjectL(KNSmlDdfDefGW); // DefGW
+    FillNodeInfoL(nDefGWDDF, aclTypesNoDelete, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfDefGWDesc);
+
+    MSmlDmDDFObject& nNetworkMaskDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfNetworkMask); // NetworkMask
+    FillNodeInfoL(nNetworkMaskDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlDdfNetworkMaskDesc);
+
+    MSmlDmDDFObject& nUsePTxtLogDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfUsePTxtLog); // UsePTxtLog
+    FillNodeInfoL(nUsePTxtLogDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlDdfUsePTxtLogDesc);
+
+    MSmlDmDDFObject& nNetworksRootDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfNetworks); // Networks 
+    FillNodeInfoL(nNetworksRootDDF, aclTypesAddGet,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nNetworksDDF = nNetworksRootDDF.AddChildObjectGroupL(); // Networks/<x>
+    FillNodeInfoL(nNetworksDDF, aclTypesAddGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nNetworkNameDDF = nNetworksDDF.AddChildObjectL(
+            KNSmlDdfNetworkName); // NetworkName
+    FillNodeInfoL(nNetworkNameDDF, aclTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfNetworkNameDesc);
+
+    MSmlDmDDFObject& nNetworkIDDDF = nNetworksDDF.AddChildObjectL(
+            KNSmlDdfNetworkID); // NetworkID
+    FillNodeInfoL(nNetworkIDDDF, aclTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EInt,
+            KNSmlDdfNetworkIDDesc);
+
+    MSmlDmDDFObject& nPPPCompDDF =
+            nNAPDefDDF.AddChildObjectL(KNSmlDdfPPPComp); // PPPComp
+    FillNodeInfoL(nPPPCompDDF, aclTypesNoDelete, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EBool,
+            KNSmlDdfPPPCompDesc);
+
+    MSmlDmDDFObject& nGPRSPDPDDF =
+            nNAPDefDDF.AddChildObjectL(KNSmlDdfGPRSPDP); // GPRSPDP
+    FillNodeInfoL(nGPRSPDPDDF, aclTypesNoDelete, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfGPRSPDPDesc);
+
+    MSmlDmDDFObject& nIPAddrFromServerDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfIPAddrFromServer); // IPAddrFromServer
+    FillNodeInfoL(nIPAddrFromServerDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlDdfIPAddrFromServerDesc);
+
+    MSmlDmDDFObject& nIPAddrDDF = nNAPDefDDF.AddChildObjectL(KNSmlDdfIPAddr); // IPAddr
+    FillNodeInfoL(nIPAddrDDF, aclTypesNoDelete, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfIPAddrDesc);
+
+    MSmlDmDDFObject& nDNSAddrFromServerDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfDNSAddrFromServer); // DNSAddrFromServer
+    FillNodeInfoL(nDNSAddrFromServerDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlDdfDNSAddrFromServerDesc);
+
+    MSmlDmDDFObject& nIPv6DNSAddrFromServerDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfIPv6DNSAddrFromServer); // IPv6DNSAddrFromServer
+    FillNodeInfoL(nIPv6DNSAddrFromServerDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlDdfIPv6DNSAddrFromServerDesc);
+
+    MSmlDmDDFObject& nIfNetworksDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfIfNetworks); // IfNetworks
+    FillNodeInfoL(nIfNetworksDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlDdfIfNetworksDesc);
+
+    MSmlDmDDFObject& nIAPServiceDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfIAPService); // IAPService
+    FillNodeInfoL(nIAPServiceDDF, aclTypesOnlyGet,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlDdfIAPServiceDesc);
+
+    MSmlDmDDFObject& nIAPSeamlessnessDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfIAPSeamlessness); // IAPService
+    FillNodeInfoL(nIAPSeamlessnessDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EInt, KNSmlDdfIAPSeamlessnessDesc);
+    MSmlDmDDFObject& nIAPMetaDataDDF = nNAPDefDDF.AddChildObjectL(
+            KNSmlDdfIAPMetaData); // IAPService
+    FillNodeInfoL(nIAPMetaDataDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EInt, KNSmlDdfIAPMetaDataDesc);
+
+    if (iWlanSupported)
+        {
+        iWlanAdapter->DDFStructureL(nNAPDefDDF); // Adds WLAN fields to DDF
+        }
+
+    //
+    //  Px-node fields
+    //
+    MSmlDmDDFObject& nPxNameDDF = nPxDDF.AddChildObjectL(KNSmlDdfPxName); // Name
+    FillNodeInfoL(nPxNameDDF, aclTypesNoDelete, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, KNSmlDdfPxDesc);
+
+    MSmlDmDDFObject& nPxIdDDF = nPxDDF.AddChildObjectL(KNSmlDdfPxId); // PxId
+    FillNodeInfoL(nPxIdDDF, aclTypesOnlyGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfPxIdDesc);
+
+    MSmlDmDDFObject& nDomainRootDDF = nPxDDF.AddChildObjectL(KNSmlDdfDomain); // Domain 
+    FillNodeInfoL(nDomainRootDDF, aclTypesAddGet,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNSmlDdfDomainDesc);
+
+    MSmlDmDDFObject& nDomainDDF = nDomainRootDDF.AddChildObjectGroupL(); // Domain<x> 
+    FillNodeInfoL(nDomainDDF, aclTypesAddGet, MSmlDmDDFObject::EOneOrMore,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nDomainLDDF =
+            nDomainDDF.AddChildObjectL(KNSmlDdfDomainL); // DomainL (Get)
+    FillNodeInfoL(nDomainLDDF, aclTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfDomainLDesc);
+
+    MSmlDmDDFObject& nPxPWDDF = nPxDDF.AddChildObjectL(KNSmlDdfPxPW); // PxPW
+    FillNodeInfoL(nPxPWDDF, aclTypesNoDelete, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfPxPWDesc);
+
+    MSmlDmDDFObject& nPxAddrDDF = nPxDDF.AddChildObjectL(KNSmlDdfPxAddr); // PxAddr
+    FillNodeInfoL(nPxAddrDDF, aclTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfPxAddrDesc);
+
+    MSmlDmDDFObject& nPortRootDDF = nPxDDF.AddChildObjectL(KNSmlDdfPort); // Port 
+    FillNodeInfoL(nPortRootDDF, aclTypesAddGet, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode,
+            KNSmlDdfPortDesc);
+
+    MSmlDmDDFObject& nPortDDF = nPortRootDDF.AddChildObjectGroupL(); // Port<x> 
+    FillNodeInfoL(nPortDDF, aclTypesAddGet, MSmlDmDDFObject::EOneOrMore,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nPortNbrDDF = nPortDDF.AddChildObjectL(KNSmlDdfPortNbr); // PortNbr (Get)
+    FillNodeInfoL(nPortNbrDDF, aclTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EInt,
+            KNSmlDdfPortNbrDesc);
+
+    MSmlDmDDFObject& nToNAPIDRootDDF =
+            nPxDDF.AddChildObjectL(KNSmlDdfToNAPID); // ToNAPID 
+    FillNodeInfoL(nToNAPIDRootDDF, aclTypesOnlyGet,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNSmlDdfToNAPIDDesc);
+
+    MSmlDmDDFObject& nToNAPIDDDF = nToNAPIDRootDDF.AddChildObjectGroupL(); // ToNAPID<x> 
+    FillNodeInfoL(nToNAPIDDDF, aclTypesOnlyGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nToNAPIDLDDF = nToNAPIDDDF.AddChildObjectL(
+            KNSmlDdfToNAPIDL); // ToNAPIDL (Get)
+    FillNodeInfoL(nToNAPIDLDDF, aclTypesOnlyGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfToNAPIDLDesc);
+
+    MSmlDmDDFObject& nPxStartpgDDF = nPxDDF.AddChildObjectL(KNSmlDdfStartpg); // Startpg
+    FillNodeInfoL(nPxStartpgDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlDdfStartpgDesc);
+
+    MSmlDmDDFObject& nPxAuthInfRootDDF = nPxDDF.AddChildObjectL(
+            KNSmlDdfPxAuthInf); // PxAuthInf 
+    FillNodeInfoL(nPxAuthInfRootDDF, aclTypesAddGet,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nPxAuthInfDDF = nPxAuthInfRootDDF.AddChildObjectGroupL(); // PxAuthInf/<x>
+    FillNodeInfoL(nPxAuthInfDDF, aclTypesAddGet, MSmlDmDDFObject::EOneOrMore,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nPxAuthIdDDF = nPxAuthInfDDF.AddChildObjectL(
+            KNSmlDdfPxAuthId); // PxAuthId
+    FillNodeInfoL(nPxAuthIdDDF, aclTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlDdfPxAuthIdDesc);
+
+    MSmlDmDDFObject& nPxAuthPWDDF = nPxAuthInfDDF.AddChildObjectL(
+            KNSmlDdfPxAuthPW); // PxAuthPW
+    FillNodeInfoL(nPxAuthPWDDF, aclTypesAddReplace,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlDdfPxAuthPWDesc);
+
+    MSmlDmDDFObject& nNoPxForRootDDF =
+            nPxDDF.AddChildObjectL(KNSmlDdfNoPxFor); // NoPxFor 
+    FillNodeInfoL(nNoPxForRootDDF, aclTypesAddGet,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNSmlDdfNoPxForDesc);
+
+    MSmlDmDDFObject& nNoPxForDDF = nNoPxForRootDDF.AddChildObjectGroupL(); // NoPxFor<x> 
+    FillNodeInfoL(nNoPxForDDF, aclTypesAddGet, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNullDesC8);
+
+    MSmlDmDDFObject& nNoPxForLDDF = nNoPxForDDF.AddChildObjectL(
+            KNSmlDdfNoPxForL); // NoPxForL (Get)
+    FillNodeInfoL(nNoPxForLDDF, aclTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr,
+            KNSmlDdfNoPxForLDesc);
+
+    _DBG_FILE("CNSmlInternetAdapter::DDFStructureL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::LingerValueL()
+//------------------------------------------------------------------------------
+
+void CNSmlInternetAdapter::LingerValueL(const TDesC8& aObject)
+    {
+
+    TBuf<100> desObj;
+    CnvUtfConverter::ConvertToUnicodeFromUtf8(desObj, aObject);
+    TInt err(KErrNone);
+    //const TDesC& value = desObj;
+    if (!Notalpha(desObj))
+        {
+        TLex lex(desObj);
+        TUint Linger = 0;
+        TInt lingerint;
+        err = lex.Val(Linger, EDecimal);
+        if (err == KErrNone)
+            {
+            lingerint = Linger;
+            if (lingerint >= 0)
+                {
+                iLingerValue = lingerint;
+                iLingerFlag = EFalse;
+                }
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWPAPNapdef::UdateligerValueL
+// 
+// -----------------------------------------------------------------------------
+//
+TBool CNSmlInternetAdapter::Notalpha(const TDesC& aValue)
+    {
+    TBool NotAlpha = EFalse;
+    TChar character;
+    for (TInt i = 0; i < aValue.Length(); i++)
+        {
+        character = aValue[i];
+        NotAlpha = character.IsAlpha();
+        if (NotAlpha)
+            break;
+        }
+
+    return NotAlpha;
+    }
+// CNSmlInternetAdapter::AddLeafObjectL()
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::AddLeafObjectL(const TDesC8& aURI,
+        const TDesC8& aParentLUID, const TDesC8& aObject,
+        const TDesC8& aType, const TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): begin");
+    DBG_ARGS8(_S8("AP:add aURI AddLeafObjectL   - %S - %S"), &aURI,
+            &aParentLUID);
+    DBG_ARGS8(_S8("AP:Object %S"), &aObject);
+
+    isAdd = ETrue;
+
+    TInt parentLUID(0);
+    if (aParentLUID.Length() <= 0)
+        {
+        if (aURI.Match(_L8("AP/*/Px/*")) != KErrNotFound)
+            {
+            if (!GetProxyIdL(aURI))
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                return;
+                }
+            }
+        if (!iLUID)
+            iLUID = IntLUID(aParentLUID);
+        parentLUID = GetAPIdFromURIL(aURI);
+        if (parentLUID == 0)
+            {
+            if (IsAPUriFormatMatchPredefined(aURI))
+                {
+                iLUID = ConstructTreeL(aURI);
+                parentLUID = GetAPIdFromURIL(aURI);
+                }
+            }
+
+        }
+    else
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::AddLeafObjectL(): PParentLUID set to parentLUID");
+        parentLUID = IntLUID(aParentLUID);
+        }
+    // Always buffer DNSAddr/<X>/*
+    if ((parentLUID == 0 || aURI.Find(KNSmlDdfDNSPriority) >= 0 || aURI.Find(
+            KNSmlDdfDNSAddrL) >= 0) && !iExecutingBuffer)
+    // Update as add
+        {
+        iLeafType = EDMUnset; // Default for leaf handling
+        AddLeafBufferL(aURI, aParentLUID, aObject, aType, aStatusRef);
+        _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): end");
+        return;
+        }
+
+    if (parentLUID == KNSmlIncompleteAP)
+        {
+        _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+        return;
+        }
+
+    //check if Stale and add leaf buffer
+    if (parentLUID > 0 && !iExecutingBuffer)
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::AddLeafObjectL(): parentLUID > 0 && !iExecutingBuffer");
+        TUint32 apID = GetAPIdFromURIL(aURI);
+        if (!APExistsL(apID))
+            {
+            AddLeafBufferL(aURI, aParentLUID, aObject, aType, aStatusRef);
+            iStaleMapUpdate = ETrue;
+            _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): end");
+            return;
+            }
+        }
+    TInt pushed = 0;
+    //
+    //  Check which field going to be handled
+    //
+    SetField(aURI);
+    if ((iField->Compare(KNSmlDdfNAPLinger) == 0))
+        {
+        TUint32 apID = GetAPIdFromURIL(aURI);
+        if (aObject.Size() == 0)
+            {
+            DeleteLingerL(apID);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            return;
+            }
+        LingerValueL(aObject);
+
+        if (!iLingerFlag)
+            {
+            iLingerFlag = ETrue;
+            TRAPD(error, AddLingerL(apID, iLingerValue));
+            if (error == !KErrNone)
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                }
+            else
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+                }
+            }
+        else
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            }
+        return;
+        }
+
+    //
+    //  On leaf handling and add, must be checked that value not set before
+    // 
+    if (iLeafType != EDMUpdate && iLeafType != EDMDelete)
+        {
+        iLeafType = EDMAdd;
+        }
+    if (iStaleMapUpdate)
+        {
+        iLeafType = EDMAdd;
+        }
+
+    TPtrC qTable = TPtrC(KNullDesC);
+    TPtrC qColumn = TPtrC(KNullDesC);
+    TPtrC qDB = TPtrC(COMMDB_ID);
+
+    if (aURI.Find(KNSmlDdfPortNbr) >= 0)
+        {
+        IsWapPort(aObject);
+        }
+    //
+    //  Get Database field type 
+    //
+
+    if (parentLUID > 0)
+        {
+        // Get IAP nbr for servicetype
+        TUint32 iapIDs = GetAPIdFromURIL(aURI);
+
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): checkluid is %d and iapId %d "),
+                parentLUID, iapIDs);
+
+        //  IAP-table search serviceType (=Bearer)
+        CCommsDbTableView* iapViews = iDatabase->OpenViewMatchingUintLC(
+                TPtrC(IAP), TPtrC(COMMDB_ID), iapIDs);
+
+        TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+
+        TInt errorCode = iapViews->GotoFirstRecord();
+
+        // Read iapService from (IAP)
+        if (errorCode == KErrNone)
+            {
+            iapViews->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+            CleanupStack::PopAndDestroy(); // iapViews
+            qTable.Set(serviceType);
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy(); // iapViews
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddLeafObjectL(): ENotFound 1 end");
+            return;
+            }
+        }
+
+    if (iWlanSupported)
+        {
+        TBool wLANfield = IsWLANfield(aURI);
+        if (wLANfield)
+            {
+            iWlanAdapter->AddLeafObjectL(aURI, aParentLUID, aObject, aType,
+                    aStatusRef);
+            CleanupStack::PopAndDestroy(pushed);
+            return;
+            }
+        }
+
+    TInt fType = GetAPFieldType(aURI);
+    if (fType == EWrong) // Error if leaf not supported
+        {
+        _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+        return;
+        }
+
+    TBool fieldOK = GetAPField(qTable, qColumn);
+    if (!fieldOK) // OK if column for table not supported
+        {
+        _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): EOk end");
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        return;
+        }
+
+    iISPId = parentLUID;
+    if (aURI.Match(_L8("AP/*/Px/*/*")) != KErrNotFound)
+        {
+        if (iProxyId == 0)
+            iProxyId = parentLUID;
+        }
+
+    if ((fType == CNSmlInternetAdapter::EStr) || (fType
+            == CNSmlInternetAdapter::EInt && aURI.Find(KNSmlDdfGPRSPDP) >= 0)
+            || // KNSmlDdfNAPAddrTy
+            (fType == CNSmlInternetAdapter::EInt && aURI.Find(
+                    KNSmlDdfNAPAddrTy) >= 0)) // KNSmlDdfNAPAddrTy
+        { // Name + NAPAddr + DNSAddr +  Networks/*/Name
+
+        if (aURI.Match(_L8("AP/*/Networks/*/Name")) != KErrNotFound)
+            {
+            TUint32 checkLUID = 0;
+            TUint32 iapID1 = GetAPIdFromURIL(aURI);
+
+            //  IAP-table NetworkId Update
+            CCommsDbTableView* iapUpdate = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(IAP), TPtrC(COMMDB_ID), iapID1);
+            TInt iapExists = iapUpdate->GotoFirstRecord();
+
+            if (iapExists == KErrNone)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL, Get network id");
+                iapUpdate->ReadUintL(TPtrC(IAP_NETWORK), checkLUID);
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObjectL(): networks is %d"),
+                        checkLUID);
+                _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL, IAP exists");
+                if (checkLUID > 0)
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL, network id > 0");
+                    //check if network exist in NETWORK TABLE 
+                    CCommsDbTableView* checknetView;
+                    checknetView = iDatabase->OpenViewMatchingUintLC(TPtrC(
+                            NETWORK), TPtrC(COMMDB_ID), checkLUID);
+                    TInt error = checknetView->GotoFirstRecord();
+                    if (error == KErrNotFound)
+                        {
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::AddLeafObjectL: Network does not exist, create it");
+                        AddNetworkL(checkLUID, aObject);
+                        if (checkLUID > 0)
+                            {
+                            _DBG_FILE(
+                                    "CNSmlInternetAdapter::AddLeafObjectL: network generation ok");
+                            DBG_ARGS8(
+                                    _S8(
+                                            "CNSmlInternetAdapter::AddLeafObjectL(): network id is %d"),
+                                    checkLUID);
+                            //iapUpdate->WriteUintL(TPtrC(IAP_NETWORK),checkLUID); 
+                            }
+                        else
+                            {
+                            _DBG_FILE(
+                                    "CNSmlInternetAdapter::AddLeafObjectL(): network generation failed");
+                            iCallBack->SetStatusL(aStatusRef,
+                                    CSmlDmAdapter::EError);
+                            return;
+                            }
+                        }
+                    // Network was found, update the name to the given name.
+                    else
+                        {
+                        if (checknetView->UpdateRecord() == KErrNone)
+                            {
+                            _DBG_FILE(
+                                    "CNSmlInternetAdapter::AddLeafObjectL: network found, update name");
+                            checknetView->WriteTextL(TPtrC(COMMDB_NAME),
+                                    ConvertTo16LC(aObject));
+                            _DBG_FILE(
+                                    "CNSmlInternetAdapter::AddLeafObjectL: network name updated");
+                            checknetView->PutRecordChanges();
+                            CleanupStack::PopAndDestroy(); //ConvertTo16LC
+                            }
+                        // writing failed for some reason
+                        else
+                            {
+                            _DBG_FILE(
+                                    "CNSmlInternetAdapter::AddLeafObjectL(): network generation failed");
+                            iCallBack->SetStatusL(aStatusRef,
+                                    CSmlDmAdapter::EError);
+                            return;
+                            }
+                        }
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL: network ok");
+                    CleanupStack::PopAndDestroy(); //checknetView
+                    }
+                }
+            // IAP does not exist yet, create network, network id will be updated later using checkLUID
+            else
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL: network does not exist, creation 2");
+                AddNetworkL(checkLUID, aObject);
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObjectL(): network id is %d"),
+                        checkLUID);
+                }
+            CleanupStack::PopAndDestroy(); // iapUpdate
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddLeafObjectL: network addition handled");
+
+            //  IAP-table NetworkId Update
+            CCommsDbTableView* iapView = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(IAP), TPtrC(COMMDB_ID), iapID1);
+            TInt iapFound = iapView->GotoFirstRecord();
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddLeafObjectL: network id update begin");
+            if (iapFound == KErrNone)
+                {
+                TBool iapReLock = EFalse;
+                if (FeatureManager::FeatureSupported(
+                        KFeatureIdSapPolicyManagement))
+                    {
+                    TBool apEnforce = EFalse;
+                    TRAPD(eError,apEnforce=CheckEnforcementL())
+                    DBG_ARGS8(_S8("CNSmlInternetAdapter::AddLeafObjectL(): EError %d , APEnforcement is %d"),eError,apEnforce);
+                    if (eError == KErrNone && apEnforce)
+                        {
+                        DoLockIAPTablesL(EFalse);
+                        ((CCommsDbProtectTableView*) iapView)->UnprotectRecord();
+                        iWAPRelock = ETrue;
+                        }
+                    }
+
+                if (IsIAPRecordLockedL(iapID1))
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is LOCKED");
+                    TInt
+                            reclockerr =
+                                    ((CCommsDbProtectTableView*) iapView)->UnprotectRecord();
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                            reclockerr);
+                    if (reclockerr == KErrNone)
+                        iapReLock = ETrue;
+                    }
+                else
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is not write protected");
+                    }
+
+                if (iapView->UpdateRecord() == KErrNone)
+                    {
+                    iapView->WriteUintL(TPtrC(IAP_NETWORK), checkLUID);
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObject(): checkLUID is %d"),
+                            checkLUID);
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObject, IAP_NETWORK set to checkLUID ");
+                    iapView->PutRecordChanges();
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObject, iap found, set iNetworkId to checkLUID");
+                    iNetworkId = checkLUID;
+                    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+                    }
+                else
+                    {
+                    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                    }
+
+                if (FeatureManager::FeatureSupported(
+                        KFeatureIdSapPolicyManagement))
+                    {
+                    if (iWAPRelock)
+                        {
+                        DoLockIAPTablesL(ETrue);
+                        ((CCommsDbProtectTableView*) iapView)->ProtectRecord();
+                        iWAPRelock = EFalse;
+                        }
+                    }
+                if (iapReLock)
+                    {
+                    TInt reclockerr = DoProtectIAPRecordL(iapID1, ETrue);
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObjectL ,Protecting IAPAccessRecord returned code = %d"),
+                            reclockerr);
+                    if (reclockerr == KErrNone)
+                        iapReLock = EFalse;
+                    }
+                }
+            else if (iapFound == KErrNotFound)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObject, iap not found, set iNetworkId");
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObject(): checkLUID is %d"),
+                        checkLUID);
+                iNetworkId = checkLUID;
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+                }
+            else
+                {
+                _DBG_FILE("CNSmlInternetAdapter::AddLeafObject, iap found");
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                }
+
+            CleanupStack::PopAndDestroy(); // iapView
+            CleanupStack::PopAndDestroy(pushed);
+
+            _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): OK end");
+            return;
+            }
+
+        else if (((aURI.Match(_L8("AP/*/Px/*/Name")) != KErrNotFound || // ProxyName
+                aURI.Match(_L8("AP/*/Px/*/PxAddr")) != KErrNotFound || // ProxyAddr
+                aURI.Match(_L8("AP/*/Px/*/DomainL")) != KErrNotFound) // DomainL (PROXY_PROTOCOL_NAME)
+                && iLeafType == EDMUpdate)
+                || ((aURI.Match(_L8("AP/*/Px/*/PxAddr")) != KErrNotFound
+                        || aURI.Match(_L8("AP/*/Px/*/DomainL"))
+                                != KErrNotFound) && iLeafType == EDMAdd))
+            {
+            CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(PROXIES), TPtrC(COMMDB_ID), iProxyId);
+            TBool proxyReLock = EFalse;
+            if (IsProxyRecordLockedL(iProxyId))
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): proxy record is LOCKED");
+                TInt
+                        reclockerr =
+                                ((CCommsDbProtectTableView*) tableView)->UnprotectRecord();
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting ProxyRecord returned code = %d"),
+                        reclockerr);
+                if (reclockerr == KErrNone)
+                    proxyReLock = ETrue;
+                }
+            else
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is not write protected");
+                }
+
+            TInt errorCode = tableView->GotoFirstRecord();
+            if (errorCode == KErrNone)
+                {
+                if (tableView->UpdateRecord() == KErrNone)
+                    {
+                    if (aURI.Match(_L8("AP/*/Px/*/PxAddr")) != KErrNotFound)
+                        {
+                        tableView->WriteLongTextL(TPtrC(PROXY_SERVER_NAME),
+                                ConvertTo16LC(aObject));
+                        pushed++;
+                        }
+                    else if (aURI.Match(_L8("AP/*/Px/*/DomainL"))
+                            != KErrNotFound)
+                        {
+                        // Accepted values are (http, https, ftp, ftps)
+                        _LIT8(KProxyProtocol, "http, https, ftp, ftps");
+
+                        TInt protocolFound = 0;
+                        if (aObject.Length() > 0)
+                            {
+                            protocolFound = KProxyProtocol().Find(aObject);
+                            }
+                        if (protocolFound == KErrNotFound && aObject.Length()
+                                > 0)
+                            {
+                            CleanupStack::PopAndDestroy(); // tableView
+                            CleanupStack::PopAndDestroy(pushed);
+                            iCallBack->SetStatusL(aStatusRef,
+                                    CSmlDmAdapter::EError);
+                            _DBG_FILE(
+                                    "CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+                            return;
+                            }
+                        if (aObject.Length() == 0)
+                            {
+                            tableView->SetNullL(TPtrC(PROXY_PROTOCOL_NAME));
+                            }
+                        else
+                            {
+                            tableView->WriteTextL(TPtrC(PROXY_PROTOCOL_NAME),
+                                    ConvertTo16LC(aObject));
+                            CleanupStack::PopAndDestroy(); //ConvertTo16LC
+                            }
+                        }
+                    tableView->PutRecordChanges();
+                    CleanupStack::PopAndDestroy(); // tableView
+                    }
+                else
+                    {
+                    CleanupStack::PopAndDestroy(); // tableView
+                    CleanupStack::PopAndDestroy(pushed);
+                    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+                    return;
+                    }
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy(); // tableView
+                CleanupStack::PopAndDestroy(pushed);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): ENotFound end");
+                return;
+                }
+            if (proxyReLock)
+                {
+                TInt reclockerr = DoProtectProxyRecordL(iProxyId, ETrue);
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting Proxy returned code = %d"),
+                        reclockerr);
+                if (reclockerr == KErrNone)
+                    proxyReLock = EFalse;
+                }
+            CleanupStack::PopAndDestroy(pushed);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): EOk end");
+            return;
+            }
+
+        if (iLeafType == EDMUpdate || (iLeafType == EDMAdd && (aURI.Find(
+                KNSmlDdfNAPName) >= 0 && aURI.Find(KNSmlDdfNAPDef) >= 0)
+                || aURI.Find(KNSmlDdfNAPAddr) >= 0 || aURI.Find(
+                KNSmlDdfGPRSPDP) >= 0 || aURI.Find(KNSmlDdfDNSAddrL) >= 0
+                || aURI.Find(KNSmlDdfAuthSecr) >= 0 || aURI.Find(
+                KNSmlDdfDefGW) >= 0 || aURI.Find(KNSmlDdfNetworkMask) >= 0
+                || aURI.Find(KNSmlDdfIPAddr) >= 0 || aURI.Find(
+                KNSmlDdfNAPAddrTy) >= 0))
+            {
+            // Get IAP nbr for servicetype
+
+            TUint32 iapID2 = GetAPIdFromURIL(aURI);
+
+            //  IAP-table search serviceType (=Bearer)
+            CCommsDbTableView
+                    * serviceView = iDatabase->OpenViewMatchingUintLC(TPtrC(
+                            IAP), qDB, iapID2);
+
+            TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+
+            TInt errorCode = serviceView->GotoFirstRecord();
+
+            // Read serviceType from (IAP)
+            if (errorCode == KErrNone)
+                {
+                serviceView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+                serviceView->ReadTextL(TPtrC(IAP_SERVICE_TYPE),
+                        iProxyServiceType); // for locking
+
+                serviceView->ReadUintL(TPtrC(IAP_SERVICE), iISPId);
+
+                CleanupStack::PopAndDestroy(); // serviceView
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy(); // serviceView
+                CleanupStack::PopAndDestroy(pushed);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): ENotFound end");
+                return;
+                }
+            qTable.Set(serviceType);
+
+            CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                    serviceType, qDB, iISPId);
+
+            errorCode = tableView->GotoFirstRecord();
+
+            if (errorCode == KErrNone)
+                {
+                TBool serviceReLock = EFalse;
+                if (IsServiceRecordLockedL(iISPId))
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is LOCKED");
+                    TInt
+                            reclockerr =
+                                    ((CCommsDbProtectTableView*) tableView)->UnprotectRecord();
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting WAPAccessRecord returned code = %d"),
+                            reclockerr);
+                    if (reclockerr == KErrNone)
+                        serviceReLock = ETrue;
+                    }
+                else
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is not write protected");
+                    }
+
+                if (tableView->UpdateRecord() != KErrNone)
+                    {
+                    //database locked
+                    CleanupStack::PopAndDestroy(); // tableView
+                    CleanupStack::PopAndDestroy(pushed);
+                    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): Update failed end");
+                    return;
+                    }
+                if (fType == CNSmlInternetAdapter::EInt)
+                    {
+                    TUint32 object32;
+                    if (aURI.Find(KNSmlDdfGPRSPDP) >= 0 || /* GPRSPDP handling */
+                    aURI.Find(KNSmlDdfNAPAddrTy) >= 0) /* NAPAddrTy handling */
+                        {
+                        if (aObject.MatchF(KNSmlDmApValIpv4) != KErrNotFound)
+                            {
+                            object32 = RPacketContext::EPdpTypeIPv4;
+                            }
+                        else if (aObject.MatchF(KNSmlDmApValIpv6)
+                                != KErrNotFound)
+                            {
+                            object32 = RPacketContext::EPdpTypeIPv6;
+                            }
+                        else if (aObject.MatchF(_L8("PPP")) != KErrNotFound)
+                            {
+                            object32 = RPacketContext::EPdpTypePPP;
+                            }
+                        else
+                            { // NotValid value
+                            tableView->CancelRecordChanges();
+                            CleanupStack::PopAndDestroy(); // tableView
+                            CleanupStack::PopAndDestroy(pushed);
+                            iCallBack->SetStatusL(aStatusRef,
+                                    CSmlDmAdapter::EError);
+                            _DBG_FILE(
+                                    "CNSmlInternetAdapter::AddLeafObjectL(): Update failed end");
+                            return;
+                            }
+                        }
+                    else
+                        {
+                        object32 = GetIntObject8(aObject);
+                        }
+
+                    tableView->WriteUintL(qColumn, object32);
+                    }
+                else
+                    {
+                    // This should be executed only when executing buffered cmds
+                    if (aURI.Find(KNSmlDdfDNSAddrL) >= 0)
+                    // DNS address 
+                        {
+                        TPtrC8 parentUri = RemoveLastSeg(aURI);
+                        TInt dnsPri = 0;
+                        TBool found = InitializeDNSParamsFromBuffL(parentUri,
+                                dnsPri);
+                        UriUtils::TUriHostType dnsAddrTy =
+                                UriUtils::HostType(aObject);
+
+                        if (!found)
+                            {
+                            UriUtils::TUriHostType dnsLuidType;
+                            TInt dnsLuidPriority;
+                            if (LuidToDns(dnsLuidType, dnsLuidPriority,
+                                    parentLUID) != KErrNone)
+                                {
+                                if (dnsAddrTy == UriUtils::EIPv4Host)
+                                    {
+                                    iDnsIpv4Pri = (iDnsIpv4Pri % 2) + 1;
+                                    dnsPri = iDnsIpv4Pri;
+                                    }
+                                else if (dnsAddrTy == UriUtils::EIPv6Host)
+                                    {
+                                    iDnsIpv6Pri = (iDnsIpv6Pri % 2) + 1;
+                                    dnsPri = iDnsIpv6Pri;
+                                    }
+                                }
+                            else
+                                {
+                                // update
+                                dnsPri = dnsLuidPriority;
+                                }
+
+                            }
+                        if (dnsPri != 0)
+                            {
+                            if (dnsPri == 1)
+                                {
+                                if (dnsAddrTy == UriUtils::EIPv4Host)
+                                    {
+                                    qColumn.Set(
+                                            TPtrC(SERVICE_IP_NAME_SERVER1));
+                                    }
+                                else
+                                    {
+                                    qColumn.Set(TPtrC(
+                                            SERVICE_IP6_NAME_SERVER1));
+
+                                    }
+                                }
+                            else
+                                {
+                                if (dnsAddrTy == UriUtils::EIPv4Host)
+                                    {
+                                    qColumn.Set(
+                                            TPtrC(SERVICE_IP_NAME_SERVER2));
+                                    }
+                                else
+                                    {
+                                    qColumn.Set(TPtrC(
+                                            SERVICE_IP6_NAME_SERVER2));
+
+                                    }
+                                }
+                            tableView->WriteTextL(qColumn, ConvertTo16LC(
+                                    aObject));
+                            pushed++;
+                            TInt dnsLuid = DnsToLuid(dnsAddrTy, dnsPri);
+                            iCallBack->SetMappingL(parentUri, SetIntObjectLC(
+                                    dnsLuid));
+                            pushed++;
+                            }
+                        else
+                            {
+                            CleanupStack::PopAndDestroy(); // tableView
+                            CleanupStack::PopAndDestroy(pushed);
+                            iCallBack->SetStatusL(aStatusRef,
+                                    CSmlDmAdapter::EError);
+                            _DBG_FILE(
+                                    "CNSmlInternetAdapter::AddLeafObjectL(): Update failed end");
+                            return;
+                            }
+
+                        }
+
+                    else
+                        {
+                        if ((serviceType == TPtrC(LAN_SERVICE))
+                                && (iField->Compare(KNSmlDdfNAPAddr) == 0))
+                            {
+                            if (!IsValidIPv4AddressL(aObject))
+                                {
+                                iCallBack->SetStatusL(aStatusRef,
+                                        CSmlDmAdapter::EInvalidObject);
+                                _DBG_FILE(
+                                        "CNSmlInternetAdapter::AddLeafObjectL(): EInvalidObject end");
+                                CleanupStack::PopAndDestroy(); // tableView
+                                CleanupStack::PopAndDestroy(pushed);
+                                return;
+                                }
+
+                            }
+                        tableView->WriteTextL(qColumn, ConvertTo16LC(aObject));
+                        pushed++;
+
+                        }
+                    // DNSAddrL <> 0.0.0.0 or empty => 
+                    if (aURI.Find(KNSmlDdfDNSAddrL) >= 0) /* DNS serviceFlag handling */
+                        {
+                        if (aObject.Match(_L8("fec0:0:0:ffff::1"))
+                                == KErrNotFound || aObject.Match(_L8(
+                                "fec0:0:0:ffff::2")) == KErrNotFound)
+                            {
+                            tableView->WriteBoolL(TPtrC(
+                                    SERVICE_IP6_DNS_ADDR_FROM_SERVER), EFalse);
+                            }
+                        else
+                            {
+                            tableView->WriteBoolL(TPtrC(
+                                    SERVICE_IP6_DNS_ADDR_FROM_SERVER), ETrue);
+                            }
+
+                        }
+                    }
+                TInt putOk = tableView->PutRecordChanges();
+                if (putOk != KErrNone)
+                    {
+                    TInt retry = KBeginTransRetryCount;
+                    while (retry > 0 && putOk == KErrLocked)
+                        {
+                        User::After(KBeginTransRetryDelay);
+                        putOk = tableView->PutRecordChanges();
+                        retry--;
+                        }
+                    if (putOk != KErrNone)
+                        {
+                        CleanupStack::PopAndDestroy(); // tableView
+                        CleanupStack::PopAndDestroy(pushed);
+                        iCallBack->SetStatusL(aStatusRef,
+                                CSmlDmAdapter::EError);
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::AddLeafObjectL(): Update failed end");
+                        DBG_ARGS(
+                                _S16(
+                                        "CNSmlInternetAdapter::AddLeafObjectL(): Update failed with Code %d"),
+                                putOk);
+                        return;
+                        }
+                    }
+                if (aURI.Find(KNSmlDdfNAPName) >= 0 && aURI.Find(
+                        KNSmlDdfAuthName) <= 0) /* NAPName */
+                    {
+                    if (UpdateIAPnameL(iapID2, aObject) != KErrNone)
+                        {
+                        iCallBack->SetStatusL(aStatusRef,
+                                CSmlDmAdapter::EError);
+                        }
+                    }
+                if (serviceReLock)
+                    {
+                    TInt reclockerr = DoProtectServiceRecordL(iISPId, ETrue);
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting WAPAccessRecord returned code = %d"),
+                            reclockerr);
+                    if (reclockerr == KErrNone)
+                        serviceReLock = EFalse;
+                    }
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy(); // tableView
+                CleanupStack::PopAndDestroy(pushed);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): ENotFound end");
+                return;
+                }
+
+            CleanupStack::PopAndDestroy(); // tableView
+            }
+
+        }
+    else if (fType == CNSmlInternetAdapter::EBool)
+        { // UseCB + UseIPSec
+        TUint32 iapID3 = GetAPIdFromURIL(aURI);
+
+        //  IAP-table search serviceType (=Bearer)
+        CCommsDbTableView* boolView = iDatabase->OpenViewMatchingUintLC(
+                TPtrC(IAP), TPtrC(COMMDB_ID), iapID3);
+        TInt errorCode = boolView->GotoFirstRecord();
+
+        TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+
+        errorCode = boolView->GotoFirstRecord();
+
+        // Read serviceType from (IAP)
+        if (errorCode == KErrNone)
+            {
+            boolView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+            boolView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), iProxyServiceType); // for locking
+            boolView->ReadUintL(TPtrC(IAP_SERVICE), iISPId);
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy(); // boolView
+            CleanupStack::PopAndDestroy(pushed);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): ENotFound end");
+            return;
+            }
+
+        CleanupStack::PopAndDestroy(); // boolView
+
+        qTable.Set(serviceType);
+        TBool ret = GetAPField(qTable, qColumn);
+        if (!ret)
+            {
+            CleanupStack::PopAndDestroy(pushed);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EInvalidObject);
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddLeafObjectL(): EInvalidObject end");
+            return;
+            }
+
+        CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                serviceType, TPtrC(COMMDB_ID), iISPId);
+
+        errorCode = tableView->GotoFirstRecord();
+
+        if (errorCode == KErrNone)
+            {
+            TBool serviceReLock = EFalse;
+            if (IsServiceRecordLockedL(iISPId))
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is LOCKED");
+                TInt
+                        reclockerr =
+                                ((CCommsDbProtectTableView*) tableView)->UnprotectRecord();
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting WAPAccessRecord returned code = %d"),
+                        reclockerr);
+                if (reclockerr == KErrNone)
+                    serviceReLock = ETrue;
+                }
+            else
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is not write protected");
+                }
+            if (tableView->UpdateRecord() != KErrNone)
+                {
+                //database locked
+                CleanupStack::PopAndDestroy(); // tableView
+                CleanupStack::PopAndDestroy(pushed);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): Update failed end");
+                return;
+                }
+            TBool tObject = EFalse;
+
+            if (aObject.CompareF(KNSmlDmApValTrue) == 0)
+                {
+                tObject = ETrue;
+                }
+            if (aURI.Right(10).Compare(KNSmlDdfUsePTxtLog) == 0)
+                {
+                tObject = !tObject;
+                }
+            if (qColumn.Match(TPtrC(SERVICE_IP_ADDR_FROM_SERVER))
+                    != KErrNotFound)
+                {
+                if (serviceType == TPtrC(LAN_SERVICE)) // Is WLAN service
+                    {
+                    if (tObject)
+                        {
+                        tableView->WriteTextL(TPtrC(
+                                SERVICE_CONFIG_DAEMON_MANAGER_NAME),
+                                KDaemonManagerName);
+                        tableView->WriteTextL(TPtrC(
+                                SERVICE_CONFIG_DAEMON_NAME),
+                                KConfigDaemonName);
+                        }
+                    else
+                        {
+                        tableView->WriteTextL(TPtrC(
+                                SERVICE_CONFIG_DAEMON_MANAGER_NAME),
+                                KNullDesC);
+                        tableView->WriteTextL(TPtrC(
+                                SERVICE_CONFIG_DAEMON_NAME), KNullDesC);
+                        }
+                    }
+                } // Is WLAN service
+
+            tableView->WriteBoolL(qColumn, tObject);
+            tableView->PutRecordChanges();
+            CleanupStack::PopAndDestroy(); // tableView
+            if (serviceReLock)
+                {
+                TInt reclockerr = DoProtectServiceRecordL(iISPId, ETrue);
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting ServiceRecord returned code = %d"),
+                        reclockerr);
+                if (reclockerr == KErrNone)
+                    serviceReLock = EFalse;
+                }
+            }
+        else
+            {
+            tableView->CancelRecordChanges();
+            CleanupStack::PopAndDestroy(); // tableView
+            CleanupStack::PopAndDestroy(pushed);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+            return;
+            }
+        }
+    else if (fType == CNSmlInternetAdapter::EInt)
+        { // UsePTxtLog + PortNbr + seamlessness and metadata
+        iObject = GetIntObject8(aObject);
+
+        if (aURI.Find(KNSmlDdfIAPSeamlessness) >= 0)
+            {
+            // TUint32 setSeam = GetIntObject8(aObject);
+            TUint32 apMetaID = GetAPIdFromURIL(aURI);
+            SetIAPSeamlessnessL(apMetaID, iObject, aStatusRef);
+            return;
+            }
+
+        else if (aURI.Find(KNSmlDdfIAPMetaData) >= 0)
+            {
+            //  TUint32 setMeta = GetIntObject8(aObject);
+            TUint32 apMetaID = GetAPIdFromURIL(aURI);
+            SetIAPMetaDataL(apMetaID, iObject, aStatusRef);
+            return;
+            }
+
+        if (aURI.Find(KNSmlDdfUsePTxtLog) >= 0)
+            {
+            TUint32 iapID4 = GetAPIdFromURIL(aURI);
+
+            //  IAP-table search serviceType (=Bearer)
+            CCommsDbTableView* iapView4 = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(IAP), TPtrC(COMMDB_ID), iapID4);
+            TInt errorCode = iapView4->GotoFirstRecord();
+
+            TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+
+            errorCode = iapView4->GotoFirstRecord();
+
+            // Read serviceType from (IAP)
+            if (errorCode == KErrNone)
+                {
+                iapView4->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+                iapView4->ReadTextL(TPtrC(IAP_SERVICE_TYPE),
+                        iProxyServiceType); // for locking
+                iapView4->ReadUintL(TPtrC(IAP_SERVICE), iISPId);
+                CleanupStack::PopAndDestroy(); // iapView4
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy(); // iapView4
+                CleanupStack::PopAndDestroy(pushed);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): ENotFound end");
+                return;
+                }
+
+            CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                    serviceType, TPtrC(COMMDB_ID), iISPId);
+
+            errorCode = tableView->GotoFirstRecord();
+
+            if (errorCode == KErrNone)
+                {
+                TBool serviceReLock = EFalse;
+                if (IsServiceRecordLockedL(iISPId))
+                    {
+
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is LOCKED");
+                    TInt
+                            reclockerr =
+                                    ((CCommsDbProtectTableView*) tableView)->UnprotectRecord();
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting WAPAccessRecord returned code = %d"),
+                            reclockerr);
+                    if (reclockerr == KErrNone)
+                        serviceReLock = ETrue;
+                    }
+                else
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is not write protected");
+                    }
+                if (tableView->UpdateRecord() != KErrNone)
+                    {
+                    //database locked
+                    CleanupStack::PopAndDestroy(); // tableView
+                    CleanupStack::PopAndDestroy(pushed);
+                    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): Update failed end");
+                    return;
+                    }
+                TBool tObject = EFalse;
+                if (iObject)
+                    {
+                    tObject = ETrue; // <> 0
+                    }
+                tableView->WriteBoolL(TPtrC(SERVICE_DISABLE_PLAIN_TEXT_AUTH),
+                        tObject);
+                tableView->PutRecordChanges();
+                if (serviceReLock)
+                    {
+                    DoProtectIAPRecordL(iapID4, ETrue);
+                    TInt reclockerr = DoProtectServiceRecordL(iISPId, ETrue);
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting ServiceRecord returned code = %d"),
+                            reclockerr);
+                    if (reclockerr == KErrNone)
+                        serviceReLock = EFalse;
+                    }
+                CleanupStack::PopAndDestroy(); // tableView
+                }
+            else
+                {
+                tableView->CancelRecordChanges();
+                CleanupStack::PopAndDestroy(); // tableView
+                CleanupStack::PopAndDestroy(pushed);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+                return;
+                }
+            }
+        else if (aURI.Find(KNSmlDdfPortNbr) >= 0)
+            {
+            if (GetProxyIdL(aURI))
+                {
+                iProxyISP = GetAPIdFromURIL(aURI);
+
+                CCommsDbTableView* tableView =
+                        iDatabase->OpenViewMatchingUintLC(TPtrC(PROXIES),
+                                TPtrC(COMMDB_ID), iProxyId);
+                TInt errorCode = tableView->GotoFirstRecord();
+                TBool proxyReLock = EFalse;
+                // Read all columns needed.
+                if (errorCode == KErrNone)
+                    {
+                    if (IsProxyRecordLockedL(iProxyId))
+                        {
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::AddLeafObjectL(): proxy record is LOCKED");
+                        TInt
+                                reclockerr =
+                                        ((CCommsDbProtectTableView*) tableView)->UnprotectRecord();
+                        DBG_ARGS8(
+                                _S8(
+                                        "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting Proxy Record returned code = %d"),
+                                reclockerr);
+                        if (reclockerr == KErrNone)
+                            proxyReLock = ETrue;
+                        }
+                    else
+                        {
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is not write protected");
+                        }
+                    if (tableView->UpdateRecord() != KErrNone)
+                        {
+                        //database locked
+                        CleanupStack::PopAndDestroy(); // tableView
+                        CleanupStack::PopAndDestroy(pushed);
+                        iCallBack->SetStatusL(aStatusRef,
+                                CSmlDmAdapter::EError);
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::AddLeafObjectL(): Update failed end");
+                        return;
+                        }
+                    iObject = GetIntObject8(aObject);
+
+                    tableView->WriteUintL(TPtrC(PROXY_PORT_NUMBER), iObject);
+                    }
+                tableView->PutRecordChanges();
+                if (proxyReLock)
+                    {
+                    TInt reclockerr = DoProtectProxyRecordL(iProxyId, ETrue);
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting Proxy Record returned code = %d"),
+                            reclockerr);
+                    if (reclockerr == KErrNone)
+                        proxyReLock = EFalse;
+                    }
+                CleanupStack::PopAndDestroy(); // tableView
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy(pushed);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): PortNbr Error end");
+                return;
+                }
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy(pushed);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddLeafObjectL(): PortNbr Error end");
+            return;
+            }
+
+        }
+
+    else if (fType == CNSmlInternetAdapter::EWap)
+        { // Startpg + PxAuthId + PxAuthPW (WAP-settings) (BasAuthId + BasAuthPW)
+        TUint32 iapID5 = GetAPIdFromURIL(aURI);
+        //
+        // Without iapID5 no insert possible, set on buffer
+        //
+        if (iapID5 < 1)
+            {
+            AddLeafBufferL(aURI, aParentLUID, aObject, aType, aStatusRef);
+            _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): end");
+            return;
+            }
+
+        GetAPField(qTable, qColumn);
+        if (WapAPExistsL(iapID5))
+            { // Update handled
+            TBool iapReLock = EFalse;
+            if (FeatureManager::FeatureSupported(
+                    KFeatureIdSapPolicyManagement))
+                {
+                TBool apEnforce = EFalse;
+                TRAPD(eError,apEnforce=CheckEnforcementL())
+                DBG_ARGS8(_S8("CNSmlInternetAdapter::AddLeafObjectL(): EError %d , APEnforcement is %d"),eError,apEnforce);
+                if (eError == KErrNone && apEnforce)
+                    {
+                    DoLockIAPTablesL(EFalse);
+                    iWAPRelock = ETrue;
+                    }
+                }
+            if (IsIAPRecordLockedL(iapID5))
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is LOCKED");
+                TInt reclockerr = DoProtectIAPRecordL(iapID5, EFalse);
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                        reclockerr);
+                if (reclockerr == KErrNone)
+                    iapReLock = ETrue;
+                }
+            else
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is not write protected");
+                }
+            CCommsDbTableView* wapView;
+            TBool wapaccesspointTableLocked = EFalse;
+
+            if (qColumn == TPtrC(WAP_START_PAGE))
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): record to be added WAP_START_PAGE, check for lock status");
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObjectL Get WapAccessPoint record access for ID = %d"),
+                        iWapId);
+                if (IsWAPAccessPointRecordLockedL(iWapId))
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): wapaccesspoint record is LOCKED");
+                    TInt reclockerr = DoProtectWAPAccessRecordL(iWapId,
+                            EFalse);
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                            reclockerr);
+                    if (reclockerr == KErrNone)
+                        wapaccesspointTableLocked = ETrue;
+                    }
+                else
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): wapaccesspoint record is not write protected");
+                    }
+                wapView = iDatabase->OpenViewMatchingUintLC(TPtrC(
+                        WAP_ACCESS_POINT), TPtrC(COMMDB_ID), iWapId);
+                pushed++;
+                }
+            else // Other WAP-data
+                {
+                wapView = iDatabase->OpenViewMatchingUintLC(TPtrC(
+                        WAP_IP_BEARER), TPtrC(WAP_ACCESS_POINT_ID), iWapId);
+                pushed++;
+                }
+
+            TInt errorCode = wapView->GotoFirstRecord();
+
+            // Read all columns needed.
+            if (errorCode == KErrNone)
+                {
+                if (wapView->UpdateRecord() != KErrNone)
+                    {
+                    //database locked
+                    CleanupStack::PopAndDestroy(pushed);
+                    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): Wapview Update failed end");
+                    if (wapaccesspointTableLocked)
+                        {
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::AddLeafObjectL(): wapaccesspoint record to be locked again ");
+                        DoProtectWAPAccessRecordL(iWapId, ETrue);
+                        wapaccesspointTableLocked = EFalse;
+                        }
+                    if (FeatureManager::FeatureSupported(
+                            KFeatureIdSapPolicyManagement))
+                        {
+                        if (iWAPRelock)
+                            {
+                            DoLockIAPTablesL(ETrue);
+                            iWAPRelock = EFalse;
+                            }
+                        }
+                    if (iapReLock)
+                        {
+                        TInt reclockerr = DoProtectIAPRecordL(iapID5, ETrue);
+                        DBG_ARGS8(
+                                _S8(
+                                        "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting WAPAccessRecord returned code = %d"),
+                                reclockerr);
+                        if (reclockerr == KErrNone)
+                            iapReLock = EFalse;
+                        }
+                    return;
+                    }
+
+                if (qColumn == TPtrC(WAP_PROXY_PORT))
+                    {
+                    TBool security = EFalse; // => 9200 + 9201, ETrue 9202 + 9203
+                    TUint32 object32;
+                    TPtrC object16 = ConvertTo16LC(aObject);
+                    pushed++;
+                    if (object16.Match(KWappPort9200) != KErrNotFound)
+                        {
+                        object32 = KWAPP_PORT_9200; // wappdef.h
+                        }
+                    else if (object16.Match(KWappPort9201) != KErrNotFound)
+                        {
+                        object32 = KWAPP_PORT_9201;
+                        }
+                    else if (object16.Match(KWappPort9202) != KErrNotFound)
+                        {
+                        object32 = KWAPP_PORT_9202;
+                        security = ETrue;
+                        }
+                    else if (object16.Match(KWappPort9203) != KErrNotFound)
+                        {
+                        object32 = KWAPP_PORT_9203;
+                        security = ETrue;
+                        }
+                    else
+                        {
+                        wapView->CancelRecordChanges();
+                        CleanupStack::PopAndDestroy(pushed);
+                        iCallBack->SetStatusL(aStatusRef,
+                                CSmlDmAdapter::EError);
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+                        if (FeatureManager::FeatureSupported(
+                                KFeatureIdSapPolicyManagement))
+                            {
+                            if (iWAPRelock)
+                                {
+                                DoLockIAPTablesL(ETrue);
+                                iWAPRelock = EFalse;
+                                }
+                            }
+                        if (iapReLock)
+                            {
+                            TInt reclockerr = DoProtectIAPRecordL(iapID5,
+                                    ETrue);
+                            DBG_ARGS8(
+                                    _S8(
+                                            "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                                    reclockerr);
+                            if (reclockerr == KErrNone)
+                                iapReLock = EFalse;
+                            }
+                        return;
+                        }
+                    wapView->WriteUintL(qColumn, object32);
+                    wapView->WriteBoolL(TPtrC(WAP_SECURITY), security);
+                    }
+                else
+                    {
+                    wapView->WriteTextL(TPtrC(qColumn),
+                            ConvertTo16LC(aObject));
+                    pushed++;
+                    }
+                }
+            wapView->PutRecordChanges();
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddLeafObjectL(): wapaccesspoint record Changes DONE successfully ");
+            if (wapaccesspointTableLocked)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): wapaccesspoint record to be locked again ");
+                TInt reclockerr = DoProtectWAPAccessRecordL(iWapId, ETrue);
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObjectL ,Protecting WAPAccessRecord %d , returned code = %d"),
+                        iWapId, reclockerr);
+                wapaccesspointTableLocked = EFalse;
+                }
+            if (FeatureManager::FeatureSupported(
+                    KFeatureIdSapPolicyManagement))
+                {
+                if (iWAPRelock)
+                    {
+                    DoLockIAPTablesL(ETrue);
+                    iWAPRelock = EFalse;
+                    }
+                }
+            if (iapReLock)
+                {
+                TInt reclockerr = DoProtectIAPRecordL(iapID5, ETrue);
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting WAPAccessRecord returned code = %d"),
+                        reclockerr);
+                if (reclockerr == KErrNone)
+                    iapReLock = EFalse;
+                }
+            CleanupStack::PopAndDestroy(pushed);
+            pushed = 0;
+            }
+        else
+            { // Insert handled
+            CCommsDbTableView* insView;
+            TInt wapInitOK = KErrCancel;
+            TBool iapReLock = EFalse;
+
+            if (FeatureManager::FeatureSupported(
+                    KFeatureIdSapPolicyManagement))
+                {
+                TBool apEnforce = EFalse;
+                TRAPD(eError,apEnforce=CheckEnforcementL())
+                DBG_ARGS8(_S8("CNSmlInternetAdapter::AddLeafObjectL(): EError %d , APEnforcement is %d"),eError,apEnforce);
+                if (eError == KErrNone && apEnforce)
+                    {
+                    DoLockIAPTablesL(EFalse);
+                    iWAPRelock = ETrue;
+                    }
+                }
+            if (iapReLock)
+                {
+                TInt reclockerr = DoProtectIAPRecordL(iapID5, ETrue);
+                DBG_ARGS8(
+                        _S8(
+                                "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting WAPAccessRecord returned code = %d"),
+                        reclockerr);
+                if (reclockerr == KErrNone)
+                    iapReLock = EFalse;
+                }
+            insView = iDatabase->OpenTableLC(TPtrC(WAP_ACCESS_POINT));
+            iWapId = 0;
+            wapInitOK = insView->InsertRecord(iWapId);
+            if (wapInitOK == KErrNone)
+                {
+                iWAPAccessPoint.Zero();
+                iWapUserName.Zero();
+                iWapPassword.Zero();
+
+                if (qColumn == TPtrC(WAP_START_PAGE))
+                    {
+                    iWAPAccessPoint = aObject;
+                    }
+                else if (qColumn == TPtrC(WAP_PROXY_LOGIN_NAME))
+                    {
+                    iWapUserName = aObject;
+                    }
+                else if (qColumn == TPtrC(WAP_PROXY_LOGIN_PASS))
+                    {
+                    iWapPassword = aObject;
+                    }
+
+                iWapBearer = TPtrC(WAP_IP_BEARER);
+                iWapName = FirstURISeg(aURI); // Name needed !!!
+
+                wapInitOK = InitializeWAPIAPL(insView, iIAPName);
+                if (wapInitOK == KErrNone)
+                    {
+                    insView->PutRecordChanges();
+                    CleanupStack::PopAndDestroy(); // insView
+
+                    CCommsDbTableView* updView;
+                    TUint32 iWapId2 = 0;
+                    iISPId = iapID5; // IAP number set
+                    updView = iDatabase->OpenTableLC(TPtrC(WAP_IP_BEARER));
+                    if (updView->InsertRecord(iWapId2) == KErrNone)
+                        {
+                        wapInitOK = InitializeWAPL(updView);
+                        }
+                    else
+                        {
+                        wapInitOK = KErrGeneral;
+                        }
+                    if (wapInitOK == KErrNone)
+                        {
+                        if (!PxExistsL(iapID5))
+                            {
+
+                            // Set mapping-data
+
+                            TPtrC8 addURI = GetAddURISeg(aURI,
+                                    KNSmlDdfStartpg);
+                            TBuf8<16> addLUID;
+                            _LIT8(KFormat, "%d");
+                            addLUID.Format(KFormat, iapID5);
+                            iCallBack->SetMappingL(addURI, addLUID);
+                            }
+                        else if (!NAPDefExistsL(iapID5))
+                            {
+
+                            // Set mapping-data
+
+                            TPtrC8 addURI = GetAddURISeg(aURI,
+                                    KNSmlDdfStartpg);
+                            TBuf8<16> addLUID;
+                            _LIT8(KFormat, "%d");
+                            addLUID.Format(KFormat, iapID5);
+                            iCallBack->SetMappingL(addURI, addLUID);
+                            }
+
+                        updView->PutRecordChanges();
+                        CleanupStack::PopAndDestroy(); // updView
+                        CleanupStack::PopAndDestroy(pushed);
+                        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+
+                        if (FeatureManager::FeatureSupported(
+                                KFeatureIdSapPolicyManagement))
+                            {
+                            if (iWAPRelock)
+                                {
+                                DoLockIAPTablesL(ETrue);
+                                iWAPRelock = EFalse;
+                                }
+                            }
+                        if (iapReLock)
+                            {
+                            TInt reclockerr = DoProtectIAPRecordL(iapID5,
+                                    ETrue);
+                            DBG_ARGS8(
+                                    _S8(
+                                            "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                                    reclockerr);
+                            if (reclockerr == KErrNone)
+                                iapReLock = EFalse;
+                            }
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::AddLeafObjectL(): EOk end");
+                        return;
+                        }
+                    else
+                        {
+                        CleanupStack::PopAndDestroy(); // updView
+                        CleanupStack::PopAndDestroy(pushed);
+                        iCallBack->SetStatusL(aStatusRef,
+                                CSmlDmAdapter::EError);
+
+                        if (FeatureManager::FeatureSupported(
+                                KFeatureIdSapPolicyManagement))
+                            {
+                            if (iWAPRelock)
+                                {
+                                DoLockIAPTablesL(ETrue);
+                                iWAPRelock = EFalse;
+                                }
+                            }
+                        if (iapReLock)
+                            {
+                            TInt reclockerr = DoProtectIAPRecordL(iapID5,
+                                    ETrue);
+                            DBG_ARGS8(
+                                    _S8(
+                                            "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                                    reclockerr);
+                            if (reclockerr == KErrNone)
+                                iapReLock = EFalse;
+                            }
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+                        return;
+                        }
+                    }
+                else
+                    {
+                    insView->CancelRecordChanges();
+                    CleanupStack::PopAndDestroy(); // insView
+                    CleanupStack::PopAndDestroy(pushed);
+                    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+
+                    if (FeatureManager::FeatureSupported(
+                            KFeatureIdSapPolicyManagement))
+                        {
+                        if (iWAPRelock)
+                            {
+                            DoLockIAPTablesL(ETrue);
+                            iWAPRelock = EFalse;
+                            }
+                        }
+                    if (iapReLock)
+                        {
+                        TInt reclockerr = DoProtectIAPRecordL(iapID5, ETrue);
+                        DBG_ARGS8(
+                                _S8(
+                                        "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                                reclockerr);
+                        if (reclockerr == KErrNone)
+                            iapReLock = EFalse;
+                        }
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+                    return;
+                    }
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy(); // insView
+                CleanupStack::PopAndDestroy(pushed);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                if (FeatureManager::FeatureSupported(
+                        KFeatureIdSapPolicyManagement))
+                    {
+                    if (iWAPRelock)
+                        {
+                        DoLockIAPTablesL(ETrue);
+                        iWAPRelock = EFalse;
+                        }
+                    }
+                if (iapReLock)
+                    {
+                    TInt reclockerr = DoProtectIAPRecordL(iapID5, ETrue);
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                            reclockerr);
+                    if (reclockerr == KErrNone)
+                        iapReLock = EFalse;
+                    }
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+                return;
+                }
+            }
+        }
+    else if (fType == CNSmlInternetAdapter::ESpec)
+        { // BearerL + NoPxForL + IAPService + Direction
+        if (aURI.Find(KNSmlDdfDirection) >= 0)
+            {
+            _LIT8(KDirection, "Outgoing");
+            if (KDirection().Find(aObject) != KErrNotFound)
+                {
+                iDirection = ECommDbConnectionDirectionOutgoing;
+                }
+            else
+                {
+                iDirection = ECommDbConnectionDirectionIncoming;
+                if (iBearer == TPtrC(OUTGOING_GPRS))
+                    {
+                    iBearer = TPtrC(INCOMING_GPRS);
+                    }
+                }
+            }
+        else if (aURI.Find(KNSmlDdfIAPService) >= 0)
+            {
+            CleanupStack::PopAndDestroy(pushed);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+            return;
+            }
+        else if (aURI.Find(KNSmlDdfNoPxForL) >= 0) /* No proxies used field handling */
+            {
+            TBool proxyFound = GetProxyIdL(aURI);
+            if (!proxyFound)
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+                CleanupStack::PopAndDestroy(pushed);
+                return;
+                }
+
+            CCommsDbTableView* specView = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(PROXIES), TPtrC(COMMDB_ID), iProxyId);
+            TInt errorCode = specView->GotoFirstRecord();
+
+            if (errorCode == KErrNone)
+                {
+                TBool proxyReLock = EFalse;
+                if (IsProxyRecordLockedL(iProxyId))
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is LOCKED");
+                    TInt
+                            reclockerr =
+                                    ((CCommsDbProtectTableView*) specView)->UnprotectRecord();
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting ProxyAccessRecord returned code = %d"),
+                            reclockerr);
+                    if (reclockerr == KErrNone)
+                        proxyReLock = ETrue;
+                    }
+                else
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is not write protected");
+                    }
+                if (specView->UpdateRecord() == KErrNone)
+                    {
+                    //database not locked
+                    specView->WriteLongTextL(TPtrC(PROXY_EXCEPTIONS),
+                            ConvertTo16LC(aObject));
+                    specView->PutRecordChanges();
+                    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+                    CleanupStack::PopAndDestroy(); // ConvertTo16LC
+                    }
+                else
+                    {
+                    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                    }
+                if (proxyReLock)
+                    {
+                    TInt reclockerr = DoProtectProxyRecordL(iProxyId, ETrue);
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting ProxyAccessRecord returned code = %d"),
+                            reclockerr);
+                    if (reclockerr == KErrNone)
+                        proxyReLock = EFalse;
+                    }
+                }
+            else
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                }
+            CleanupStack::PopAndDestroy(); // specView
+
+            CleanupStack::PopAndDestroy(pushed);
+            _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+            return;
+            }
+        else if (aURI.Find(KNSmlDdfBearerL) >= 0) /* Bearer handling */
+            {
+            if (aObject.Match(KNSmlDmApValGsmGprs) != KErrNotFound)
+                {
+                if (iDirection == ECommDbConnectionDirectionIncoming)
+                    {
+                    iBearer = TPtrC(INCOMING_GPRS);
+                    }
+                else
+                    {
+                    iBearer = TPtrC(OUTGOING_GPRS);
+                    }
+                }
+
+            else if (aObject.Match(KNSmlDmApVal3Gppps) != KErrNotFound)
+                {
+                i3GPPPS = ETrue;
+                if (iDirection == ECommDbConnectionDirectionIncoming)
+                    {
+                    iBearer = TPtrC(INCOMING_GPRS);
+                    }
+                else
+                    {
+                    iBearer = TPtrC(OUTGOING_GPRS);
+                    }
+                }
+            else if (aObject.Match(KNSmlDmApValVpn) != KErrNotFound)
+                {
+                iBearer = TPtrC(VPN_SERVICE);
+                }
+            else if ((aObject.Match(KNSmlDmApValWlan) != KErrNotFound)
+                    && iWlanSupported)
+                {
+                iBearer = TPtrC(LAN_SERVICE);
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy(pushed);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddLeafObjectL(): UNKNOWN Bearer Error end");
+                return;
+                }
+            }
+        else if (aURI.Find(KNSmlDdfNAPName) >= 0)
+            {
+            iIAPName.Copy(aObject);
+            TUint32 iapID2 = GetAPIdFromURIL(aURI);
+            if (iapID2 > 0 && UpdateIAPnameL(iapID2, aObject) != KErrNone)
+                {
+                CleanupStack::PopAndDestroy(pushed);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                return;
+                }
+            }
+        }
+
+    CleanupStack::PopAndDestroy(pushed);
+    pushed = 0;
+
+    //  Update CommsDB IAP + insert iBearer Table
+
+    if (IsInsertAllowedL() && iLeafType == EDMAdd && fType
+            == CNSmlInternetAdapter::ESpec) //iIAPExists  
+        {
+        TInt initOK = KErrCancel;
+
+        iISPId = GetMaxIdL() + 1; // For new data
+
+        SaveIAPDataL(aURI); // Level 1 Mapping inside
+
+        CCommsDbTableView* newAPView;
+
+        newAPView = iDatabase->OpenTableLC(iBearer);
+        // 3GPPPS  = OUTGOING/INCOMING_GPRS
+        if (iBearer == TPtrC(OUTGOING_GPRS) || iBearer
+                == TPtrC(INCOMING_GPRS))
+            {
+            if (newAPView->InsertRecord(iISPId) == KErrNone)
+                {
+                initOK = InitializeGPRSL(newAPView);
+                }
+            else
+                {
+                initOK = KErrGeneral;
+                }
+            }
+
+        else if (iBearer == TPtrC(VPN_SERVICE))
+            {
+            if (newAPView->InsertRecord(iISPId) == KErrNone)
+                {
+                initOK = InitializeVPNServiceL(newAPView);
+                }
+            else
+                {
+                initOK = KErrGeneral;
+                }
+            }
+        else if ((iBearer == TPtrC(LAN_SERVICE)) && iWlanSupported)
+            {
+            if (newAPView->InsertRecord(iISPId) == KErrNone)
+                {
+                initOK = InitializeLANServiceL(newAPView);
+                }
+            else
+                {
+                initOK = KErrGeneral;
+                }
+            }
+        else
+            {
+            initOK = KErrCancel;
+            }
+
+        if (initOK == KErrNone)
+            {
+            TUint32 newId = 0;
+            newAPView->PutRecordChanges();
+            newAPView->ReadUintL(TPtrC(COMMDB_ID), newId);
+
+            // To update right Id
+
+            iISPId = newId;
+
+            SaveIAPDataL(aURI);
+
+            TUint32 iapID2 = GetAPIdFromURIL(aURI);
+            UpdateIAPnameL(iapID2, iIAPName);
+            //
+            // Set mapping-data (levels 2 and 3 )
+            //
+            TPtrC8 addURI = GetAddURISeg(aURI, KNSmlDdfNAPDef);
+
+            TBuf8<16> addLUID;
+            _LIT8(KFormat, "%d");
+            addLUID.Format(KFormat, newId);
+
+            // Also NAPDef  (level 2)
+            iCallBack->SetMappingL(addURI, addLUID);
+            DBG_ARGS8(_S8("AP:level2 URI - <%S> <%S> <%d>"), &addURI,
+                    &addLUID, newId);
+
+            // Also BearerL (level 3)
+            TPtrC8 addURI2 = GetAddURISeg(aURI, KNSmlDdfBearer);
+            if (i3GPPPS)
+                {
+                newId = KNSmlAp3gpppsLowerBase + newId;
+                addLUID.Format(KFormat, newId);
+                i3GPPPS = EFalse;
+                }
+            iCallBack->SetMappingL(addURI2, addLUID);
+            DBG_ARGS8(_S8("AP:level3 URI - <%S> <%S> <%d>"), &addURI2,
+                    &addLUID, newId);
+            }
+        else
+            {
+            if (initOK == KErrCancel)
+                {
+                newAPView->CancelRecordChanges();
+                }
+            CleanupStack::PopAndDestroy(newAPView);
+            CleanupStack::PopAndDestroy(pushed);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): EError end");
+            return;
+            }
+
+        CleanupStack::PopAndDestroy(newAPView);
+        }
+    else if (IsInsertAllowedL() && iLeafType == EDMAdd && aURI.Find(
+            KNSmlDdfBearerL) >= 0)
+
+        {
+        CleanupStack::PopAndDestroy(pushed);
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EAlreadyExists);
+        _DBG_FILE(
+                "CNSmlInternetAdapter::AddLeafObjectL(): EAlreadyExists BearerL end");
+        return;
+        }
+    CleanupStack::PopAndDestroy(pushed);
+    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+    _DBG_FILE("CNSmlInternetAdapter::AddLeafObjectL(): OK end");
+    return;
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& aType )
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::UpdateLeafObjectL(const TDesC8& aURI,
+        const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& aType,
+        const TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::UpdateLeafObjectL(): begin");
+
+    DBG_ARGS8(_S8("AP:update aURI UpdateLeafObjectL   - %S - %S"), &aURI,
+            &aLUID);
+    DBG_ARGS8(_S8("AP:Object %S"), &aObject);
+    if (iTransactionCommitted)
+        {
+        TInt dberr = iDatabase->BeginTransaction();
+        if (dberr == KErrLocked)
+            {
+            _DBG_FILE("UpdateLeafObjectL: CommsDat was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && dberr == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("UpdateLeafObjectL: Slept 1 second. Try again");
+                dberr = iDatabase->BeginTransaction();
+                retry--;
+                }
+            if (dberr != KErrNone)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter: BeginTransaction failed completely.");
+                User::Leave(dberr);
+                }
+            }
+        iTransactionCommitted = EFalse;
+        }
+    if ((aURI.Match(_L8("*/WLAN*")) != KErrNotFound) && iWlanSupported)
+        {
+        AddLeafBufferL(aURI, aLUID, aObject, aType, aStatusRef, ETrue);
+        iDatabase->CommitTransaction();
+        iTransactionCommitted = ETrue;
+        _DBG_FILE("CNSmlInternetAdapter::UpdateLeafObjectL(): WLAN end");
+
+        return;
+        }
+    //
+    //  No direct update allowed only update as add
+    //
+    if (aLUID.Length() > 0 && aURI.Find(KNSmlDdfNAPDef) >= 0)
+    /*( aURI.Find(KNSmlDdfBearerL)   >= 0 ||
+     aURI.Find(KNSmlDdfDirection) >= 0 || 
+     aURI.Find(KNSmlDdfNAPName) >= 0 ) */
+        {
+        _DBG_FILE(
+                "Bearer | direction CNSmlInternetAdapter::UpdatelaefObject ( ): EError end");
+
+        AddLeafBufferL(aURI, aLUID, aObject, aType, aStatusRef, EFalse);
+        iDatabase->CommitTransaction();
+        iTransactionCommitted = ETrue;
+        return;
+        }
+
+    iLeafType = EDMUpdate;
+
+    TRAP_IGNORE(AddLeafObjectL(aURI, aLUID, aObject, aType, aStatusRef));
+    iDatabase->CommitTransaction();
+    iTransactionCommitted = ETrue;
+    //
+    //  If try to update field that has value which is not default errorvalue should be returned
+    //
+    iLeafType = EDMUnset;
+
+    _DBG_FILE("CNSmlInternetAdapter::UpdateLeafObjectL(): end");
+
+    return;
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::UpdateLeafObjectL( const TDesC8& aURI, 
+// const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& aType )
+//------------------------------------------------------------------------------
+
+void CNSmlInternetAdapter::UpdateLeafObjectL(const TDesC8& /*aURI*/,
+        const TDesC8& /*aLUID*/, RWriteStream*& /*aStream*/,
+        const TDesC8& /*aType*/, TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::UpdateLeafObjectL(RWriteStream): begin");
+    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlInternetAdapter::UpdateLeafObjectL(RWriteStream): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::DeleteObjectL( const TDesC& aURI, const TDesC& aLUID, 
+// const TInt aStatusRef )
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::DeleteObjectL(const TDesC8& aURI,
+        const TDesC8& aLUID, const TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL( ): begin");
+    if (iTransactionCommitted)
+        {
+        TInt dberr = iDatabase->BeginTransaction();
+        if (dberr == KErrLocked)
+            {
+            _DBG_FILE("DeleteObjectL: CommsDat was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && dberr == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("DeleteObjectL: Slept 1 second. Try again");
+                dberr = iDatabase->BeginTransaction();
+                retry--;
+                }
+            if (dberr != KErrNone)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter: BeginTransaction failed completely.");
+                User::Leave(dberr);
+                }
+            }
+        iTransactionCommitted = EFalse;
+        }
+
+    if ((aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*")) != KErrNotFound)
+            && iWlanSupported)
+        {
+        iWlanAdapter->DeleteObjectL(aURI, aLUID, aStatusRef);
+        _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL( ): end");
+        return;
+        }
+
+    //
+    //  Check which field going to be handled
+    //
+    SetField(aURI);
+
+    iLUID = IntLUID(aLUID);
+
+    TUint32 checkLUID = IntLUID(aLUID);
+    //
+    //  Check which kind node to be deleted (Leaf delete not supported)
+    //
+    if (aURI.Match(_L8("AP/*")) != KErrNotFound && aURI.Match(_L8("AP/*/*"))
+            == KErrNotFound)
+        {
+        // Check if AP exists
+        if (!APExistsL(checkLUID))
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL(): ENotFound end");
+            return;
+            }
+        if (DeleteAPL(checkLUID))
+            {
+            iPrevURI->Des().Format(KNullDesC8);
+            iPrevLUID = 0;
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL(): EOk end");
+            return;
+            }
+        else
+            {
+            iPrevURI->Des().Format(KNullDesC8);
+            iPrevLUID = 0;
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL(): EError end");
+            return;
+            }
+        }
+
+    if (aURI.Match(_L8("AP/*/Px/*/Startpg")) != KErrNotFound) //Key for WAP-delete  
+        {
+        // Check if WAPAp exists
+        if (!WapAPExistsL(checkLUID))
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL(): ENotFound end");
+            return;
+            }
+        if (DeleteWapAPL(checkLUID))
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL(): EOk end");
+            return;
+            }
+        else
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL(): EError end");
+            return;
+            }
+        }
+
+    if (aURI.Match(_L8("AP/*/NAPDef/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/NAPDef/*/*")) == KErrNotFound)
+        {
+        // Check if NAPDef exists
+        if (!NAPDefExistsL(checkLUID))
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL(): ENotFound end");
+            return;
+            }
+        if (DeleteNAPDefL(checkLUID))
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL(): EOk end");
+            return;
+            }
+        }
+
+    if (aURI.Match(_L8("AP/*/Px/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/Px/*/*")) == KErrNotFound)
+        {
+        // Check if PX exists
+        if (!PxExistsL(checkLUID))
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL(): ENotFound end");
+            return;
+            }
+        if (DeleteProxyL(checkLUID))
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL(): EOk end");
+            return;
+            }
+        }
+
+    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlInternetAdapter::DeleteObjectL( ): end");
+    return;
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::FetchLeafObjectSizeL()
+//------------------------------------------------------------------------------
+
+void CNSmlInternetAdapter::FetchLeafObjectSizeL(const TDesC8& aURI,
+        const TDesC8& aLUID, const TDesC8& aType, TInt aResultsRef,
+        TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::FetchLeafObjectSizeL(): begin");
+
+    DBG_ARGS8(_S8("AP:Fetch aURI - %S - %S"), &aURI, &aLUID);
+    CBufBase *lObject = CBufFlat::NewL(128);
+    CleanupStack::PushL(lObject);
+
+    // call to internal fetchleafobj.
+    CSmlDmAdapter::TError status = FetchLeafObjectL(aURI, aLUID, aType,
+            *lObject);
+
+    if (status == CSmlDmAdapter::EOk)
+        {
+        lObject->Compress();
+        TBuf8<8> size;
+        size.Num(lObject->Size());
+        lObject->Reset();
+        lObject->InsertL(0, size);
+        iCallBack->SetResultsL(aResultsRef, *lObject, aType);
+        }
+    iCallBack->SetStatusL(aStatusRef, status);
+
+    CleanupStack::PopAndDestroy(lObject);
+    _DBG_FILE("CNSmlInternetAdapter::FetchLeafObjectSizeL(): end");
+
+    return;
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::FetchLeafObjectL()
+//------------------------------------------------------------------------------
+
+void CNSmlInternetAdapter::FetchLeafObjectL(const TDesC8& aURI,
+        const TDesC8& aLUID, const TDesC8& aType, const TInt aResultsRef,
+        const TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::FetchLeafObjectL(): begin");
+
+    DBG_ARGS8(_S8("AP:Fetch aURI - %S - %S"), &aURI, &aLUID);
+    CBufBase *lObject = CBufFlat::NewL(128);
+    CleanupStack::PushL(lObject);
+
+    // Add call to internal fetchleafobj
+    CSmlDmAdapter::TError status = FetchLeafObjectL(aURI, aLUID, aType,
+            *lObject);
+    if (status == CSmlDmAdapter::EOk)
+        {
+        iCallBack->SetResultsL(aResultsRef, *lObject, aType);
+        }
+    iCallBack->SetStatusL(aStatusRef, status);
+
+    CleanupStack::PopAndDestroy(); //lObject 
+    _DBG_FILE("CNSmlInternetAdapter::FetchLeafObjectL(): end");
+    return;
+    }
+
+//------------------------------------------------------------------------------
+// CSmlDmInternetAdapter::FetchLeafObjectL()
+//------------------------------------------------------------------------------
+
+CSmlDmAdapter::TError CNSmlInternetAdapter::FetchLeafObjectL(
+        const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aType,
+        CBufBase& aObject)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::FetchLeafObjectL(internal)(): begin");
+
+    TInt pushed = 0;
+    TUint32 iapID = 0;
+    TBool treeConstructed(EFalse);
+    //
+    // If no proxy no fetch allowed 
+    //
+    if (aURI.Match(_L8("AP/*/Px/*")) != KErrNotFound)
+        {
+        if (!GetProxyIdL(aURI))
+            {
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+            return CSmlDmAdapter::ENotFound;
+            }
+        }
+    if (!iLUID)
+        iLUID = IntLUID(aLUID);
+
+    iapID = GetAPIdFromURIL(aURI);
+
+    if (iapID == 0)
+        {
+        if (IsAPUriFormatMatchPredefined(aURI))
+            {
+            iLUID = ConstructTreeL(aURI);
+            iapID = GetAPIdFromURIL(aURI);
+            treeConstructed = ETrue;
+            }
+
+        }
+    // Check if values for Given LUID
+    if (!iLUID && (!IsWLANfield(aURI) || !iWlanSupported))
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+        return CSmlDmAdapter::ENotFound;
+        }
+    //
+    //  Check which field going to be handled
+    //
+    SetField(aURI);
+
+    aObject.Reset();
+
+    //Linger value 
+    if ((iField->Compare(KNSmlDdfNAPLinger) == 0))
+        {
+        TInt lingerInterval;
+        TRAPD(err, GetLingerL(iapID, lingerInterval));
+        if (err == KErrNotFound)
+            {
+
+            return CSmlDmAdapter::ENotFound;
+            }
+        else if (err != KErrNone)
+            {
+
+            return CSmlDmAdapter::EError;
+
+            }
+        else
+            {
+            TBuf<10> slinger;
+            slinger.AppendNum(lingerInterval);
+
+            aObject.InsertL(aObject.Size(), ConvertTo8LC(slinger));
+            CleanupStack::PopAndDestroy();
+            return CSmlDmAdapter::EOk;
+            }
+        }
+    TPtrC qTable = TPtrC(KNullDesC);
+    TPtrC qColumn = TPtrC(KNullDesC);
+    TPtrC qDB = TPtrC(COMMDB_ID);
+
+    if (aURI.Find(KNSmlDdfPortNbr) >= 0) // Check if WAP or PROXY port asked
+        {
+        _LIT8(KWap, "/WAP");
+        if (aURI.Find(KWap) >= 0)
+            {
+            iWapPort = ETrue;
+            }
+        else
+            {
+            iWapPort = EFalse;
+            }
+        }
+
+    if (iWlanSupported)
+        {
+        TBool wLANfield = IsWLANfield(aURI);
+        if (wLANfield)
+            {
+            //
+            //      WLAN-adapter handles all WLAN fields
+            //
+            return iWlanAdapter->FetchLeafObjectL(aURI, aLUID, aType, aObject);
+            }
+        }
+
+    //
+    //  Get Database field type 
+    //
+    TInt fType = GetAPFieldType(aURI);
+
+    if (fType == EWrong)
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): EError end");
+        return CSmlDmAdapter::EError;
+        }
+    //
+    iISPId = iLUID;
+    //
+    //  IAP-table search serviceType (=Bearer)
+
+    CCommsDbTableView* serviceView = iDatabase->OpenViewMatchingUintLC(TPtrC(
+            IAP), qDB, iapID);
+
+    TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+    TUint32 serviceId = 0;
+
+    TInt errorCode = serviceView->GotoFirstRecord();
+
+    // Read serviceType from (IAP)
+    if (errorCode == KErrNone)
+        {
+        serviceView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+        serviceView->ReadUintL(TPtrC(IAP_SERVICE), serviceId);
+        CleanupStack::PopAndDestroy(); // serviceView
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy(); // serviceView
+        _DBG_FILE(
+                "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+        CleanupStack::PopAndDestroy(pushed);
+        return CSmlDmAdapter::ENotFound;
+        }
+    qTable.Set(serviceType);
+
+    TBool allowed = GetAPField(qTable, qColumn);
+
+    if (!allowed)
+        {
+        if (aURI.Find(KNSmlDdfNAPAddrTy) >= 0) /* NAPAddrTy handling */
+            {
+            if (serviceType == TPtrC(OUTGOING_GPRS) || serviceType == TPtrC(
+                    INCOMING_GPRS))
+                {
+                _LIT8(KApn, "APN");
+                aObject.InsertL(aObject.Size(), KApn);
+
+                }
+            CleanupStack::PopAndDestroy(pushed);
+            return CSmlDmAdapter::EOk;
+
+            }
+        _DBG_FILE(
+                "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): FieldNot allowed");
+        CleanupStack::PopAndDestroy(pushed);
+        return CSmlDmAdapter::EError;
+        }
+
+    if (fType == CNSmlInternetAdapter::EStr)
+        { // Name + NAPAddr + DNSAddrL
+        if (aURI.Match(_L8("AP/*/Networks/*/Name")) != KErrNotFound) // Networks-name
+            {
+            // TUint32 iapID8 = IntLUID(aLUID);
+
+            //  IAP-table NetworkId Fetch
+            CCommsDbTableView* networkView =
+                    iDatabase->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(
+                            COMMDB_ID), iapID);
+            networkView->GotoFirstRecord();
+            TRAPD(leavecode, networkView->ReadUintL(TPtrC(IAP_NETWORK),
+                    iISPId));
+            CleanupStack::PopAndDestroy(); // networkView
+            if (leavecode != 0)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                CleanupStack::PopAndDestroy(pushed);
+                return CSmlDmAdapter::ENotFound;
+                }
+
+            CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(NETWORK), TPtrC(COMMDB_ID), iISPId);
+
+            errorCode = tableView->GotoFirstRecord();
+
+            if (errorCode == KErrNone)
+                {
+                TBuf<KCommsDbSvrMaxFieldLength> columnValue;
+
+                tableView->ReadTextL(qColumn, columnValue);
+
+                aObject.InsertL(aObject.Size(), ConvertTo8LC(columnValue));
+                pushed++;
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy(); // tableView
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                CleanupStack::PopAndDestroy(pushed);
+                return CSmlDmAdapter::ENotFound;
+                }
+            }
+        else if (aURI.Match(_L8("AP/*/Px/*/Name")) != KErrNotFound || // ProxyName
+                aURI.Match(_L8("AP/*/Px/*/PxAddr")) != KErrNotFound || // ProxyAddr
+                aURI.Match(_L8("AP/*/Px/*/DomainL")) != KErrNotFound) // DomainL (PROXY_PROTOCOL_NAME)
+            {
+            CCommsDbTableView* proxyView = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(PROXIES), TPtrC(COMMDB_ID), iProxyId);
+
+            errorCode = proxyView->GotoFirstRecord();
+
+            if (errorCode == KErrNone)
+                {
+                if (aURI.Match(_L8("AP/*/Px/*/DomainL")) != KErrNotFound)
+                    {
+                    TBuf<KCommsDbSvrMaxFieldLength> columnValue;
+
+                    proxyView->ReadTextL(TPtrC(PROXY_PROTOCOL_NAME),
+                            columnValue);
+
+                    aObject.InsertL(aObject.Size(), ConvertTo8LC(columnValue));
+                    pushed++;
+                    }
+
+                else if (aURI.Match(_L8("AP/*/Px/*/PxAddr")) != KErrNotFound)
+                    {
+                    HBufC* serverName = proxyView->ReadLongTextLC(TPtrC(
+                            PROXY_SERVER_NAME));
+                    pushed++;
+
+                    aObject.InsertL(aObject.Size(), ConvertTo8LC(*serverName));
+                    pushed++;
+                    }
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy(); // proxyView
+                CleanupStack::PopAndDestroy(pushed);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                return CSmlDmAdapter::ENotFound;
+                }
+            }
+        else
+            {
+            CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                    serviceType, qDB, serviceId);
+
+            errorCode = tableView->GotoFirstRecord();
+
+            if (errorCode == KErrNone)
+                {
+                if (aURI.Find(KNSmlDdfDNSPriority) >= 0) /* DNSPriority */
+                    {
+                    UriUtils::TUriHostType theType;
+                    TInt dnsPri;
+
+                    // This resets iLUID to match aLUID, which is needed in this case.
+                    // Otherwise iLUID has a different value
+                    if (!treeConstructed)
+                        iLUID = IntLUID(aLUID);
+
+                    if (LuidToDns(theType, dnsPri, iLUID) == KErrNone)
+                        {
+                        if (dnsPri == 1)
+                            {
+                            aObject.InsertL(aObject.Size(), KNSmlFirstDNSPri);
+                            }
+                        else
+                            {
+                            aObject.InsertL(aObject.Size(), KNSmlSecondDNSPri);
+                            }
+                        }
+                    else
+                        {
+                        CleanupStack::PopAndDestroy(tableView); // tableView
+                        CleanupStack::PopAndDestroy(pushed);
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                        return CSmlDmAdapter::ENotFound;
+                        }
+                    }
+                else if (aURI.Find(KNSmlDdfDNSAddrTy) >= 0) /* DNSAddrTy */
+                    {
+                    UriUtils::TUriHostType theType;
+                    TInt dnsPri;
+                    // This resets iLUID to match aLUID, which is needed in this case.
+                    // Otherwise iLUID has a different value
+                    if (!treeConstructed)
+                        iLUID = IntLUID(aLUID);
+                    if (LuidToDns(theType, dnsPri, iLUID) == KErrNone)
+                        {
+                        if (theType == UriUtils::EIPv4Host)
+                            {
+                            aObject.InsertL(aObject.Size(), KNSmlDNSIp);
+                            }
+                        else
+                            {
+                            aObject.InsertL(aObject.Size(), KNSmlDNSIp6);
+                            }
+                        }
+                    else
+                        {
+                        CleanupStack::PopAndDestroy(tableView); // tableView
+                        CleanupStack::PopAndDestroy(pushed);
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                        return CSmlDmAdapter::ENotFound;
+                        }
+                    }
+                else
+                    {
+                    TBuf<KCommsDbSvrMaxFieldLength> columnValue;
+                    if (aURI.Find(KNSmlDdfDNSAddrL) >= 0)
+                        {
+                        UriUtils::TUriHostType theType;
+                        TInt dnsPri;
+
+                        // This resets iLUID to match aLUID, which is needed in this case.
+                        // Otherwise iLUID has a different value
+                        if (!treeConstructed)
+                            iLUID = IntLUID(aLUID);
+                        if (LuidToDns(theType, dnsPri, iLUID) == KErrNone)
+                            {
+                            if (dnsPri == 1)
+                                {
+                                if (theType == UriUtils::EIPv4Host)
+                                    {
+                                    qColumn.Set(
+                                            TPtrC(SERVICE_IP_NAME_SERVER1));
+                                    }
+                                else
+                                    {
+                                    qColumn.Set(TPtrC(
+                                            SERVICE_IP6_NAME_SERVER1));
+
+                                    }
+                                }
+                            else
+                                {
+                                if (theType == UriUtils::EIPv4Host)
+                                    {
+                                    qColumn.Set(
+                                            TPtrC(SERVICE_IP_NAME_SERVER2));
+                                    }
+                                else
+                                    {
+                                    qColumn.Set(TPtrC(
+                                            SERVICE_IP6_NAME_SERVER2));
+
+                                    }
+                                }
+                            }
+                        else
+                            {
+                            CleanupStack::PopAndDestroy(tableView); // tableView
+                            CleanupStack::PopAndDestroy(pushed);
+                            _DBG_FILE(
+                                    "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                            return CSmlDmAdapter::ENotFound;
+                            }
+                        }
+                    TRAPD(leavecode, tableView->ReadTextL(qColumn,
+                            columnValue));
+                    if (leavecode != 0)
+                        {
+                        CleanupStack::PopAndDestroy(); // tableView
+                        CleanupStack::PopAndDestroy(pushed);
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                        return CSmlDmAdapter::ENotFound;
+                        }
+                    aObject.InsertL(aObject.Size(), ConvertTo8LC(columnValue));
+                    pushed++;
+                    }
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy(); // tableView
+                CleanupStack::PopAndDestroy(pushed);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                return CSmlDmAdapter::ENotFound;
+                }
+            }
+        CleanupStack::PopAndDestroy(); // tableView
+        }
+    else if (fType == CNSmlInternetAdapter::EBool)
+        { // UseCB
+        CCommsDbTableView* boolView = iDatabase->OpenViewMatchingUintLC(
+                serviceType, qDB, serviceId);
+
+        errorCode = boolView->GotoFirstRecord();
+
+        TBool objectBool = EFalse;
+        if (errorCode == KErrNone)
+            {
+            TRAPD(leavecode, boolView->ReadBoolL(qColumn, objectBool));
+            if (leavecode == KErrUnknown) // value is null
+                {
+                }
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy(); // boolView
+            CleanupStack::PopAndDestroy(pushed);
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): EError end");
+            return CSmlDmAdapter::EError;
+            }
+
+        if (objectBool)
+            {
+            aObject.InsertL(aObject.Size(), KNSmlDmApValTrue);
+            }
+        else
+            {
+            aObject.InsertL(aObject.Size(), KNSmlDmApValFalse);
+            }
+
+        CleanupStack::PopAndDestroy(); // boolView
+        }
+    else if (fType == CNSmlInternetAdapter::EInt)
+        { // NAPId +Bearer + NAPAddrTy + PxID + PortNbr + UsePTxtLog
+        // CBTy + LnkSpeed
+
+        if (aURI.Match(_L8("AP/*/Px/*/PxID")) != KErrNotFound)
+            {
+            aObject.InsertL(aObject.Size(), SetIntObjectLC(iISPId));
+            pushed++;
+            }
+
+        else if (aURI.Find(KNSmlDdfIAPSeamlessness) >= 0) /* Seamlessness handling */
+            {
+            TInt seam = GetIAPSeamlessnessL(iapID);
+            aObject.InsertL(aObject.Size(), SetIntObjectLC(seam));
+            pushed++;
+            }
+        else if (aURI.Find(KNSmlDdfIAPMetaData) >= 0)
+            {
+            TInt meta = GetIAPMetaDataL(iapID);
+            aObject.InsertL(aObject.Size(), SetIntObjectLC(meta));
+            pushed++;
+            }
+
+        else if (aURI.Match(_L8("AP/*/Networks/*/ID")) != KErrNotFound)
+            {
+
+            iISPId = IntLUID(aLUID);
+
+            CCommsDbTableView* nwidView = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(IAP), TPtrC(COMMDB_ID), iISPId);
+            nwidView->GotoFirstRecord();
+            nwidView->ReadUintL(TPtrC(IAP_NETWORK), iISPId);
+            CleanupStack::PopAndDestroy(); // nwidView
+
+            aObject.InsertL(aObject.Size(), SetIntObjectLC(iISPId));
+            pushed++;
+            }
+        else if (aURI.Match(_L8("AP/*/Px/*/PortNbr")) != KErrNotFound)
+            {
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): PortNbr");
+            DBG_ARGS8(_S8("iISPId = %d "), iISPId);
+            DBG_ARGS8(_S8("proxyid = %d "), iProxyId);
+            CCommsDbTableView* portView = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(PROXIES), TPtrC(COMMDB_ID), iProxyId);
+
+            errorCode = portView->GotoFirstRecord();
+
+            if (errorCode == KErrNone)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): Portview opened");
+                TUint32 object32 = 0;
+
+                TRAPD(leavecode, portView->ReadUintL(qColumn, object32));
+                if (leavecode == KErrNone)
+                    {
+                    aObject.InsertL(aObject.Size(), SetIntObjectLC(object32));
+                    pushed++;
+                    }
+                else
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): db read failed");
+                    CleanupStack::PopAndDestroy(); // portView
+                    CleanupStack::PopAndDestroy(pushed);
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): EError end");
+                    return CSmlDmAdapter::EError;
+                    }
+                }
+            else
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): Portview opening failed");
+                CleanupStack::PopAndDestroy(); // portView
+                CleanupStack::PopAndDestroy(pushed);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                return CSmlDmAdapter::ENotFound;
+                }
+            CleanupStack::PopAndDestroy(); // portView
+            }
+        else if (aURI.Match(_L8("AP/*/NAPID")) != KErrNotFound || aURI.Match(
+                _L8("AP/*/ToNAPIDL")) != KErrNotFound)
+            {
+            iObject = iapID;
+            TPtrC8 napidUri = FirstURISeg(aURI);
+            aObject.InsertL(aObject.Size(), napidUri);
+
+            }
+        else
+            {
+            iObject = 0;
+
+            CCommsDbTableView* colView = iDatabase->OpenViewMatchingUintLC(
+                    serviceType, qDB, serviceId);
+
+            errorCode = colView->GotoFirstRecord();
+
+            TUint32 object32 = 0;
+            if (errorCode == KErrNone)
+                {
+                if (aURI.Find(KNSmlDdfUsePTxtLog) >= 0)
+                    {
+                    TBool objectBool = EFalse;
+                    TRAPD(leavecode, colView->ReadBoolL(qColumn, objectBool));
+                    errorCode = leavecode;
+                    object32 = objectBool;
+                    }
+                else
+                    {
+                    TRAPD(leavecode, colView->ReadUintL(qColumn, object32));
+                    errorCode = leavecode;
+                    }
+                }
+
+            if (errorCode == KErrNone)
+                {
+
+                if (aURI.Find(KNSmlDdfNAPAddrTy) >= 0 || /* NAPAddrTy handling */
+                aURI.Find(KNSmlDdfGPRSPDP) >= 0) /* NAPAddrTy handling */
+                    {
+                    if (object32 == RPacketContext::EPdpTypeIPv4)
+                        {
+                        aObject.InsertL(aObject.Size(), KNSmlDmApValIpv4);
+                        }
+                    else if (object32 == RPacketContext::EPdpTypeIPv6)
+                        {
+                        aObject.InsertL(aObject.Size(), KNSmlDmApValIpv6);
+                        }
+                    else if (object32 == RPacketContext::EPdpTypePPP)
+                        {
+                        _LIT8(KPpp, "PPP");
+                        aObject.InsertL(aObject.Size(), KPpp);
+                        }
+                    else
+                        {
+                        aObject.InsertL(aObject.Size(), KNullDesC8);
+                        }
+                    }
+                else
+                    {
+                    aObject.InsertL(aObject.Size(), SetIntObjectLC(object32));
+                    pushed++;
+                    }
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy(); // colView
+                CleanupStack::PopAndDestroy(pushed);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                return CSmlDmAdapter::ENotFound;
+                }
+            CleanupStack::PopAndDestroy(); // colView
+            }
+        }
+
+    else if (fType == CNSmlInternetAdapter::EWap)
+        { // Startpg + PxAuthId + PxAuthPW + PortNbr (BasAuthId + BasAuthPW)
+        CCommsDbTableView* wapView = iDatabase->OpenViewMatchingUintLC(TPtrC(
+                WAP_IP_BEARER), TPtrC(WAP_IAP), iapID);
+
+        errorCode = wapView->GotoFirstRecord();
+
+        if (errorCode == KErrNone)
+            {
+            TBuf<KCommsDbSvrMaxFieldLength> columnValue;
+
+            if (qColumn == TPtrC(WAP_START_PAGE))
+                {
+                TRAPD(leavecode, wapView->ReadUintL(
+                        TPtrC(WAP_ACCESS_POINT_ID), iWapId));
+                CleanupStack::PopAndDestroy(); // wapView
+                if (leavecode != KErrNone)
+                    {
+                    CleanupStack::PopAndDestroy(pushed);
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): EError end");
+                    return CSmlDmAdapter::EError;
+
+                    }
+
+                CCommsDbTableView* wapView2 =
+                        iDatabase->OpenViewMatchingUintLC(TPtrC(
+                                WAP_ACCESS_POINT), TPtrC(COMMDB_ID), iWapId);
+
+                errorCode = wapView2->GotoFirstRecord();
+                if (errorCode != KErrNone)
+                    {
+                    CleanupStack::PopAndDestroy(); // wapView2
+                    CleanupStack::PopAndDestroy(pushed);
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                    return CSmlDmAdapter::ENotFound;
+                    }
+
+                HBufC* tmpVal = wapView2->ReadLongTextLC(qColumn);
+
+                aObject.InsertL(aObject.Size(), ConvertTo8LC(tmpVal->Des()));
+                CleanupStack::PopAndDestroy(); // ReadLongTextLC
+                CleanupStack::PopAndDestroy(); // wapView2
+                pushed++;
+                }
+            else
+                {
+                if (qColumn == TPtrC(WAP_PROXY_PORT))
+                    {
+                    TUint32 object32;
+                    wapView->ReadUintL(qColumn, object32);
+                    if (object32 == KWAPP_PORT_9200) // wappdef.h
+                        {
+                        aObject.InsertL(aObject.Size(), ConvertTo8LC(
+                                KWappPort9200));
+                        }
+                    else if (object32 == KWAPP_PORT_9201)
+                        {
+                        aObject.InsertL(aObject.Size(), ConvertTo8LC(
+                                KWappPort9201));
+                        }
+                    else if (object32 == KWAPP_PORT_9202)
+                        {
+                        aObject.InsertL(aObject.Size(), ConvertTo8LC(
+                                KWappPort9202));
+                        }
+                    else if (object32 == KWAPP_PORT_9203)
+                        {
+                        aObject.InsertL(aObject.Size(), ConvertTo8LC(
+                                KWappPort9203));
+                        }
+                    else
+                        {
+                        CleanupStack::PopAndDestroy(); // wapView
+                        CleanupStack::PopAndDestroy(pushed);
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                        return CSmlDmAdapter::ENotFound;
+                        }
+
+                    pushed++;
+                    }
+                else
+                    {
+                    wapView->ReadTextL(qColumn, columnValue);
+                    aObject.InsertL(aObject.Size(), ConvertTo8LC(columnValue));
+                    pushed++;
+                    }
+                CleanupStack::PopAndDestroy(); // wapView
+                }
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy(); // wapView
+            CleanupStack::PopAndDestroy(pushed);
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+            return CSmlDmAdapter::ENotFound;
+            }
+        }
+    else if (fType == CNSmlInternetAdapter::ESpec)
+        {
+        // name
+        if (aURI.Find(KNSmlDdfNAPName) >= 0)
+            {
+            TUint32 iapID10 = IntLUID(aLUID);
+            /*  CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(serviceType,
+             qDB,
+             serviceId);*/
+            CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(IAP), TPtrC(COMMDB_ID), iapID);
+
+            errorCode = tableView->GotoFirstRecord();
+
+            if (errorCode == KErrNone)
+                {
+                TBuf<KCommsDbSvrMaxFieldLength> columnValue;
+                TRAPD(leavecode, tableView->ReadTextL(TPtrC(COMMDB_NAME),
+                        columnValue));
+                if (leavecode != 0)
+                    {
+                    CleanupStack::PopAndDestroy(); // tableView
+                    CleanupStack::PopAndDestroy(pushed);
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                    return CSmlDmAdapter::ENotFound;
+                    }
+                aObject.InsertL(aObject.Size(), ConvertTo8LC(columnValue));
+                pushed++;
+                }
+            CleanupStack::PopAndDestroy(); // tableView
+            CleanupStack::PopAndDestroy(pushed);
+            return CSmlDmAdapter::EOk;
+            }
+        // BearerL + NoPxForL + IAPService
+        else if (aURI.Find(KNSmlDdfIAPService) >= 0)
+            {
+            aObject.InsertL(aObject.Size(), SetIntObjectLC(serviceId));
+            pushed++;
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): EOk end");
+            CleanupStack::PopAndDestroy(pushed);
+            return CSmlDmAdapter::EOk;
+            }
+        else if (aURI.Find(KNSmlDdfNoPxForL) >= 0) /* No proxies used handling */
+            {
+            TBool proxyFound = GetProxyIdL(aURI);
+            if (!proxyFound)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                CleanupStack::PopAndDestroy(pushed);
+                return CSmlDmAdapter::ENotFound;
+                }
+
+            CCommsDbTableView* exeptionView =
+                    iDatabase->OpenViewMatchingUintLC(TPtrC(PROXIES), TPtrC(
+                            COMMDB_ID), iProxyId);
+            errorCode = exeptionView->GotoFirstRecord();
+
+            if (errorCode == KErrNone)
+                {
+                HBufC* proxyExceptions = exeptionView->ReadLongTextLC(TPtrC(
+                        PROXY_EXCEPTIONS));
+                pushed++;
+
+                aObject.InsertL(aObject.Size(),
+                        ConvertTo8LC(*proxyExceptions));
+                pushed++;
+                }
+            else
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): ENotFound end");
+                CleanupStack::PopAndDestroy(pushed);
+                return CSmlDmAdapter::ENotFound;
+                }
+            CleanupStack::PopAndDestroy(); // exeptionView
+
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::FetchLeafObjectL(internal)()(): EOk end");
+            CleanupStack::PopAndDestroy(pushed);
+            return CSmlDmAdapter::EOk;
+            }
+
+        if (aURI.Find(KNSmlDdfDirection) >= 0)
+            {
+            if (serviceType == TPtrC(OUTGOING_GPRS))
+                {
+                aObject.InsertL(aObject.Size(), KNSmlDmApValOutgoing);
+                }
+            else if (serviceType == TPtrC(INCOMING_GPRS))
+                {
+                aObject.InsertL(aObject.Size(), KNSmlDmApValIncoming);
+                }
+            else if (serviceType == TPtrC(LAN_SERVICE)) // Wlan ADD
+                {
+                aObject.InsertL(aObject.Size(), KNSmlDmApValOutgoing);
+                }
+            else if (serviceType == TPtrC(VPN_SERVICE))
+                {
+                aObject.InsertL(aObject.Size(), KNSmlDmApValOutgoing);
+                }
+            else
+                {
+                _LIT8(KDirectionUnk, "DirectionUnknown");
+                aObject.InsertL(aObject.Size(), KDirectionUnk);
+                }
+            }
+        else
+            {
+            if (serviceType == TPtrC(OUTGOING_GPRS) || serviceType == TPtrC(
+                    INCOMING_GPRS))
+                {
+                if (i3GPPPS)
+                    {
+                    aObject.InsertL(aObject.Size(), KNSmlDmApVal3Gppps);
+                    i3GPPPS = EFalse;
+                    }
+                else
+                    {
+                    aObject.InsertL(aObject.Size(), KNSmlDmApValGsmGprs);
+                    }
+
+                }
+
+            else if (serviceType == TPtrC(OUTGOING_GPRS) || serviceType
+                    == TPtrC(INCOMING_GPRS))
+                {
+                if (i3GPPPS)
+                    {
+                    aObject.InsertL(aObject.Size(), KNSmlDmApVal3Gppps);
+                    i3GPPPS = EFalse;
+                    }
+                else
+                    {
+                    aObject.InsertL(aObject.Size(), KNSmlDmApValGsmGprs);
+                    }
+
+                }
+            else if (serviceType == TPtrC(VPN_SERVICE))
+                {
+                aObject.InsertL(aObject.Size(), KNSmlDmApValVpn);
+                }
+
+            else if ((serviceType == TPtrC(LAN_SERVICE) && iWlanSupported))
+                {
+                aObject.InsertL(aObject.Size(), KNSmlDmApValWlan);
+                }
+            else
+                {
+                _LIT8(KUnkBearer, "Unknown Bearer");
+                aObject.InsertL(aObject.Size(), KUnkBearer);
+                }
+            }
+        }
+    else
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::FetchLeafObjectL(internal)(): ENotFound end");
+        CleanupStack::PopAndDestroy(pushed);
+        return CSmlDmAdapter::ENotFound;
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::FetchLeafObjectL(internal)(): end");
+    CleanupStack::PopAndDestroy(pushed);
+    return CSmlDmAdapter::EOk;
+
+    }
+
+//------------------------------------------------------------------------------
+// CSmlDmAdapter::ChildURIListL()
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::ChildURIListL(const TDesC8& aURI,
+        const TDesC8& aLUID,
+        const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
+        const TInt aResultsRef, const TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): begin");
+    DBG_ARGS8(_S8("AP:ChildURIListL URI - <%S> <%S>"), &aURI, &aLUID);
+
+    CBufBase* currentURISegmentList = CBufFlat::NewL(128);
+    CleanupStack::PushL(currentURISegmentList);
+
+    TUint32 checkLUID = IntLUID(aLUID);
+
+    // If this is command to proxy node we'll need to make sure that
+    // the LUID is for proxy node and not AP node.
+    // If this command comes to predefined AP node then 
+    // the LUID passed is inherited from that node and is not
+    // proper proxy node.
+    if (aURI.Match(_L8("AP/*/Px/*")) != KErrNotFound)
+        {
+        TLex8 lex(aLUID);
+        TUint tempLUID;
+        if (!((lex.Val(tempLUID) == KErrNone) && (tempLUID
+                > KNSmlApProxyLowerBase)
+                && (tempLUID < KNSmlApProxyUpperBase)))
+            {
+            // Non-proxy LUID         
+            checkLUID = 0;
+            }
+        }
+
+    // Fetch all data for child
+    if (!checkLUID && (!IsWLANfield(aURI) || !iWlanSupported))
+        {
+        if (aURI.Match(KNSmlDdfAP) == KErrNotFound) // Not for AP
+            {
+            CleanupStack::PopAndDestroy(); // currentURISegmentList
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): ENotFound end");
+            return;
+            }
+        }
+
+    TUint32 apId = GetAPIdFromURIL(aURI);
+
+    if (aURI.Match(_L8("AP/*")) != KErrNotFound && !APExistsL(apId))
+        {
+        if (aLUID.Length() > 0)
+            {
+            // Stale data, remove mapping. 
+            TInt ret = iCallBack->RemoveMappingL(KNSmlInternetAdapterImplUid,
+                    GetDynamicAPNodeUri(aURI), ETrue);
+            }
+
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE(
+                "CNSmlInternetAdapter::ChildURIListL(): AP doesn't exist: ENotFound end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*")) != KErrNotFound && aURI.Match(_L8("AP/*/*"))
+            == KErrNotFound)
+        {
+        // Check if AP exists
+        if (!APExistsL(checkLUID))
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            CleanupStack::PopAndDestroy(); // currentURISegmentList
+            _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): ENotFound end");
+            return;
+            }
+        currentURISegmentList->InsertL(0, KNSmlAPnode);
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): end");
+        return;
+        }
+
+    // Check that queried proxy exists
+    if (aURI.Match(_L8("AP/*/Px/*")) != KErrNotFound && !PxExistsL(checkLUID))
+        {
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): ENotFound end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/Px/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/Px/*/*")) == KErrNotFound)
+        {
+        // Check if PX exists
+        if (!PxExistsL(checkLUID))
+            {
+            // Only WAP-data  
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            CleanupStack::PopAndDestroy(); // currentURISegmentList
+            _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): ENotFound end");
+            return;
+            }
+        // List all Px
+        currentURISegmentList->InsertL(0, KNSmlPxnode);
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): OK end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/NAPDef/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/NAPDef/*/*")) == KErrNotFound)
+        {
+        // Check if IAP has luid mapped
+        HBufC8* iapIdBuf = iCallBack->GetLuidAllocL(RemoveLastSeg(aURI));
+        TInt iapIdInt = GetIntObject8(iapIdBuf->Des());
+
+        delete iapIdBuf;
+        iapIdBuf = NULL;
+
+        if (iapIdInt > 0)
+            {
+            CCommsDbTableView* iapView = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(IAP), TPtrC(COMMDB_ID), iapIdInt);
+            TInt error = iapView->GotoFirstRecord();
+            TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+            if (error == KErrNone)
+                {
+                iapView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+                }
+            CleanupStack::PopAndDestroy(iapView);
+
+            // Check if NAPDef exists
+            if (!NAPDefExistsL(checkLUID))
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                CleanupStack::PopAndDestroy(); // currentURISegmentList
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::ChildURIListL(): ENotFound end");
+                return;
+                }
+            // List all NAPDef
+            if (IsWlanL(aURI) && iWlanSupported)
+                {
+                iWlanAdapter->ChildURIListL(aURI, aLUID,
+                        aPreviousURISegmentList, aResultsRef, aStatusRef);
+                CleanupStack::PopAndDestroy(); // currentURISegmentList
+                _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): WLAN end");
+                return;
+                }
+            _LIT(KGprs, "*GPRS*");
+            _LIT(K3gppps, "*3GPPPS*");
+            if (serviceType.Match(KGprs) != KErrNotFound
+                    || serviceType.Match(K3gppps) != KErrNotFound)
+                {
+                currentURISegmentList->InsertL(0, KNSmlNAPDefGPRSnode);
+                }
+
+#ifdef __SYNCML_DM_LSCRIPT
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),KNSmlLoginscriptnode);
+#endif
+
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                    KNullDesC8);
+            }
+        else
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            }
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): end");
+        return;
+        }
+
+    if ((aURI.Match(_L8("AP/*/WLAN")) != KErrNotFound || aURI.Match(_L8(
+            "AP/*/WLAN/*")) != KErrNotFound) && iWlanSupported)
+        {
+        iWlanAdapter->ChildURIListL(aURI, aLUID, aPreviousURISegmentList,
+                aResultsRef, aStatusRef);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): WLAN end");
+        return;
+        }
+    //
+    //  Get all AP numbers from IAP-table
+    //
+    if (aURI.Match(KNSmlDdfAP) != KErrNotFound)
+        {
+        TBool inDatabase = EFalse;
+
+        CCommsDbTableView* apView = iDatabase->OpenTableLC(TPtrC(IAP));
+
+        TInt errorCode = apView->GotoFirstRecord();
+
+        while (errorCode == KErrNone)
+            {
+            TUint32 lValue;
+            TBool validService = EFalse;
+            TInt lLine(0);
+            apView->ReadUintL(TPtrC(COMMDB_ID), lValue);
+
+            TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+            apView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+            TUint32 bearerId = 0;
+            apView->ReadUintL(TPtrC(IAP_BEARER), bearerId);
+            //
+            // Skip other service types than GSM outgoing
+            //
+            if (serviceType == TPtrC(OUTGOING_GPRS) || serviceType == TPtrC(
+                    INCOMING_GPRS))
+                {
+                validService = ETrue;
+                }
+
+            else if (serviceType == TPtrC(LAN_SERVICE) && bearerId > 1)
+                {
+                validService = ETrue;
+                }
+            else if (serviceType == TPtrC(VPN_SERVICE))
+                {
+                validService = ETrue;
+                }
+            else if ((serviceType == TPtrC(LAN_SERVICE)) && iWlanSupported)
+                {
+                validService = ETrue;
+                }
+
+            if (validService)
+                {
+                // Skip others
+                //
+                //  Check if in aPreviousURISegmentList
+                // 
+                while (!inDatabase && lLine < aPreviousURISegmentList.Count())
+                    {
+                    TUint32 list = GetIntObject8(aPreviousURISegmentList.At(
+                            lLine).iURISegLUID);
+                    if (list == lValue)
+                        {
+                        inDatabase = ETrue;
+                        }
+                    else
+                        {
+                        lLine++;
+                        }
+                    }
+
+                if (inDatabase)
+                    {
+                    currentURISegmentList->InsertL(
+                            currentURISegmentList->Size(),
+                            aPreviousURISegmentList.At(lLine).iURISeg);
+                    currentURISegmentList->InsertL(
+                            currentURISegmentList->Size(), KNSmlDmApValFSlash);
+                    inDatabase = EFalse;
+                    DBG_ARGS8(_S8("InList: Id = %d Name %S"), lValue,
+                            &aPreviousURISegmentList.At(lLine).iURISeg);
+
+                    }
+                else
+                    {
+                    _LIT8(Kprev, "APId");
+                    TBuf8<9> addNAME(Kprev); // APIdnnn , nnn = profileid
+                    addNAME.AppendNumFixedWidth(lValue, EDecimal, 3);
+
+                    currentURISegmentList->InsertL(
+                            currentURISegmentList->Size(), addNAME);
+                    currentURISegmentList->InsertL(
+                            currentURISegmentList->Size(), KNSmlDmApValFSlash);
+                    DBG_ARGS8(_S8("NotInList: Id = %d Name %S"), lValue,
+                            &addNAME);
+
+                    // KNSmlDMStart includes start text for URISeg
+                    TBuf8<20> addURI; // AP/APIdnnn , nnn = profileid
+                    addURI.Append(_L8("AP/APId"));
+                    addURI.AppendNumFixedWidth(lValue, EDecimal, 3);
+
+                    TBuf8<16> addLUID;
+                    _LIT8(KFormat, "%d");
+                    addLUID.Format(KFormat, lValue);
+
+                    // Also added to mapping
+                    iCallBack->SetMappingL(addURI, addLUID);
+                    }
+                } // Skip
+            errorCode = apView->GotoNextRecord();
+            }
+
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+
+        CleanupStack::PopAndDestroy(2); // apView, currentURISegmentList
+
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): AP end");
+        return;
+        }
+
+    iISPId = IntLUID(aLUID);
+
+    //
+    //  Get all NAPDef numbers
+    //
+    if (aURI.Match(_L8("AP/*/NAPDef")) != KErrNotFound)
+        {
+        TBool inDatabase = EFalse;
+        TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+        TUint32 serviceId;
+
+        CCommsDbTableView* napdefView = iDatabase->OpenViewMatchingUintLC(
+                TPtrC(IAP), TPtrC(COMMDB_ID), iISPId);
+
+        TInt errorCode = napdefView->GotoFirstRecord();
+
+        if (errorCode != KErrNone)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::ChildURIListL(): NAPDef error end");
+            CleanupStack::PopAndDestroy(2); // napdefView, currentURISegmentList
+            return;
+            }
+        else
+            {
+            napdefView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+            napdefView->ReadUintL(TPtrC(IAP_SERVICE), serviceId); // ID  
+            CleanupStack::PopAndDestroy(); // napdefView
+            }
+
+        CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                serviceType, TPtrC(COMMDB_ID), serviceId);
+
+        errorCode = tableView->GotoFirstRecord();
+
+        while (errorCode == KErrNone)
+            {
+            TUint32 lValue;
+            TInt lLine(0);
+            tableView->ReadUintL(TPtrC(COMMDB_ID), lValue);
+            //
+            //  Check if in aPreviousURISegmentList
+            // 
+            while (!inDatabase && lLine < aPreviousURISegmentList.Count())
+                {
+                TUint32 list = GetIntObject8(
+                        aPreviousURISegmentList.At(lLine).iURISegLUID);
+                if (list == lValue)
+                    {
+                    inDatabase = ETrue;
+                    }
+                else
+                    {
+                    lLine++;
+                    }
+                }
+
+            if (inDatabase)
+                {
+                currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                        aPreviousURISegmentList.At(lLine).iURISeg);
+                currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                        KNSmlDmApValFSlash);
+                inDatabase = EFalse;
+                }
+            else
+                {
+                _LIT8(Kprev, "NAPId");
+                TBuf8<15> addNAME(Kprev); // APIdnnn , nnn = profileid
+                addNAME.AppendNumFixedWidth(lValue, EDecimal, 3);
+
+                currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                        addNAME);
+                currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                        KNSmlDmApValFSlash);
+
+                _LIT8(Kprev2, "/NAPId");
+                TBuf8<80> addURI; // AP/xxx/NAPDef/NAPIdnnn , nnn = id nbr
+                addURI.Append(aURI);
+                addURI.Append(Kprev2);
+                addURI.AppendNumFixedWidth(lValue, EDecimal, 3);
+
+                TBuf8<16> addLUID;
+                _LIT8(KFormat, "%d");
+                addLUID.Format(KFormat, lValue);
+
+                // Also added to mapping
+                iCallBack->SetMappingL(addURI, addLUID);
+                }
+            errorCode = tableView->GotoNextRecord();
+            }
+
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+
+        CleanupStack::PopAndDestroy(2); // tableView, currentURISegmentList
+
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): AP end");
+        return;
+        }
+
+    //  Get all Px numbers 
+    //  Check also AP-nbr + serviceType and nbr for Proxy
+    //  To get right data for AP
+    //
+    if (aURI.Match(_L8("AP/*/Px")) != KErrNotFound)
+        {
+        TBool inDatabase = EFalse;
+        TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+        TUint32 ServiceIsp;
+
+        CCommsDbTableView* pxView = iDatabase->OpenViewMatchingUintLC(TPtrC(
+                IAP), TPtrC(COMMDB_ID), iISPId);
+
+        TInt errorCode = pxView->GotoFirstRecord();
+
+        if (errorCode != KErrNone)
+            {
+            CleanupStack::PopAndDestroy(2); // pxView, currentURISegmentList
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::ChildURIListL(): NAPDef error end");
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            return;
+            }
+        else
+            {
+            pxView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType); // Type
+            pxView->ReadUintL(TPtrC(IAP_SERVICE), ServiceIsp); // ID  
+            CleanupStack::PopAndDestroy(); // pxView
+            }
+
+        CCommsDbTableView* tableView = iDatabase->OpenViewMatchingTextLC(
+                TPtrC(PROXIES), TPtrC(PROXY_SERVICE_TYPE), serviceType);
+
+        errorCode = tableView->GotoFirstRecord();
+
+        TBool proxyFound(false);
+        while (errorCode == KErrNone)
+            {
+            TUint32 lProxyIspId;
+            TUint32 lProxyId;
+            TInt lLine(0);
+            tableView->ReadUintL(TPtrC(PROXY_ISP), lProxyIspId);
+            tableView->ReadUintL(TPtrC(COMMDB_ID), lProxyId);
+            if (lProxyIspId == ServiceIsp) // Right value ISP
+                {
+                proxyFound = true;
+                tableView->ReadUintL(TPtrC(COMMDB_ID), lProxyId);
+                //
+                //  Check if in aPreviousURISegmentList
+                // 
+                while (!inDatabase && lLine < aPreviousURISegmentList.Count())
+                    {
+                    TUint32 list = GetIntObject8(aPreviousURISegmentList.At(
+                            lLine).iURISegLUID) - KNSmlApProxyLowerBase;
+                    if (list == lProxyId)
+                        {
+                        inDatabase = ETrue;
+                        }
+                    else
+                        {
+                        lLine++;
+                        }
+                    }
+
+                if (inDatabase)
+                    {
+                    currentURISegmentList->InsertL(
+                            currentURISegmentList->Size(),
+                            aPreviousURISegmentList.At(lLine).iURISeg);
+                    currentURISegmentList->InsertL(
+                            currentURISegmentList->Size(), KNSmlDmApValFSlash);
+                    inDatabase = EFalse;
+                    DBG_ARGS8(_S8("InList: Id = %d Name %S"), lProxyId
+                            + KNSmlApProxyLowerBase,
+                            &aPreviousURISegmentList.At(lLine).iURISeg);
+                    }
+                else
+                    {
+                    _LIT8(Kprev, "PXId");
+                    TBuf8<9> addNAME(Kprev); // PXIdnnn , nnn = profileid
+                    addNAME.AppendNumFixedWidth(lProxyId, EDecimal, 3);
+
+                    currentURISegmentList->InsertL(
+                            currentURISegmentList->Size(), addNAME);
+                    currentURISegmentList->InsertL(
+                            currentURISegmentList->Size(), KNSmlDmApValFSlash);
+                    DBG_ARGS8(_S8("NotInList: Id = %d Name %S"), lProxyId,
+                            &addNAME);
+                    TBuf8<80> addURI; // AP/xxx/Px/PXIdnnn , nnn = id nbr
+                    addURI.Append(aURI);
+                    _LIT8(KPxid, "/PXId");
+                    addURI.Append(KPxid);
+                    addURI.AppendNumFixedWidth(lProxyId, EDecimal, 3);
+
+                    TBuf8<16> addLUID;
+                    _LIT8(KFormat, "%d");
+                    addLUID.Format(KFormat, KNSmlApProxyLowerBase + lProxyId); // 100000 + lProxyId
+
+                    // Also added to mapping
+                    iCallBack->SetMappingL(addURI, addLUID);
+                    }
+                }
+            errorCode = tableView->GotoNextRecord();
+            }
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): AP end");
+        if (proxyFound)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            }
+        else
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            }
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+
+        CleanupStack::PopAndDestroy(2); //  tableView, currentURISegmentList
+
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/Bearer/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/Bearer/*/*")) == KErrNotFound)
+        {
+        currentURISegmentList->InsertL(currentURISegmentList->Size(), (_L8(
+                "BearerL/Direction"))); // Direction
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): BearerL end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/Bearer")) != KErrNotFound)
+        {
+        if (aPreviousURISegmentList.Count() > 0) // Allready mapped
+            {
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    aPreviousURISegmentList.At(0).iURISeg);
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    KNSmlDmApValFSlash);
+            }
+        else
+            {
+            _LIT8(Kprev, "BId");
+            TBuf8<9> addNAME(Kprev); // Id
+            addNAME.AppendNumFixedWidth(checkLUID, EDecimal, 3);
+
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    addNAME);
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    KNSmlDmApValFSlash);
+
+            TBuf8<80> addURI; // AP/xxx/NapDef/Bearer/BIdn , n=aLUID
+            addURI.Append(aURI);
+            _LIT8(KBid, "/BId");
+            addURI.Append(KBid);
+            addURI.AppendNumFixedWidth(checkLUID, EDecimal, 3);
+
+            TBuf8<16> addLUID;
+            _LIT8(KFormat, "%d");
+            addLUID.Format(KFormat, checkLUID);
+
+            // Also added to mapping
+            iCallBack->SetMappingL(addURI, addLUID);
+            }
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): Bearer end");
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+
+        CleanupStack::PopAndDestroy(); //  currentURISegmentList
+
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/DNSAddr/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/DNSAddr/*/*")) == KErrNotFound)
+        {
+        currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                KNSmlDNSAddrNode);
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): DNSAddrL end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/DNSAddr")) != KErrNotFound)
+        {
+
+        TBuf<KCommsDbSvrMaxFieldLength> ServType;
+        TUint32 servId;
+
+        CCommsDbTableView* napdefView = iDatabase->OpenViewMatchingUintLC(
+                TPtrC(IAP), TPtrC(COMMDB_ID), iISPId);
+
+        TInt errorCode = napdefView->GotoFirstRecord();
+
+        if (errorCode != KErrNone)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::ChildURIListL(): DNSAddr error end");
+            CleanupStack::PopAndDestroy(2); // napdefView, currentURISegmentList
+            return;
+            }
+        else
+            {
+            napdefView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), ServType);
+            napdefView->ReadUintL(TPtrC(IAP_SERVICE), servId); // ID  
+            CleanupStack::PopAndDestroy(napdefView); // napdefView
+            }
+
+        CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                ServType, TPtrC(COMMDB_ID), servId);
+
+        errorCode = tableView->GotoFirstRecord();
+
+        if (errorCode != KErrNone)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::ChildURIListL(): DNSAddr error end");
+            CleanupStack::PopAndDestroy(2); // tableView, currentURISegmentList
+            return;
+            }
+        else
+            {
+            // Now we can read DNSAddrL values
+            TInt leavecode;
+            TBuf<KCommsDbSvrMaxFieldLength> columnValue;
+            TBuf8<16> addLUID;
+            TBuf8<80> addURI; // AP/xxx/NAPDef/DNSAddr/DNSx
+            _LIT8(KFormat, "%d");
+            TRAP(leavecode, tableView->ReadTextL(TPtrC(
+                    SERVICE_IP_NAME_SERVER1), columnValue));
+            if ((leavecode == KErrNone) && (columnValue.Length() > 0))
+                {
+                addURI.Append(aURI);
+                addURI.Append(KNSmlDNS1);
+                _LIT8(KDns1, "DNS1");
+                currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                        KDns1);
+                addLUID.Format(KFormat, DnsToLuid(UriUtils::EIPv4Host, 1));
+                iCallBack->SetMappingL(addURI, addLUID);
+                addURI.Zero();
+                }
+
+            TRAP(leavecode, tableView->ReadTextL(TPtrC(
+                    SERVICE_IP_NAME_SERVER2), columnValue));
+            if (leavecode == KErrNone && (columnValue.Length() > 0))
+                {
+                if (currentURISegmentList->Size() > 0)
+                    {
+                    currentURISegmentList->InsertL(
+                            currentURISegmentList->Size(), KNSmlDmApValFSlash);
+                    }
+                addURI.Append(aURI);
+                addURI.Append(KNSmlDNS2);
+                _LIT8(KDns2, "DNS2");
+                currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                        KDns2);
+                addLUID.Format(KFormat, DnsToLuid(UriUtils::EIPv4Host, 2));
+                iCallBack->SetMappingL(addURI, addLUID);
+                addURI.Zero();
+                }
+
+            TRAP(leavecode, tableView->ReadTextL(TPtrC(
+                    SERVICE_IP6_NAME_SERVER1), columnValue));
+            if (leavecode == KErrNone && (columnValue.Length() > 0))
+                {
+                if (currentURISegmentList->Size() > 0)
+                    {
+                    currentURISegmentList->InsertL(
+                            currentURISegmentList->Size(), KNSmlDmApValFSlash);
+                    }
+                addURI.Append(aURI);
+                addURI.Append(KNSmlDNS3);
+                _LIT8(KDns3, "DNS3");
+                currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                        KDns3);
+                addLUID.Format(KFormat, DnsToLuid(UriUtils::EIPv6Host, 1));
+                iCallBack->SetMappingL(addURI, addLUID);
+                addURI.Zero();
+                }
+
+            TRAP(leavecode, tableView->ReadTextL(TPtrC(
+                    SERVICE_IP6_NAME_SERVER2), columnValue));
+            if (leavecode == KErrNone && (columnValue.Length() > 0))
+                {
+                if (currentURISegmentList->Size() > 0)
+                    {
+                    currentURISegmentList->InsertL(
+                            currentURISegmentList->Size(), KNSmlDmApValFSlash);
+                    }
+                addURI.Append(aURI);
+                addURI.Append(KNSmlDNS4);
+                _LIT8(KDns4, "DNS4");
+                currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                        KDns4);
+                addLUID.Format(KFormat, DnsToLuid(UriUtils::EIPv6Host, 2));
+                iCallBack->SetMappingL(addURI, addLUID);
+                }
+
+            _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): DNSAddr end");
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                    KNullDesC8);
+
+            CleanupStack::PopAndDestroy(tableView);
+            CleanupStack::PopAndDestroy(currentURISegmentList); //  currentURISegmentList
+            }
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/Port/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/Port/*/*")) == KErrNotFound)
+        {
+        currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                KNSmlDdfPortNbr);
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): Port end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/Port")) != KErrNotFound)
+        {
+
+        TUint32 iapID10 = GetAPIdFromURIL(aURI);
+
+        if (WapAPExistsL(iapID10)) // WapPort
+            {
+            TBuf8<80> addURI; // AP/xxx/Px/Port/WAP
+            addURI.Append(aURI);
+            _LIT8(KWap, "/WAP");
+            addURI.Append(KWap);
+            _LIT8(KWap2, "WAP/");
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    KWap2);
+            }
+
+        if (PxExistsL(checkLUID)) // ProxyPort
+            {
+            TBuf8<80> addURI; // AP/xxx/Px/Port/PROXY
+            addURI.Append(aURI);
+            _LIT8(KProxy, "/PROXY");
+            addURI.Append(KProxy);
+            _LIT8(KProxy2, "PROXY/");
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    KProxy2);
+            }
+
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): Port end");
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+
+        CleanupStack::PopAndDestroy(); //  currentURISegmentList
+
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/NAPAuthInf/*")) != KErrNotFound && aURI.Match(
+            _L8("AP/*/NAPAuthInf/*/*")) == KErrNotFound)
+        {
+        _LIT8(KAuthFields, "AuthName/AuthSecr");
+        currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                (KAuthFields));
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): NAPAuthInfL end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/NAPAuthInf")) != KErrNotFound)
+        {
+        _LIT8(Kprev, "AUId");
+        TBuf8<9> addNAME(Kprev); // Id
+        addNAME.AppendNumFixedWidth(checkLUID, EDecimal, 3);
+
+        currentURISegmentList->InsertL(currentURISegmentList->Size(), addNAME);
+        currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                KNSmlDmApValFSlash);
+
+        TBuf8<80> addURI; // AP/xxx/NapDef/NAPAuthInf/AUIdn , n=aLUID
+        addURI.Append(aURI);
+        _LIT8(KAuid, "/AUId");
+        addURI.Append(KAuid);
+        addURI.AppendNumFixedWidth(checkLUID, EDecimal, 3);
+
+        TBuf8<16> addLUID;
+        _LIT8(KFormat, "%d");
+        addLUID.Format(KFormat, checkLUID);
+
+        // Also added to mapping
+        iCallBack->SetMappingL(addURI, addLUID);
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): NAPAuthInf end");
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+
+        CleanupStack::PopAndDestroy(); //  currentURISegmentList
+
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/PxAuthInf/*")) != KErrNotFound && aURI.Match(
+            _L8("AP/*/PxAuthInf/*/*")) == KErrNotFound)
+        {
+        _LIT8(KPxAuthFields, "PxAuthId/PxAuthPW");
+        currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                (KPxAuthFields));
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): NAPAuthInfL end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/PxAuthInf")) != KErrNotFound)
+        {
+        _LIT8(Kprev, "AUPxId");
+        TBuf8<11> addNAME(Kprev); // Id
+        addNAME.AppendNumFixedWidth(checkLUID, EDecimal, 3);
+
+        currentURISegmentList->InsertL(currentURISegmentList->Size(), addNAME);
+        currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                KNSmlDmApValFSlash);
+
+        TBuf8<80> addURI; // AP/xxx/Px/PxAuthInf/AUPxIdn , n=aLUID
+        addURI.Append(aURI);
+        _LIT8(KAupxid, "/AUPxId");
+        addURI.Append(KAupxid);
+        addURI.AppendNumFixedWidth(checkLUID, EDecimal, 3);
+
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): NAPAuthInf end");
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+
+        CleanupStack::PopAndDestroy(); //  currentURISegmentList
+
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/ToNAPID/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/ToNAPID/*/*")) == KErrNotFound)
+        {
+        currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                (KNSmlDdfToNAPIDL));
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): ToNAPIDL end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/ToNAPID")) != KErrNotFound)
+        {
+        _LIT8(Kprev, "TId");
+        TBuf8<9> addNAME(Kprev); // Id
+        addNAME.AppendNumFixedWidth(checkLUID, EDecimal, 3);
+
+        currentURISegmentList->InsertL(currentURISegmentList->Size(), addNAME);
+        currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                KNSmlDmApValFSlash);
+
+        TBuf8<80> addURI; // AP/xxx/NapDef/ToNAPID/TIdn , n=aLUID
+        addURI.Append(aURI);
+        _LIT8(KTid, "/TId");
+        addURI.Append(KTid);
+        addURI.AppendNumFixedWidth(checkLUID, EDecimal, 3);
+
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): ToNAPID end");
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+
+        CleanupStack::PopAndDestroy(); //  currentURISegmentList
+
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/Networks/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/Networks/*/*")) == KErrNotFound)
+        {
+        _LIT8(KNameId, "Name/ID");
+        currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                (KNameId));
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): Networks end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/Networks")) != KErrNotFound)
+        {
+        checkLUID = GetAPIdFromURIL(aURI);
+
+        CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                TPtrC(IAP), TPtrC(COMMDB_ID), checkLUID);
+
+        TInt errorCode = tableView->GotoFirstRecord();
+
+        if (errorCode == KErrNone)
+            {
+            TUint32 nwLUID = 0;
+            tableView->ReadUintL(TPtrC(IAP_NETWORK), nwLUID); // Networks luid
+            if (!NetworkExistsL(nwLUID))
+                {
+                errorCode = KErrNotFound;
+                }
+            }
+
+        CleanupStack::PopAndDestroy(); // tableView
+
+        if (errorCode != KErrNone)
+            {
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::ChildURIListL(): Networks error end");
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            CleanupStack::PopAndDestroy(); //  currentURISegmentList
+            return;
+            }
+
+        if (aPreviousURISegmentList.Count() > 0) // Allready mapped
+            {
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    aPreviousURISegmentList.At(0).iURISeg);
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    KNSmlDmApValFSlash);
+            }
+        else
+            {
+            _LIT8(Kprev, "NwId");
+            TBuf8<9> addNAME(Kprev); // Id
+            addNAME.AppendNumFixedWidth(checkLUID, EDecimal, 3);
+
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    addNAME);
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    KNSmlDmApValFSlash);
+
+            TBuf8<80> addURI; // AP/xxx/NapDef/Networks/NwIdn , n=aLUID
+            addURI.Append(aURI);
+            _LIT8(KNwid, "/NwId");
+            addURI.Append(KNwid);
+            addURI.AppendNumFixedWidth(checkLUID, EDecimal, 3);
+
+            TBuf8<16> addLUID;
+            _LIT8(KFormat, "%d");
+            addLUID.Format(KFormat, checkLUID);
+
+            // Also added to mapping
+            iCallBack->SetMappingL(addURI, addLUID);
+            }
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): Networks end");
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+
+        CleanupStack::PopAndDestroy(); //  currentURISegmentList
+
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/NoPxFor/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/NoPxFor/*/*")) == KErrNotFound)
+        {
+        currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                (KNSmlDdfNoPxForL));
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): NoPxFor end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/NoPxFor")) != KErrNotFound)
+        {
+        if (aPreviousURISegmentList.Count() > 0) // Allready mapped
+            {
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    aPreviousURISegmentList.At(0).iURISeg);
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    KNSmlDmApValFSlash);
+            }
+        else
+            {
+            _LIT8(KexepPrev, "eXC");
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    KexepPrev);
+            }
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): NoPxFor end");
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+
+        CleanupStack::PopAndDestroy(); //  currentURISegmentList
+
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/Domain/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/Domain/*/*")) == KErrNotFound)
+        {
+        currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                (KNSmlDdfDomainL));
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+        CleanupStack::PopAndDestroy(); // currentURISegmentList
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): Domain end");
+        return;
+        }
+
+    if (aURI.Match(_L8("AP/*/Domain")) != KErrNotFound)
+        {
+        if (aPreviousURISegmentList.Count() > 0) // Allready mapped
+            {
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    aPreviousURISegmentList.At(0).iURISeg);
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    KNSmlDmApValFSlash);
+            }
+        else
+            {
+            _LIT8(KexepPrev, "dOM");
+            currentURISegmentList->InsertL(currentURISegmentList->Size(),
+                    KexepPrev);
+            }
+        _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): Domain end");
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentURISegmentList,
+                KNullDesC8);
+
+        CleanupStack::PopAndDestroy(); //  currentURISegmentList
+
+        return;
+        }
+
+    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+    iCallBack->SetResultsL(aResultsRef, *currentURISegmentList, KNullDesC8);
+    _DBG_FILE("CNSmlInternetAdapter::ChildURIListL(): end");
+
+    CleanupStack::PopAndDestroy(); // currentURISegmentList
+
+    return;
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::AddNodeBufferL()
+// Inserts new AP-data to database
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::AddNodeBufferL(const TDesC8& aURI,
+        const TDesC8& /*aParentLUID*/, const TInt aStatusRef,
+        const TBool aDnsUpd, const TBool aWlan)
+    {
+    TInt index = -1;
+
+    for (TInt i = 0; i < iBuffer->Count(); i++)
+        {
+        TPtrC8 parentUri = FirstURISeg(aURI);
+        if (iBuffer->At(i).iMappingName->Compare(parentUri) == 0)
+            {
+            index = i;
+            break;
+            }
+        }
+
+    if (index < 0)
+        {
+        TNSmlAPBufferElement newNode;
+        newNode.iMappingName = aURI.AllocLC();
+
+        NextAPNameL(*LastURISeg(aURI).AllocLC());
+        CleanupStack::PopAndDestroy();
+
+        newNode.iName = iIAPName.AllocLC();
+        newNode.iNodeBuf = new (ELeave) CArrayFixFlat<TNSmlAPAddElement> (
+                KNSmlAPGranularity);
+        newNode.iWlanNodeBuf
+                = new (ELeave) CArrayFixFlat<TNSmlAPAddElement> (
+                        KNSmlAPGranularity);
+        newNode.iExecuted = EFalse;
+        newNode.iBearer = EFalse;
+        newNode.iDirection = EFalse;
+        newNode.iNameReceived = EFalse;
+        if (aDnsUpd)
+            {
+            newNode.iDnsUpdateBuf = ETrue;
+            }
+        else
+            {
+            newNode.iDnsUpdateBuf = EFalse;
+            }
+        newNode.iLuid = 0;
+        iBuffer->AppendL(newNode);
+        CleanupStack::Pop(2); //newNode.iMappingName,newNode.iName
+
+        index = iBuffer->Count() - 1;
+        }
+
+    if (!aDnsUpd)
+        {
+        TNSmlAPAddElement newCommand;
+        newCommand.iUri = aURI.AllocLC();
+        newCommand.iData = 0;
+        newCommand.iStatusRef = aStatusRef;
+        newCommand.iLeaf = EFalse;
+        newCommand.iDone = EFalse;
+
+        TPtrC8 parentUri = FirstURISeg(aURI);
+        newCommand.iLuid = iCallBack->GetLuidAllocL(parentUri);
+
+        if (aWlan)
+            {
+            iBuffer->At(index).iWlanNodeBuf->AppendL(newCommand);
+            }
+        else
+            {
+            iBuffer->At(index).iNodeBuf->AppendL(newCommand);
+            }
+        CleanupStack::Pop(); //newCommand.iUri
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::AddLeafBufferL()
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::AddLeafBufferL(const TDesC8& aURI,
+        const TDesC8& aParentLUID, const TDesC8& aObject,
+        const TDesC8& /*aType*/, const TInt aStatusRef, const TBool aWlan)
+    {
+    TInt index = -1;
+
+    for (TInt i = 0; i < iBuffer->Count(); i++)
+        {
+        TPtrC8 parentUri = FirstURISeg(aURI);
+        if (iBuffer->At(i).iMappingName->Compare(parentUri) == 0)
+            {
+            index = i;
+            break;
+            }
+        }
+
+    if (index < 0)
+        {
+        if (aParentLUID.Length() < 0)
+            {
+            DBG_ARGS8(_S8("AP:AddLeafBufferL URI - <%S> <%S> NOTFOUND"),
+                    &aURI, &aParentLUID);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            return;
+            }
+        else
+            {
+            // this means update to DNSAddr/<X>
+            TPtrC8 apURI = FirstURISeg(aURI);
+            HBufC8* luid = iCallBack->GetLuidAllocL(apURI);
+            CleanupStack::PushL(luid);
+
+            AddNodeBufferL(apURI, luid->Des(), -2, ETrue);
+            iDnsIpv4Pri = 0;
+            iDnsIpv6Pri = 0;
+
+            CleanupStack::PopAndDestroy(luid);
+            index = 0;
+            }
+        }
+
+    TNSmlAPAddElement newCommand;
+
+    newCommand.iUri = aURI.AllocLC(); //aURI.AllocLC();
+    newCommand.iData = aObject.AllocLC();
+    newCommand.iStatusRef = aStatusRef;
+    newCommand.iLuid = aParentLUID.AllocLC();
+    newCommand.iLeaf = ETrue;
+    newCommand.iDone = EFalse;
+
+    if (aWlan)
+        {
+        iBuffer->At(index).iWlanNodeBuf->AppendL(newCommand);
+        }
+    else
+        {
+        iBuffer->At(index).iNodeBuf->AppendL(newCommand);
+        }
+
+    CleanupStack::Pop(3); //newCommand.iLastUriSeg, newCommand.iData, newCommand.iLuid
+
+    if (aURI.Find(KNSmlDdfBearerL) >= 0) // Bearer added
+        {
+        if (aObject.Match(KNSmlDmApValGsmGprs) != KErrNotFound)
+            {
+            iBuffer->At(index).iBearer = ETrue;
+            }
+
+        else if (aObject.Match(KNSmlDmApVal3Gppps) != KErrNotFound
+                || aObject.Match(KNSmlDmApValVpn) != KErrNotFound)
+            {
+            iBuffer->At(index).iBearer = ETrue;
+            }
+        if ((aObject.Match(KNSmlDmApValWlan) != KErrNotFound)
+                && iWlanSupported) // Valid Bearer
+            {
+            iBuffer->At(index).iBearer = ETrue;
+            }
+        }
+
+    if (aURI.Find(KNSmlDdfDirection) >= 0) // Direction added
+        {
+        iBuffer->At(index).iDirection = ETrue;
+        }
+
+    if (aURI.Match(_L8("AP/*/NAPDef/*/*")) != KErrNotFound && aURI.Match(_L8(
+            "AP/*/NAPDef/*/*/*")) == KErrNotFound
+            && LastURISeg(aURI).Compare(KNSmlDdfNAPName) == 0)
+        {
+        iIAPExists = EFalse;
+        iBuffer->At(index).iNameReceived = ETrue;
+
+        delete iBuffer->At(index).iName;
+        iBuffer->At(index).iName = 0;
+
+        iBuffer->At(index).iName = aObject.AllocLC();
+        iIAPName.Copy(aObject);
+        CleanupStack::Pop();
+
+        // Check if Name and LUID match
+        TPtrC qTable = TPtrC(IAP); // Check if IAP-table free
+        TPtrC qDB = TPtrC(COMMDB_ID);
+        TPtrC8 parentUri = FirstURISeg(aURI);
+        HBufC8* luid = iCallBack->GetLuidAllocL(parentUri);
+        CleanupStack::PushL(luid);
+
+        CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                qTable, qDB, IntLUID(*luid));
+
+        TInt errorCode = tableView->GotoFirstRecord();
+        if (errorCode != KErrNotFound)
+            {
+            // Check the name
+            TBuf8<KCommsDbSvrMaxFieldLength> name;
+            tableView->ReadTextL(TPtrC(COMMDB_NAME), name);
+            if (name.Compare(aObject) != 0)
+                {
+                // Not correct name                                    
+                // Remove all mappings from AP/xxx level
+                if (isAdd)
+                    {
+                    TInt ret = iCallBack->RemoveMappingL(
+                            KNSmlInternetAdapterImplUid, GetDynamicAPNodeUri(
+                                    aURI), ETrue);
+                    iPrevURI->Des().Format(KNullDesC8);
+                    iPrevLUID = 0;
+                    }
+                else
+                    {
+                    iIAPExists = ETrue;
+                    iLeafType = EDMUpdate;
+                    }
+
+                }
+            else
+                {
+                iIAPExists = ETrue;
+                iLeafType = EDMUpdate;
+                }
+            }
+        CleanupStack::PopAndDestroy(tableView);
+        CleanupStack::PopAndDestroy(luid);
+        }
+    //    
+
+    //  If Bearer data + Direction + name => add is possible for AP
+    //
+    if (iBuffer->At(index).iDirection && iBuffer->At(index).iBearer
+            && iBuffer->At(index).iNameReceived && !iExecutingBuffer)
+        {
+        iBearer.Zero();
+        iDirection = ECommDbConnectionDirectionUnknown;
+        ExecuteBufferL(aURI);
+
+        }
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::AddNodeObjectL()
+// Inserts new AP-data to database
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::AddNodeObjectL(const TDesC8& aURI,
+        const TDesC8& aParentLUID, const TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::AddNodeObjectL(): begin");
+
+    DBG_ARGS8(
+            _S8(
+                    "CNSmlInternetAdapter::AddNodeObjectL(): aURI=<%S>, aParentLUID=<%S>"),
+            &aURI, &aParentLUID);
+
+    if (iLeafType == EDMUpdate && iExecutingBuffer)
+        {
+        // This is an update to an old IAP. All node additions return KErrAlreadyExists.
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EAlreadyExists); // EError
+        _DBG_FILE(
+                "CNSmlInternetAdapter::AddNodeObjectL(): EAlreadyExists end");
+        return;
+        }
+
+    // Save LUID to local variable to be able to reset the value, if needed.
+    TBuf8<KSmlMaxURISegLen> parentLUID;
+    parentLUID.Zero();
+    parentLUID = aParentLUID;
+
+    TUint32 apId = GetAPIdFromURIL(aURI);
+
+    if (parentLUID.Length() > 0 && IntLUID(parentLUID) > 0
+            && !APExistsL(apId))
+        {
+        // AP has been deleted. Handle as new data.
+        _DBG_FILE(
+                "CNSmlInternetAdapter::AddNodeObjectL(): parentLUID.Length() > 0 && !APExistsL() -> Remove mapping ");
+        TInt ret = iCallBack->RemoveMappingL(KNSmlInternetAdapterImplUid,
+                GetDynamicAPNodeUri(aURI), ETrue);
+        if (ret)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            return;
+            }
+        parentLUID.Zero();
+        iPrevURI->Des().Format(KNullDesC8);
+        iPrevLUID = 0;
+        }
+
+    if (parentLUID.Length() <= 0)
+        {
+        // Check OOD before saving new 
+        RFs fs;
+        User::LeaveIfError(fs.Connect());
+        CleanupClosePushL(fs);
+
+        if (SysUtil::FFSSpaceBelowCriticalLevelL(&fs,
+                KNSmlInternetAdapterFatMinSize))
+            {
+            CleanupStack::PopAndDestroy(); // fs
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EDiskFull);
+            _DBG_FILE("CNSmlInternetAdapter::AddNodeObjectL(): DISK FULL end");
+            return;
+            // do not write
+            }
+        CleanupStack::PopAndDestroy(); //fs
+        }
+    //
+    //  Check if AP-add
+    //
+    if ((aURI.Match(_L8("AP/*")) != KErrNotFound && aURI.Match(_L8("AP/*/*"))
+            == KErrNotFound) || (aURI.Match(_L8("AP/*/NAPDef/*"))
+            != KErrNotFound && aURI.Match(_L8("AP/*/NAPDef/*/*"))
+            == KErrNotFound) || aURI.Match(_L8("AP/*/NAPDef"))
+            != KErrNotFound || aURI.Match(_L8("AP/*/NAPDef/*/Bearer"))
+            != KErrNotFound || (aURI.Match(_L8("AP/*/NAPDef/*/Bearer/*"))
+            != KErrNotFound && aURI.Match(_L8("AP/*/NAPDef/*/Bearer/*/*"))
+            == KErrNotFound) || aURI.Match(_L8("*/WLAN*")) != KErrNotFound)
+        {
+        if ((parentLUID.Length() <= 0) && (aURI.Match(_L8("*/WLAN*"))
+                != KErrNotFound))
+            {
+            AddNodeBufferL(aURI, parentLUID, aStatusRef, EFalse, ETrue);
+            return;
+            }
+        if (parentLUID.Length() <= 0)
+            {
+            AddNodeBufferL(aURI, parentLUID, aStatusRef, EFalse);
+            return;
+            }
+
+        if (iTransactionCommitted && !iDatabase->InTransaction())
+            {
+
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddNode object, begin commsdb transaction ");
+            TInt codeBegin = iDatabase->BeginTransaction();
+            TInt retry = KBeginTransRetryCount;
+            if (codeBegin == KErrNone)
+                {
+                iTransactionCommitted = EFalse;
+                }
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlInternetAdapter::AddNode object iDatabase->Begintransaction start of addobjectL return code = %d"),
+                    codeBegin);
+            if (codeBegin == KErrLocked)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::Addnodeobject Database->Begintransaction has returned KErrLocked");
+                while (retry > 0 && codeBegin == KErrLocked)
+                    {
+                    User::After(KBeginTransRetryDelay);
+                    codeBegin = iDatabase->BeginTransaction();
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::AddNode object iDatabase->Begintransaction after 2 seconds of wait of addobjectL return code = %d"),
+                            codeBegin);
+                    retry--;
+                    }
+
+                if (codeBegin == KErrNone)
+                    {
+                    iTransactionCommitted = EFalse;
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::AddNode object transaction commited is false ");
+                    }
+
+                }
+
+            }
+        if ((aURI.Match(_L8("*/WLAN*")) != KErrNotFound) && iWlanSupported)
+            {
+            DBG_ARGS8(
+                    _S8(
+                            "To WlanAdapter::AddNodeObjectL - uri: <%S> to parentLUID: <%S>"),
+                    &aURI, &parentLUID);
+            iWlanAdapter->AddNodeObjectL(aURI, parentLUID, aStatusRef);
+            return;
+            }
+
+        TInt pluid = IntLUID(parentLUID);
+
+        if (pluid < 0)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            _DBG_FILE("CNSmlInternetAdapter::AddNodeObjectL(): end");
+            return;
+            }
+        iIAPId = pluid;
+
+        TPtrC qTable = TPtrC(IAP); // Check if IAP-table free
+        TPtrC qDB = TPtrC(COMMDB_ID);
+
+        //Check if URI is /AP/*/NAPDef/* then it should be check IAP ID in DB not IAPService
+        if ((iIAPId >= 0)
+                && ((aURI.Match(_L8("AP/*/NAPDef/*")) != KErrNotFound)
+                        || (aURI.Match(_L8("AP/*/NAPDef/*/Bearer/*"))
+                                != KErrNotFound) || (aURI.Match(_L8("AP/*"))
+                        != KErrNotFound) || (aURI.Match(_L8("AP/*/NAPDef"))
+                        != KErrNotFound)))
+            {
+            //Get parent UID and check if that exist if not add 
+            iIAPId = GetAPIdFromURIL(aURI);
+
+            }
+        CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                qTable, qDB, iIAPId);
+
+        TInt errorCode = tableView->GotoFirstRecord();
+
+        CleanupStack::PopAndDestroy(tableView);
+
+        // Node allready exists => No adding possible
+        if (errorCode == KErrNone)
+            {
+            if (!iExecutingBuffer)
+                {
+                AddNodeBufferL(aURI, parentLUID, aStatusRef, EFalse);
+                }
+            else
+                {
+                iCallBack->SetStatusL(aStatusRef,
+                        CSmlDmAdapter::EAlreadyExists); // EError
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddNodeObjectL(): EAlreadyExists end");
+                }
+            return;
+            }
+        else if (iIAPId == 0)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlInternetAdapter::AddNodeObjectL(): ENotFound end");
+            return;
+            }
+        else if (iIAPId > 0 && errorCode == KErrNotFound) // Stale data, needs update
+            {
+
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddNodeObjectL(): stale data Add to buffer");
+            AddNodeBufferL(aURI, parentLUID, aStatusRef, EFalse);
+            iStaleMapUpdate = ETrue;
+            return;
+            }
+
+        }
+    else if (aURI.Match(_L8("AP/*/Px/*")) != KErrNotFound && // How to check if already added
+            aURI.Match(_L8("AP/*/Px/*/*")) == KErrNotFound) // dm-tree knows last LUID
+        {
+        if (parentLUID.Length() <= 0)
+            {
+            AddNodeBufferL(aURI, parentLUID, aStatusRef, EFalse);
+            return;
+            }
+
+        // Check if already exists on database (=> only One possible for AP)
+        if (GetProxyIdL(aURI))
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EAlreadyExists);
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddNodeObjectL(): EAlreadyExists end");
+            return;
+            }
+
+        TUint32 iapID = GetAPIdFromURIL(aURI);
+
+        //  IAP-table search serviceType (=Bearer)
+        CCommsDbTableView* iapView = iDatabase->OpenViewMatchingUintLC(TPtrC(
+                IAP), TPtrC(COMMDB_ID), iapID);
+
+        TInt errorCode = iapView->GotoFirstRecord();
+
+        // Read serviceType from (IAP)
+        if (errorCode == KErrNone)
+            {
+            iapView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), iProxyServiceType);
+            iapView->ReadUintL(TPtrC(IAP_SERVICE), iProxyISP);
+            CleanupStack::PopAndDestroy(); // iapView
+            }
+        else if (iapID > 0 && errorCode == KErrNotFound) // Stale data, needs update
+            {
+
+            CleanupStack::PopAndDestroy(); // iapViewv
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddNodeObjectL(): stale data for proxy this as new AP ");
+            AddNodeBufferL(aURI, parentLUID, aStatusRef, EFalse);
+            iStaleMapUpdate = ETrue;
+            return;
+            }
+        else
+            {
+            CleanupStack::PopAndDestroy(); // iapView
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlInternetAdapter::AddNodeObjectL(): ENotFound end");
+            return;
+            }
+
+        CCommsDbTableView* proxyTable;
+
+        proxyTable = iDatabase->OpenTableLC(TPtrC(PROXIES));
+
+        TInt initOK = proxyTable->InsertRecord(iapID);
+
+        TInt retry = KBeginTransRetryCount;
+        while (retry > 0 && initOK != KErrNone)
+            {
+            User::After(KBeginTransRetryDelay);
+            initOK = proxyTable->InsertRecord(iapID);
+            retry--;
+            }
+
+        if (initOK == KErrNone)
+            {
+            iProxyServerName = LastURISeg(aURI); // Name from URI
+            initOK = InitializeProxyL(proxyTable);
+
+            User::After(KBeginTransRetryDelay);
+            if (initOK == KErrNone)
+                {
+                TUint32 newId = 0;
+                initOK = proxyTable->PutRecordChanges();
+
+                retry = KBeginTransRetryCount;
+                while (retry > 0 && initOK != KErrNone)
+                    {
+                    User::After(KBeginTransRetryDelay);
+                    initOK = proxyTable->PutRecordChanges();
+                    retry--;
+                    }
+
+                proxyTable->ReadUintL(TPtrC(COMMDB_ID), newId);
+                //
+                // Set mapping-data
+                //
+                TBuf8<16> addLUID;
+                _LIT8(KFormat, "%d");
+                addLUID.Format(KFormat, KNSmlApProxyLowerBase + newId); // 100000 + lProxyId
+
+                // Also added to mapping
+                iCallBack->SetMappingL(aURI, addLUID);
+                }
+            else
+                {
+                proxyTable->CancelRecordChanges();
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddNodeObjectL(): EError end");
+                }
+            }
+        else
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddNodeObjectL(): EError end Insert failed");
+            }
+        CleanupStack::PopAndDestroy(); // proxyTable
+
+        }
+    else if (aURI.Match(_L8("AP/*/Px/*/*")) != KErrNotFound)
+        {
+        if (parentLUID.Length() <= 0)
+            {
+            AddNodeBufferL(aURI, parentLUID, aStatusRef, EFalse);
+            _DBG_FILE("CNSmlInternetAdapter::AddNodeObjectL(): end");
+            return;
+            }
+
+        TInt pluid = IntLUID(parentLUID);
+
+        if (pluid < 0)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            _DBG_FILE("CNSmlInternetAdapter::AddNodeObjectL(): end");
+            return;
+            }
+        else
+            {
+            TUint32 apID = GetAPIdFromURIL(aURI);
+            CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(IAP), TPtrC(COMMDB_ID), apID);
+            TInt errorCode = tableView->GotoFirstRecord();
+            CleanupStack::PopAndDestroy(tableView);
+            if (apID > 0 && errorCode == KErrNotFound) // Stale data, needs update
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddNodeObjectL(): stale data for proxy this as new AP ");
+                AddNodeBufferL(aURI, parentLUID, aStatusRef, EFalse);
+                iStaleMapUpdate = ETrue;
+                return;
+                }
+
+            }
+        }
+
+    else if (aURI.Match(_L8("AP/*/Px")) != KErrNotFound)
+        {
+        if (parentLUID.Length() <= 0)
+            {
+            AddNodeBufferL(aURI, parentLUID, aStatusRef, EFalse);
+            return;
+            }
+
+        TInt pluid = IntLUID(parentLUID);
+
+        if (pluid < 0)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            _DBG_FILE("CNSmlInternetAdapter::AddNodeObjectL(): end");
+            return;
+            }
+        else if (pluid == 0)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            _DBG_FILE("CNSmlInternetAdapter::AddNodeObjectL(): EError");
+            return;
+            }
+        else
+            {
+            TUint32 apID = GetAPIdFromURIL(aURI);
+            CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                    TPtrC(IAP), TPtrC(COMMDB_ID), apID);
+            TInt errorCode = tableView->GotoFirstRecord();
+            CleanupStack::PopAndDestroy(tableView);
+            if (apID > 0 && errorCode == KErrNotFound) // Stale data, needs update
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter::AddNodeObjectL(): stale data for proxy this as new AP ");
+                AddNodeBufferL(aURI, parentLUID, aStatusRef, EFalse);
+                iStaleMapUpdate = ETrue;
+                return;
+                }
+            }
+        }
+
+    else if (aURI.Match(_L8("AP/*/Networks/*")) != KErrNotFound
+            && aURI.Match(_L8("AP/*/Networks/*/*")) == KErrNotFound)
+        {
+        iIAPId = IntLUID(parentLUID);
+        }
+
+    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+    _DBG_FILE("CNSmlInternetAdapter::AddNodeObjectL(): end");
+    return;
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::ExecuteCommandL
+// not supported
+//------------------------------------------------------------------------------
+
+
+void CNSmlInternetAdapter::ExecuteCommandL(const TDesC8&/* aURI*/,
+        const TDesC8& /*aLUID*/, const TDesC8& /*aArgument*/,
+        const TDesC8& /*aType*/, TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::ExecuteCommandL(): begin");
+    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlInternetAdapter::ExecuteCommandL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::ExecuteCommandL ( .. RWriteStream ..)
+// not supported
+//------------------------------------------------------------------------------
+
+
+void CNSmlInternetAdapter::ExecuteCommandL(const TDesC8& /*aURI*/,
+        const TDesC8& /*aLUID*/, RWriteStream*& /*aStream*/,
+        const TDesC8& /*aType*/, TInt aStatusref)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::ExecuteCommandL(): begin");
+    iCallBack->SetStatusL(aStatusref, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlInternetAdapter::ExecuteCommandL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::CopyCommandL
+// not supported
+//------------------------------------------------------------------------------
+
+
+void CNSmlInternetAdapter::CopyCommandL(const TDesC8& /*aTargetURI*/,
+        const TDesC8& /*aTargetLUID*/, const TDesC8& /*aSourceURI*/,
+        const TDesC8& /*aSourceLUID*/, const TDesC8& /*aType*/,
+        TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::CopyCommandL(): begin");
+    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlInternetAdapter::CopyCommandL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::StartAtomicL
+// not supported
+//------------------------------------------------------------------------------
+
+
+void CNSmlInternetAdapter::StartAtomicL()
+    {
+    _DBG_FILE("CNSmlInternetAdapter::StartAtomicL(): begin");
+    _DBG_FILE("CNSmlInternetAdapter::StartAtomicL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::CommitAtomicL
+// not supported
+//------------------------------------------------------------------------------
+
+
+void CNSmlInternetAdapter::CommitAtomicL()
+    {
+    _DBG_FILE("CNSmlInternetAdapter::CommitAtomicL(): begin");
+    _DBG_FILE("CNSmlInternetAdapter::CommitAtomicL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::RollbackAtomicL
+// not supported
+//------------------------------------------------------------------------------
+
+void CNSmlInternetAdapter::RollbackAtomicL()
+    {
+    _DBG_FILE("CNSmlInternetAdapter::RollbackAtomicL(): begin");
+    _DBG_FILE("CNSmlInternetAdapter::RollbackAtomicL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::StreamingSupport
+// returns EFalse
+//------------------------------------------------------------------------------
+
+TBool CNSmlInternetAdapter::StreamingSupport(TInt& /*aItemSize*/)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::StreamingSupport(): begin");
+    _DBG_FILE("CNSmlInternetAdapter::StreamingSupport(): end");
+    return EFalse;
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::StreamCommittedL
+// not used in this adapter
+//------------------------------------------------------------------------------
+
+void CNSmlInternetAdapter::StreamCommittedL()
+    {
+    _DBG_FILE("CNSmlInternetAdapter::StreamCommittedL(): begin");
+    _DBG_FILE("CNSmlInternetAdapter::StreamCommittedL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::CompleteOutstandingCmdsL
+// 
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::CompleteOutstandingCmdsL()
+    {
+
+    _DBG_FILE("CNSmlInternetAdapter::CompleteOutstandingCmdsL(): begin");
+    //
+    //  Handle possible unhandled buffered nodes
+    //
+    if (!iDatabase->InTransaction())
+        {
+        _DBG_FILE("CompleteOutstandingCmds: Try first begintransaction.");
+        TInt err = iDatabase->BeginTransaction();
+        if (err == KErrLocked)
+            {
+            _DBG_FILE("CompleteOutstandingCmds: CommsDat was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && err == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE(
+                        "CompleteOutstandingCmds: Slept 1 second. Try again");
+                err = iDatabase->BeginTransaction();
+                retry--;
+                }
+            if (err != KErrNone)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter: BeginTransaction failed completely.");
+                User::Leave(err);
+                }
+            }
+        }
+    _DBG_FILE("CompleteOutstandingCmds: BeginTransaction was successful");
+
+    iDnsIpv4Pri = 0;
+    iDnsIpv6Pri = 0;
+    _LIT8(KDummy, "/Dummy");
+    for (TInt h = iBuffer->Count() - 1; h >= 0; h--) // Through buffers
+        {
+        TBuf8<80> commandURI;
+        commandURI.Append(iBuffer->At(h).iMappingName->Des());
+        commandURI.Append(KDummy); // Removed on execution
+        ExecuteBufferL(commandURI, ETrue);
+        }
+    iDnsUpdate = EFalse;
+    iDnsIpv4Pri = 0;
+    iDnsIpv6Pri = 0;
+    iBuffer->Reset();
+
+    if (iWlanSupported)
+        {
+        iWlanAdapter->CompleteOutstandingCmdsL(); // Execute possible unhandled WLAN commands 
+        }
+
+    iNetworkId = KErrNotFound;
+
+    iDatabase->CommitTransaction();
+    iTransactionCommitted = ETrue;
+    _DBG_FILE("CNSmlInternetAdapter::CompleteOutstandingCmdsL(): end");
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::GetAPField()
+//      Match URI fieldname to 
+//      CommsDb table and column
+//      
+//=============================================
+TBool CNSmlInternetAdapter::GetAPField(TPtrC& aTableName, TPtrC& aColumn) const
+    {
+    _DBG_FILE("CNSmlInternetAdapter::GetAPField(): Start");
+
+    TBool fRet = EFalse;
+
+    aColumn.Set(TPtrC(KNullDesC));
+
+    if (iField->Compare(KNSmlDdfAuthName) == 0)
+        {
+        if (aTableName == TPtrC(OUTGOING_GPRS) || aTableName == TPtrC(
+                INCOMING_GPRS))
+            {
+            aColumn.Set(TPtrC(SERVICE_IF_AUTH_NAME));
+            }
+        else
+            {
+            return fRet;
+            }
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfNAPName) == 0)
+        {
+        aColumn.Set(TPtrC(COMMDB_NAME));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfToNAPIDL) == 0)
+        {
+        aColumn.Set(TPtrC(COMMDB_ID));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfNAPID) == 0)
+        {
+        aColumn.Set(TPtrC(COMMDB_ID));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfPxId) == 0)
+        {
+        aColumn.Set(TPtrC(COMMDB_ID));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfPxAddr) == 0)
+        {
+        aTableName.Set(TPtrC(PROXIES));
+        aColumn.Set(TPtrC(PROXY_SERVER_NAME));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfNAPAddrTy) == 0) // Is valid
+        {
+        return fRet;
+        }
+    else if (iField->Compare(KNSmlDdfDNSAddrL) == 0)
+        {
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfDNSPriority) == 0)
+        {
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfDNSAddrTy) == 0)
+        {
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfNAPAddr) == 0)
+        {
+        if (aTableName == TPtrC(OUTGOING_GPRS) || aTableName == TPtrC(
+                INCOMING_GPRS))
+            {
+            aColumn.Set(TPtrC(GPRS_APN)); // GPRS_PDP_ADDRESS
+            }
+        else if (aTableName == TPtrC(LAN_SERVICE)) // Wlan ADD
+            {
+            aColumn.Set(TPtrC(ISP_IP_ADDR));
+            // Leni: Should this be LAN_IP_ADDR  ??
+            }
+        else
+            {
+            return fRet;
+            }
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfBearerL) == 0)
+        {
+        aTableName.Set(TPtrC(IAP));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfDirection) == 0)
+        {
+        aTableName.Set(TPtrC(IAP));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfAuthSecr) == 0)
+        {
+        if (aTableName == TPtrC(OUTGOING_GPRS) || aTableName == TPtrC(
+                INCOMING_GPRS))
+            {
+            aColumn.Set(TPtrC(SERVICE_IF_AUTH_PASS));
+            }
+        else
+            {
+            return fRet; // NotValid
+            }
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfPortNbr) == 0)
+        {
+        if (iWapPort)
+            {
+            aTableName.Set(TPtrC(WAP_IP_BEARER));
+            aColumn.Set(TPtrC(WAP_PROXY_PORT));
+            }
+        else
+            {
+            aTableName.Set(TPtrC(PROXIES));
+            aColumn.Set(TPtrC(PROXY_PORT_NUMBER));
+            }
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfStartpg) == 0)
+        {
+        aTableName.Set(TPtrC(WAP_ACCESS_POINT));
+        aColumn.Set(TPtrC(WAP_START_PAGE));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfPxAuthId) == 0) // No KNSmlDdfBasAuthId
+        {
+        aTableName.Set(TPtrC(WAP_IP_BEARER));
+        aColumn.Set(TPtrC(WAP_PROXY_LOGIN_NAME));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfPxAuthPW) == 0) // No KNSmlDdfBasAuthPW
+        {
+        aTableName.Set(TPtrC(WAP_IP_BEARER));
+        aColumn.Set(TPtrC(WAP_PROXY_LOGIN_PASS));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfUsePTxtLog) == 0)
+        {
+        if (aTableName == TPtrC(OUTGOING_GPRS) || aTableName == TPtrC(
+                INCOMING_GPRS))
+            {
+            aColumn.Set(TPtrC(SERVICE_DISABLE_PLAIN_TEXT_AUTH));
+            fRet = ETrue;
+            }
+        else
+            {
+            return fRet; // NotValid
+            }
+        }
+    else if (iField->Compare(KNSmlDdfDefGW) == 0)
+        {
+        aColumn.Set(TPtrC(SERVICE_IP_GATEWAY));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfNetworkMask) == 0)
+        {
+        aColumn.Set(TPtrC(SERVICE_IP_NETMASK));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfNetworkID) == 0)
+        {
+        aColumn.Set(TPtrC(COMMDB_ID));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfPPPComp) == 0)
+        {
+        if (aTableName == TPtrC(OUTGOING_GPRS) || aTableName == TPtrC(
+                INCOMING_GPRS))
+            {
+            aColumn.Set(TPtrC(GPRS_DATA_COMPRESSION));
+            }
+        else
+            {
+            return fRet; // NotValid
+            }
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfGPRSPDP) == 0)
+        {
+        if (aTableName == TPtrC(OUTGOING_GPRS) || aTableName == TPtrC(
+                INCOMING_GPRS))
+            {
+            aColumn.Set(TPtrC(GPRS_PDP_TYPE));
+            }
+        else
+            {
+            return fRet; // NotValid
+            }
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfNoPxForL) == 0)
+        {
+        aColumn.Set(TPtrC(PROXY_EXCEPTIONS));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfDomainL) == 0)
+        {
+        aColumn.Set(TPtrC(PROXY_PROTOCOL_NAME));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfIPAddrFromServer) == 0)
+        {
+        aColumn.Set(TPtrC(SERVICE_IP_ADDR_FROM_SERVER));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfIPAddr) == 0)
+        {
+        aColumn.Set(TPtrC(SERVICE_IP_ADDR));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfDNSAddrFromServer) == 0)
+        {
+        aColumn.Set(TPtrC(SERVICE_IP_DNS_ADDR_FROM_SERVER));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfIPv6DNSAddrFromServer) == 0)
+        {
+        aColumn.Set(TPtrC(SERVICE_IP6_DNS_ADDR_FROM_SERVER));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfIfNetworks) == 0)
+        {
+        aColumn.Set(TPtrC(SERVICE_IF_NETWORKS));
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfIAPService) == 0)
+        {
+        aColumn.Set(TPtrC(IAP_SERVICE));
+        fRet = ETrue;
+        }
+
+    else if (iField->Compare(KNSmlDdfIAPSeamlessness) == 0)
+        {
+        fRet = ETrue;
+        }
+    else if (iField->Compare(KNSmlDdfIAPMetaData) == 0)
+        {
+        fRet = ETrue;
+        }
+
+    DBG_ARGS(_S16("GetAPField: aURI    - %S - %S - %S"), &aTableName,
+            &aColumn, &*iField);
+
+    _DBG_FILE("CNSmlInternetAdapter::GetAPField(): EOk");
+
+    return fRet;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::GetAPFieldType()
+//      Match fieldtype to Commsdb-database 
+//      
+//=============================================
+CNSmlInternetAdapter::TNSmlAPFieldType CNSmlInternetAdapter::GetAPFieldType(
+        const TDesC8& aURI) const
+    {
+    if (iField->Compare(KNSmlDdfBearerL) == 0)
+        {
+        return CNSmlInternetAdapter::ESpec;
+        }
+    else if (iField->Compare(KNSmlDdfDirection) == 0)
+        {
+        return CNSmlInternetAdapter::ESpec;
+        }
+    else if (iField->Compare(KNSmlDdfBearer) == 0)
+        {
+        return CNSmlInternetAdapter::EInt;
+        }
+    else if (iField->Compare(KNSmlDdfToNAPIDL) == 0)
+        {
+        return CNSmlInternetAdapter::EInt;
+        }
+    else if (iField->Compare(KNSmlDdfNAPID) == 0)
+        {
+        return CNSmlInternetAdapter::EInt;
+        }
+    else if (iField->Compare(KNSmlDdfPxId) == 0)
+        {
+        return CNSmlInternetAdapter::EInt;
+        }
+    else if (iField->Compare(KNSmlDdfAuthName) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfNAPName) == 0 || iField->Compare(
+            KNSmlDdfPxName) == 0 || iField->Compare(KNSmlDdfNetworkName) == 0)
+        {
+        if (aURI.Match(_L8("AP/*/Px/*/Name")) != KErrNotFound || aURI.Match(
+                _L8("AP/*/Networks/*/Name")) != KErrNotFound)
+            {
+            return CNSmlInternetAdapter::EStr;
+            }
+        else
+            {
+            return CNSmlInternetAdapter::ESpec; // For NAPName
+            }
+        }
+    else if (iField->Compare(KNSmlDdfNAPAddrTy) == 0)
+        {
+        return CNSmlInternetAdapter::EInt;
+        }
+    else if (iField->Compare(KNSmlDdfNAPAddr) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfStartpg) == 0)
+        {
+        return CNSmlInternetAdapter::EWap;
+        }
+    else if (iField->Compare(KNSmlDdfPxAuthId) == 0)
+        {
+        return CNSmlInternetAdapter::EWap;
+        }
+    else if (iField->Compare(KNSmlDdfPxAuthPW) == 0)
+        {
+        return CNSmlInternetAdapter::EWap;
+        }
+    else if (iField->Compare(KNSmlDdfPxAddr) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfDNSAddrFromServer) == 0)
+        {
+        return CNSmlInternetAdapter::EBool;
+        }
+    else if (iField->Compare(KNSmlDdfIPv6DNSAddrFromServer) == 0)
+        {
+        return CNSmlInternetAdapter::EBool;
+        }
+    else if (iField->Compare(KNSmlDdfDNSAddrL) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfDNSAddrTy) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfDNSPriority) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfPxName) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfAuthSecr) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfPxId) == 0)
+        {
+        return CNSmlInternetAdapter::EInt;
+        }
+    else if (iField->Compare(KNSmlDdfPxPW) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfPortNbr) == 0)
+        {
+        if (iWapPort) // Different handlig for WAP and Proxy PortNbr
+            {
+            return CNSmlInternetAdapter::EWap;
+            }
+        else
+            {
+            return CNSmlInternetAdapter::EInt;
+            }
+        }
+    else if (iField->Compare(KNSmlDdfUsePTxtLog) == 0)
+        {
+        return CNSmlInternetAdapter::EBool;
+        }
+    else if (iField->Compare(KNSmlDdfDefGW) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfNetworkMask) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfNetworkID) == 0)
+        {
+        return CNSmlInternetAdapter::EInt;
+        }
+    else if (iField->Compare(KNSmlDdfPPPComp) == 0)
+        {
+        return CNSmlInternetAdapter::EBool;
+        }
+    else if (iField->Compare(KNSmlDdfGPRSPDP) == 0)
+        {
+        return CNSmlInternetAdapter::EInt;
+        }
+    else if (iField->Compare(KNSmlDdfDomainL) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfNoPxForL) == 0)
+        {
+        return CNSmlInternetAdapter::ESpec;
+        }
+    else if (iField->Compare(KNSmlDdfIPAddrFromServer) == 0)
+        {
+        return CNSmlInternetAdapter::EBool;
+        }
+    else if (iField->Compare(KNSmlDdfIPAddr) == 0)
+        {
+        return EStr;
+        }
+    else if (iField->Compare(KNSmlDdfIfNetworks) == 0)
+        {
+        return CNSmlInternetAdapter::EStr;
+        }
+    else if (iField->Compare(KNSmlDdfIAPService) == 0)
+        {
+        return CNSmlInternetAdapter::ESpec;
+        }
+
+    else if (iField->Compare(KNSmlDdfIAPSeamlessness) == 0)
+        {
+        return CNSmlInternetAdapter::EInt;
+        }
+    else if (iField->Compare(KNSmlDdfIAPMetaData) == 0)
+        {
+        return CNSmlInternetAdapter::EInt;
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::GetAPFieldType(): Error");
+
+    return EWrong;
+    }
+
+//------------------------------------------------------------------------------
+//
+//------------------------------------------------------------------------------
+#ifndef IMPLEMENTATION_PROXY_ENTRY
+#define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr)  {{aUid},(aFuncPtr)}
+#endif
+
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY(0x101F6DE2, CNSmlInternetAdapter::NewL)
+    };
+
+//------------------------------------------------------------------------------
+// TImplementationProxy* ImplementationGroupProxy()
+//------------------------------------------------------------------------------
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
+        TInt& aTableCount)
+    {
+    _DBG_FILE("ImplementationGroupProxy() for CNSmlInternetAdapter: begin");
+
+    aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
+
+    _DBG_FILE("ImplementationGroupProxy() for CNSmlInternetAdapter: end");
+    return ImplementationTable;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::IntLUID()
+//      Returns IntValue for aLUID
+//=============================================
+TInt CNSmlInternetAdapter::IntLUID(const TDesC8& aLUID)
+    {
+    TLex8 lex(aLUID);
+
+    if (lex.Val(iLUID) == KErrNone)
+        {
+        if ((iLUID > KNSmlApProxyUpperBase) && (iLUID
+                < KNSmlApDnsLuidUpperBase))
+            {
+            iLUID = iLUID - KNSmlApProxyUpperBase;
+            }
+        else if ((iLUID > KNSmlApProxyLowerBase) && (iLUID
+                < KNSmlApProxyUpperBase))
+            {
+            iProxyId = iLUID - KNSmlApProxyLowerBase; // Proxy 
+            iLUID = iProxyId;
+            }
+        else if ((iLUID > KNSmlAp3gpppsLowerBase) && (iLUID
+                <= KNSmlApProxyLowerBase))
+            {
+            iLUID = iLUID - KNSmlAp3gpppsLowerBase;
+            i3GPPPS = ETrue;
+            }
+        else
+            {
+            iProxyId = 0;
+            }
+        return iLUID;
+        }
+    else
+        {
+        return 0;
+        }
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::GetIntObject8()
+//      Returns IntValue for aObject
+//=============================================
+TInt CNSmlInternetAdapter::GetIntObject8(const TDesC8& aObject)
+    {
+    TLex8 lex(aObject);
+
+    TInt lValue = 0;
+
+    if (lex.Val(lValue) == KErrNone)
+        {
+        return lValue;
+        }
+    else
+        {
+        return lValue;
+        }
+    }
+//=============================================
+//      CNSmlInternetAdapter::SetIntObjectLC()
+//      Returns IntValue for aObject
+//=============================================
+TDesC8& CNSmlInternetAdapter::SetIntObjectLC(const TInt& aObject)
+    {
+    HBufC8* buf = HBufC8::NewLC(8);
+    TPtr8 ptrBuf = buf->Des();
+
+    ptrBuf.Num(aObject);
+
+    return *buf;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::NotValidStrLenght()
+//      False if datalength is valid
+//=============================================
+TBool CNSmlInternetAdapter::NotValidStrLenght(const TDesC& aSource)
+    {
+    TInt len = aSource.Length();
+    TBool theBool = EFalse;
+
+    if (len > KCommsDbSvrMaxFieldLength)
+        {
+        theBool = ETrue;
+        }
+    return theBool;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::SetField()
+//      String after last '/' is returned
+//      
+//=============================================
+TInt CNSmlInternetAdapter::SetField(const TDesC8& aSource)
+    {
+    if (aSource.LocateReverse('/') == KErrNotFound)
+        {
+        iField->Des().Format(aSource);
+        }
+    else
+        {
+        iField->Des().Format(aSource.Mid(aSource.LocateReverse('/') + 1));
+        }
+
+    return KErrNone;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::ConvertTo8LC()
+//      Converts string value to 8-bit
+//      
+//=============================================
+TDesC8& CNSmlInternetAdapter::ConvertTo8LC(const TDesC& aSource)
+    {
+    HBufC8* buf = HBufC8::NewLC(aSource.Length() * 2);
+    TPtr8 bufPtr = buf->Des();
+    CnvUtfConverter::ConvertFromUnicodeToUtf8(bufPtr, aSource);
+
+    return *buf;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::ConvertTo16LC()
+//      Converts string value to 16-bit
+//      
+//=============================================
+TDesC16& CNSmlInternetAdapter::ConvertTo16LC(const TDesC8& aSource)
+    {
+    HBufC16* buf16 = HBufC16::NewLC(aSource.Length());
+    TPtr bufPtr16 = buf16->Des();
+
+    CnvUtfConverter::ConvertToUnicodeFromUtf8(bufPtr16, aSource);
+
+    return *buf16;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::InitializeGPRSL()
+//      Initialize GPRS-data before insert
+//      
+//=============================================
+TInt CNSmlInternetAdapter::InitializeGPRSL(CCommsDbTableView* aTable)
+    {
+    TBuf<KCommsDbSvrMaxFieldLength> user;
+    TBuf<KCommsDbSvrMaxFieldLength> pass;
+
+    _LIT(Kdns6Address, "0:0:0:0:0:0:0:0");
+    _LIT(KgifNetworks, "ip");
+
+    // COMMON DATA 
+    aTable->WriteBoolL(TPtrC(SERVICE_DISABLE_PLAIN_TEXT_AUTH), EFalse);
+
+    aTable->WriteTextL(TPtrC(GPRS_IF_NETWORKS), KgifNetworks);
+
+    aTable->WriteTextL(TPtrC(COMMDB_NAME), ConvertTo16LC(iIAPName)); // Same as IAP
+    CleanupStack::PopAndDestroy(); //ConvertTo16LC
+
+    aTable->WriteBoolL(TPtrC(GPRS_IF_PROMPT_FOR_AUTH), EFalse);
+    aTable->WriteTextL(TPtrC(GPRS_IF_AUTH_NAME), user);
+    aTable->WriteTextL(TPtrC(GPRS_IF_AUTH_PASS), pass);
+
+    aTable->WriteBoolL(TPtrC(GPRS_IP_ADDR_FROM_SERVER), ETrue);
+    aTable->WriteTextL(TPtrC(GPRS_IP_ADDR), KNSmlEmptyIpv4Address);
+
+    aTable->WriteBoolL(TPtrC(GPRS_IP_DNS_ADDR_FROM_SERVER), ETrue);
+    aTable->WriteTextL(TPtrC(GPRS_IP_NAME_SERVER1), KNSmlEmptyIpv4Address);
+    aTable->WriteTextL(TPtrC(GPRS_IP_NAME_SERVER2), KNSmlEmptyIpv4Address);
+
+    aTable->WriteBoolL(TPtrC(GPRS_IP6_DNS_ADDR_FROM_SERVER), ETrue);
+    aTable->WriteTextL(TPtrC(GPRS_IP6_NAME_SERVER1), Kdns6Address);
+    aTable->WriteTextL(TPtrC(GPRS_IP6_NAME_SERVER2), Kdns6Address);
+    // GPRS DATA
+
+    aTable->WriteTextL(TPtrC(GPRS_APN), ConvertTo16LC(iIAPName)); // Same as IAP
+    CleanupStack::PopAndDestroy(); //ConvertTo16LC
+
+    aTable->WriteUintL(TPtrC(GPRS_REQ_PRECEDENCE), 0);
+    aTable->WriteUintL(TPtrC(GPRS_REQ_DELAY), 0);
+    aTable->WriteUintL(TPtrC(GPRS_REQ_RELIABILITY), 0);
+    aTable->WriteUintL(TPtrC(GPRS_REQ_PEAK_THROUGHPUT), 0);
+    aTable->WriteUintL(TPtrC(GPRS_REQ_MEAN_THROUGHPUT), 0);
+    aTable->WriteUintL(TPtrC(GPRS_MIN_PRECEDENCE), 0);
+    aTable->WriteUintL(TPtrC(GPRS_MIN_DELAY), 0);
+    aTable->WriteUintL(TPtrC(GPRS_MIN_RELIABILITY), 0);
+    aTable->WriteUintL(TPtrC(GPRS_MIN_PEAK_THROUGHPUT), 0);
+    aTable->WriteUintL(TPtrC(GPRS_MIN_MEAN_THROUGHPUT), 0);
+
+    aTable->WriteUintL(TPtrC(GPRS_IF_AUTH_RETRIES), 0);
+
+    aTable->WriteBoolL(TPtrC(GPRS_DATA_COMPRESSION), EFalse);
+    aTable->WriteUintL(TPtrC(GPRS_PDP_TYPE), RPacketContext::EPdpTypeIPv4); // IPV4
+
+    aTable->WriteBoolL(TPtrC(GPRS_ENABLE_LCP_EXTENSIONS), EFalse);
+    aTable->WriteBoolL(TPtrC(GPRS_ANONYMOUS_ACCESS), EFalse);
+    aTable->WriteBoolL(TPtrC(GPRS_HEADER_COMPRESSION), EFalse);
+
+    aTable->WriteBoolL(TPtrC(GPRS_IP_ADDR_FROM_SERVER), ETrue);
+    aTable->WriteTextL(TPtrC(GPRS_IP_GATEWAY), KNSmlEmptyIpv4Address);
+
+    aTable->WriteTextL(TPtrC(GPRS_IP_ADDR), KNSmlEmptyIpv4Address);
+    aTable->WriteTextL(TPtrC(GPRS_IF_PARAMS), KNullDesC);
+    aTable->WriteTextL(TPtrC(GPRS_IP_NETMASK), KNullDesC);
+
+    aTable->WriteUintL(TPtrC(GPRS_QOS_WARNING_TIMEOUT), 0xffffffff);
+
+    aTable->WriteUintL(TPtrC(GPRS_AP_TYPE), (TUint32) EIspTypeInternetAndWAP);
+
+    return KErrNone;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::InitializeProxyL()
+//      Initialize Proxy-data before insert
+//      
+//=============================================
+TInt CNSmlInternetAdapter::InitializeProxyL(CCommsDbTableView* aTable)
+    {
+    _LIT(KprotocolName, "http"); // http, https, ftp, ftps
+    const TUint32 KPortNumber(80);
+
+    aTable->WriteUintL(TPtrC(PROXY_ISP), iProxyISP); // ISP with which these proxies are associated 
+
+    aTable->WriteTextL(TPtrC(PROXY_SERVICE_TYPE), iProxyServiceType); // Type ISP/GPRS
+    aTable->WriteBoolL(TPtrC(PROXY_USE_PROXY_SERVER), ETrue);
+
+    TPtr proxyName16 = HBufC::NewLC(iProxyServerName.Length())->Des();
+    CnvUtfConverter::ConvertToUnicodeFromUtf8(proxyName16, iProxyServerName);
+
+    aTable->WriteLongTextL(TPtrC(PROXY_SERVER_NAME), proxyName16); // Name of the proxy server
+    aTable->WriteTextL(TPtrC(PROXY_PROTOCOL_NAME), KprotocolName); // also https + ftps
+
+    aTable->WriteUintL(TPtrC(PROXY_PORT_NUMBER), KPortNumber);
+
+    aTable->WriteLongTextL(TPtrC(PROXY_EXCEPTIONS), KNullDesC);
+
+    CleanupStack::PopAndDestroy(); //proxyName16
+    return KErrNone;
+    }
+
+//      CNSmlInternetAdapter::IsInsertAllowedL
+//      Check if possible to Add new AP
+//
+//=============================================
+TBool CNSmlInternetAdapter::IsInsertAllowedL()
+    {
+    TBool theBool = EFalse;
+    //
+    //  Id + Name + Bearer needed for Insert
+    //
+    if (iIAPName.Length() > 0 && iBearer.Length() > 0 && iDirection
+            != ECommDbConnectionDirectionUnknown)
+        {
+        theBool = ETrue;
+        }
+    //
+    //  Should check also if Name or iISPId in USE !!!
+    //
+    if (theBool)
+        {
+        CCommsDbTableView* tableView = iDatabase->OpenViewMatchingTextLC(
+                iBearer, TPtrC(COMMDB_NAME), iIAPName);
+        TInt errorCode = tableView->GotoFirstRecord();
+
+        // Node allready exists => No adding possible
+        if (errorCode == KErrNone)
+            {
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlInternetAdapter::NODE NAME <%S> ALLREADY(): error"),
+                    &iIAPName);
+            theBool = EFalse;
+            }
+        CleanupStack::PopAndDestroy(tableView);
+        }
+    return theBool;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::SaveIAPDataL
+//      Saves data to IAP-table
+//      
+//=============================================
+void CNSmlInternetAdapter::SaveIAPDataL(const TDesC8& aURI)
+    {
+    TInt errorCode;
+    CCommsDbTableView* tableView;
+
+    TBool apEnforce = EFalse;
+    TBool iapReLock = EFalse;
+
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        TRAPD(eError,apEnforce=CheckEnforcementL())
+        DBG_ARGS8(_S8("CNSmlInternetAdapter::SaveIAPDataL(): EError %d , APEnforcement is %d"),eError,apEnforce);
+        if (eError == KErrNone && apEnforce)
+            {
+            DoLockIAPTablesL(EFalse);
+            iWAPRelock = ETrue;
+            }
+        }
+    if (iIAPExists)
+        {
+        tableView = iDatabase->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(
+                COMMDB_ID), iIAPId);
+        if (IsIAPRecordLockedL(iIAPId))
+            {
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is LOCKED");
+            TInt
+                    reclockerr =
+                            ((CCommsDbProtectTableView*) tableView)->UnprotectRecord();
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                    reclockerr);
+            if (reclockerr == KErrNone)
+                iapReLock = ETrue;
+            }
+        else
+            {
+            _DBG_FILE(
+                    "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is not write protected");
+            }
+
+        errorCode = tableView->GotoFirstRecord();
+
+        if (errorCode == KErrNone)
+            {
+            if (FeatureManager::FeatureSupported(
+                    KFeatureIdSapPolicyManagement))
+                {
+                // if enforcement is on and rec exists, it needs to be unprotected
+                if (apEnforce)
+                    {
+                    ((CCommsDbProtectTableView*) tableView)->UnprotectRecord();
+                    }
+                }
+            errorCode = tableView->UpdateRecord();
+            }
+        }
+    else
+        {
+        tableView = iDatabase->OpenTableLC(TPtrC(IAP));
+
+        errorCode = tableView->InsertRecord(iIAPId);
+        }
+
+    if (errorCode == KErrNone)
+        {
+        TUint32 modemISPId = 1; // Default
+        TBuf<KCommsDbSvrMaxFieldLength> modemBearer = TPtrC(MODEM_BEARER);
+        if (iBearer == TPtrC(LAN_SERVICE))
+            {
+            modemBearer = TPtrC(LAN_BEARER);
+            }
+        else if (iBearer == TPtrC(VPN_SERVICE))
+            {
+            modemBearer = TPtrC(VIRTUAL_BEARER);
+            }
+        else
+            {
+            modemBearer = TPtrC(MODEM_BEARER);
+            }
+
+        if (modemBearer == TPtrC(MODEM_BEARER))
+            {
+            GetModemBearerL(modemISPId);
+            }
+        else if (modemBearer == TPtrC(VIRTUAL_BEARER))
+            {
+            modemISPId = 1;
+            }
+        else if (iWlanSupported)
+            {
+            GetLanBearerL(modemISPId);
+            }
+        tableView->WriteTextL(TPtrC(COMMDB_NAME), ConvertTo16LC(iIAPName));
+        CleanupStack::PopAndDestroy(); //ConvertTo16LC
+
+        // ISP id must be written
+        tableView->WriteUintL(TPtrC(IAP_SERVICE), iISPId);
+        tableView->WriteTextL(TPtrC(IAP_SERVICE_TYPE), iBearer);
+
+        tableView->WriteUintL(TPtrC(IAP_BEARER), modemISPId);
+        tableView->WriteTextL(TPtrC(IAP_BEARER_TYPE), modemBearer);
+        if (iNetworkId != KErrNotFound)
+            {
+            tableView->WriteUintL(TPtrC(IAP_NETWORK), iNetworkId); // First name on network table    
+            }
+        tableView->WriteUintL(TPtrC(IAP_NETWORK_WEIGHTING), 0);
+        tableView->WriteUintL(TPtrC(IAP_LOCATION), 2); // Minimum=2
+
+
+        errorCode = tableView->PutRecordChanges();
+        }
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        if (iWAPRelock)
+            {
+            DoLockIAPTablesL(ETrue);
+            ((CCommsDbProtectTableView*) tableView)->ProtectRecord();
+            iWAPRelock = EFalse;
+            }
+        }
+    if (iapReLock)
+        {
+        TInt reclockerr = DoProtectIAPRecordL(iIAPId, ETrue);
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                reclockerr);
+        if (reclockerr == KErrNone)
+            iapReLock = EFalse;
+        }
+
+    if (errorCode == KErrNone)
+        {
+        if (!iIAPExists)
+            {
+            TUint32 lValue;
+            tableView->ReadUintL(TPtrC(COMMDB_ID), lValue);
+
+            // Add AP
+            TPtrC8 addURI = GetAddURISeg(aURI, KNSmlDdfAP);
+
+            TBuf8<16> addLUID;
+            _LIT8(KFormat, "%d");
+            addLUID.Format(KFormat, lValue);
+
+            // Also added to mapping
+            iCallBack->SetMappingL(addURI, addLUID);
+            DBG_ARGS8(_S8("AP:level1 URI - <%S> <%S> <%d>"), &addURI,
+                    &addLUID, lValue);
+            }
+
+        iIAPExists = ETrue;
+        }
+
+    if (apEnforce)
+        apEnforce = EFalse; // to rget rid of warnings
+
+    CleanupStack::PopAndDestroy(); // tableView
+    User::LeaveIfError(errorCode);
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::GetMaxIdL
+//      Get max id from given bearer
+//      
+//=============================================
+TUint32 CNSmlInternetAdapter::GetMaxIdL()
+    {
+    CCommsDbTableView* checkView;
+    TUint32 maxGPRS(0);
+    checkView = iDatabase->OpenTableLC(iBearer);
+    TInt errorCodem = checkView->GotoFirstRecord();
+    while (errorCodem == KErrNone)
+        {
+        TUint32 lValue;
+        checkView->ReadUintL(TPtrC(COMMDB_ID), lValue);
+        if (lValue > maxGPRS)
+            {
+            maxGPRS = lValue;
+            }
+        errorCodem = checkView->GotoNextRecord();
+        }
+
+    CleanupStack::PopAndDestroy(); // checkView
+
+    return (maxGPRS);
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::GetProxyIdL
+//      Get proxy id for given IAP
+//      
+//=============================================
+TBool CNSmlInternetAdapter::GetProxyIdL(const TDesC8& aURI)
+    {
+    TBool proxyFound = EFalse;
+
+    CCommsDbTableView* checkView;
+
+    // Get servicetype for IAP nbr  
+
+    TUint32 iapID = GetAPIdFromURIL(aURI);
+    if (iapID == 0)
+        {
+        if (IsAPUriFormatMatchPredefined(aURI))
+            {
+            iLUID = ConstructTreeL(aURI);
+            iapID = GetAPIdFromURIL(aURI);
+            }
+
+        }
+    //  IAP-table search serviceType + serviceId
+    CCommsDbTableView* iapView = iDatabase->OpenViewMatchingUintLC(
+            TPtrC(IAP), TPtrC(COMMDB_ID), iapID);
+
+    TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+    TUint32 serviceId;
+
+    TInt errorCode = iapView->GotoFirstRecord();
+
+    // Read serviceType from (IAP)
+    if (errorCode == KErrNone)
+        {
+        iapView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+        iapView->ReadUintL(TPtrC(IAP_SERVICE), serviceId);
+        CleanupStack::PopAndDestroy(); // iapView
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy(); // iapView
+        return proxyFound;
+        }
+
+    checkView = iDatabase->OpenViewMatchingTextLC(TPtrC(PROXIES), TPtrC(
+            PROXY_SERVICE_TYPE), serviceType);
+
+    TInt errorCodem = checkView->GotoFirstRecord();
+
+    while (errorCodem == KErrNone)
+        {
+        TUint32 lValue;
+        checkView->ReadUintL(TPtrC(PROXY_ISP), lValue);
+        if (lValue == serviceId)
+            {
+            checkView->ReadUintL(TPtrC(COMMDB_ID), iProxyId);
+            proxyFound = ETrue;
+            break;
+            }
+        errorCodem = checkView->GotoNextRecord();
+        }
+
+    CleanupStack::PopAndDestroy(); // checkView
+
+    return proxyFound;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::APExistsL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::APExistsL(TUint32 aId)
+    {
+    TBool ret = EFalse;
+    CCommsDbTableView* checkView;
+
+    checkView = iDatabase->OpenViewMatchingUintLC(TPtrC(IAP),
+            TPtrC(COMMDB_ID), aId);
+    TInt error = checkView->GotoFirstRecord();
+    if (error == KErrNone)
+        {
+        ret = ETrue;
+        }
+    CleanupStack::PopAndDestroy(); // checkView
+
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::NetworkExistsL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::NetworkExistsL(TUint32 aId)
+    {
+    TBool ret = EFalse;
+    CCommsDbTableView* checkView;
+
+    checkView = iDatabase->OpenViewMatchingUintLC(TPtrC(NETWORK), TPtrC(
+            COMMDB_ID), aId);
+    TInt error = checkView->GotoFirstRecord();
+    if (error == KErrNone)
+        {
+        ret = ETrue;
+        }
+    CleanupStack::PopAndDestroy(); // checkView
+
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::NetworkNameExistsL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::NetworkNameExistsL(TUint32& aId,
+        const TDesC8& aObject)
+    {
+    TBool ret = EFalse;
+    CCommsDbTableView* checkView;
+
+    checkView = iDatabase->OpenViewMatchingTextLC(TPtrC(NETWORK), TPtrC(
+            COMMDB_NAME), ConvertTo16LC(aObject));
+    TInt error = checkView->GotoFirstRecord();
+    if (error == KErrNone)
+        {
+        checkView->ReadUintL(TPtrC(COMMDB_ID), aId);
+        ret = ETrue;
+        }
+
+    CleanupStack::PopAndDestroy(2); // checkView ConvertTo16LC
+
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::AddNetworkL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::AddNetworkL(TUint32& aId, const TDesC8& aObject)
+    {
+    TBool ret = EFalse;
+    TUint32 newId;
+    CCommsDbTableView* networkView = iDatabase->OpenTableLC(TPtrC(NETWORK));
+
+    if (networkView->InsertRecord(newId) == KErrNone)
+        {
+        networkView->WriteTextL(TPtrC(COMMDB_NAME), ConvertTo16LC(aObject));
+        if (networkView->PutRecordChanges() == KErrNone)
+            {
+            networkView->ReadUintL(TPtrC(COMMDB_ID), aId); // New networks Id
+            ret = ETrue;
+            }
+        CleanupStack::PopAndDestroy(); //ConvertTo16LC
+        }
+    CleanupStack::PopAndDestroy(); // networkView
+    DBG_ARGS8(_S8("NsmlInternetAdapter: AddNetworkL:networkId %d"), aId);
+
+    return ret;
+    }
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::NAPDefExistsL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::NAPDefExistsL(TUint32 aId)
+    {
+    TBool ret = EFalse;
+    CCommsDbTableView* checkView;
+
+    checkView = iDatabase->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(
+            IAP_SERVICE), aId);
+    TInt error = checkView->GotoFirstRecord();
+    if (error == KErrNone)
+        {
+        TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+
+        checkView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+        CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                serviceType, TPtrC(COMMDB_ID), aId);
+        error = tableView->GotoFirstRecord();
+
+        if (error == KErrNone)
+            {
+            ret = ETrue;
+            }
+        CleanupStack::PopAndDestroy(); // tableView
+        }
+
+    CleanupStack::PopAndDestroy(); // checkView
+
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::PxExistsL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::PxExistsL(TUint32 aId)
+    {
+    TBool ret = EFalse;
+    CCommsDbTableView* pxView;
+
+    pxView = iDatabase->OpenViewMatchingUintLC(TPtrC(PROXIES), TPtrC(
+            COMMDB_ID), aId);
+
+    TInt errorCode = pxView->GotoFirstRecord();
+
+    if (errorCode == KErrNone)
+        {
+        ret = ETrue;
+        }
+    CleanupStack::PopAndDestroy(); // pxView
+
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::WapAPExistsL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::WapAPExistsL(TUint32 aId)
+    {
+    TBool ret = EFalse;
+    CCommsDbTableView* wapView;
+
+    wapView = iDatabase->OpenViewMatchingUintLC(TPtrC(WAP_IP_BEARER), TPtrC(
+            WAP_IAP), aId);
+
+    TInt errorCode = wapView->GotoFirstRecord();
+
+    if (errorCode == KErrNone)
+        {
+        wapView->ReadUintL(TPtrC(WAP_ACCESS_POINT_ID), iWapId);
+        ret = ETrue;
+        }
+    CleanupStack::PopAndDestroy(); // wapView
+
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TUint32 CNSmlInternetAdapter::GetAPIdFromURIL(const TDesC8& aURI)
+//         Get AP luid for given aURI
+//------------------------------------------------------------------------------
+TUint32 CNSmlInternetAdapter::GetAPIdFromURIL(const TDesC8& aURI)
+    {
+    HBufC8* apURI = HBufC8::NewLC(aURI.Length());
+
+    _DBG_FILE("CNSmlInternetAdapter::GetAPIdFromURIL(): begin");
+    DBG_ARGS8(_S8("AP:add aURI GetAPIdFromURIL   - %S "), &aURI);
+    //
+    //  Second slash after AP
+    //
+    TInt i = 0;
+    for (i = aURI.Find(KNSmlDdfAP) + 3; i < aURI.Length(); i++)
+        {
+        if (aURI[i] == '/')
+            {
+            break;
+            }
+        }
+    DBG_ARGS8(_S8("AP:add aURI GetAPIdFromURIL i is %d "), i);
+    if (i > 0)
+        {
+        apURI->Des().Format(aURI.Left(i));
+        }
+    //
+    //  Same profile as previous
+    //
+    if (iPrevURI->Match(*apURI) != KErrNotFound)
+        {
+        _DBG_FILE("CNSmlInternetAdapter::GetAPIdFromURIL(): previous uri");
+        CleanupStack::PopAndDestroy(); // apURI
+        return iPrevLUID;
+        }
+    //
+    //  Fetch AP-id for URI
+    //
+    HBufC8* apLUID = iCallBack->GetLuidAllocL(*apURI);
+    CleanupStack::PushL(apLUID);
+
+    TUint32 resLUID = IntLUID(*apLUID);
+    DBG_ARGS8(_S8("AP:add aURI GetAPIdFromURIL luidallocation is %d "),
+            resLUID);
+
+    if (resLUID > 0)
+        {
+        iPrevURI->Des().Format(*apURI);
+        iPrevLUID = resLUID;
+        }
+
+    CleanupStack::PopAndDestroy(2); // apURI, apLUID
+
+    return resLUID;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::DeleteProxyL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::DeleteProxyL(TUint32 aId)
+    {
+    TBool ret = EFalse;
+    CCommsDbTableView* pxView;
+
+    pxView = iDatabase->OpenViewMatchingUintLC(TPtrC(PROXIES), TPtrC(
+            COMMDB_ID), aId);
+
+    TInt errorCode = pxView->GotoFirstRecord();
+
+    if (errorCode == KErrNone)
+        {
+        errorCode = pxView->DeleteRecord();
+        if (errorCode == KErrNone)
+            {
+            ret = ETrue;
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); // pxView
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::DeleteWapAPL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::DeleteWapAPL(TUint32 aId)
+    {
+    TBool ret = EFalse;
+    CCommsDbTableView* wapView;
+
+    TUint32 wapId = 0;
+
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        TBool apEnforce = EFalse;
+        TRAPD(eError,apEnforce=CheckEnforcementL())
+        DBG_ARGS8(_S8("CNSmlInternetAdapter::DeleteWAPAPL(): EError %d , APEnforcement is %d"),eError,apEnforce);
+        if (eError == KErrNone && apEnforce)
+            {
+            DoLockIAPTablesL(EFalse);
+            iWAPRelock = ETrue;
+            }
+        }
+    wapView = iDatabase->OpenViewMatchingUintLC(TPtrC(WAP_IP_BEARER), TPtrC(
+            WAP_IAP), aId);
+
+    TInt errorCode = wapView->GotoFirstRecord();
+
+    if (errorCode == KErrNone)
+        {
+        wapView->ReadUintL(TPtrC(WAP_ACCESS_POINT_ID), wapId); // WapIAP id
+        errorCode = wapView->DeleteRecord();
+        if (errorCode == KErrNone)
+            {
+            ret = ETrue;
+            }
+        }
+
+    if (ret)
+        {
+        CCommsDbTableView* wapApView = iDatabase->OpenViewMatchingUintLC(
+                TPtrC(WAP_ACCESS_POINT), TPtrC(COMMDB_ID), wapId);
+
+        errorCode = wapApView->GotoFirstRecord();
+
+        if (errorCode == KErrNone)
+            {
+            errorCode = wapApView->DeleteRecord();
+            if (errorCode == KErrNone)
+                {
+                ret = ETrue;
+                }
+            }
+        CleanupStack::PopAndDestroy(); // wapApView
+        }
+
+    CleanupStack::PopAndDestroy(); // wapView
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        if (iWAPRelock)
+            {
+            DoLockIAPTablesL(ETrue);
+            iWAPRelock = EFalse;
+            }
+        }
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::DeleteNAPDefL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::DeleteNAPDefL(TUint32 aId)
+    {
+    TBool ret = EFalse;
+    CCommsDbTableView* checkView;
+    TBool apEnforce = EFalse;
+    TBool iapReLock = EFalse;
+
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        TRAPD( eError,apEnforce=CheckEnforcementL() )
+        DBG_ARGS8(_S8("CNSmlInternetAdapter::DeleteNAPDefL(): EError %d , APEnforcement is %d"),eError,apEnforce);
+        if (eError == KErrNone && apEnforce)
+            {
+            DoLockIAPTablesL(EFalse);
+            iWAPRelock = ETrue;
+            }
+        }
+
+    checkView = iDatabase->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(
+            IAP_SERVICE), aId);
+    if (IsIAPRecordLockedL(aId))
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is LOCKED");
+        TInt reclockerr =
+                ((CCommsDbProtectTableView*) checkView)->UnprotectRecord();
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                reclockerr);
+        if (reclockerr == KErrNone)
+            iapReLock = ETrue;
+        }
+    else
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is not write protected");
+        }
+    TInt error = checkView->GotoFirstRecord();
+    if (error == KErrNone)
+        {
+        TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+
+        checkView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+
+        CCommsDbTableView* tableView = iDatabase->OpenViewMatchingUintLC(
+                serviceType, TPtrC(COMMDB_ID), aId);
+        error = tableView->GotoFirstRecord();
+
+        if (error == KErrNone)
+            {
+            if (FeatureManager::FeatureSupported(
+                    KFeatureIdSapPolicyManagement))
+                {
+                if (apEnforce)
+                    {
+                    ((CCommsDbProtectTableView*) tableView)->UnprotectRecord();
+                    }
+                }
+
+            error = tableView->DeleteRecord();
+            if (error == KErrNone)
+                {
+                ret = ETrue;
+                }
+            }
+        CleanupStack::PopAndDestroy(); // tableView
+        }
+
+    CleanupStack::PopAndDestroy(); // checkView
+
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        if (iWAPRelock)
+            {
+            DoLockIAPTablesL(ETrue);
+            iWAPRelock = EFalse;
+            }
+        }
+
+    if (iapReLock)
+        {
+        TInt reclockerr = DoProtectIAPRecordL(aId, ETrue);
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting WAPAccessRecord returned code = %d"),
+                reclockerr);
+        if (reclockerr == KErrNone)
+            iapReLock = EFalse;
+        }
+    if (apEnforce)
+        apEnforce = EFalse; // to get rid of warnings
+
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// Removes iapID and linger interval from CentralRepository
+// ---------------------------------------------------------------------------
+//
+void CNSmlInternetAdapter::DeleteLingerL(const TInt aIapId)
+    {
+    TInt err(KErrNone);
+
+    // Open repository
+    CRepository* repository = CRepository::NewLC(KCRUidPDPContextManager);
+
+    // Find if an entry for "iapId" already exists in CentRep 
+    RArray<TUint32> foundKeys;
+    foundKeys.Reset();
+
+    err = repository->FindEqL(KIapColumn, // partial key
+            KColumnMask, // key mask
+            aIapId, // value
+            foundKeys); // found keys
+
+    if (err == KErrNone)
+        {
+        if (foundKeys.Count() > 0)
+            {
+            TInt arrayCount(0);
+
+            // Get number of iapId&linger entries in Centrep
+            err = repository->Get(KPdpContextManagerLingerArrayCount,
+                    arrayCount);
+
+            if (err == KErrNone)
+                {
+                TInt32 row = foundKeys[0] & KRowMask;
+
+                // Shift existing entries one position left
+                for (TInt i = row + 1; i <= arrayCount; i++)
+                    {
+                    TInt iapId(0);
+                    TInt linger(0);
+
+                    err = repository->Get((KIapColumn | i), iapId);
+
+                    if (err == KErrNone)
+                        {
+                        err = repository->Get((KLingerColumn | i), linger);
+                        }
+
+                    if (err == KErrNone)
+                        {
+                        err = repository->Set((KIapColumn | (i - 1)), iapId);
+                        }
+
+                    if (err == KErrNone)
+                        {
+                        err = repository->Set((KLingerColumn | (i - 1)),
+                                linger);
+                        }
+                    }
+
+                // Remove the last entry on row arrayCount
+                if (err == KErrNone)
+                    {
+                    TUint32 errorKey(0);
+
+                    err = repository->Delete((KIapColumn | arrayCount),
+                            0xFFFFFFFF, errorKey);
+
+                    if (err == KErrNone)
+                        {
+                        err = repository->Delete(
+                                (KLingerColumn | arrayCount), 0xFFFFFFFF,
+                                errorKey);
+                        arrayCount--;
+                        }
+                    }
+
+                // Update number of iapId&linger entries in Centrep
+                err = repository->Set(KPdpContextManagerLingerArrayCount,
+                        arrayCount);
+                }
+            }
+        }
+
+    foundKeys.Close();
+    CleanupStack::PopAndDestroy(repository);
+
+    }
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::DeleteAPL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::DeleteAPL(TUint32 aId)
+    {
+    TBool ret = EFalse;
+
+    //Check MIP IAP first then go forward
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        TBool apEnforce = EFalse;
+        TBool wlanEnforce = EFalse;
+        TInt wError = KErrNone;
+        TRAP(wError, wlanEnforce = CheckWLANEnforcementL());TRAPD( eError,apEnforce=CheckEnforcementL() )
+        if( wlanEnforce)
+            {
+            UnprotectWLANAPItemL(aId);
+            }
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::DeleteAPL(): EError %d , APEnforcement is %d"),
+                eError, apEnforce);
+        if (eError == KErrNone && apEnforce)
+            {
+            DoLockIAPTablesL(EFalse);
+            iWAPRelock = ETrue;
+            }
+        }
+
+    if (iDatabase->InTransaction())
+        iDatabase->CommitTransaction();
+    RCmManagerExt cmManagerExt;
+    cmManagerExt.OpenL();
+    RCmConnectionMethodExt cmConMethodExt;
+    TRAPD(err, cmConMethodExt = cmManagerExt.ConnectionMethodL(aId));
+    CleanupClosePushL(cmConMethodExt);
+    if (err == KErrNone)
+        {
+        TRAPD(dError, cmConMethodExt.DeleteL());
+        if (dError == KErrNone)
+            {
+            DeleteLingerL(aId);
+            ret = ETrue;
+            }
+        }
+
+    CleanupStack::PopAndDestroy();
+    cmManagerExt.Close();
+    if (!iDatabase->InTransaction())
+        {
+        TInt dberr = iDatabase->BeginTransaction();
+        if (dberr == KErrLocked)
+            {
+            _DBG_FILE("DeleteAPL: CommsDat was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && dberr == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("DeleteAPL: Slept 1 second. Try again");
+                dberr = iDatabase->BeginTransaction();
+                retry--;
+                }
+            if (dberr != KErrNone)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter: BeginTransaction failed completely.");
+                User::Leave(dberr);
+                }
+            }
+        }
+
+    //The following code is kept under #ifndef , so that it can be removed
+    //after RD_DM_APPLICATION_LEVEL_ROAMING_SUPPORT becomes stable.
+
+    /* #ifndef RD_DM_APPLICATION_LEVEL_ROAMING_SUPPORT
+     CCommsDbTableView*  checkView;
+     CCommsDbTableView*  proxyView;
+     
+     checkView = iDatabase->OpenViewMatchingUintLC(TPtrC(IAP),TPtrC(COMMDB_ID),  aId);
+     TInt error = checkView->GotoFirstRecord();
+     if (error == KErrNone)
+     {
+     //
+     // Remove possible NAPDef-data first if ONLY IAP
+     //
+     TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+     TUint32                         serviceId;
+
+     checkView->ReadTextL(TPtrC(IAP_SERVICE_TYPE),   serviceType);
+     checkView->ReadUintL(TPtrC(IAP_SERVICE),        serviceId);  
+
+
+     CCommsDbTableView* tableView;
+     tableView= iDatabase->OpenViewMatchingUintLC(serviceType, TPtrC(COMMDB_ID), serviceId);
+     error = tableView->GotoFirstRecord();
+     if (error == KErrNone )
+     {
+     error = tableView->DeleteRecord();
+     }
+     CleanupStack::PopAndDestroy();  // tableView
+     
+     //
+     // Delete Proxies for AP also
+     //
+     proxyView = iDatabase->OpenViewMatchingTextLC(TPtrC(PROXIES),
+     TPtrC(PROXY_SERVICE_TYPE),
+     serviceType);
+
+     TInt errorProxy = proxyView->GotoFirstRecord();
+
+     while (errorProxy == KErrNone)
+     {
+     TUint32 lValue;
+     proxyView->ReadUintL(TPtrC(PROXY_ISP),lValue);
+     if(lValue ==  serviceId)
+     {
+     proxyView->ReadUintL(TPtrC(COMMDB_ID),iProxyId);
+     DBG_ARGS8(_S8("DeleteAPL:Delete ServiceId=%d ProxyId=%d"),lValue, iProxyId);
+     error = proxyView->DeleteRecord();
+     }
+     errorProxy = proxyView->GotoNextRecord();
+     }
+     
+     CleanupStack::PopAndDestroy();  // proxyView
+
+     error = checkView->DeleteRecord();
+     if( error == KErrNone )
+     {
+     ret = ETrue;
+     }
+
+     // Delete WAP also
+     if(WapAPExistsL(aId))
+     {
+     DeleteWapAPL(aId);
+     }
+     }
+
+     CleanupStack::PopAndDestroy();      // checkView
+     #endif
+     */
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        if (iWAPRelock)
+            {
+            DoLockIAPTablesL(ETrue);
+            iWAPRelock = EFalse;
+            }
+        }
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TPtrC8 CNSmlInternetAdapter::LastURISeg(const TDesC8& aURI)
+// Returns only the last uri segment
+//------------------------------------------------------------------------------
+TPtrC8 CNSmlInternetAdapter::LastURISeg(const TDesC8& aURI)
+    {
+    TInt i;
+    for (i = aURI.Length() - 1; i >= 0; i--)
+        {
+        if (aURI[i] == '/')
+            {
+            break;
+            }
+        }
+    if (i == 0)
+        {
+        return aURI;
+        }
+    else
+        {
+        return aURI.Mid(i + 1);
+        }
+    }
+
+//------------------------------------------------------------------------------
+// TPtrC8 CNSmlInternetAdapter::FirstURISeg(const TDesC8& aURI)
+// returns parent uri, i.e. removes last uri segment
+//------------------------------------------------------------------------------
+TPtrC8 CNSmlInternetAdapter::FirstURISeg(const TDesC8& aURI)
+    {
+    TInt j = 0;
+    for (TInt i = 0; i <= aURI.Length() - 1; i++)
+        {
+        if (aURI[i] == '/')
+            {
+            for (j = i + 1; j <= aURI.Length() - 1; j++)
+                {
+                if (aURI[j] == '/') // Second slash => AP/xxxx
+                    break;
+                }
+            break;
+            }
+        }
+    return aURI.Left(j);
+    }
+
+//------------------------------------------------------------------------------
+// TPtrC8 CNSmlInternetAdapter::GetDynamicAPNodeUri( const TDesC8& aURI )
+// returns AP/xxx URI
+//------------------------------------------------------------------------------
+TPtrC8 CNSmlInternetAdapter::GetDynamicAPNodeUri(const TDesC8& aURI)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::GetDynamicAPNodeUri(): begin");
+    DBG_ARGS8(_S8("CNSmlInternetAdapter::GetDynamicAPNodeUri() - <%S> "),
+            &aURI);
+
+    TInt i = 0;
+    for (i = aURI.Find(KNSmlDdfAP) + 3; i < aURI.Length(); i++)
+        {
+        if (aURI[i] == '/')
+            {
+            break;
+            }
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::GetDynamicAPNodeUri(): end");
+
+    return aURI.Left(i);
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlInternetAdapter::ExecuteBufferL(const TDesC8& aURI)
+// Executes commands for AP after Bearer-data is set
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::ExecuteBufferL(const TDesC8& aURI,
+        const TBool aCompleting)
+    {
+    //
+    // Choose AP according to aURI
+    //
+    iExecutingBuffer = ETrue;
+    for (TInt i = 0; i < iBuffer->Count(); i++)
+        {
+        TPtrC8 parentUri = FirstURISeg(aURI);
+        if (iBuffer->At(i).iMappingName->Compare(parentUri) == 0)
+            {
+            iExecutionIndex = i;
+            break;
+            }
+        }
+
+    if ((iExecutionIndex < 0) || (iExecutionIndex >= iBuffer->Count()))
+        {
+        return;
+        }
+
+    iISPId = 0;
+    //
+    // Execute all commands for One AP NAPDef
+    //
+    if (iBuffer->At(iExecutionIndex).iDnsUpdateBuf)
+        {
+        iDnsUpdate = ETrue;
+        }
+
+    for (TInt cmd = iBuffer->At(iExecutionIndex).iNodeBuf->Count() - 1; cmd
+            >= 0; cmd--)
+        {
+        TBuf8<16> addLUID;
+        _LIT8(KFormat, "%d");
+
+        if (iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd).iUri->Match(_L8(
+                "AP/*/Px*")) != 0)
+            {
+
+            if (!iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd).iLeaf)
+                {
+                addLUID.Format(KFormat, 0);
+                if (iBuffer->At(iExecutionIndex).iLuid > 0)
+                    {
+                    addLUID.Format(KFormat, -1); // Used for Status return
+                    }
+                AddNodeObjectL(
+                        iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd).iUri->Des(),
+                        addLUID, iBuffer->At(iExecutionIndex).iNodeBuf->At(
+                                cmd).iStatusRef);
+
+                iBuffer->At(iExecutionIndex).iExecuted = ETrue;
+                }
+            else
+                {
+                if (iBuffer->At(iExecutionIndex).iDnsUpdateBuf)
+                    {
+                    addLUID.Zero();
+                    addLUID.Append(iBuffer->At(iExecutionIndex).iNodeBuf->At(
+                            cmd).iLuid->Des());
+                    }
+                else
+                    {
+                    addLUID.Format(KFormat,
+                            iBuffer->At(iExecutionIndex).iLuid);
+                    if (!iBuffer->At(iExecutionIndex).iDirection || // The three values has to be set
+                            !iBuffer->At(iExecutionIndex).iBearer
+                            || !iBuffer->At(iExecutionIndex).iNameReceived) // before new AP set
+                        {
+                        addLUID.Format(KFormat, KNSmlIncompleteAP); // (-1) Used for error 
+                        } // Status return
+                    }
+                //iIAPName = iBuffer->At(iExecutionIndex).iName->Des();
+
+                AddLeafObjectL(
+                        iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd).iUri->Des(),
+                        addLUID,
+                        iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd).iData->Des(),
+                        KNSmlMimeTypeTextPlain,
+                        iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd).iStatusRef);
+
+                if (iBuffer->At(iExecutionIndex).iLuid == 0) // After BearerL
+                    iBuffer->At(iExecutionIndex).iLuid = iISPId;
+                }
+
+            TInt uidValue = IntLUID(addLUID);
+            if ((iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd).iUri->Des().Match(
+                    _L8("AP/*/NAPDef/*/NAPAddr")) != KErrNotFound)
+                    && (uidValue == KErrNone))
+                {
+                iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd).iDone = EFalse;
+                }
+            else
+                {
+                iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd).iDone = ETrue;
+                }
+
+            }
+
+        }
+    //
+    // Execute all commands for One AP Px
+    //
+    for (TInt cmd2 = 0; cmd2 < iBuffer->At(iExecutionIndex).iNodeBuf->Count(); cmd2++)
+        {
+        TBuf8<16> addLUID2;
+        _LIT8(KFormat, "%d");
+        if (!iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iDone)
+            {
+            if (!iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iLeaf)
+                {
+                addLUID2.Format(KFormat, 0);
+                if (iBuffer->At(iExecutionIndex).iLuid > 0)
+                    {
+                    addLUID2.Format(KFormat, -1); // Used for Status return
+                    }
+                AddNodeObjectL(
+                        iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iUri->Des(),
+                        addLUID2, iBuffer->At(iExecutionIndex).iNodeBuf->At(
+                                cmd2).iStatusRef);
+
+                iBuffer->At(iExecutionIndex).iExecuted = ETrue;
+                }
+            else
+                {
+                addLUID2.Format(KFormat, iBuffer->At(iExecutionIndex).iLuid);
+                iIAPName = iBuffer->At(iExecutionIndex).iName->Des();
+                if (!iBuffer->At(iExecutionIndex).iDirection || // Allvalues has to be set
+                        !iBuffer->At(iExecutionIndex).iBearer
+                        || !iBuffer->At(iExecutionIndex).iName) // before new AP set
+                    {
+                    addLUID2.Format(KFormat, KNSmlIncompleteAP); // (-1) Used for error 
+                    } // Status return
+
+                AddLeafObjectL(
+                        iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iUri->Des(),
+                        addLUID2,
+                        iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iData->Des(),
+                        KNSmlMimeTypeTextPlain,
+                        iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iStatusRef);
+
+                if (iBuffer->At(iExecutionIndex).iLuid == 0) // After BearerL
+                    iBuffer->At(iExecutionIndex).iLuid = iISPId;
+                }
+            } //++
+
+        iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iDone = ETrue;
+
+        delete iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iUri;
+        iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iUri = NULL;
+
+        if (iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iData)
+            {
+            delete iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iData;
+            iBuffer->At(iExecutionIndex).iNodeBuf->At(cmd2).iData = NULL;
+            }
+        }
+
+    // Wlan buffer execution only when called from CompleteOutstandingCmdsL (= aCompleting)
+    for (TInt i = 0; aCompleting && i
+            < iBuffer->At(iExecutionIndex).iWlanNodeBuf->Count(); ++i)
+        {
+        TBuf8<16> addLUID;
+        _LIT8(KFormat, "%d");
+
+        if (!iBuffer->At(iExecutionIndex).iWlanNodeBuf->At(i).iLeaf)
+            {
+            addLUID.Format(KFormat, 0);
+
+            if (iBuffer->At(iExecutionIndex).iLuid > 0)
+                {
+                addLUID.Format(KFormat, iBuffer->At(iExecutionIndex).iLuid);
+                }
+
+            AddNodeObjectL(
+                    iBuffer->At(iExecutionIndex).iWlanNodeBuf->At(i).iUri->Des(),
+                    addLUID,
+                    iBuffer->At(iExecutionIndex).iWlanNodeBuf->At(i).iStatusRef);
+
+            iBuffer->At(iExecutionIndex).iExecuted = ETrue;
+            }
+        else
+            {
+            addLUID.Zero();
+            addLUID.Append(
+                    iBuffer->At(iExecutionIndex).iWlanNodeBuf->At(i).iLuid->Des());
+
+            iIAPName = iBuffer->At(iExecutionIndex).iName->Des();
+
+            AddLeafObjectL(
+                    iBuffer->At(iExecutionIndex).iWlanNodeBuf->At(i).iUri->Des(),
+                    addLUID,
+                    iBuffer->At(iExecutionIndex).iWlanNodeBuf->At(i).iData->Des(),
+                    KNSmlMimeTypeTextPlain,
+                    iBuffer->At(iExecutionIndex).iWlanNodeBuf->At(i).iStatusRef);
+
+            if (iBuffer->At(iExecutionIndex).iLuid == 0) // After BearerL            
+                {
+                iBuffer->At(iExecutionIndex).iLuid = iISPId;
+                }
+
+            }
+
+        iBuffer->At(iExecutionIndex).iWlanNodeBuf->At(i).iDone = ETrue;
+        }
+
+    //
+    //  Remove data from handled AP-commands
+    //
+
+    ClearBuffer(iBuffer->At(iExecutionIndex).iNodeBuf);
+
+    if (aCompleting)
+        {
+        delete iBuffer->At(iExecutionIndex).iNodeBuf;
+
+        ClearBuffer(iBuffer->At(iExecutionIndex).iWlanNodeBuf);
+        delete iBuffer->At(iExecutionIndex).iWlanNodeBuf;
+
+        if (iBuffer->At(iExecutionIndex).iMappingName)
+            {
+            delete iBuffer->At(iExecutionIndex).iMappingName;
+            iBuffer->At(iExecutionIndex).iMappingName = NULL;
+            }
+
+        if (iBuffer->At(iExecutionIndex).iName)
+            {
+            delete iBuffer->At(iExecutionIndex).iName;
+            iBuffer->At(iExecutionIndex).iName = NULL;
+            }
+
+        iBuffer->Delete(iExecutionIndex);
+        iBuffer->Compress();
+        }
+
+    iExecutingBuffer = EFalse;
+    iStaleMapUpdate = EFalse;
+    }
+
+//------------------------------------------------------------------------------
+// TPtrC16 CNSmlInternetAdapter::GetAddURISeg(const TDesC8& aURI,const TDesC8 aName)
+// Returns uri segment until the next segment after given aName
+//------------------------------------------------------------------------------
+TPtrC8 CNSmlInternetAdapter::GetAddURISeg(const TDesC8& aURI,
+        const TDesC8& aName)
+    {
+    TInt lStrt = aURI.Find(aName);
+    if (lStrt == KErrNotFound)
+        {
+        return aURI;
+        }
+
+    lStrt += 1;
+    TInt i = 0;
+    for (i = lStrt + aName.Length(); i <= aURI.Length() - 1; i++)
+        {
+        if (aURI[i] == '/')
+            {
+            break;
+            }
+        }
+    if (i == 0)
+        {
+        return aURI;
+        }
+    else
+        {
+        return aURI.Left(i);
+        }
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::InitializeWAPAIPL()
+//      Initialize WAP IAP-data before insert
+//      
+//=============================================
+TInt CNSmlInternetAdapter::InitializeWAPIAPL(CCommsDbTableView* aTable,
+        const TDesC8& aName)
+    {
+    aTable->WriteTextL(TPtrC(COMMDB_NAME), ConvertTo16LC(aName)); // Same as IAP
+
+
+    aTable->WriteTextL(TPtrC(WAP_CURRENT_BEARER), iWapBearer);
+    aTable->WriteLongTextL(TPtrC(WAP_START_PAGE), ConvertTo16LC(
+            iWAPAccessPoint));
+    CleanupStack::PopAndDestroy(2); //ConvertTo16LC
+    return KErrNone;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::InitializeWAPL()
+//      Initialize WAP IP Bearer-data  before insert
+//      
+//=============================================
+TInt CNSmlInternetAdapter::InitializeWAPL(CCommsDbTableView* aTable)
+    {
+    TUint32 wapPortNumber = 0;
+
+    aTable->WriteUintL(TPtrC(WAP_ACCESS_POINT_ID), iWapId);
+    aTable->WriteTextL(TPtrC(WAP_GATEWAY_ADDRESS), KNSmlEmptyIpv4Address);
+
+    aTable->WriteUintL(TPtrC(WAP_WSP_OPTION), EWapWspOptionConnectionOriented); // EWapWspOptionConnectionless
+    aTable->WriteBoolL(TPtrC(WAP_SECURITY), EFalse); // if 9200 => false
+
+    aTable->WriteUintL(TPtrC(WAP_IAP), iISPId);
+    aTable->WriteUintL(TPtrC(WAP_PROXY_PORT), wapPortNumber);
+
+    aTable->WriteTextL(TPtrC(WAP_PROXY_LOGIN_NAME), ConvertTo16LC(
+            iWapUserName));
+    aTable->WriteTextL(TPtrC(WAP_PROXY_LOGIN_PASS), ConvertTo16LC(
+            iWapPassword));
+
+    CleanupStack::PopAndDestroy(2); //ConvertTo16LC
+    return KErrNone;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::IsWapPort()
+//      Check if portnbr for proxy or wap
+//      
+//=============================================
+void CNSmlInternetAdapter::IsWapPort(const TDesC8& aObject)
+    {
+    iWapPort = EFalse;
+    TInt portNbr = GetIntObject8(aObject);
+    if (portNbr >= KNSmlApWapLowerBase && portNbr <= KNSmlApWapUpperBase)
+        {
+        iWapPort = ETrue;
+        }
+    }
+
+// -------------------------------------------------------------------------------------
+// CNSmlInternetAdapter::FillNodeInfoL()
+// Fills the node info in ddf structure
+// -------------------------------------------------------------------------------------
+void CNSmlInternetAdapter::FillNodeInfoL(MSmlDmDDFObject& aNode,
+        TSmlDmAccessTypes aAccTypes, MSmlDmDDFObject::TOccurence aOccurrence,
+        MSmlDmDDFObject::TScope aScope, MSmlDmDDFObject::TDFFormat aFormat,
+        const TDesC8& aDescription)
+
+    {
+    aNode.SetAccessTypesL(aAccTypes);
+    aNode.SetOccurenceL(aOccurrence);
+    aNode.SetScopeL(aScope);
+    aNode.SetDFFormatL(aFormat);
+    if (aFormat != MSmlDmDDFObject::ENode)
+        {
+        aNode.AddDFTypeMimeTypeL(KNSmlMimeType);
+        }
+    aNode.SetDescriptionL(aDescription);
+    }
+
+//=======================================================
+//      CNSmlInternetAdapter::UpdateIAPnameL()
+//      Update IAP-table name add Network-table if needed
+//      Add/update WAP-table name also
+//      
+//=======================================================
+TInt CNSmlInternetAdapter::UpdateIAPnameL(TUint32 aId, const TDesC8& aObject)
+    {
+
+    TUint32 nwId = 0;
+    TInt ret = KErrNone;
+    TBool iapReLock = EFalse;
+
+    TBool apEnforce = EFalse;
+    TRAPD( eError,apEnforce=CheckEnforcementL() )
+    DBG_ARGS8(_S8("CNSmlInternetAdapter::UpdateIAPNAme(): EError %d , APEnforcement is %d"),eError,apEnforce);
+    if (eError == KErrNone && apEnforce)
+        {
+        DoLockIAPTablesL(EFalse);
+        iWAPRelock = ETrue;
+        }
+
+    CCommsDbTableView* iapUpdate = iDatabase->OpenViewMatchingUintLC(TPtrC(
+            IAP), TPtrC(COMMDB_ID), aId);
+    if (IsIAPRecordLockedL(aId))
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is LOCKED");
+        TInt reclockerr =
+                ((CCommsDbProtectTableView*) iapUpdate)->UnprotectRecord();
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                reclockerr);
+        if (reclockerr == KErrNone)
+            iapReLock = ETrue;
+        }
+    else
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::AddLeafObjectL(): apaccesspoint record is not write protected");
+        }
+    TInt error = iapUpdate->GotoFirstRecord();
+    if (error == KErrNone)
+        {
+        _DBG_FILE("CNSmlInternetAdapter::UpdateIAPName, IAP_NETWORK set");
+        TRAPD(err, iapUpdate->ReadUintL(TPtrC(IAP_NETWORK), nwId));
+
+        if (iapUpdate->UpdateRecord() == KErrNone)
+            {
+            iapUpdate->WriteTextL(TPtrC(COMMDB_NAME), ConvertTo16LC(aObject));
+
+            if (err != KErrNone) // Network entry not yet created
+                {
+                AddNetworkL(nwId, aObject);
+                if (nwId > 0)
+                    {
+                    _DBG_FILE(
+                            "CNSmlInternetAdapter::UpdateIAPName, IAP_NETWORK set");
+                    DBG_ARGS8(
+                            _S8(
+                                    "CNSmlInternetAdapter::UpdateIAPName(): networks is %d"),
+                            nwId);
+                    iapUpdate->WriteUintL(TPtrC(IAP_NETWORK), nwId);
+                    }
+                else
+                    {
+                    ret = KErrGeneral;
+                    }
+                }
+            iapUpdate->PutRecordChanges();
+            }
+        CleanupStack::PopAndDestroy(); //ConvertTo16LC
+        }
+    CleanupStack::PopAndDestroy(); // iapUpdate
+
+
+    if (WapAPExistsL(aId))
+        { // Update handled
+        CCommsDbTableView* wapView;
+        wapView = iDatabase->OpenViewMatchingUintLC(TPtrC(WAP_ACCESS_POINT),
+                TPtrC(COMMDB_ID), iWapId);
+        TInt errorCode = wapView->GotoFirstRecord();
+
+        // Read all columns needed.
+        if (errorCode == KErrNone)
+            {
+            if (wapView->UpdateRecord() == KErrNone)
+                {
+                wapView->WriteTextL(TPtrC(COMMDB_NAME),
+                        ConvertTo16LC(aObject));
+                wapView->PutRecordChanges();
+                CleanupStack::PopAndDestroy(); //ConvertTo16LC
+                }
+            }
+        CleanupStack::PopAndDestroy(); // wapView
+        }
+    else
+        { // Insert handled
+        CCommsDbTableView* insView;
+        TInt wapInitOK = KErrCancel;
+
+        insView = iDatabase->OpenTableLC(TPtrC(WAP_ACCESS_POINT));
+        iWapId = 0;
+        wapInitOK = insView->InsertRecord(iWapId);
+        if (wapInitOK == KErrNone)
+            {
+            iWAPAccessPoint.Zero();
+            iWapUserName.Zero();
+            iWapPassword.Zero();
+            iWapBearer = TPtrC(WAP_IP_BEARER);
+
+            wapInitOK = InitializeWAPIAPL(insView, aObject);
+            wapInitOK = insView->PutRecordChanges();
+
+            if (wapInitOK == KErrNone)
+                {
+                CCommsDbTableView* updView;
+                TUint32 iWapId2 = 0;
+                iISPId = aId; // IAP number set
+                updView = iDatabase->OpenTableLC(TPtrC(WAP_IP_BEARER));
+                if (updView->InsertRecord(iWapId2) == KErrNone)
+                    {
+                    InitializeWAPL(updView);
+                    updView->PutRecordChanges();
+                    }
+                CleanupStack::PopAndDestroy(); // updView
+                }
+            }
+        else
+            {
+            ret = KErrGeneral;
+            }
+        CleanupStack::PopAndDestroy(); // insView
+        }
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        if (iWAPRelock)
+            {
+            DoLockIAPTablesL(ETrue);
+            iWAPRelock = EFalse;
+            }
+        }
+    if (iapReLock)
+        {
+        TInt reclockerr = DoProtectIAPRecordL(aId, ETrue);
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::AddLeafObjectL ,UnProtecting IAPAccessRecord returned code = %d"),
+                reclockerr);
+        if (reclockerr == KErrNone)
+            iapReLock = EFalse;
+        }
+    return ret;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::InitializeVPNServiceL()
+//      Initialize VPNService-data before insert
+//=============================================
+TInt CNSmlInternetAdapter::InitializeVPNServiceL(CCommsDbTableView* aTable)
+    {
+    _LIT(KdefPolicy, "Home");
+
+    aTable->WriteTextL(TPtrC(COMMDB_NAME), iIAPName); // Same as IAP
+
+    aTable->WriteTextL(TPtrC(VPN_SERVICE_POLICY), KdefPolicy);
+    aTable->WriteUintL(TPtrC(VPN_SERVICE_IAP), 1);
+    aTable->WriteUintL(TPtrC(VPN_SERVICE_NETWORKID), 1);
+
+    return KErrNone;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::InitializeLANServiceL()
+//      Initialize LANService-data before insert
+//=============================================
+TInt CNSmlInternetAdapter::InitializeLANServiceL(CCommsDbTableView* aTable)
+    {
+    if (!iWlanSupported)
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::InitializeLANServiceL, WLAN not supported.");
+        return KErrNotSupported;
+        }
+    _LIT(KgifNetworks, "ip,ip6");
+    _LIT(Kdns6Address, "0:0:0:0:0:0:0:0");
+    _LIT(KdefaultNetmask, "255.255.255.0");
+
+    aTable->WriteTextL(TPtrC(COMMDB_NAME), ConvertTo16LC(iIAPName)); // Same as IAP
+    aTable->WriteTextL(TPtrC(LAN_IF_NETWORKS), KgifNetworks);
+    aTable->WriteBoolL(TPtrC(SERVICE_IP_ADDR_FROM_SERVER), ETrue); // DHCP by default.
+    aTable->WriteTextL(TPtrC(SERVICE_IP_ADDR), KNSmlEmptyIpv4Address);
+    aTable->WriteTextL(TPtrC(SERVICE_IP_NETMASK), KdefaultNetmask);
+    aTable->WriteBoolL(TPtrC(SERVICE_IP_DNS_ADDR_FROM_SERVER), ETrue);
+    aTable->WriteTextL(TPtrC(SERVICE_IP_NAME_SERVER1), KNSmlEmptyIpv4Address);
+    aTable->WriteTextL(TPtrC(SERVICE_IP_NAME_SERVER2), KNSmlEmptyIpv4Address);
+    aTable->WriteTextL(TPtrC(SERVICE_IP_GATEWAY), KNSmlEmptyIpv4Address);
+
+    aTable->WriteBoolL(TPtrC(SERVICE_IP6_DNS_ADDR_FROM_SERVER), ETrue);
+    aTable->WriteTextL(TPtrC(SERVICE_IP6_NAME_SERVER1), Kdns6Address);
+    aTable->WriteTextL(TPtrC(SERVICE_IP6_NAME_SERVER2), Kdns6Address);
+    aTable->WriteTextL(TPtrC(SERVICE_CONFIG_DAEMON_MANAGER_NAME),
+            KDaemonManagerName);
+    aTable->WriteTextL(TPtrC(SERVICE_CONFIG_DAEMON_NAME), KConfigDaemonName);
+
+    CleanupStack::PopAndDestroy(); //ConvertTo16LC
+    return KErrNone;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::IsWLANfield()
+//      Check if handled by WLAN-adapter
+//=============================================
+TBool CNSmlInternetAdapter::IsWLANfield(const TDesC8& aURI)
+    {
+    TBool ret(EFalse);
+
+    SetField(aURI);
+
+    if (KNSmlDdfNetworkID().Match(*iField) == 0) // ID not valid
+        {
+        return ret;
+        }
+    if (KNSmlDdfAP().Match(*iField) == 0) // AP not valid
+        {
+        return ret;
+        }
+    if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*")) != KErrNotFound)
+        {
+        DBG_ARGS8(_S8("AP:IsWLANfield URI - <%S> <%S> FOUND"), &aURI, iField);
+        ret = ETrue;
+        }
+
+    return ret;
+    }
+
+//=============================================
+//      CNSmlInternetAdapter::IsWlanL()
+//      Check if WLAN accesspoint
+//=============================================
+TBool CNSmlInternetAdapter::IsWlanL(const TDesC8& aURI)
+    {
+    TBool ret(EFalse);
+
+    if (!iWlanSupported)
+        {
+        _DBG_FILE("CNSmlInternetAdapter::IsWlanL, WLAN not supported.");
+        return ret;
+        }
+
+    TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+
+    // Get IAP nbr for servicetype
+    TUint32 apWlan = GetAPIdFromURIL(aURI);
+
+    //  IAP-table search serviceType (=Bearer)
+    CCommsDbTableView* iapViews = iDatabase->OpenViewMatchingUintLC(
+            TPtrC(IAP), TPtrC(COMMDB_ID), apWlan);
+
+    TInt errorCode = iapViews->GotoFirstRecord();
+
+    // Read iapService from (IAP)
+    if (errorCode == KErrNone)
+        {
+        iapViews->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+        if (serviceType == TPtrC(LAN_SERVICE))
+            {
+            ret = ETrue;
+            }
+        }
+    CleanupStack::PopAndDestroy(); // iapViews
+
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::GetLanBearerL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::GetLanBearerL(TUint32& aId)
+    {
+    TBool ret = EFalse;
+
+    if (!iWlanSupported)
+        {
+        _DBG_FILE("CNSmlInternetAdapter::GetLanBearerL, WLAN not supported.");
+        return ret;
+        }
+
+    CCommsDbTableView* checkView;
+
+    HBufC* bName = HBufC::NewLC(15);
+    TPtr bNamePtr = bName->Des();
+    _LIT(KWlanBearer, "WLANBearer");
+    bNamePtr.Format(KWlanBearer);
+
+    checkView = iDatabase->OpenViewMatchingTextLC(TPtrC(LAN_BEARER), TPtrC(
+            COMMDB_NAME), bNamePtr);
+    TInt error = checkView->GotoFirstRecord();
+    if (error == KErrNone)
+        {
+        checkView->ReadUintL(TPtrC(COMMDB_ID), aId);
+        ret = ETrue;
+        }
+    else
+        {
+        aId = 1; // Default modem 
+        }
+    DBG_ARGS8(_S8("CNSmlInternetAdapter:GetLanBearerL %d"), aId);
+
+    CleanupStack::PopAndDestroy(2); // checkView bName
+
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::GetModemBearerL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::GetModemBearerL(TUint32& aId)
+    {
+    TBool ret = EFalse;
+    CCommsDbTableView* checkView;
+
+    HBufC* bName = HBufC::NewLC(15);
+    TPtr bNamePtr = bName->Des();
+
+    if (iBearer == TPtrC(OUTGOING_GPRS) || iBearer == TPtrC(INCOMING_GPRS))
+        {
+        _LIT(KGprsModem, "GPRS Modem");
+        bNamePtr.Format(KGprsModem);
+        }
+
+    checkView = iDatabase->OpenViewMatchingTextLC(TPtrC(MODEM_BEARER), TPtrC(
+            COMMDB_NAME), bNamePtr);
+    TInt error = checkView->GotoFirstRecord();
+    if (error == KErrNone)
+        {
+        checkView->ReadUintL(TPtrC(COMMDB_ID), aId);
+        ret = ETrue;
+        }
+    else
+        {
+        aId = 5; // Default modem 1->5 ???
+        }
+    DBG_ARGS8(_S8("CNSmlInternetAdapter:GetModemBearerL %d"), aId);
+
+    CleanupStack::PopAndDestroy(2); // checkView bName
+
+    return ret;
+    }
+
+// ---------------------------------------------------------
+//      NextAPNameL()
+//      Generates new AP name.
+// ---------------------------------------------------------
+void CNSmlInternetAdapter::NextAPNameL(const TDesC8& aName)
+    {
+    // generate name candidate
+    HBufC8* nameCandidate = HBufC8::NewLC(aName.Length() + 12);
+    TPtr8 candidatePtr = nameCandidate->Des();
+
+    // loop while valid name is found
+    TBool validName;
+
+    // loop while valid name is found
+    TInt i = 0;
+    do
+        {
+        validName = ETrue;
+        candidatePtr.Format(aName);
+        if (i > 0)
+            {
+            _LIT(KLeftBrace, "(");
+            _LIT(KRightBrace, ")");
+            HBufC* buf = HBufC::NewLC(10); //10 = max length of 32bit integer
+            TPtr ptrBuf = buf->Des();
+            ptrBuf.Num(i);
+            candidatePtr.Append(KLeftBrace);
+            candidatePtr.Append(ptrBuf);
+            candidatePtr.Append(KRightBrace);
+            CleanupStack::PopAndDestroy(); //buf
+            }
+        i++;
+        if (!IsValidNameL(candidatePtr))
+            {
+            validName = EFalse;
+            }
+        }
+    while (!validName);
+
+    iIAPName = candidatePtr;
+
+    CleanupStack::PopAndDestroy(); //nameCandidate
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::IsValidNameL()
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::IsValidNameL(const TDesC8& aName)
+    {
+    TBool ret = ETrue;
+    CCommsDbTableView* nameView;
+
+    nameView = iDatabase->OpenViewMatchingTextLC(TPtrC(IAP), TPtrC(
+            COMMDB_NAME), aName);
+
+    TInt errorCode = nameView->GotoFirstRecord();
+
+    if (errorCode == KErrNone)
+        {
+        ret = EFalse; // If found error returned        
+        }
+
+    CleanupStack::PopAndDestroy(); // nameView
+    return ret;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::InitializeDNSParamsFromBuffL(const TPtrC8 aParentUri,
+//                                                          TInt& aDnsPri )
+// Finds parameters needed in updating DNSAddrL from buffer
+//------------------------------------------------------------------------------
+TBool CNSmlInternetAdapter::InitializeDNSParamsFromBuffL(
+        const TPtrC8 aParentUri, TInt& aDnsPri)
+    {
+    TInt cmd(0);
+    TBool found(EFalse);
+
+    TNSmlAPBufferElement& thisElem = iBuffer->At(0);
+
+    // Parse URI to match
+    CBufBase* buf = CBufFlat::NewL(150);
+    CleanupStack::PushL(buf);
+    buf->InsertL(0, aParentUri);
+    buf->InsertL(buf->Size(), KNSmlDmApValFSlash);
+    buf->InsertL(buf->Size(), KNSmlDdfDNSPriority);
+    TBuf8<150> tmp;
+    buf->Read(0, tmp, buf->Size());
+
+    cmd = thisElem.iNodeBuf->Count() - 1;
+    // check if the DNSPriority is sent for DNSAddr/<x>
+    while (cmd >= 0)
+        {
+        if (thisElem.iNodeBuf->At(cmd).iUri->Match(tmp) != KErrNotFound)
+            {
+            TLex8 lex(thisElem.iNodeBuf->At(cmd).iData->Des());
+            lex.Val(aDnsPri);
+            thisElem.iNodeBuf->At(cmd).iDone = ETrue;
+            found = ETrue;
+            }
+        cmd--;
+        }
+    CleanupStack::PopAndDestroy(buf);
+    return found;
+    }
+
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::DnsToLuid(const UriUtils::TUriHostType aType,)
+//                                      const TInt aPriority ) const
+// Encodes special luid for DNSAddr/<X>
+//------------------------------------------------------------------------------
+TInt CNSmlInternetAdapter::DnsToLuid(const UriUtils::TUriHostType aType,
+        const TInt aPriority) const
+    {
+    return KNSmlApDnsLuidUpperBase + static_cast<TInt> (aType) * 10
+            + aPriority;
+    }
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::LuidToDns(UriUtils::TUriHostType& aType,)
+//                                     TInt& aPriority, const TInt aLuid ) const
+// Decodes DNAddr/<X> type from LUID
+//------------------------------------------------------------------------------
+TInt CNSmlInternetAdapter::LuidToDns(UriUtils::TUriHostType& aType,
+        TInt& aPriority, const TInt aLuid) const
+    {
+    TInt err = KErrNone;
+    if (aLuid < KNSmlApDnsLuidUpperBase)
+        {
+        err = KErrGeneral;
+        }
+    else
+        {
+        aPriority = (aLuid - KNSmlApDnsLuidUpperBase) % 10;
+        if ((aPriority > 0) && (aPriority < 3))
+            {
+            TInt type = (aLuid - KNSmlApDnsLuidUpperBase - aPriority) / 10;
+            if ((type >= 0) && (type < 2))
+                {
+                aType = static_cast<UriUtils::TUriHostType> (type);
+                }
+            else
+                {
+                err = KErrGeneral;
+                }
+            }
+        else
+            {
+            err = KErrGeneral;
+            }
+        }
+    return err;
+    }
+//------------------------------------------------------------------------------
+// TBool CNSmlInternetAdapter::RemoveLastSeg(const TDesC8& aURI)
+// Returns URI without its last segment
+//------------------------------------------------------------------------------
+TPtrC8 CNSmlInternetAdapter::RemoveLastSeg(const TDesC8& aURI) const
+    {
+    TInt i;
+    for (i = aURI.Length() - 1; i >= 0; i--)
+        {
+        if (aURI[i] == KNSmlDMUriSeparator)
+            {
+            break;
+            }
+        }
+    if (i > 0)
+        {
+        return aURI.Left(i);
+        }
+    else
+        {
+        return KNullDesC8();
+        }
+    }
+
+//------------------------------------------------------------------------------
+// void CNSmlInternetAdapter::ClearBuffer()
+// Deletes all dynamically allocated data from given array's each element
+// and resets the buffer.
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::ClearBuffer(
+        CArrayFixFlat<TNSmlAPAddElement>* aBuffer)
+    {
+    for (TInt i = 0; i < aBuffer->Count(); i++)
+        {
+        delete aBuffer->At(i).iUri;
+        aBuffer->At(i).iUri = NULL;
+
+        delete aBuffer->At(i).iData;
+        aBuffer->At(i).iData = NULL;
+
+        delete aBuffer->At(i).iLuid;
+        aBuffer->At(i).iLuid = NULL;
+        }
+
+    aBuffer->Reset();
+    }
+
+//----------------------------------------------------------------------
+//TBool CNSmlInternetAdapter::IsValidIPv4AddressL(const TDesC8& aNapAddr)
+//Checks if the string is of correct IPV4 address format x.x.x.x and 
+//numbers are within the range 0-255
+//returns true on sucess and false on failure.
+//----------------------------------------------------------------------
+TBool CNSmlInternetAdapter::IsValidIPv4AddressL(const TDesC8& aNapAddr)
+    {
+    TInt digitLen(0);
+    TBool ret = EFalse;
+    _LIT8(KNSmlDMV4Format, "*.*.*.*");
+
+    if (aNapAddr.Match(KNSmlDMV4Format) != KErrNotFound)
+        {
+        TInt pos = 0;
+        TInt numDots = 0;
+        TInt maxIP = 255;
+        TInt minIP = 0;
+        for (TInt i = 0; i < aNapAddr.Length(); i++)
+            {
+            digitLen++;
+            //Check if aNapAddr contain any characters other than 
+            // 0 - 9 and ".",  If yes return from the function.
+            if (aNapAddr[i] != KNSmlDMDot && (aNapAddr[i]
+                    < KNSmlDMAsciiIntStart || aNapAddr[i]
+                    > KNSmlDMAsciiIntEnd))
+                {
+                ret = EFalse;
+                break;
+                }
+            if (aNapAddr[i] == KNSmlDMDot)
+                {
+                ret = ETrue;
+                if (i > 0)
+                    {
+                    TInt digit;
+                    TPtrC8 ptrOneDigit = aNapAddr.Mid(pos, digitLen - 1);
+                    TLex8 lexint(ptrOneDigit);
+                    if (lexint.Val(digit) != KErrNone || digit >= maxIP
+                            || digit < minIP)
+                        {
+                        ret = EFalse;
+                        break;
+                        }
+                    } // end of if i > 0
+                pos = i + 1;
+                numDots++;
+                digitLen = 0;
+                } // end of if
+            } //End of for
+        if (numDots == 3 && ret)
+            {
+            ret = ETrue;
+            }
+        else
+            {
+            ret = EFalse;
+            }
+        } // end of outer if, format check
+    return ret;
+    }
+
+TBool CNSmlInternetAdapter::IsWAPAccessPointRecordLockedL(TUint32 aRecord)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::IsWAPAccessPointRecordLockedL():  BEGIN");
+    TBool ret = EFalse;
+    CCommsDbTableView* wapView;
+    DBG_ARGS8(
+            _S8(
+                    "CNSmlInternetAdapter::IsWAPAccessPointRecordLockedL record being checked = %d"),
+            aRecord);
+    wapView = iDatabase->OpenViewMatchingUintLC(TPtrC(WAP_ACCESS_POINT),
+            TPtrC(COMMDB_ID), aRecord);
+
+    TInt aAccess(0);
+    if (wapView != NULL)
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::IsWAPAccessPointRecordLockedL():wap record exists, check for access type");
+        TInt err = (((CCommsDbProtectTableView*) wapView)->GetRecordAccess(
+                aAccess));
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::IsWAPAccessPointRecordLockedL , GetrecordAccess code is =%d and acess type of record = %d"),
+                err, aAccess);
+        CleanupStack::PopAndDestroy(wapView);
+        if (aAccess == RDbRowSet::EReadOnly)
+            ret = ETrue;
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::IsWAPAccessPointRecordLockedL():  END");
+    return ret;
+
+    }
+//----------------------------------------------------------------------
+//TBool CNSmlInternetAdapter::DoProtectWAPAccessRecordL(TUint32 aRecord,TBool aProtect)
+// protect or unprotect wapaccesspoint record of access point being altered 
+//----------------------------------------------------------------------
+
+
+TInt CNSmlInternetAdapter::DoProtectWAPAccessRecordL(TUint32 aRecord,
+        TBool aProtect)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::DoProtectWAPAccessRecordL():  BEGIN");
+    DBG_ARGS8(
+            _S8(
+                    "CNSmlInternetAdapter::DoProtectWAPAccessRecordL , record and protect value  =%d  = %d"),
+            aRecord, aProtect);
+    TInt err = KErrNone;
+
+    CCommsDbTableView* wapView;
+    wapView = iDatabase->OpenViewMatchingUintLC(TPtrC(WAP_ACCESS_POINT),
+            TPtrC(COMMDB_ID), aRecord);
+    if (wapView != NULL)
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::DoProtectWAPAccessRecordL():  wap record exists");
+        if (!aProtect)
+            {
+            err = ((CCommsDbProtectTableView*) wapView)->UnprotectRecord();
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlInternetAdapter::DoProtectWAPAccessRecordL ,error code of Unprotectrecord = %d"),
+                    err);
+            }
+
+        else
+            {
+            err = ((CCommsDbProtectTableView*) wapView)->ProtectRecord();
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlInternetAdapter::DoProtectWAPAccessRecordL ,error code of ProtectRecord = %d"),
+                    err);
+            }
+
+        CleanupStack::PopAndDestroy(wapView);
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::DoProtectWAPAccessRecordL():  END");
+    return err;
+    }
+
+//------------------------------------------------------------------------------
+// TUint32 CNSmlInternetAdapter::GetIAPSeamlessnessL(TUint32 aId)
+// Gets the seamlessness value from the IAPMetadata table though the cmmanager API
+//------------------------------------------------------------------------------
+
+TUint32 CNSmlInternetAdapter::GetIAPSeamlessnessL(TUint32 aId)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::GetIAPSeamlessnessL(): begin");
+    //Deleting iDatabase, Required since CommsDB has one view open for reading and commsdat API would
+    //return KErrLocked if this is not done
+    TBool reopenTransaction(EFalse);
+    if (iDatabase->InTransaction())
+        {
+        iDatabase->CommitTransaction();
+        iTransactionCommitted = ETrue;
+        reopenTransaction = ETrue;
+        }
+
+    RCmManagerExt cmManagerExt;
+    cmManagerExt.OpenL();
+    RCmConnectionMethodExt cm = cmManagerExt.ConnectionMethodL(aId);
+    CleanupClosePushL(cm);
+    TUint32 smless = cm.GetIntAttributeL(CMManager::ECmSeamlessnessLevel);
+    CleanupStack::PopAndDestroy();
+    cmManagerExt.Close();
+
+    //Recreate reference to CommsDB since other tables
+    //are manipulated with Commsdb 
+    if (reopenTransaction)
+        {
+        TInt dberr = iDatabase->BeginTransaction();
+        if (dberr == KErrLocked)
+            {
+            _DBG_FILE("GetIAPSeamlessnessL: CommsDat was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && dberr == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("GetIAPSeamlessnessL: Slept 1 second. Try again");
+                dberr = iDatabase->BeginTransaction();
+                retry--;
+                }
+            if (dberr != KErrNone)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter: BeginTransaction failed completely.");
+                User::Leave(dberr);
+                }
+            }
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::GetIAPSeamlessnessL(): End");
+    return smless;
+
+    }
+
+//------------------------------------------------------------------------------
+// TUint32 CNSmlInternetAdapter::GetIAPMetaDataL(TUint32 aId)
+// Gets the metadata value from the IAPMetadata table though the cmmanager API
+//--------------------------------------------------------------------------
+
+TUint32 CNSmlInternetAdapter::GetIAPMetaDataL(TUint32 aId)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::GetIAPMetaDataL(): begin");
+    //Deleting iDatabase, Required since CommsDB has one view open for reading and commsdat API would
+    //return KErrLocked if this is not done 
+    TBool reopenTransaction(EFalse);
+    if (iDatabase->InTransaction())
+        {
+        iDatabase->CommitTransaction();
+        iTransactionCommitted = ETrue;
+        reopenTransaction = ETrue;
+        }
+
+    TUint32 metadata, highlight, hidden;
+    RCmManagerExt cmManagerExt;
+
+    cmManagerExt.OpenL();
+    RCmConnectionMethodExt cm = cmManagerExt.ConnectionMethodL(aId);
+    CleanupClosePushL(cm);
+
+    TBool metaHidden = cm.GetBoolAttributeL(CMManager::ECmMetaHiddenAgent);
+    TBool metaHL = cm.GetBoolAttributeL(CMManager::ECmMetaHighlight);
+    highlight = EMetaHighlight & metaHL;
+    hidden = EMetaHiddenAgent & metaHidden;
+    metadata = highlight | hidden;
+
+    CleanupStack::PopAndDestroy();
+    cmManagerExt.Close();
+    //Recreate reference to CommsDB since other tables
+    //are manipulated with Commsdb 
+    if (reopenTransaction)
+        {
+        TInt dberr = iDatabase->BeginTransaction();
+        if (dberr == KErrLocked)
+            {
+            _DBG_FILE("GetIAPMetaDataL: CommsDat was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && dberr == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("GetIAPMetaDataL: Slept 1 second. Try again");
+                dberr = iDatabase->BeginTransaction();
+                retry--;
+                }
+            if (dberr != KErrNone)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter: BeginTransaction failed completely.");
+                User::Leave(dberr);
+                }
+            }
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::GetIAPMetaDataL(): end");
+    return metadata;
+
+    }
+//------------------------------------------------------------------------------
+// void CNSmlInternetAdapter::SetIAPSeamlessnessL(TUint32 apMetaID,TUint32 aSeam,TInt aStatusRef)
+// Sets the seamlessness value to the IAPMetadata table though the cmmanager API
+//------------------------------------------------------------------------------
+void CNSmlInternetAdapter::SetIAPSeamlessnessL(TUint32 apMetaID,
+        TUint32 aSeam, TInt aStatusRef)
+    {
+
+    _DBG_FILE("CNSmlInternetAdapter::SetIAPSeamlessnessL(): begin");
+    TBool reopenTransaction(EFalse);
+    if (iDatabase->InTransaction())
+        {
+        iDatabase->CommitTransaction();
+        iTransactionCommitted = ETrue;
+        reopenTransaction = ETrue;
+        }
+
+    RCmManagerExt cmManagerExt;
+    cmManagerExt.OpenL();
+    RCmConnectionMethodExt cm;
+    TInt cmerror = KErrNone;
+    TRAP(cmerror, cm = cmManagerExt.ConnectionMethodL(apMetaID));
+    CleanupClosePushL(cm);TRAPD(sErr,cm.SetIntAttributeL( CMManager::ECmSeamlessnessLevel,aSeam ))
+    if(sErr == KErrNone)
+        {
+        cm.UpdateL();
+        iCallBack->SetStatusL(aStatusRef,CSmlDmAdapter::EOk);
+        }
+    else
+        {
+        iCallBack->SetStatusL(aStatusRef,CSmlDmAdapter::EError);
+        }
+
+    CleanupStack::PopAndDestroy();
+
+    cmManagerExt.Close();
+    //  iDatabase = CCommsDatabase::NewL();
+    if (reopenTransaction)
+        {
+        TInt dberr = iDatabase->BeginTransaction();
+        if (dberr == KErrLocked)
+            {
+            _DBG_FILE("SetIAPSeamlessnessL: CommsDat was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && dberr == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("SetIAPSeamlessnessL: Slept 1 second. Try again");
+                dberr = iDatabase->BeginTransaction();
+                retry--;
+                }
+            if (dberr != KErrNone)
+                {
+                _DBG_FILE(
+                        "CNSmlInternetAdapter: BeginTransaction failed completely.");
+                User::Leave(dberr);
+                }
+            }
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::SetIAPSeamlessnessL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// void CNSmlInternetAdapter::SetIAPMetaDataL(TUint32 apMetaID,TUint32 aMeta,TInt aStatusRef)
+// Sets the metadata value to the IAPMetadata table though the cmmanager API
+//------------------------------------------------------------------------------
+
+void CNSmlInternetAdapter::SetIAPMetaDataL(TUint32 apMetaID, TUint32 aMeta,
+        TInt aStatusRef)
+    {
+
+    _DBG_FILE("CNSmlInternetAdapter::SetIAPMetaDataL(): begin");
+    TInt hMHLErr = KErrNone;
+    TInt hMHAErr = KErrNone;
+    if (iDatabase)
+        {
+        iDatabase->CommitTransaction();
+        // delete iDatabase;
+        }
+    RCmManagerExt cmManagerExt;
+    cmManagerExt.OpenL();
+    RCmConnectionMethodExt cm = cmManagerExt.ConnectionMethodL(apMetaID);
+    CleanupClosePushL(cm);
+
+    if (aMeta & EMetaHighlight)
+        {
+        TRAP(hMHLErr,
+                cm.SetBoolAttributeL(CMManager::ECmMetaHighlight, ETrue));
+        }
+    else
+        {
+        TRAP(hMHLErr, cm.SetBoolAttributeL(CMManager::ECmMetaHighlight,
+                EFalse));
+        }
+
+    if (aMeta & EMetaHiddenAgent)
+        {
+        TRAP(hMHAErr, cm.SetBoolAttributeL(CMManager::ECmMetaHiddenAgent,
+                ETrue));
+        }
+    else
+        {
+        TRAP(hMHAErr, cm.SetBoolAttributeL(CMManager::ECmMetaHiddenAgent,
+                EFalse));
+        }
+    if ((hMHAErr == KErrNone) && (hMHLErr == KErrNone))
+        {
+        cm.UpdateL();
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+
+        }
+    else
+        {
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+        }
+
+    CleanupStack::PopAndDestroy();
+
+    cmManagerExt.Close();
+    TInt dberr = iDatabase->BeginTransaction();
+    if (dberr == KErrLocked)
+        {
+        _DBG_FILE("SetIAPMetaDataL: CommsDat was locked.");
+        TInt retry = KBeginTransRetryCount;
+        while (retry > 0 && dberr == KErrLocked)
+            {
+            User::After(KBeginTransRetryDelay);
+            _DBG_FILE("SetIAPMetaDataL: Slept 1 second. Try again");
+            dberr = iDatabase->BeginTransaction();
+            retry--;
+            }
+        if (dberr != KErrNone)
+            {
+            _DBG_FILE(
+                    "CNSmlInternetAdapter: BeginTransaction failed completely.");
+            User::Leave(dberr);
+            }
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::SetIAPMetaDataL(): end");
+    }
+
+void CNSmlInternetAdapter::AddLingerL(const TInt aIapId,
+        const TInt aLingerInterval)
+    {
+    TInt err(KErrNone);
+
+    // Open repository
+    CRepository* repository = CRepository::NewLC(KCRUidPDPContextManager);
+
+    // Find if an entry for "iapId" already exists in CentRep 
+    RArray<TUint32> foundKeys;
+    foundKeys.Reset();
+
+    err = repository->FindEqL(KIapColumn, // partial key
+            KColumnMask, // key mask
+            aIapId, // value
+            foundKeys); // found keys
+
+    if (err == KErrNone || err == KErrNotFound)
+        {
+        if (foundKeys.Count() == 0)
+            {
+            // Add a new entry
+            TInt arrayCount(0);
+
+            // Get number of iapId&linger entries in Centrep
+            err = repository->Get(KPdpContextManagerLingerArrayCount,
+                    arrayCount);
+
+            if (err == KErrNone)
+                {
+                arrayCount++;
+
+                err = repository->Create((KIapColumn | arrayCount), aIapId);
+
+                if (err == KErrNone)
+                    {
+                    err = repository->Create((KLingerColumn | arrayCount),
+                            aLingerInterval);
+                    }
+
+                if (err == KErrNone)
+                    {
+                    // Update number of iapId&linger entries in Centrep
+                    err = repository->Set(KPdpContextManagerLingerArrayCount,
+                            arrayCount);
+                    }
+                }
+            }
+        else
+            {
+            // Update existing entry on current row
+            TInt32 row = foundKeys[0] & KRowMask;
+
+            err = repository->Set((KLingerColumn | row), aLingerInterval);
+            }
+        }
+
+    foundKeys.Close();
+    CleanupStack::PopAndDestroy(repository);
+
+    User::LeaveIfError(err);
+    }
+
+void CNSmlInternetAdapter::UpdateLingerL(const TInt aIapId,
+        const TInt aLingerInterval)
+    {
+    TInt err(KErrNone);
+
+    // Open repository
+    CRepository* repository = CRepository::NewLC(KCRUidPDPContextManager);
+
+    // Find if an entry for "iapId" already exists in CentRep 
+    RArray<TUint32> foundKeys;
+    foundKeys.Reset();
+
+    err = repository->FindEqL(KIapColumn, // partial key
+            KColumnMask, // key mask
+            aIapId, // value
+            foundKeys); // found keys
+
+    if (err == KErrNone || err == KErrNotFound)
+        {
+
+        if (foundKeys.Count() == 0)
+            {
+            // Add a new entry
+            TInt arrayCount(0);
+
+            // Get number of iapId&linger entries in Centrep
+            err = repository->Get(KPdpContextManagerLingerArrayCount,
+                    arrayCount);
+
+            if (err == KErrNone)
+                {
+                arrayCount++;
+
+                err = repository->Create((KIapColumn | arrayCount), aIapId);
+
+                if (err == KErrNone)
+                    {
+                    err = repository->Create((KLingerColumn | arrayCount),
+                            aLingerInterval);
+                    }
+
+                if (err == KErrNone)
+                    {
+                    // Update number of iapId&linger entries in Centrep
+                    err = repository->Set(KPdpContextManagerLingerArrayCount,
+                            arrayCount);
+                    }
+                }
+            }
+        else
+            {
+            // Update existing entry on currebt row
+            TInt32 row = foundKeys[0] & KRowMask;
+
+            err = repository->Set((KLingerColumn | row), aLingerInterval);
+            }
+        }
+
+    foundKeys.Close();
+    CleanupStack::PopAndDestroy(repository);
+
+    User::LeaveIfError(err);
+    }
+void CNSmlInternetAdapter::GetLingerL(const TInt aIapId,
+        TInt& aLingerInterval)
+    {
+    TInt err(KErrNone);
+
+    // Open repository
+    CRepository* repository = CRepository::NewLC(KCRUidPDPContextManager);
+
+    // Find if an entry for "iapId" already exists in CentRep 
+    RArray<TUint32> foundKeys;
+    foundKeys.Reset();
+
+    err = repository->FindEqL(KIapColumn, // partial key
+            KColumnMask, // key mask
+            aIapId, // value
+            foundKeys); // found keys
+
+    if (err == KErrNone)
+        {
+        if (foundKeys.Count() > 0)
+            {
+            // Find linger interval for the iap id on current row
+            TInt32 row = foundKeys[0] & KRowMask;
+
+            err = repository->Get((KLingerColumn | row), aLingerInterval);
+            }
+        }
+
+    foundKeys.Close();
+    CleanupStack::PopAndDestroy(repository);
+
+    User::LeaveIfError(err);
+    }
+
+//----------------------------------------------------------------------
+//TBool CNSmlInternetAdapter::CheckEnforcementL()
+// If AP policy is enforced true is returned else false
+//----------------------------------------------------------------------
+TBool CNSmlInternetAdapter::CheckEnforcementL()
+    {
+    CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL();
+    CleanupStack::PushL(info);
+    TBool enforceActive(EFalse);
+    User::LeaveIfError(info->EnforcementActive(EAPEnforcement, enforceActive));
+    CleanupStack::PopAndDestroy(info);
+    return enforceActive;
+    }
+
+//----------------------------------------------------------------------
+//TBool CNSmlInternetAdapter::CheckWLANEnforcementL()
+// If WLAN AP policy is enforced true is returned else false
+//----------------------------------------------------------------------
+TBool CNSmlInternetAdapter::CheckWLANEnforcementL()
+    {
+    CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL();
+    CleanupStack::PushL(info);
+    TBool enforceActive(EFalse);
+    User::LeaveIfError(info->EnforcementActive(EWLANEnforcement,
+            enforceActive));
+    CleanupStack::PopAndDestroy(info);
+    return enforceActive;
+    }
+
+//----------------------------------------------------------------------
+//TInt CNSmlInternetAdapter::DoProtectWAPTablesL(TBool aProtect)
+// if aProtect is true , tables are locked otherwise tables are unlocked.
+//----------------------------------------------------------------------
+
+TInt CNSmlInternetAdapter::DoProtectWAPTablesL(TBool aProtect)
+    {
+    TInt err = KErrNone;
+    CCommsDatabaseProtect* dbprotect = CCommsDatabaseProtect::NewL();
+    CleanupStack::PushL(dbprotect);
+    for (TInt i(0); i < iLockTableList.Count(); i++)
+        {
+        if (!aProtect)
+            {
+            err = dbprotect->UnProtectTable(iLockTableList[i]);
+            }
+        else
+            {
+            err = dbprotect->ProtectTable(iLockTableList[i]);
+            }
+
+        }
+    CleanupStack::PopAndDestroy(dbprotect);
+    return err;
+    }
+//----------------------------------------------------------------------
+//void CNSmlInternetAdapter::DoLockIAPTablesL(TBool aProtect)
+// if aProtect is true , tables are locked otherwise tables are unlocked.
+//----------------------------------------------------------------------
+
+void CNSmlInternetAdapter::DoLockIAPTablesL(TBool aLock)
+    {
+    TInt protError = KErrNone;
+    TInt err = KErrNone;
+    iDatabase->CommitTransaction();
+    iLockTableList.AppendL(TPtrC(WAP_ACCESS_POINT));
+    iLockTableList.AppendL(TPtrC(WAP_IP_BEARER));
+    iLockTableList.AppendL(TPtrC(IAP));
+
+    TRAP(err, protError = DoProtectWAPTablesL(aLock));
+    DBG_ARGS8(
+            _S8(
+                    "CNSmlInternetAdapter::DoLockIAPTablesL(): Table protect error %d , leave error %d "),
+            protError, err);
+
+    if (protError != KErrNone) // To remove the warnings
+        {
+        protError = KErrNone;
+        }
+    TInt dberr = iDatabase->BeginTransaction();
+    if (dberr == KErrLocked)
+        {
+        _DBG_FILE("DoLockIAPTablesL: CommsDat was locked.");
+        TInt retry = KBeginTransRetryCount;
+        while (retry > 0 && dberr == KErrLocked)
+            {
+            User::After(KBeginTransRetryDelay);
+            _DBG_FILE("DoLockIAPTablesL: Slept 1 second. Try again");
+            dberr = iDatabase->BeginTransaction();
+            retry--;
+            }
+        if (dberr != KErrNone)
+            {
+            _DBG_FILE(
+                    "CNSmlInternetAdapter: BeginTransaction failed completely.");
+            User::Leave(dberr);
+            }
+        }
+    }
+//--------------------------------------------------------------------
+//TInt UnprotectWLANAPItemL(TUint32 aId)
+//Unprotect the wlan AP if only wlan enforcement is on
+//-------------------------------------------------------------------
+TInt CNSmlInternetAdapter::UnprotectWLANAPItemL(TUint32 aId)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::UnprotectWLANAPItemL():  BEGIN");
+    CCommsDbTableView* wapView;
+
+    TInt errorCode = KErrNone;
+    TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+
+    //check if its WLAN AP being deleted
+    wapView = iDatabase->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(COMMDB_ID),
+            aId);
+
+    errorCode = wapView->GotoFirstRecord();
+
+    if (errorCode == KErrNone)
+        {
+        wapView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+        if (serviceType != TPtrC(LAN_SERVICE))
+            {
+            CleanupStack::PopAndDestroy(); // wapView   
+            return KErrNone;
+            }
+        }
+
+    ((CCommsDbProtectTableView*) wapView)->UnprotectRecord();
+
+    CleanupStack::PopAndDestroy(); // wapView   
+
+    _DBG_FILE("CNSmlInternetAdapter::UnprotectWLANAPItemL():  END");
+    return errorCode;
+    }
+
+//----------------------------------------------------------------------
+//TBool CNSmlInternetAdapter::IsIAPRecordLockedL(TUint32 aRecord)
+//check for wap access point record  lock status 
+//----------------------------------------------------------------------
+
+TBool CNSmlInternetAdapter::IsIAPRecordLockedL(TUint32 aRecord)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::IsIAPRecordLockedL():  BEGIN");
+    TBool ret = EFalse;
+    CCommsDbTableView* apView;
+    DBG_ARGS8(
+            _S8(
+                    "CNSmlInternetAdapter::IsIAPRecordLockedL record being checked = %d"),
+            aRecord);
+    apView = iDatabase->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(COMMDB_ID),
+            aRecord);
+
+    TInt aAccess(0);
+    if (apView != NULL)
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::IsIAPRecordLockedL():wap record exists, check for access type");
+        TInt err = (((CCommsDbProtectTableView*) apView)->GetRecordAccess(
+                aAccess));
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::IsIAPRecordLockedL , GetrecordAccess code is =%d and acess type of record = %d"),
+                err, aAccess);
+        CleanupStack::PopAndDestroy(apView);
+        if (aAccess == RDbRowSet::EReadOnly)
+            ret = ETrue;
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::IsIAPRecordLockedL():  END");
+    return ret;
+
+    }
+//----------------------------------------------------------------------
+//TBool CNSmlInternetAdapter::DoProtectIAPRecordL(TUint32 aRecord,TBool aProtect)
+// protect or unprotect wapaccesspoint record of access point being altered 
+//----------------------------------------------------------------------
+
+
+TInt CNSmlInternetAdapter::DoProtectIAPRecordL(TUint32 aRecord,
+        TBool aProtect)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::DoProtectIAPRecordL():  BEGIN");
+    DBG_ARGS8(
+            _S8(
+                    "CNSmlInternetAdapter::DoProtectIAPRecordL , record and protect value  =%d  = %d"),
+            aRecord, aProtect);
+    TInt err = KErrNone;
+
+    CCommsDbTableView* apView;
+    apView = iDatabase->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(COMMDB_ID),
+            aRecord);
+    if (apView != NULL)
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::DoProtectIAPRecordL():  wap record exists");
+        if (!aProtect)
+            {
+            err = ((CCommsDbProtectTableView*) apView)->UnprotectRecord();
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlInternetAdapter::DoProtectIAPAccessRecordL ,error code of Unprotectrecord = %d"),
+                    err);
+            }
+
+        else
+            {
+            err = ((CCommsDbProtectTableView*) apView)->ProtectRecord();
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlInternetAdapter::DoProtectIAPRecordL ,error code of ProtectRecord = %d"),
+                    err);
+            }
+
+        CleanupStack::PopAndDestroy(apView);
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::DoProtectIAPRecordL():  END");
+    return err;
+    }
+//----------------------------------------------------------------------
+//TBool CNSmlInternetAdapter::IsProxyRecordLockedL(TUint32 aRecord)
+//check for proxy record  lock status 
+//----------------------------------------------------------------------
+
+TBool CNSmlInternetAdapter::IsProxyRecordLockedL(TUint32 aRecord)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::IsProxyRecordLockedL():  BEGIN");
+    TBool ret = EFalse;
+    CCommsDbTableView* proxyView;
+    DBG_ARGS8(
+            _S8(
+                    "CNSmlInternetAdapter::IsProxyRecordLockedL record being checked = %d"),
+            aRecord);
+    proxyView = iDatabase->OpenViewMatchingUintLC(TPtrC(PROXIES), TPtrC(
+            COMMDB_ID), aRecord);
+
+    TInt aAccess(0);
+    if (proxyView != NULL)
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::IsProxyRecordLockedL():wap record exists, check for access type");
+        TInt err = (((CCommsDbProtectTableView*) proxyView)->GetRecordAccess(
+                aAccess));
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::IsProxyRecordLockedL , GetrecordAccess code is =%d and acess type of record = %d"),
+                err, aAccess);
+        CleanupStack::PopAndDestroy(proxyView);
+        if (aAccess == RDbRowSet::EReadOnly)
+            ret = ETrue;
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::IsProxyRecordLockedL():  END");
+    return ret;
+
+    }
+//----------------------------------------------------------------------
+//TBool CNSmlInternetAdapter::DoProtectProxyRecordL(TUint32 aRecord,TBool aProtect)
+// protect or unprotect proxy record of access point being altered 
+//----------------------------------------------------------------------
+
+
+TInt CNSmlInternetAdapter::DoProtectProxyRecordL(TUint32 aRecord,
+        TBool aProtect)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::DoProtectProxyRecordL():  BEGIN");
+    DBG_ARGS8(
+            _S8(
+                    "CNSmlInternetAdapter::DoProtectProxyRecordL , record and protect value  =%d  = %d"),
+            aRecord, aProtect);
+    TInt err = KErrNone;
+
+    CCommsDbTableView* proxyView;
+    proxyView = iDatabase->OpenViewMatchingUintLC(TPtrC(PROXIES), TPtrC(
+            COMMDB_ID), aRecord);
+    if (proxyView != NULL)
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::DoProtectProxyRecordL():  wap record exists");
+        if (!aProtect)
+            {
+            err = ((CCommsDbProtectTableView*) proxyView)->UnprotectRecord();
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlInternetAdapter::DoProtectProxyRecordL ,error code of Unprotectrecord = %d"),
+                    err);
+            }
+
+        else
+            {
+            err = ((CCommsDbProtectTableView*) proxyView)->ProtectRecord();
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlInternetAdapter::DoProtectProxyRecordL ,error code of ProtectRecord = %d"),
+                    err);
+            }
+
+        CleanupStack::PopAndDestroy(proxyView);
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::DoProtectProxyRecordL():  END");
+    return err;
+    }
+
+//----------------------------------------------------------------------
+//TBool CNSmlInternetAdapter::IsServiceRecordLockedL(TUint32 aRecord)
+//check for proxy record  lock status 
+//----------------------------------------------------------------------
+
+TBool CNSmlInternetAdapter::IsServiceRecordLockedL(TUint32 aRecord)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::IsProxyRecordLockedL():  BEGIN");
+    TBool ret = EFalse;
+    CCommsDbTableView* serviceView;
+    DBG_ARGS8(
+            _S8(
+                    "CNSmlInternetAdapter::IsProxyRecordLockedL record being checked = %d"),
+            aRecord);
+    serviceView = iDatabase->OpenViewMatchingUintLC(iProxyServiceType, TPtrC(
+            COMMDB_ID), aRecord);
+
+    TInt aAccess(0);
+    if (serviceView != NULL)
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::IsProxyRecordLockedL():wap record exists, check for access type");
+        TInt err =
+                (((CCommsDbProtectTableView*) serviceView)->GetRecordAccess(
+                        aAccess));
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::IsProxyRecordLockedL , GetrecordAccess code is =%d and acess type of record = %d"),
+                err, aAccess);
+        CleanupStack::PopAndDestroy(serviceView);
+        if (aAccess == RDbRowSet::EReadOnly)
+            ret = ETrue;
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::IsProxyRecordLockedL():  END");
+    return ret;
+
+    }
+//----------------------------------------------------------------------
+//TBool CNSmlInternetAdapter::DoProtectProxyRecordL(TUint32 aRecord,TBool aProtect)
+// protect or unprotect proxy record of access point being altered 
+//----------------------------------------------------------------------
+
+
+TInt CNSmlInternetAdapter::DoProtectServiceRecordL(TUint32 aRecord,
+        TBool aProtect)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::DoProtectProxyRecordL():  BEGIN");
+    DBG_ARGS8(
+            _S8(
+                    "CNSmlInternetAdapter::DoProtectProxyRecordL , record and protect value  =%d  = %d"),
+            aRecord, aProtect);
+    TInt err = KErrNone;
+
+    CCommsDbTableView* serviceView;
+    serviceView = iDatabase->OpenViewMatchingUintLC(iProxyServiceType, TPtrC(
+            COMMDB_ID), aRecord);
+    if (serviceView != NULL)
+        {
+        _DBG_FILE(
+                "CNSmlInternetAdapter::DoProtectProxyRecordL():  wap record exists");
+        if (!aProtect)
+            {
+            err
+                    = ((CCommsDbProtectTableView*) serviceView)->UnprotectRecord();
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlInternetAdapter::DoProtectProxyRecordL ,error code of Unprotectrecord = %d"),
+                    err);
+            }
+
+        else
+            {
+            err = ((CCommsDbProtectTableView*) serviceView)->ProtectRecord();
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlInternetAdapter::DoProtectProxyRecordL ,error code of ProtectRecord = %d"),
+                    err);
+            }
+
+        CleanupStack::PopAndDestroy(serviceView);
+        }
+
+    _DBG_FILE("CNSmlInternetAdapter::DoProtectProxyRecordL():  END");
+    return err;
+    }
+//--------------------------------------------------------------------
+//TInt CNSmlInternetAdapter::IsAPUriFormatMatchPredefined(const TDesC8 & aURI)
+//
+//-------------------------------------------------------------------
+
+
+TBool CNSmlInternetAdapter::IsAPUriFormatMatchPredefined(const TDesC8 & aURI)
+    {
+    if (aURI.Match(_L8("AP/APId*")) != KErrNotFound || aURI.Match(_L8(
+            "AP/APId*/NAPDef/NAPId*")) != KErrNotFound)
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+
+    }
+//--------------------------------------------------------------------
+//TInt CNSmlInternetAdapter::ConstructTreeL(const TDesC8& aURI)
+//
+//-------------------------------------------------------------------
+
+
+TUint32 CNSmlInternetAdapter::ConstructTreeL(const TDesC8& aURI)
+    {
+    _DBG_FILE("CNSmlInternetAdapter::ConstructTreeL(): AP begin");
+    TUint32 returnLuid = 0; // IAP doesn't exist
+
+    CCommsDbTableView* apView = iDatabase->OpenTableLC(TPtrC(IAP));
+
+    TInt errorCode = apView->GotoFirstRecord();
+
+    while (errorCode == KErrNone)
+        {
+        TUint32 lValue;
+        TBool validService = EFalse;
+        apView->ReadUintL(TPtrC(COMMDB_ID), lValue);
+
+        TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+        apView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+        TUint32 bearerId = 0;
+        apView->ReadUintL(TPtrC(IAP_BEARER), bearerId);
+        //
+        // Skip other service types than GSM outgoing
+        //
+        if (serviceType == TPtrC(OUTGOING_GPRS) || serviceType == TPtrC(
+                INCOMING_GPRS))
+            {
+            validService = ETrue;
+            }
+
+        else if (serviceType == TPtrC(LAN_SERVICE) && bearerId > 0)
+            {
+            validService = ETrue;
+            }
+        else if (serviceType == TPtrC(VPN_SERVICE))
+            {
+            validService = ETrue;
+            }
+
+        if (validService)
+            {
+            // Skip others
+            //
+            //  Check if in aPreviousURISegmentList
+            // 
+            TBool skipToNextIAP = EFalse;
+            // KNSmlDMStart includes start text for URISeg
+            TBuf8<20> addAPURI; // AP/APIdnnn , nnn = profileid
+            addAPURI.Append(_L8("AP/APId"));
+            addAPURI.AppendNumFixedWidth(lValue, EDecimal, 3);
+
+            TBuf8<16> addLUID;
+            _LIT8(KFormat, "%d");
+            addLUID.Format(KFormat, lValue);
+
+            HBufC8* mapInfo = iCallBack->GetLuidAllocL(addAPURI);
+            CleanupStack::PushL(mapInfo);
+            if (mapInfo->Length() == 0)
+                {
+                iCallBack->SetMappingL(addAPURI, addLUID);
+                if (aURI.Find(addAPURI) >= 0)
+                    {
+                    returnLuid = lValue;
+                    iPrevLUID = lValue;
+                    }
+                }
+            else
+                {
+                skipToNextIAP = ETrue;
+                }
+            CleanupStack::PopAndDestroy(mapInfo);
+
+            if (!skipToNextIAP)
+                {
+                // Add the NAPDef also 
+
+                TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+                TUint32 serviceId(NULL);
+
+                CCommsDbTableView* napdefView =
+                        iDatabase->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(
+                                COMMDB_ID), lValue);
+
+                errorCode = napdefView->GotoFirstRecord();
+                if (errorCode == KErrNone)
+                    {
+                    napdefView->ReadTextL(TPtrC(IAP_SERVICE_TYPE),
+                            serviceType);
+                    napdefView->ReadUintL(TPtrC(IAP_SERVICE), serviceId); // ID 
+                    }
+
+                CCommsDbTableView* tableView =
+                        iDatabase->OpenViewMatchingUintLC(serviceType, TPtrC(
+                                COMMDB_ID), serviceId);
+
+                errorCode = tableView->GotoFirstRecord();
+
+                while (errorCode == KErrNone)
+                    {
+                    TUint32 lValue;
+                    tableView->ReadUintL(TPtrC(COMMDB_ID), lValue);
+                    //
+                    //  Check if in aPreviousURISegmentList
+                    // 
+
+                    _LIT8(Kprev, "NAPId");
+                    TBuf8<15> addNAME(Kprev); // APIdnnn , nnn = profileid
+                    addNAME.AppendNumFixedWidth(lValue, EDecimal, 3);
+
+                    _LIT8(Kprev2, "/NAPDef/NAPId");
+                    TBuf8<80> addURI; // AP/xxx/NAPDef/NAPIdnnn , nnn = id nbr
+                    addURI.Append(addAPURI);
+                    addURI.Append(Kprev2);
+                    addURI.AppendNumFixedWidth(lValue, EDecimal, 3);
+
+                    TBuf8<16> addLUID;
+                    _LIT8(KFormat, "%d");
+                    addLUID.Format(KFormat, lValue);
+
+                    HBufC8* mapInfo = iCallBack->GetLuidAllocL(addURI);
+                    CleanupStack::PushL(mapInfo);
+                    if (mapInfo->Length() == 0)
+                        {
+                        // Also added to mapping
+                        iCallBack->SetMappingL(addURI, addLUID);
+                        if (aURI.Find(addURI) >= 0)
+                            returnLuid = lValue;
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::ConstructTreeL(): Set NAPDef Mapping ");
+
+                        TBuf<KCommsDbSvrMaxFieldLength> columnValue;
+                        TBuf8<16> addDNSLUID;
+                        TBuf8<80> addDNSURI; // AP/xxx/NAPDef/DNSAddr/DNSx
+                        _LIT8(KFormat, "%d");
+                        tableView->ReadTextL(TPtrC(SERVICE_IP_NAME_SERVER1),
+                                columnValue);
+
+                        if ((columnValue.Length() > 0))
+                            {
+                            _LIT8(Kprev2, "/DNSAddr/DNS1");
+                            addDNSURI.Append(addURI);
+                            addDNSURI.Append(Kprev2);
+                            addLUID.Format(KFormat, DnsToLuid(
+                                    UriUtils::EIPv4Host, 1));
+                            iCallBack->SetMappingL(addDNSURI, addLUID);
+                            if (aURI.Find(addDNSURI) >= 0)
+                                returnLuid
+                                        = DnsToLuid(UriUtils::EIPv4Host, 1);
+                            addDNSURI.Zero();
+                            }
+
+                        tableView->ReadTextL(TPtrC(SERVICE_IP_NAME_SERVER2),
+                                columnValue);
+                        if (columnValue.Length() > 0)
+                            {
+                            _LIT8(Kprev2, "/DNSAddr/DNS2");
+                            addDNSURI.Append(addURI);
+                            addDNSURI.Append(Kprev2);
+                            addLUID.Format(KFormat, DnsToLuid(
+                                    UriUtils::EIPv4Host, 2));
+                            iCallBack->SetMappingL(addDNSURI, addLUID);
+                            if (aURI.Find(addDNSURI) >= 0)
+                                returnLuid
+                                        = DnsToLuid(UriUtils::EIPv4Host, 2);
+                            addDNSURI.Zero();
+                            }
+
+                        tableView->ReadTextL(TPtrC(SERVICE_IP6_NAME_SERVER1),
+                                columnValue);
+                        if (columnValue.Length() > 0)
+                            {
+                            _LIT8(Kprev2, "/DNSAddr/DNS3");
+                            addDNSURI.Append(addURI);
+                            addDNSURI.Append(Kprev2);
+                            addLUID.Format(KFormat, DnsToLuid(
+                                    UriUtils::EIPv6Host, 1));
+                            iCallBack->SetMappingL(addDNSURI, addLUID);
+                            if (aURI.Find(addDNSURI) >= 0)
+                                returnLuid
+                                        = DnsToLuid(UriUtils::EIPv6Host, 1);
+                            addDNSURI.Zero();
+                            }
+                        tableView->ReadTextL(TPtrC(SERVICE_IP6_NAME_SERVER2),
+                                columnValue);
+                        if (columnValue.Length() > 0)
+                            {
+                            _LIT8(Kprev2, "/DNSAddr/DNS4");
+                            addDNSURI.Append(addURI);
+                            addDNSURI.Append(Kprev2);
+                            addLUID.Format(KFormat, DnsToLuid(
+                                    UriUtils::EIPv6Host, 2));
+                            iCallBack->SetMappingL(addDNSURI, addLUID);
+                            if (aURI.Find(addDNSURI) >= 0)
+                                returnLuid
+                                        = DnsToLuid(UriUtils::EIPv6Host, 2);
+                            addDNSURI.Zero();
+                            }
+                        _DBG_FILE(
+                                "CNSmlInternetAdapter::ConstructTreeL(): Set DNS Mapping ");
+
+                        TUint32 nwID = 0;
+                        napdefView->ReadUintL(TPtrC(IAP_NETWORK), nwID); // Networks luid
+
+                        CCommsDbTableView* nwView =
+                                iDatabase->OpenViewMatchingUintLC(TPtrC(
+                                        NETWORK), TPtrC(COMMDB_ID), nwID);
+
+                        errorCode = nwView->GotoFirstRecord();
+
+                        if (errorCode == KErrNone)
+                            {
+                            _LIT8(Kprev2, "/Networks/NwId");
+                            TBuf8<80> addNwURI; // AP/xxx/NAPDef/xxx/Networks/NwIdnnn , nnn = id nbr
+                            addNwURI.Append(addURI);
+                            addNwURI.Append(Kprev2);
+                            addNwURI.AppendNumFixedWidth(nwID, EDecimal, 3);
+                            TBuf8<16> addNwLUID;
+                            _LIT8(KFormat, "%d");
+                            addNwLUID.Format(KFormat, nwID);
+                            HBufC8* mapInfo = iCallBack->GetLuidAllocL(
+                                    addNwURI);
+                            CleanupStack::PushL(mapInfo);
+
+                            if (mapInfo->Length() == 0)
+                                {
+                                // Also added to mapping
+                                iCallBack->SetMappingL(addNwURI, addNwLUID);
+                                if (aURI.Find(addNwURI) >= 0)
+                                    returnLuid = nwID;
+                                _DBG_FILE(
+                                        "CNSmlInternetAdapter::ConstructTreeL(): Set Networks Mapping ");
+                                }
+                            CleanupStack::PopAndDestroy(mapInfo);
+                            }
+                        CleanupStack::PopAndDestroy(); // nwView              
+
+                        if (iWlanSupported)
+                            {
+                            // Check WLAN node
+                            if (serviceType == TPtrC(LAN_SERVICE))
+                                {
+                                TUint32 wlanID = serviceId;
+                                _LIT8(Kprev2, "/WLAN/WLId");
+                                TBuf8<80> addWlanURI; // AP/xxx/NAPDef/xxx/WLAN/WLIdnnn , nnn = id nbr
+                                addWlanURI.Append(addURI);
+                                addWlanURI.Append(Kprev2);
+                                addWlanURI.AppendNumFixedWidth(wlanID,
+                                        EDecimal, 3);
+                                TBuf8<16> addWlanLUID;
+                                _LIT8(KFormat, "%d");
+                                addWlanLUID.Format(KFormat, wlanID);
+                                HBufC8* mapInfo = iCallBack->GetLuidAllocL(
+                                        addWlanURI);
+                                CleanupStack::PushL(mapInfo);
+
+                                if (mapInfo->Length() == 0)
+                                    {
+                                    // Also added to mapping
+                                    iCallBack->SetMappingL(addWlanURI,
+                                            addWlanLUID);
+                                    if (aURI.Find(addWlanURI) >= 0)
+                                        returnLuid = wlanID;
+                                    _DBG_FILE(
+                                            "CNSmlInternetAdapter::ConstructTreeL(): Set WLAN Mapping ");
+
+                                    TBuf<KCommsDbSvrMaxFieldLength> value;
+                                    TBuf8<16> addWkLUID;
+                                    TBuf8<80> addWkURI; // AP/xxx/NAPDef/xxx/WLAN/xxx/WEPKey/WKIdn, n = id nbr
+
+                                    for (TInt value = 1; value <= 4; value++)
+                                        {
+                                        _LIT8(Kprev2, "/WEPKey/WKId");
+                                        addWkURI.Append(addWlanURI);
+                                        addWkURI.Append(Kprev2);
+                                        addWkURI.AppendNumFixedWidth(value,
+                                                EDecimal, 1);
+                                        _LIT8(KFormat, "%d");
+                                        addWkLUID.Format(KFormat, (1000
+                                                * value) + value);
+                                        iCallBack->SetMappingL(addWkURI,
+                                                addWkLUID);
+                                        if (aURI.Find(addWkURI) >= 0)
+                                            returnLuid = (1000 * value)
+                                                    + value;
+                                        addWkURI.Zero();
+                                        }
+                                    }
+                                CleanupStack::PopAndDestroy(mapInfo);
+                                }
+                            }
+
+                        //Check Bearer node 
+
+                        CCommsDbTableView* bView =
+                                iDatabase->OpenViewMatchingUintLC(TPtrC(
+                                        NETWORK), TPtrC(COMMDB_ID), lValue);
+                        errorCode = bView->GotoFirstRecord();
+
+                        if (errorCode == KErrNone)
+                            {
+                            _LIT8(Kprev2, "/Bearer/BId");
+                            TBuf8<80> addbURI; // AP/xxx/NAPDef/xxx/Bearer/BIdnnn , nnn = id nbr
+                            addbURI.Append(addURI);
+                            addbURI.Append(Kprev2);
+                            addbURI.AppendNumFixedWidth(lValue, EDecimal, 3);
+                            TBuf8<16> addbLUID;
+                            _LIT8(KFormat, "%d");
+                            addbLUID.Format(KFormat, lValue);
+                            HBufC8* mapInfo = iCallBack->GetLuidAllocL(
+                                    addbURI);
+                            CleanupStack::PushL(mapInfo);
+
+                            if (mapInfo->Length() == 0)
+                                {
+                                // Also added to mapping
+                                iCallBack->SetMappingL(addbURI, addbLUID);
+                                if (aURI.Find(addbURI) >= 0)
+                                    returnLuid = lValue;
+                                _DBG_FILE(
+                                        "CNSmlInternetAdapter::ConstructTreeL(): Set Bearer Mapping ");
+                                }
+                            CleanupStack::PopAndDestroy(mapInfo);
+                            }
+                        CleanupStack::PopAndDestroy(); // bView 
+
+                        //Check NAPAuthInf node NAPAuthInf/AUId
+
+                        CCommsDbTableView* authView =
+                                iDatabase->OpenViewMatchingUintLC(TPtrC(
+                                        NETWORK), TPtrC(COMMDB_ID), lValue);
+
+                        errorCode = authView->GotoFirstRecord();
+
+                        if (errorCode == KErrNone)
+                            {
+                            _LIT8(Kprev2, "/Bearer/BId");
+                            TBuf8<80> addauthURI; // AP/xxx/NAPDef/xxx/Bearer/BIdnnn , nnn = id nbr
+                            addauthURI.Append(addURI);
+                            addauthURI.Append(Kprev2);
+                            addauthURI.AppendNumFixedWidth(lValue, EDecimal,
+                                    3);
+                            TBuf8<16> addauthLUID;
+                            _LIT8(KFormat, "%d");
+                            addauthLUID.Format(KFormat, lValue);
+                            HBufC8* mapInfo = iCallBack->GetLuidAllocL(
+                                    addauthURI);
+                            CleanupStack::PushL(mapInfo);
+
+                            if (mapInfo->Length() == 0)
+                                {
+                                // Also added to mapping
+                                iCallBack->SetMappingL(addauthURI,
+                                        addauthLUID);
+                                if (aURI.Find(addauthURI) >= 0)
+                                    returnLuid = lValue;
+                                _DBG_FILE(
+                                        "CNSmlInternetAdapter::ConstructTreeL(): Set NAPAuthInf Mapping ");
+                                }
+                            CleanupStack::PopAndDestroy(mapInfo);
+                            }
+                        CleanupStack::PopAndDestroy(); // authView  
+
+                        //Check Proxy node          
+
+                        CCommsDbTableView* pxView =
+                                iDatabase->OpenViewMatchingTextLC(TPtrC(
+                                        PROXIES), TPtrC(PROXY_SERVICE_TYPE),
+                                        serviceType);
+
+                        errorCode = pxView->GotoFirstRecord();
+                        if (errorCode == KErrNone)
+                            {
+                            while (errorCode == KErrNone)
+                                {
+                                TUint32 lProxyIspId;
+                                TUint32 lProxyId;
+                                pxView->ReadUintL(TPtrC(PROXY_ISP),
+                                        lProxyIspId);
+                                if (lProxyIspId == serviceId) //ServiceIsp) // Right value ISP
+                                    {
+                                    pxView->ReadUintL(TPtrC(COMMDB_ID),
+                                            lProxyId);
+
+                                    _LIT8(Kprev2, "/Px/PXId");
+                                    TBuf8<80> addURI; // AP/xxx/Px/PXIdnnn , nnn = id nbr
+                                    addURI.Append(addAPURI);
+                                    addURI.Append(Kprev2);
+                                    addURI.AppendNumFixedWidth(lProxyId,
+                                            EDecimal, 3);
+
+                                    TBuf8<16> addLUID;
+                                    _LIT8(KFormat, "%d");
+                                    addLUID.Format(KFormat,
+                                            KNSmlApProxyLowerBase + lProxyId); // 100000 + lProxyId
+                                    HBufC8* mapInfo =
+                                            iCallBack->GetLuidAllocL(addURI);
+                                    CleanupStack::PushL(mapInfo);
+
+                                    if (mapInfo->Length() == 0)
+                                        {
+                                        // Also added to mapping
+                                        iCallBack->SetMappingL(addURI,
+                                                addLUID);
+                                        if (aURI.Find(addURI) >= 0)
+                                            returnLuid
+                                                    = KNSmlApProxyLowerBase
+                                                            + lProxyId;
+                                        _DBG_FILE(
+                                                "CNSmlInternetAdapter::ConstructTreeL(): Set Proxy Mapping ");
+                                        _LIT8(KProxy, "/Port/PROXY");
+                                        TBuf8<80> addPortURI; // AP/xxx/Px/Port/PROXY
+                                        addPortURI.Append(addURI);
+                                        addPortURI.Append(KProxy);
+                                        TBuf8<16> addPortLUID;
+                                        _LIT8(KFormat, "%d");
+                                        addPortLUID.Format(KFormat, 1);
+                                        iCallBack->SetMappingL(addPortURI,
+                                                addPortLUID);
+                                        if (aURI.Find(addPortURI) >= 0)
+                                            returnLuid = 1;
+                                        }
+                                    CleanupStack::PopAndDestroy(mapInfo);
+                                    }
+                                errorCode = pxView->GotoNextRecord();
+                                }
+                            }
+                        CleanupStack::PopAndDestroy();//Pxview             
+                        }
+                    CleanupStack::PopAndDestroy(mapInfo);
+                    errorCode = tableView->GotoNextRecord();
+                    }
+                CleanupStack::PopAndDestroy();//tableview
+                CleanupStack::PopAndDestroy();//napdefview
+                }
+            }
+        errorCode = apView->GotoNextRecord();
+        }
+    CleanupStack::PopAndDestroy(); // apView
+    _DBG_FILE("CNSmlInternetAdapter::ConstructTreeL(): AP end");
+    return returnLuid;
+    }
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldminternet/src/NSmlInternetAdapter.rss	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,45 @@
+CHARACTER_SET UTF8/*
+* 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:   Internet-settings resources
+*
+*/
+
+ 
+
+
+#include <registryinfo.rh>
+#include "nsmldmconstants.h"
+
+RESOURCE REGISTRY_INFO theRegistryInfo
+  {
+  dll_uid = 0x101F6DEA; //The DLL's 3rd UID.
+  interfaces = 
+      {
+      INTERFACE_INFO
+          {
+          interface_uid = KNSmlDMInterfaceUid; // DM interface UID
+          implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x101F6DE2; // DM Internet Adapter
+                version_no = 1; 
+                display_name = "";
+                default_data = "";
+                opaque_data = "";
+                }
+            };
+          }
+      };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldminternet/src/NSmlWLanAdapter.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,4379 @@
+/*
+ * Copyright (c) 2002-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:   Wlan Adapter
+ *
+ */
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <commsdat_partner.h>
+#endif
+#include "NSmlWLanAdapter.h"
+#include "NSmlWlanSettings.h"
+#include "nsmldebug.h"
+#include <commdb.h>
+#include <utf.h>
+#include <cdbstore.h>
+#include <cdbcols.h>
+#include <EapType.h>
+#include <nsmldmuri.h>
+#include <EapExpandedType.h>
+#include <EapGeneralSettings.h>
+
+#ifndef __WINS__
+// This lowers the unnecessary compiler warning (armv5) to remark.
+// "Warning:  #174-D: expression has no effect..." is caused by 
+// DBG_ARGS8 macro in no-debug builds.
+#pragma diag_remark 174
+#endif
+
+const TInt KMaxBuf = 255;
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::NewL( )
+//-----------------------------------------------------------------------------
+CNSmlWLanAdapter* CNSmlWLanAdapter::NewL(MSmlDmCallback* aDmCallback,
+        CCommsDatabase& aDatabase)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::NewL(): begin");
+
+    CNSmlWLanAdapter* self = NewLC(aDmCallback, aDatabase);
+    CleanupStack::Pop(self);
+
+    _DBG_FILE("CNSmlWLanAdapter::NewL(): end");
+    return self;
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::NewLC( )
+//-----------------------------------------------------------------------------
+CNSmlWLanAdapter* CNSmlWLanAdapter::NewLC(MSmlDmCallback* aDmCallback,
+        CCommsDatabase& aDatabase)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::NewLC(): begin");
+
+    CNSmlWLanAdapter* self = new (ELeave) CNSmlWLanAdapter(aDmCallback,
+            aDatabase);
+    CleanupStack::PushL(self);
+
+    self->iCallBack = aDmCallback;
+    self->ConstructL(aDatabase);
+
+    _DBG_FILE("CNSmlWLanAdapter::NewLC(): end");
+    return self;
+    }
+
+//-----------------------------------------------------------------------------
+// void CNSmlWLanAdapter::ConstructL( )
+// Second phase constructor
+//-----------------------------------------------------------------------------
+void CNSmlWLanAdapter::ConstructL(CCommsDatabase& aDatabase)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::ConstructL(): begin");
+
+    iWlanSettings = CWlanSettings::NewL(aDatabase);
+    iBuffer = new (ELeave) CArrayFixFlat<TNSmlWepKeyBufferElement> (
+            KNSmlWepKeyGranularity);
+    iSettings = new (ELeave) TWlanSettings;
+    iEAPSettings = new (ELeave) EAPSettings;
+
+    _DBG_FILE("CNSmlWLanAdapter::ConstructL(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter::CNSmlWLanAdapter( )
+// Constructor
+//-----------------------------------------------------------------------------
+CNSmlWLanAdapter::CNSmlWLanAdapter(TAny* aEcomArguments,
+        CCommsDatabase& aDatabase) :
+    CSmlDmAdapter(aEcomArguments), iDatabase(aDatabase)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::CNSmlWLanAdapter(): begin");
+    _DBG_FILE("CNSmlWLanAdapter::CNSmlWLanAdapter(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter::~CNSmlWLanAdapter( )
+// Destructor
+//-----------------------------------------------------------------------------
+CNSmlWLanAdapter::~CNSmlWLanAdapter()
+    {
+    _DBG_FILE("CNSmlWLanAdapter::~CNSmlWLanAdapter(): begin");
+
+    if (iBuffer)
+        {
+
+        for (TInt index = 0; index < iBuffer->Count(); index++)
+            {
+            delete iBuffer->At(index).iUri;
+            delete iBuffer->At(index).iData;
+
+            iBuffer->Delete(index);
+            }
+
+        iBuffer->Reset();
+        delete iBuffer;
+
+        }
+    delete iWlanSettings;
+    delete iSettings;
+
+    TRAP_IGNORE(DeleteEAPStructL());
+
+    for (TInt i = 0; i < iEAPBuffer.Count(); i++)
+        {
+        iEAPBuffer[i]->iStatusRefArray.Close();
+        iEAPBuffer[i]->iEAPSettings->iEnabledEncapsulatedEAPExpandedTypes.Close();
+        iEAPBuffer[i]->iEAPSettings->iDisabledEncapsulatedEAPExpandedTypes.Close();
+        iEAPBuffer[i]->iEAPSettings->iCipherSuites.Close();
+        delete iEAPBuffer[i]->iEAPSettings;
+        iEAPBuffer[i]->iEAPSettings = NULL;
+        }
+    iEAPBuffer.ResetAndDestroy();
+
+    TInt count = iSecondaryBuffer.Count();
+    for (TInt index = 0; index < count; index++)
+        {
+        delete iSecondaryBuffer[index];
+        }
+
+    iSecondaryBuffer.Reset();
+
+    _DBG_FILE("CNSmlWLanAdapter::~CNSmlWLanAdapter(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::DDFVersionL( CBufBase& aDDFVersion )
+//-----------------------------------------------------------------------------
+void CNSmlWLanAdapter::DDFVersionL(CBufBase& aDDFVersion)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::DDFVersionL(): begin");
+
+    aDDFVersion.InsertL(0, KNSmlWLanAdapterDDFversion);
+
+    _DBG_FILE("CNSmlWLanAdapter::DDFVersionL(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::DDFStructureL( MSmlDmDDFObject& aDDF )
+//-----------------------------------------------------------------------------
+void CNSmlWLanAdapter::DDFStructureL(MSmlDmDDFObject& aDDF)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::DDFStructureL(): begin");
+
+    TSmlDmAccessTypes *aclTypes = new (ELeave) TSmlDmAccessTypes();
+    CleanupStack::PushL(aclTypes);
+    //
+    // Set Get as acceptable operations
+    //
+    aclTypes->SetGet();
+    aclTypes->SetAdd(); // 041208 Added
+    aclTypes->SetDelete();
+    aclTypes->SetReplace();
+
+    TSmlDmAccessTypes accessTypesAll;
+    accessTypesAll.SetGet();
+    accessTypesAll.SetDelete();
+    accessTypesAll.SetAdd();
+    accessTypesAll.SetReplace();
+
+    TSmlDmAccessTypes accessTypesNoDelete;
+    accessTypesNoDelete.SetGet();
+    accessTypesNoDelete.SetAdd();
+    accessTypesNoDelete.SetReplace();
+
+    TSmlDmAccessTypes accessTypesGetAdd;
+    accessTypesGetAdd.SetGet();
+    accessTypesGetAdd.SetAdd();
+
+    TSmlDmAccessTypes accessTypesGetAddDel;
+    accessTypesGetAddDel.SetGet();
+    accessTypesGetAddDel.SetAdd();
+    accessTypesGetAddDel.SetDelete();
+    //WLAN
+    MSmlDmDDFObject& rootNode = aDDF.AddChildObjectL(KNSmlWLanNodeName);
+    FillNodeInfoL(rootNode, accessTypesGetAdd, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNSmlEmpty);
+
+    //WLAN/<x>
+    MSmlDmDDFObject& wlanNode = rootNode.AddChildObjectGroupL();
+    FillNodeInfoL(wlanNode, accessTypesGetAddDel, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNSmlEmpty);
+
+    //WLAN/<x>/SSID
+    MSmlDmDDFObject& ssid = wlanNode.AddChildObjectL(KNSmlWLanSsid);
+    FillNodeInfoL(ssid, accessTypesNoDelete, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/UsedSSID
+    MSmlDmDDFObject& usedSsid = wlanNode.AddChildObjectL(KNSmlWLanUsedSsid);
+    FillNodeInfoL(usedSsid, accessTypesNoDelete, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/SSIDHidden
+    MSmlDmDDFObject& ssidHidden = wlanNode.AddChildObjectL(
+            KNSmlWLanSsidHidden);
+    FillNodeInfoL(ssidHidden, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlEmpty);
+
+    //WLAN/<x>/NetworkMode
+    MSmlDmDDFObject& networkMode = wlanNode.AddChildObjectL(
+            KNSmlWLanNetworkMode);
+    FillNodeInfoL(networkMode, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/SecurityMode
+    MSmlDmDDFObject& securityMode = wlanNode.AddChildObjectL(
+            KNSmlWLanSecurityMode);
+    FillNodeInfoL(securityMode, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/UseWPAPSK
+    MSmlDmDDFObject& useWPAPSK = wlanNode.AddChildObjectL(KNSmlWLanUseWPAPSK);
+    FillNodeInfoL(useWPAPSK, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlEmpty);
+
+    //WLAN/<x>/WPAPreSharedKey
+    MSmlDmDDFObject& wpaPreSharedKey = wlanNode.AddChildObjectL(
+            KNSmlWLanWpaPreSharedKey);
+    FillNodeInfoL(wpaPreSharedKey, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBin, KNSmlEmpty);
+
+    //WLAN/<x>/WLANEAPList
+    MSmlDmDDFObject& wlanEapList = wlanNode.AddChildObjectL(KNSmlWLanEapList);
+    FillNodeInfoL(wlanEapList, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/WEPKeyIndex
+    MSmlDmDDFObject& wepKeyIndex =
+            wlanNode.AddChildObjectL(KNSmlWLanWepIndex);
+    FillNodeInfoL(wepKeyIndex, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EInt, KNSmlEmpty);
+
+    //WLAN/<x>/WEPAuthMode
+    MSmlDmDDFObject& wlanWepAuthMode = wlanNode.AddChildObjectL(
+            KNSmlWLanAuthMode);
+    FillNodeInfoL(wlanWepAuthMode, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EInt, KNSmlEmpty);
+
+    //WLAN/<x>/WEPKey/
+    MSmlDmDDFObject& wepKeyRoot = wlanNode.AddChildObjectL(KNSmlWLanWepKey);
+    FillNodeInfoL(wepKeyRoot, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNSmlEmpty);
+
+    //WLAN/<x>/WEPKey/<x>
+    MSmlDmDDFObject& wepKey = wepKeyRoot.AddChildObjectGroupL();
+    FillNodeInfoL(wepKey, accessTypesGetAdd, MSmlDmDDFObject::EOneOrN,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNSmlEmpty);
+
+    //WLAN/<x>/WEPKey/<x>/WEPKeyID
+    MSmlDmDDFObject& wepKeyId = wepKey.AddChildObjectL(KNSmlWLanWepKeyId);
+    FillNodeInfoL(wepKeyId, accessTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EInt, KNSmlEmpty);
+
+    //WLAN/<x>/WEPKey/<x>/Data
+    MSmlDmDDFObject& data = wepKey.AddChildObjectL(KNSmlWLanWepKeyData);
+    FillNodeInfoL(data, accessTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EBin, KNSmlEmpty);
+
+    //WLAN/<x>/SecondarySSID/
+    MSmlDmDDFObject& secondarySSidRoot = wlanNode.AddChildObjectL(
+            KNSmlWLanSecSsid);
+    FillNodeInfoL(secondarySSidRoot, accessTypesGetAdd,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNSmlEmpty);
+
+    //WLAN/<x>/SecondarySSID/<x>
+    MSmlDmDDFObject& secondarySSid = secondarySSidRoot.AddChildObjectGroupL();
+    FillNodeInfoL(secondarySSid, accessTypesGetAddDel,
+            MSmlDmDDFObject::EOneOrN, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNSmlEmpty);
+
+    //WLAN/<x>/SecondarySSID/<x>/SSID
+    MSmlDmDDFObject& secSsidId = secondarySSid.AddChildObjectL(KNSmlWLanSsid);
+    FillNodeInfoL(secSsidId, accessTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/SecondarySSID/<x>/UsedSSID
+    MSmlDmDDFObject& secUsedSsidId = secondarySSid.AddChildObjectL(
+            KNSmlWLanUsedSsid);
+    FillNodeInfoL(secUsedSsidId, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/
+    MSmlDmDDFObject& eapRoot = wlanNode.AddChildObjectL(KNSmlWLanEap);
+    FillNodeInfoL(eapRoot, accessTypesGetAdd, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>
+    MSmlDmDDFObject& eap = eapRoot.AddChildObjectGroupL();
+    FillNodeInfoL(eap, accessTypesGetAdd, MSmlDmDDFObject::EOneOrN,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::ENode, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/EAPType
+    MSmlDmDDFObject& eapType = eap.AddChildObjectL(KNSmlWLanEapType);
+    FillNodeInfoL(eapType, accessTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/Username
+    MSmlDmDDFObject& eapUsername = eap.AddChildObjectL(KNSmlWLanUsername);
+    FillNodeInfoL(eapUsername, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/Password
+    MSmlDmDDFObject& eapPassword = eap.AddChildObjectL(KNSmlWLanPassword);
+    FillNodeInfoL(eapPassword, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/Realm
+    MSmlDmDDFObject& eapRealm = eap.AddChildObjectL(KNSmlWLanRealm);
+    FillNodeInfoL(eapRealm, accessTypesNoDelete, MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/UsePseudonym
+    MSmlDmDDFObject& eapPseudo = eap.AddChildObjectL(KNSmlWLanUsePseudonym);
+    FillNodeInfoL(eapPseudo, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/Encapsulation
+    // Encapsulation is not supported using this parameter. It is done
+    // with */EAP/EAPIdxxx-yyy/* where xxx is the encapsulated and yyy the encapsulating method.
+    /*MSmlDmDDFObject& eapEncapsulation = eap.AddChildObjectL( KNSmlWLanEncapsulation );
+     FillNodeInfoL( eapEncapsulation,
+     accessTypesNoDelete,
+     MSmlDmDDFObject::EZeroOrOne,
+     MSmlDmDDFObject::EDynamic,
+     MSmlDmDDFObject::EChr,
+     KNSmlEmpty );                           */
+
+    //WLAN/<x>/EAP/<x>/VerifyCertRealm
+    MSmlDmDDFObject& eapVerifyCertRealm = eap.AddChildObjectL(
+            KNSmlWLanVerifyCertRealm);
+    FillNodeInfoL(eapVerifyCertRealm, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/RequireClientAuthentication
+    MSmlDmDDFObject& eapRequireClientAuthentication = eap.AddChildObjectL(
+            KNSmlWLanRequireClientAuthentication);
+    FillNodeInfoL(eapRequireClientAuthentication, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/SessionValidityTime
+    MSmlDmDDFObject& eapSessionValidityTime = eap.AddChildObjectL(
+            KNSmlWLanSessionValidityTime);
+    FillNodeInfoL(eapSessionValidityTime, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/CipherSuite
+    MSmlDmDDFObject& eapCipherSuite = eap.AddChildObjectL(
+            KNSmlWLanCipherSuite);
+    FillNodeInfoL(eapCipherSuite, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/AllowPEAPv0
+    MSmlDmDDFObject& eapAllowPEAPv0 = eap.AddChildObjectL(
+            KNSmlWLanAllowPEAPv0);
+    FillNodeInfoL(eapAllowPEAPv0, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/AllowPEAPv1
+    MSmlDmDDFObject& eapAllowPEAPv1 = eap.AddChildObjectL(
+            KNSmlWLanAllowPEAPv1);
+    FillNodeInfoL(eapAllowPEAPv1, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/AllowPEAPv2
+    MSmlDmDDFObject& eapAllowPEAPv2 = eap.AddChildObjectL(
+            KNSmlWLanAllowPEAPv2);
+    FillNodeInfoL(eapAllowPEAPv2, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool, KNSmlEmpty);
+
+#ifdef FF_WLAN_EXTENSIONS 
+
+    //WLAN/<x>/EAP/<x>/AuthProvModeAllowed
+    MSmlDmDDFObject& authProvMode = eap.AddChildObjectL( KNSmlWLanAuthProvMode );
+    FillNodeInfoL( authProvMode,
+            accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool,
+            KNSmlEmpty );
+
+    //WLAN/<x>/EAP/<x>/UnauthProvModeAllowed
+    MSmlDmDDFObject& unauthProvMode = eap.AddChildObjectL( KNSmlWLanUnauthProvMode );
+    FillNodeInfoL( unauthProvMode,
+            accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool,
+            KNSmlEmpty );
+
+    //WLAN/<x>/EAP/<x>/PACGroupReference
+    MSmlDmDDFObject& pacGroupRef = eap.AddChildObjectL( KNSmlWLanPACGroupRef );
+    FillNodeInfoL( pacGroupRef,
+            accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr,
+            KNSmlEmpty );
+
+    //WLAN/<x>/EAP/<x>/WarnADHPNoPAC
+    MSmlDmDDFObject& warnADHPNoPAC = eap.AddChildObjectL( KNSmlWLanWarnADHPNoPAC );
+    FillNodeInfoL( warnADHPNoPAC,
+            accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool,
+            KNSmlEmpty );
+
+    //WLAN/<x>/EAP/<x>/WarnADHPNoMatchingPAC
+    MSmlDmDDFObject& warnADHPNoMatchingPAC = eap.AddChildObjectL( KNSmlWLanWarnADHPNoMatchPAC );
+    FillNodeInfoL( warnADHPNoMatchingPAC,
+            accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool,
+            KNSmlEmpty );
+
+    //WLAN/<x>/EAP/<x>/WarnNotDefaultServer
+    MSmlDmDDFObject& warnNoDefServ = eap.AddChildObjectL( KNSmlWLanWarnNotDefaultSrv );
+    FillNodeInfoL( warnNoDefServ,
+            accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne,
+            MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EBool,
+            KNSmlEmpty );
+
+#endif           
+
+    //WLAN/<x>/EAP/<x>/Certificate
+    MSmlDmDDFObject& eapCertificateRoot = eap.AddChildObjectL(
+            KNSmlWLanCertificate);
+    FillNodeInfoL(eapCertificateRoot, accessTypesGetAdd,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/Certificate/<x>
+    MSmlDmDDFObject& eapCertificate =
+            eapCertificateRoot.AddChildObjectGroupL();
+    FillNodeInfoL(eapCertificate, accessTypesGetAdd,
+            MSmlDmDDFObject::EOneOrMore, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::ENode, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/Certificate/<x>/IssuerName
+    MSmlDmDDFObject& eapIssuerName = eapCertificate.AddChildObjectL(
+            KNSmlWLanIssuerName);
+    FillNodeInfoL(eapIssuerName, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/Certificate/<x>/SubjectName
+    MSmlDmDDFObject& eapSubjectName = eapCertificate.AddChildObjectL(
+            KNSmlWLanSubjectName);
+    FillNodeInfoL(eapSubjectName, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/Certificate/<x>/CertType
+    MSmlDmDDFObject& eapCertType = eapCertificate.AddChildObjectL(
+            KNSmlWLanCertType);
+    FillNodeInfoL(eapCertType, accessTypesNoDelete, MSmlDmDDFObject::EOne,
+            MSmlDmDDFObject::EDynamic, MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/Certificate/<x>/SerialNumber
+    MSmlDmDDFObject& eapSerialNumber = eapCertificate.AddChildObjectL(
+            KNSmlWLanSerialNumber);
+    FillNodeInfoL(eapSerialNumber, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/Certificate/<x>/SubjectKeyId
+    MSmlDmDDFObject& eapSubjectKeyId = eapCertificate.AddChildObjectL(
+            KNSmlWLanSubjectKeyId);
+    FillNodeInfoL(eapSubjectKeyId, accessTypesNoDelete,
+            MSmlDmDDFObject::EOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    //WLAN/<x>/EAP/<x>/Certificate/<x>/Fingerprint
+    MSmlDmDDFObject& eapFingerprint = eapCertificate.AddChildObjectL(
+            KNSmlWLanFingerprint);
+    FillNodeInfoL(eapFingerprint, accessTypesNoDelete,
+            MSmlDmDDFObject::EZeroOrOne, MSmlDmDDFObject::EDynamic,
+            MSmlDmDDFObject::EChr, KNSmlEmpty);
+
+    CleanupStack::PopAndDestroy(); //aclTypes
+
+    _DBG_FILE("CNSmlWLanAdapter::DDFStructureL(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::AddLeafObjectL( const TDesC& aURI,const 
+// TDesC& aParentLUID, const TDesC8& aObject, const TDesC& aType, 
+// const TInt aStatusRef )
+//-----------------------------------------------------------------------------
+void CNSmlWLanAdapter::AddLeafObjectL(const TDesC8& aURI,
+        const TDesC8& aParentLUID, const TDesC8& aObject,
+        const TDesC8& /*aType*/, const TInt aStatusRef)
+    {
+    DBG_ARGS8(_S8("CNSmlWLanAdapter::AddLeafObjectL - <%S> <%S> <%S>"),
+            &aURI, &aParentLUID, &aObject);
+
+    TInt uriSegs = NumOfUriSegs(aURI);
+    TInt luid = GetIdFromLuid(aParentLUID);
+    TInt err(KErrNone);
+    TPtrC8 lastUriSeg = GetLastUriSeg(aURI);
+
+    TInt eapIndex(0);
+
+    TInt eapId = GetEAPIdFromUri(aURI);
+    if (eapId == KErrNotFound)
+        {
+        _DBG_FILE("CNSmlWLanAdapter::AddLeafObjectL(): Non-EAP setting.");
+        if (luid == KErrNotFound)
+            {
+            return;
+            }
+        err = iWlanSettings->GetWlanSettings(luid, *iSettings);
+        }
+    else
+        {
+        _DBG_FILE("CNSmlWLanAdapter::AddLeafObjectL(): EAP setting.");
+        TInt encapsEapId = GetEncapsEAPIdFromUri(aURI);
+        if (encapsEapId == KErrNotFound)
+            {
+            _DBG_FILE(
+                    "CNSmlWLanAdapter::AddLeafObjectL(): Does not have encapsulation id xx-xx.");
+            encapsEapId = EEapNone;
+            }
+        // append it to the appropriate list ('+' enabled, '-' disabled)
+        _LIT8(KPadding, "\xFE\0\0\0\0\0\0");
+        _LIT8(KMsChapV2Padding, "\xFE\xFF\xFF\xFF\0\0\0");
+        const TInt KPlainMsChapV2ImplUid = 99;
+
+        TBuf8<KExpandedEapIdLength> cmpbuf;
+        if (eapId == KPlainMsChapV2ImplUid)
+            {
+            cmpbuf.Append(KMsChapV2Padding);
+            }
+        else
+            {
+            cmpbuf.Append(KPadding);
+            }
+        cmpbuf.Append(eapId);
+        TEapExpandedType expandedTypecmbuf(cmpbuf);
+
+        TBuf8<KExpandedEapIdLength> encapscmpbuf;
+        if (encapsEapId == KPlainMsChapV2ImplUid)
+            {
+            encapscmpbuf.Append(KMsChapV2Padding);
+            }
+        else
+            {
+            encapscmpbuf.Append(KPadding);
+            }
+        encapscmpbuf.Append(encapsEapId);
+        TEapExpandedType expandedTypeencapscmbuf(encapscmpbuf);
+
+        TInt i(0);
+        // This is EAP addition. Check if the buffer for this EAP already exists
+        for (i = 0; i < iEAPBuffer.Count(); i++)
+            {
+            if ((expandedTypecmbuf.Compare(
+                    iEAPBuffer[i]->iEAPSettings->iEAPExpandedType) == 0)
+                    && (expandedTypeencapscmbuf.Compare(
+                            iEAPBuffer[i]->iEncapsulatingExpandedEapId) == 0))
+                {
+                // The correct buffer was found.     			
+                _DBG_FILE(
+                        "CNSmlWLanAdapter::AddLeafObjectL(): Found existing buffer.");
+                eapIndex = i;
+                break;
+                }
+            }
+        if (i == iEAPBuffer.Count())
+            {
+            DBG_ARGS8(
+                    _S8(
+                            "CNSmlWLanAdapter::AddLeafObjectL(): No buffer found. Create new: <%d>-<%d>"),
+                    eapId, encapsEapId);
+            // Buffer was not found. Create new.
+            TInt WLANServiceId = GetServiceIdFromUriL(aURI);
+
+            if (WLANServiceId == KErrNotFound)
+                {
+                _DBG_FILE(
+                        "CNSmlWLanAdapter::AddLeafObjectL(): Could not find WLAN service ID from URI.");
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                return;
+                }
+
+            TNSmlEAPBufferElement* buffer =
+                    new (ELeave) TNSmlEAPBufferElement;
+            CleanupStack::PushL(buffer);
+
+            buffer->iEAPSettings = new (ELeave) EAPSettings;
+            CleanupStack::PushL(buffer->iEAPSettings);
+
+            // append it to the appropriate list ('+' enabled, '-' disabled)
+            _LIT8(KPadding, "\xFE\0\0\0\0\0\0");
+            _LIT8(KMsChapV2Padding, "\xFE\xFF\xFF\xFF\0\0\0");
+            const TInt KPlainMsChapV2ImplUid = 99;
+
+            TBuf8<KExpandedEapIdLength> tempbuf;
+            if (eapId == KPlainMsChapV2ImplUid)
+                {
+                tempbuf.Append(KMsChapV2Padding);
+                }
+            else
+                {
+                tempbuf.Append(KPadding);
+                }
+            tempbuf.Append(eapId);
+
+            buffer->iEAPSettings->iEAPExpandedType = tempbuf;
+            buffer->iWLANServiceId = WLANServiceId;
+            TBuf8<KExpandedEapIdLength> encapsTempbuf;
+            if (encapsEapId == KPlainMsChapV2ImplUid)
+                {
+                encapsTempbuf.Append(KMsChapV2Padding);
+                }
+            else
+                {
+                encapsTempbuf.Append(KPadding);
+                }
+            encapsTempbuf.Append(encapsEapId);
+
+            buffer->iEncapsulatingExpandedEapId = encapsTempbuf;
+            iEAPBuffer.AppendL(buffer);
+
+            CleanupStack::Pop(buffer->iEAPSettings);
+            CleanupStack::Pop(buffer);
+
+            eapIndex = iEAPBuffer.Count() - 1;
+            }
+        }
+    if (err != KErrNone)
+        {
+        DBG_ARGS(_S16("CNSmlWLanAdapter::AddLeafObjectL - ErrorCode <%D>"),
+                err);
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+        return;
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*/*"))
+            != KErrNotFound && uriSegs == 9)
+        {
+        TInt wepKeyId = GetWepKeyIdFromLuid(aParentLUID);
+
+        if (wepKeyId != KErrNotFound)
+            {
+            if (lastUriSeg.Match(KNSmlWLanWepKeyData) != KErrNotFound)
+                {
+                switch (wepKeyId)
+                    {
+                    case 1:
+                        iSettings->WepKey1 = aObject;
+                        break;
+                    case 2:
+                        iSettings->WepKey2 = aObject;
+                        break;
+                    case 3:
+                        iSettings->WepKey3 = aObject;
+                        break;
+                    case 4:
+                        iSettings->WepKey4 = aObject;
+                        break;
+                    default:
+                        iCallBack->SetStatusL(aStatusRef,
+                                CSmlDmAdapter::ENotFound);
+                        return;
+                    }
+                }
+            else if (lastUriSeg.Match(KNSmlWLanWepKeyId) != KErrNotFound)
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+                return;
+                }
+            else
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                return;
+                }
+            }
+
+        else
+            {
+            TInt index = -1;
+
+            for (TInt i = 0; i < iBuffer->Count(); i++)
+                {
+                if (aURI.Find(iBuffer->At(i).iUri->Des()) != KErrNotFound)
+                    {
+                    index = i;
+                    break;
+                    }
+                }
+            if (index < 0)
+                {
+                wepKeyId = GetWepKeyIdFromUri(aURI);
+
+                TBuf8<80> addLUID; // AP/<x>/NapDef/<x>/WLAN/<x>/WEPKey/WKIdnnn
+                addLUID.AppendNum(wepKeyId);
+                addLUID.AppendNumFixedWidth(luid, EDecimal, 3);
+
+                DBG_ARGS8(
+                        _S8(
+                                "WLanAdapter::AddleafObject - mapping uri: <%S> to luid: <%S>"),
+                        &aURI, &addLUID);
+                DBG_ARGS8(_S8("Parametrit - <%S> <%S>"), &aURI, &addLUID);
+                iCallBack->SetMappingL(aURI, addLUID);
+                if (lastUriSeg.Match(KNSmlWLanWepKeyData) != KErrNotFound)
+                    {
+                    switch (wepKeyId)
+                        {
+                        case 1:
+                            iSettings->WepKey1 = aObject;
+                            break;
+                        case 2:
+                            iSettings->WepKey2 = aObject;
+                            break;
+                        case 3:
+                            iSettings->WepKey3 = aObject;
+                            break;
+                        case 4:
+                            iSettings->WepKey4 = aObject;
+                            break;
+                        default:
+                            iCallBack->SetStatusL(aStatusRef,
+                                    CSmlDmAdapter::ENotFound);
+                            return;
+                        }
+                    }
+                else if (lastUriSeg.Match(KNSmlWLanWepKeyId) != KErrNotFound)
+                    {
+                    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+                    return;
+                    }
+                else
+                    {
+                    iCallBack->SetStatusL(aStatusRef,
+                            CSmlDmAdapter::ENotFound);
+                    return;
+                    }
+                }
+            else
+                {
+                //Add WepKeyId and execute buffer
+                if (lastUriSeg.Match(KNSmlWLanWepKeyId) != KErrNotFound)
+                    {
+                    iBuffer->At(index).iWepKeyId = DesToInt(aObject);
+                    iBuffer->At(index).iIdStatusRef = aStatusRef;
+
+                    //                  ExecuteBufferL( ); (JPLA-6M29NR caused error in WEPkey Data if buffer is executed here)
+                    return;
+                    }
+
+                else if (lastUriSeg.Match(KNSmlWLanWepKeyData)
+                        != KErrNotFound)
+                    {
+                    iBuffer->At(index).iData = aObject.AllocLC();
+                    iBuffer->At(index).iDataSet = ETrue;
+                    CleanupStack::Pop(); //iBuffer->At(index).iData
+                    iBuffer->At(index).iDataStatusRef = aStatusRef;
+                    return;
+                    }
+                else
+                    {
+                    iCallBack->SetStatusL(aStatusRef,
+                            CSmlDmAdapter::ENotFound);
+                    return;
+                    }
+                }
+            }
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/*")) != KErrNotFound
+            && uriSegs == 7)
+        {
+        if (lastUriSeg.Compare(KNSmlWLanSsid) == 0)
+            {
+            TInt returnValue = CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                    iSettings->SSID, aObject);
+            DBG_ARGS(_S16("WLanAdapter::ssid convert: <%D>"), returnValue);
+            if (returnValue != KErrNone)
+                {
+                // setting the default value to the network name
+                iSettings->SSID = TPtrC(KNSmlWLanDefaultSSID);
+                DBG_ARGS(
+                        _S16(
+                                "CNSmlWLanAdapter::AddLeafObjectL SSID - ErrorCode <%D>"),
+                        returnValue);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                return;
+                }
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanUsedSsid) == 0)
+            {
+            TInt returnValue = CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                    iSettings->UsedSSID, aObject);
+            DBG_ARGS(_S16("WLanAdapter::usedSsid convert: <%D>"), returnValue);
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanSsidHidden) == 0)
+            {
+            if (aObject.MatchF(_L8("True")) != KErrNotFound)
+                {
+                iSettings->ScanSSID = 1;
+                }
+            else
+                {
+                iSettings->ScanSSID = 0;
+                }
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanNetworkMode) == 0)
+            {
+            if (aObject.MatchF(_L8("ADHOC")) != KErrNotFound)
+                {
+                iSettings->ConnectionMode = EAdhoc;
+                }
+
+            else if (aObject.MatchF(_L8("Infrastructure")) != KErrNotFound)
+                {
+                iSettings->ConnectionMode = EInfrastructure;
+                }
+            else
+                {
+                iCallBack->SetStatusL(aStatusRef,
+                        CSmlDmAdapter::EInvalidObject);
+                return;
+                }
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanSecurityMode) == 0)
+            {
+            if (aObject.MatchF(_L8("NONE")) != KErrNotFound)
+                {
+                iSettings->SecurityMode = EAllowUnsecure;
+                }
+            else if (aObject.MatchF(_L8("WEP")) != KErrNotFound)
+                {
+                iSettings->SecurityMode = EWep;
+                }
+            else if (aObject.MatchF(_L8("8021X")) != KErrNotFound)
+                {
+                iSettings->SecurityMode = EWlan8021x;
+                }
+            else if (aObject.MatchF(_L8("WPA")) != KErrNotFound)
+                {
+                iSettings->SecurityMode = EWpa;
+                }
+            else if (aObject.MatchF(_L8("WPA2")) != KErrNotFound)
+                {
+                iSettings->SecurityMode = EWpa2;
+                }
+            else
+                {
+                iCallBack->SetStatusL(aStatusRef,
+                        CSmlDmAdapter::EInvalidObject);
+                return;
+                }
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanUseWPAPSK) == 0)
+            {
+            if (aObject.MatchF(_L8("True")) != KErrNotFound)
+                {
+                iSettings->UseWPAPSK = 1;
+                }
+            else
+                {
+                iSettings->UseWPAPSK = 0;
+                }
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanWpaPreSharedKey) == 0)
+            {
+            if (aObject.Length() > KMaxPSKLength)
+                {
+                iCallBack->SetStatusL(aStatusRef,
+                        CSmlDmAdapter::ETooLargeObject);
+                return;
+                }
+            /*else if(aObject.Length() < KMinPSKLength)
+             {
+             iCallBack->SetStatusL( aStatusRef, CSmlDmAdapter::EInvalidObject );
+             return;
+             }*/
+            else
+                {
+                iSettings->WPAPreSharedKey = aObject;
+                }
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanEapList) == 0)
+            {
+            TInt returnValue = CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                    iSettings->EapList, aObject);
+            DBG_ARGS(_S16("WLanAdapter::EapList convert: <%D>"), returnValue);
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanAuthMode) == 0)
+            {
+            if (aObject.MatchF(_L8("1")) != KErrNotFound)
+                {
+                iSettings->AuthMode = EShared;
+                }
+            else
+                {
+                iSettings->AuthMode = EOpen;
+                }
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanWepIndex) == 0)
+            {
+            TInt32 actualIndex = DesToInt(aObject);
+            if (actualIndex < 4 && actualIndex >= 0)
+                {
+                iSettings->WepIndex = actualIndex;
+                }
+            else
+                {
+                if (actualIndex > 3)
+                    {
+                    iCallBack->SetStatusL(aStatusRef,
+                            CSmlDmAdapter::ETooLargeObject);
+                    }
+                else
+                    {
+                    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                    }
+                return;
+                }
+            }
+
+        else
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            return;
+            }
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*/*"))
+            != KErrNotFound && uriSegs == 9)
+        {
+        TSecondarySSID ssid;
+        ssid.Id = 0;
+        TUint32 id = GetSecSSIDFromUriL(aURI);
+        RArray<TSecondarySSID> secondaryList;
+        CleanupClosePushL(secondaryList);
+        iWlanSettings->GetSecondarySSIDListL(luid, secondaryList);
+        TInt count = secondaryList.Count();
+        for (TInt i = 0; i < count; i++)
+            {
+            if (id == secondaryList[i].Id)
+                {
+                ssid = secondaryList[i];
+                break;
+                }
+            }
+        CleanupStack::PopAndDestroy(&secondaryList);
+        if (ssid.Id == 0)
+            {
+
+            _DBG_FILE("CNSmlWLanAdapter::Coming to check buffer ");
+
+            //Check if its buffered here - Divya
+            TInt index = -1;
+
+            for (TInt i = 0; i < iSecondaryBuffer.Count(); i++)
+                {
+                if (aURI.Find(iSecondaryBuffer[i]->iUri->Des())
+                        != KErrNotFound)
+                    {
+                    index = i;
+                    _DBG_FILE("CNSmlWLanAdapter::one indexis matched :-)");
+                    break;
+                    }
+                }
+            if (index < 0)
+                {
+                _DBG_FILE("CNSmlWLanAdapter::one indexis matched :-)");
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                return;
+                }
+            else
+                {
+                DBG_ARGS8(
+                        _S8(
+                                "CWlanadaptes::Execute Buffer - copying in buffer instead of giving 404 uri: object id  : <%S>"),
+                        &aObject);
+
+                if (lastUriSeg.Compare(KNSmlWLanSsid) == 0)
+                    {
+                    if (aObject.Length() <= KMaxTextLength)
+                        {
+                        iSecondaryBuffer[index]->ScannedId.Copy(aObject);
+                        }
+                    else
+                        {
+                        _DBG_FILE(
+                                "CNSmlWLanAdapter::AddLeafObject - SecondarySSID too long");
+                        iCallBack->SetStatusL(aStatusRef,
+                                CSmlDmAdapter::EError);
+                        return;
+                        }
+
+                    }
+                else if (lastUriSeg.Compare(KNSmlWLanUsedSsid) == 0)
+                    {
+                    iSecondaryBuffer[index]->UsedId.Copy(aObject);
+                    }
+
+                }
+
+            }
+
+        else
+            {
+
+            if (lastUriSeg.Compare(KNSmlWLanSsid) == 0)
+                {
+                ssid.ScannedId.Copy(aObject);
+                }
+            else if (lastUriSeg.Compare(KNSmlWLanUsedSsid) == 0)
+                {
+                ssid.UsedId.Copy(aObject);
+                }
+            TInt retval = iWlanSettings->WriteSecondarySSIDL(luid, ssid,
+                    EFalse);
+            if (retval == KErrNone)
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+                }
+            else
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                }
+            }
+        }
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*/*")) != KErrNotFound
+            && uriSegs == 9)
+        {
+        DBG_ARGS8(_S8("CNSmlWLanAdapter::AddLeafObjectL - EAP index: <%d>"),
+                eapIndex);
+
+        if (lastUriSeg.Compare(KNSmlWLanEapType) == 0)
+            {
+            TInt eapid = GetEAPIdFromUri(aURI);
+            // append it to the appropriate list ('+' enabled, '-' disabled)
+            _LIT8(KPadding, "\xFE\0\0\0\0\0\0");
+            _LIT8(KMsChapV2Padding, "\xFE\xFF\xFF\xFF\0\0\0");
+            const TInt KPlainMsChapV2ImplUid = 99;
+            TBuf8<KExpandedEapIdLength> tempbuf;
+            if (eapid == KPlainMsChapV2ImplUid)
+                {
+                tempbuf.Append(KMsChapV2Padding);
+                }
+            else
+                {
+                tempbuf.Append(KPadding);
+                }
+            tempbuf.Append(eapid);
+            // Get EAP ID from URI instead of the value because the server gives the value
+            // incorrectly as the textual representation of the EAP method instead of the IANA number.            
+            iEAPBuffer[eapIndex]->iEAPSettings->iEAPExpandedType = tempbuf;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanUsername) == 0)
+            {
+            TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                    iEAPBuffer[eapIndex]->iEAPSettings->iUsername, aObject);
+            if (retval == KErrNone)
+                {
+                iEAPBuffer[eapIndex]->iEAPSettings->iUsernamePresent = ETrue;
+                }
+            else
+                {
+                iEAPBuffer[eapIndex]->iEAPSettings->iUsername.Zero();
+                DBG_ARGS(
+                        _S16(
+                                "CNSmlWLanAdapter::AddLeafObjectL EAP username - ErrorCode <%D>"),
+                        retval);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                return;
+                }
+
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanPassword) == 0)
+            {
+            TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                    iEAPBuffer[eapIndex]->iEAPSettings->iPassword, aObject);
+            if (retval == KErrNone)
+                {
+                iEAPBuffer[eapIndex]->iEAPSettings->iPasswordPresent = ETrue;
+                }
+            else
+                {
+                iEAPBuffer[eapIndex]->iEAPSettings->iPassword.Zero();
+                DBG_ARGS(
+                        _S16(
+                                "CNSmlWLanAdapter::AddLeafObjectL EAP password - ErrorCode <%D>"),
+                        retval);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                return;
+                }
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanRealm) == 0)
+            {
+            TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                    iEAPBuffer[eapIndex]->iEAPSettings->iRealm, aObject);
+            if (retval == KErrNone)
+                iEAPBuffer[eapIndex]->iEAPSettings->iRealmPresent = ETrue;
+
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanUsePseudonym) == 0)
+            {
+            if ((aObject == KTrue) || (aObject == KTtrue))
+                iEAPBuffer[eapIndex]->iEAPSettings->iUsePseudonyms = ETrue;
+            else
+                iEAPBuffer[eapIndex]->iEAPSettings->iUsePseudonyms = EFalse;
+
+            iEAPBuffer[eapIndex]->iEAPSettings->iUsePseudonymsPresent = ETrue;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanEncapsulation) == 0)
+            {
+            TBuf8<KExpandedEAPIdLength> dummy;
+            //ConvertEAPStringToIds( aObject, dummy, iEAPBuffer[eapIndex]->iEncapsulatingExpandedEapId );
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanVerifyCertRealm) == 0)
+            {
+            if ((aObject == KTrue) || (aObject == KTtrue))
+                iEAPBuffer[eapIndex]->iEAPSettings->iVerifyServerRealm
+                        = ETrue;
+            else
+                iEAPBuffer[eapIndex]->iEAPSettings->iVerifyServerRealm
+                        = EFalse;
+
+            iEAPBuffer[eapIndex]->iEAPSettings->iVerifyServerRealmPresent
+                    = ETrue;
+
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanRequireClientAuthentication)
+                == 0)
+            {
+            if ((aObject == KTrue) || (aObject == KTtrue))
+                iEAPBuffer[eapIndex]->iEAPSettings->iRequireClientAuthentication
+                        = ETrue;
+            else
+                iEAPBuffer[eapIndex]->iEAPSettings->iRequireClientAuthentication
+                        = EFalse;
+
+            iEAPBuffer[eapIndex]->iEAPSettings->iRequireClientAuthenticationPresent
+                    = ETrue;
+
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanSessionValidityTime) == 0)
+            {
+            TLex8 lex(aObject);
+            TUint newVal;
+            TInt sesValErr = lex.Val(newVal);
+            // Check whether the conversion went ok
+            if (sesValErr == KErrNone)
+                {
+                iEAPBuffer[eapIndex]->iEAPSettings->iSessionValidityTime
+                        = newVal;
+                iEAPBuffer[eapIndex]->iEAPSettings->iSessionValidityTimePresent
+                        = ETrue;
+                }
+            else
+                {
+                // there were errors, let's leave the function and update status
+                DBG_ARGS(
+                        _S16(
+                                "CNSmlWLanAdapter::AddLeafObjectL SessionValidityTime - ErrorCode <%D>"),
+                        sesValErr);
+                iCallBack->SetStatusL(aStatusRef,
+                        CSmlDmAdapter::EInvalidObject);
+                return;
+                }
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanCipherSuite) == 0)
+            {
+            FillCipherSuitesL(aObject, eapIndex);
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanAllowPEAPv0) == 0)
+            {
+            if ((aObject == KTrue) || (aObject == KTtrue))
+                iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv0Allowed = ETrue;
+            else
+                iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv0Allowed = EFalse;
+
+            iEAPBuffer[eapIndex]->iEAPSettings->iPEAPVersionsPresent = ETrue;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanAllowPEAPv1) == 0)
+            {
+            if ((aObject == KTrue) || (aObject == KTtrue))
+                iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv1Allowed = ETrue;
+            else
+                iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv1Allowed = EFalse;
+
+            iEAPBuffer[eapIndex]->iEAPSettings->iPEAPVersionsPresent = ETrue;
+
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanAllowPEAPv2) == 0)
+            {
+            if ((aObject == KTrue) || (aObject == KTtrue))
+                iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv2Allowed = ETrue;
+            else
+                iEAPBuffer[eapIndex]->iEAPSettings->iPEAPv2Allowed = EFalse;
+
+            iEAPBuffer[eapIndex]->iEAPSettings->iPEAPVersionsPresent = ETrue;
+            }
+
+#ifdef FF_WLAN_EXTENSIONS 
+        else if (lastUriSeg.Compare(KNSmlWLanAuthProvMode) == 0)
+            {
+            if ( (aObject == KTrue) || (aObject == KTtrue) )
+            iEAPBuffer[eapIndex]->iEAPSettings->iAuthProvModeAllowed = ETrue;
+            else
+            iEAPBuffer[eapIndex]->iEAPSettings->iAuthProvModeAllowed = EFalse;
+
+            iEAPBuffer[eapIndex]->iEAPSettings->iAuthProvModeAllowedPresent = ETrue;
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanUnauthProvMode) == 0)
+            {
+            if ( (aObject == KTrue) || (aObject == KTtrue) )
+            iEAPBuffer[eapIndex]->iEAPSettings->iUnauthProvModeAllowed = ETrue;
+            else
+            iEAPBuffer[eapIndex]->iEAPSettings->iUnauthProvModeAllowed = EFalse;
+
+            iEAPBuffer[eapIndex]->iEAPSettings->iUnauthProvModeAllowedPresent = ETrue;
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanPACGroupRef) == 0)
+            {
+            TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8( iEAPBuffer[eapIndex]->iEAPSettings->iPACGroupReference, aObject );
+            if (retval == KErrNone)
+            iEAPBuffer[eapIndex]->iEAPSettings->iPACGroupReferencePresent = ETrue;
+
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanWarnADHPNoPAC) == 0)
+            {
+            if ( (aObject == KTrue) || (aObject == KTtrue) )
+            iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoPAC = ETrue;
+            else
+            iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoPAC = EFalse;
+
+            iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoPACPresent = ETrue;
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanWarnADHPNoMatchPAC) == 0)
+            {
+            if ( (aObject == KTrue) || (aObject == KTtrue) )
+            iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoMatchingPAC = ETrue;
+            else
+            iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoMatchingPAC = EFalse;
+
+            iEAPBuffer[eapIndex]->iEAPSettings->iWarnADHPNoMatchingPACPresent = ETrue;
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanWarnNotDefaultSrv) == 0)
+            {
+            if ( (aObject == KTrue) || (aObject == KTtrue) )
+            iEAPBuffer[eapIndex]->iEAPSettings->iWarnNotDefaultServer = ETrue;
+            else
+            iEAPBuffer[eapIndex]->iEAPSettings->iWarnNotDefaultServer = EFalse;
+
+            iEAPBuffer[eapIndex]->iEAPSettings->iWarnNotDefaultServerPresent = ETrue;
+            }
+
+#endif            
+
+        // Save the status reference
+        iEAPBuffer[eapIndex]->iStatusRefArray.AppendL(aStatusRef);
+        return;
+        }
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*/*"))
+            != KErrNotFound && uriSegs == 11)
+        {
+        TPtrC8 ptr = NSmlDmURI::ParentURI(aURI);
+
+        TBuf<KGeneralStringMaxLength> certBuffer;
+
+        // Get the LUID from ptr2
+        HBufC8* certLuid = iCallBack->GetLuidAllocL(ptr);
+
+        TInt certIndex = GetIdFromLuid(*certLuid);
+
+        delete certLuid;
+
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlWLanAdapter::AddLeafObjectL - cert index: <%d>, cert count: <%d>"),
+                certIndex,
+                iEAPBuffer[eapIndex]->iEAPSettings->iCertificates.Count());
+
+        if (iEAPBuffer[eapIndex]->iEAPSettings->iCertificates.Count() - 1
+                < certIndex)
+            {
+            _DBG_FILE(
+                    "CNSmlWLanAdapter::AddLeafObject - Certificate buffer does not exist. Create it.");
+            // The certificate buffer does not exist. Create a new one
+            EapCertificateEntry *entry = new (ELeave) EapCertificateEntry;
+            iEAPBuffer[eapIndex]->iEAPSettings->iCertificates.Append(entry);
+            iEAPBuffer[eapIndex]->iEAPSettings->iCertificatesPresent = ETrue;
+
+            certIndex
+                    = iEAPBuffer[eapIndex]->iEAPSettings->iCertificates.Count()
+                            - 1;
+
+            TBuf8<2> newLuid;
+            newLuid.Num(certIndex);
+
+            DBG_ARGS8(
+                    _S8(
+                            "WLanAdapter::AddLeafObjectL - mapping uri: <%S> to luid: <%S>"),
+                    &aURI, &newLuid);
+            iCallBack->SetMappingL(aURI, newLuid);
+            }
+
+        if (lastUriSeg.Compare(KNSmlWLanIssuerName) == 0)
+            {
+            TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                    certBuffer, aObject);
+            iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex]->SetIssuerName(
+                    certBuffer);
+            if (retval == KErrNone)
+                iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex]->SetIssuerNamePresent();
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanSubjectName) == 0)
+            {
+            certBuffer.FillZ();
+            TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                    certBuffer, aObject);
+            iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex]->SetSubjectName(
+                    certBuffer);
+
+            if (retval == KErrNone)
+                iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex]->SetSubjectNamePresent();
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanCertType) == 0)
+            {
+            iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex]->SetCertType(
+                    (EapCertificateEntry::TCertType) DesToInt(aObject));
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanSerialNumber) == 0)
+            {
+            certBuffer.FillZ();
+            TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                    certBuffer, aObject);
+            iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex]->SetSerialNumber(
+                    certBuffer);
+            if (retval == KErrNone)
+                iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex]->SetSerialNumberPresent();
+
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanSubjectKeyId) == 0)
+            {
+
+            // Define literals to search the subject key for possible 0X/0x beginning
+            _LIT(KHexIdLC, "0x");
+            _LIT(KHexIdUC, "0X");
+            TBuf<2> hexIdBuf;
+            // The lenght of the key given as input
+            TInt keyLen = aObject.Length();
+
+            // setting the given key to the key buffer
+            TBuf8<KNsmlSubjectKeyIdLength> origKey = aObject;
+            origKey.SetLength(keyLen);
+            TBuf8<KIdentifierLength> key;
+            TLex8 tmpByte;
+            TUint16 byte;
+
+            // Remove possible spaces from the beginning
+            origKey.TrimLeft();
+
+            // the key should be atleast two chars long
+            if (origKey.Length() >= 2)
+                {
+                // Copy the two left most characters in to the buffer
+                hexIdBuf.Copy(origKey.Left(2));
+
+                // If the first characters are 0x or 0X, then thet should be ignored
+                if (hexIdBuf.Compare(KHexIdLC) == 0 || hexIdBuf.Compare(
+                        KHexIdUC) == 0)
+                    {
+                    // delete two characters
+                    origKey.Delete(0, 2);
+                    }
+                }
+
+            // looping the subject key through, removing whitespaces
+            for (TInt i = 0; i < keyLen; i++)
+                {
+                // removing white spaces from the left side of the key
+                origKey.TrimLeft();
+                // check that there are characters left
+                if (origKey.Length() >= 2)
+                    {
+                    // pick the two left most bytes from the key
+                    tmpByte = origKey.Left(2);
+                    // convert byte into binary format
+                    err = tmpByte.Val(byte, EHex);
+
+                    // check whether conversion to decimal went ok
+                    if (err != KErrNone)
+                        {
+                        // if there are problems, then leave the loop
+                        break;
+                        }
+
+                    // store the appended byte into the key variable
+                    key.Append(byte);
+                    // delete two characters from the left side of the character array in the buffer
+                    origKey.Delete(0, 2);
+                    }
+                else if (origKey.Length() == 1)
+                    {
+                    // pick the left most byte from the key
+                    tmpByte = origKey.Left(1);
+                    // convert byte into binary format
+                    err = tmpByte.Val(byte, EHex);
+
+                    // check whether conversion to decimal went ok
+                    if (err != KErrNone)
+                        {
+                        // if there are problems, then leave the loop
+                        break;
+                        }
+
+                    // store the appended byte into the key variable
+                    key.Append(byte);
+                    // delete two characters from the left side of the character array in the buffer
+                    origKey.Delete(0, 1);
+                    }
+                else
+                    {
+                    // leave the loop, no characters are left
+                    break;
+                    }
+                }
+            // store key value only if no errors occurred
+            if (err == KErrNone)
+                {
+                iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex]->SetSubjectKeyId(
+                        key);
+                iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex]->SetSubjectKeyIdPresent();
+                }
+            else
+                {
+                // there were errors, let's leave the function and update status
+                DBG_ARGS(_S16(
+                        "CNSmlWLanAdapter::AddLeafObjectL - ErrorCode <%D>"),
+                        err);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+                return;
+                }
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanFingerprint) == 0)
+            {
+            certBuffer.FillZ();
+            TInt retval = CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                    certBuffer, aObject);
+            iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex]->SetThumbprint(
+                    certBuffer);
+            if (retval == KErrNone)
+                iEAPBuffer[eapIndex]->iEAPSettings->iCertificates[certIndex]->SetThumbprintPresent();
+            }
+        // Save the status reference
+        iEAPBuffer[eapIndex]->iStatusRefArray.AppendL(aStatusRef);
+
+        return;
+        }
+
+    if (eapId == KErrNotFound)
+        {
+        err = iWlanSettings->WriteWlanSettings(*iSettings);
+        }
+
+    if (err != KErrNone)
+        {
+        DBG_ARGS(_S16("CNSmlWLanAdapter::AddLeafObjectL - ErrorCode <%D>"),
+                err);
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+        return;
+        }
+
+    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+
+    _DBG_FILE("CNSmlWLanAdapter::AddLeafObjectL(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::UpdateLeafObjectL( const TDesC& aURI, 
+//    const TDesC& aLUID, const TDesC8& aObject, const TDesC& aType, 
+//    const TInt aStatusRef )
+//-----------------------------------------------------------------------------
+void CNSmlWLanAdapter::UpdateLeafObjectL(const TDesC8& aURI,
+        const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& aType,
+        const TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::UpdateLeafObjectL(): begin");
+    DBG_ARGS8(_S8("WLanAdapter::UpdateLeafObjectL - <%S> <%S> <%S>"), &aURI,
+            &aLUID, &aObject);
+
+    AddLeafObjectL(aURI, aLUID, aObject, aType, aStatusRef);
+
+    _DBG_FILE("CNSmlWLanAdapter::UpdateLeafObjectL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlWLanAdapter::UpdateLeafObjectL( const TDesC8& aURI, 
+// const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& aType )
+//------------------------------------------------------------------------------
+
+void CNSmlWLanAdapter::UpdateLeafObjectL(const TDesC8& /*aURI*/,
+        const TDesC8& /*aLUID*/, RWriteStream*& /*aStream*/,
+        const TDesC8& /*aType*/, TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::UpdateLeafObjectL(): begin");
+    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlWLanAdapter::UpdateLeafObjectL(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::DeleteObjectL( const TDesC8& aURI, 
+// const TDesC8& aLUID, const TInt aStatusRef )
+//-----------------------------------------------------------------------------
+void CNSmlWLanAdapter::DeleteObjectL(const TDesC8& aURI, const TDesC8& aLUID,
+        const TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL(): begin");
+    CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound;
+
+    if (aLUID.Length() == 0)
+        {
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+
+        _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL(): end");
+        return;
+        }
+
+    TInt luid = GetIdFromLuid(aLUID);
+
+    if ((NumOfUriSegs(aURI) < 6) || (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*"))
+            != KErrNotFound && NumOfUriSegs(aURI) == 6))
+        {
+        if (luid == KErrNotFound)
+            {
+            return;
+            }
+        TInt ret = iWlanSettings->DeleteWlanSettings(luid);
+
+        if (ret == KErrNone)
+            {
+            status = CSmlDmAdapter::EOk;
+            }
+        else
+            {
+            status = CSmlDmAdapter::EError;
+            }
+
+        }
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/WEPKey")) != KErrNotFound
+            && NumOfUriSegs(aURI) == 7)
+        {
+        // Individual WLAN settings cannot be deleted and this case should never happen.
+        // These are deleted through WLAN parent nodes.
+        status = CSmlDmAdapter::EError;
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*"))
+            != KErrNotFound && NumOfUriSegs(aURI) == 8)
+        {
+        _DBG_FILE(
+                "CNSmlWLanAdapter::DeleteObjectL(): matching SecondarySSID/*");
+        //Check if the secondary SSID is present , if so delete that 
+        TUint32 secid = GetSecSSIDFromUriL(aURI);
+        TInt retvalue(KErrNone);
+        _DBG_FILE(
+                "CNSmlWLanAdapter::DeleteObjectL() before call to DeleteOneSecondarySSIDL ");
+        TRAPD(ssidError, retvalue = iWlanSettings->DeleteOneSecondarySSIDL(
+                luid, secid));
+        _DBG_FILE(
+                "CNSmlWLanAdapter::DeleteObjectL() After call to DeleteOneSecondarySSIDL ");
+        DBG_ARGS8(_S8(
+                "TRAP ERROR  ssidError : Id = %d and retvalue eror = %d"),
+                ssidError, retvalue);
+
+        if (ssidError == KErrNone)
+            {
+            _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL() SSID trap KERRONONE");
+            if (retvalue == KErrNone)
+                {
+                _DBG_FILE(
+                        "CNSmlWLanAdapter::DeleteObjectL() retvalue also  KERRONONE, so its deleted");
+                status = CSmlDmAdapter::EOk;
+                }
+
+            else if (retvalue == KErrNotFound)
+                {
+                status = CSmlDmAdapter::ENotFound;
+                _DBG_FILE(
+                        "CNSmlWLanAdapter::DeleteObjectL() retvalue KErrNotFound :-(");
+                }
+
+            else
+                {
+                _DBG_FILE(
+                        "CNSmlWLanAdapter::DeleteObjectL() retvalue some error :-(");
+                status = CSmlDmAdapter::EError;
+                }
+
+            }
+        else
+            {
+            _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL() trap error :-( ");
+            status = CSmlDmAdapter::EError;
+            }
+
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/*")) != KErrNotFound
+            && NumOfUriSegs(aURI) == 7)
+        {
+        // Individual WLAN settings cannot be deleted and this case should never happen.
+        // These are deleted through WLAN parent nodes.
+        status = CSmlDmAdapter::EError;
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*")) != KErrNotFound
+            && NumOfUriSegs(aURI) == 8)
+        {
+        // Individual WEP keys cannot be deleted and this case should never happen.
+        // These are deleted through WLAN parent nodes.
+        status = CSmlDmAdapter::EError;
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*/Data"))
+            != KErrNotFound && NumOfUriSegs(aURI) == 9)
+        {
+        // Individual WEP keys cannot be deleted and this case should never happen.
+        // These are deleted through WLAN parent nodes.	
+        status = CSmlDmAdapter::EError;
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*")) != KErrNotFound
+            && NumOfUriSegs(aURI) == 8)
+        {
+        // Individual EAP settings cannot be deleted and this case should never happen.
+        // These are deleted through WLAN parent nodes.	
+        status = CSmlDmAdapter::EError;
+        }
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*/*")) != KErrNotFound
+            && NumOfUriSegs(aURI) == 9)
+        {
+        // Individual EAP settings cannot be deleted and this case should never happen.
+        // These are deleted through WLAN parent nodes.
+        status = CSmlDmAdapter::EError;
+        }
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*"))
+            != KErrNotFound && NumOfUriSegs(aURI) == 10)
+        {
+        // Individual certificates are not allowed to be deleted and this case should never happen
+        // These are deleted through WLAN parent nodes.
+        status = CSmlDmAdapter::EError;
+
+        }
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*/*"))
+            != KErrNotFound && NumOfUriSegs(aURI) == 11)
+        {
+        // Individual certificate fields are not allowed to be deleted and this case should never happen.
+        // These are deleted through WLAN parent nodes.
+        status = CSmlDmAdapter::EError;
+        }
+
+    iCallBack->SetStatusL(aStatusRef, status);
+
+    _DBG_FILE("CNSmlWLanAdapter::DeleteObjectL(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::FetchLeafObjectL( const TDesC8& aURI, 
+//                     const TDesC8& aLUID, const TDesC8& aType, 
+//                     const TInt aResultsRef, const TInt aStatusRef )
+// not used.
+//-----------------------------------------------------------------------------
+
+void CNSmlWLanAdapter::FetchLeafObjectSizeL(const TDesC8& /*aURI*/,
+        const TDesC8& /*aLUID*/, const TDesC8& /*aType*/,
+        TInt /*aResultsRef*/, TInt /*aStatusRef*/)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectSizeL(): begin");
+    _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectSizeL(): end");
+    return;
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::FetchLeafObjectL( const TDesC8& aURI, 
+//                     const TDesC8& aLUID, const TDesC8& aType, 
+//                     const TInt aResultsRef, const TInt aStatusRef )
+//-----------------------------------------------------------------------------
+void CNSmlWLanAdapter::FetchLeafObjectL(const TDesC8& /*aURI*/,
+        const TDesC8& /*aLUID*/, const TDesC8& /*aType*/,
+        const TInt /*aResultsRef*/, const TInt /*aStatusRef*/)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): begin");
+    _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): end");
+
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::FetchLeafObjectL( const TDesC& aURI, 
+//                     const TDesC& aLUID, const TDesC& aType, 
+//                     const TInt aResultsRef, const TInt aStatusRef )
+//-----------------------------------------------------------------------------
+CSmlDmAdapter::TError CNSmlWLanAdapter::FetchLeafObjectL(const TDesC8& aURI,
+        const TDesC8& aLUID, const TDesC8& aType, CBufBase& aObject)
+    {
+
+    _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): begin");
+    DBG_ARGS8(_S8("WLanAdapter::FetchLeafObjectL - <%S> <%S> <%S>"), &aURI,
+            &aLUID, &aType);
+
+    if (aLUID.Length() == 0)
+        {
+
+        _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): ENotFound");
+        return CSmlDmAdapter::ENotFound;
+        }
+
+    CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound;
+
+    // This luid is the service table id (Found from EAP node and parents)
+    TInt luid;
+    if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*")) != KErrNotFound)
+        {
+        luid = GetServiceIdFromUriL(aURI);
+        }
+    else
+        {
+        // The luid supplied is ok
+        luid = GetIdFromLuid(aLUID);
+        }
+
+    TPtrC8 lastUriSeg = GetLastUriSeg(aURI);
+
+    if (luid == KErrNotFound)
+        {
+        return;
+        }
+
+    TInt err = iWlanSettings->GetWlanSettings(luid, *iSettings);
+
+    if (err == KErrNotFound)
+        {
+
+        _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): ENotFound");
+        return CSmlDmAdapter::ENotFound;
+        }
+
+    if (lastUriSeg.Compare(KNSmlWLanSsid) == 0)
+        {
+
+        if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*"))
+                != KErrNotFound)
+            {
+            RArray<TSecondarySSID> secondarySSIDs;
+            CleanupClosePushL(secondarySSIDs);
+            iWlanSettings->GetSecondarySSIDListL(luid, secondarySSIDs);
+            TSecondarySSID ssid;
+            ssid.Id = 0;
+            TUint32 id = GetSecSSIDFromUriL(aURI);
+            TInt count = secondarySSIDs.Count();
+            for (TInt i = 0; i < count; i++)
+                {
+                if (id == secondarySSIDs[i].Id)
+                    {
+                    ssid = secondarySSIDs[i];
+                    break;
+                    }
+                }
+            CleanupStack::PopAndDestroy(&secondarySSIDs);
+            if (ssid.Id == 0)
+                {
+                status = CSmlDmAdapter::ENotFound;
+                }
+            else
+                {
+                HBufC* data = ssid.ScannedId.AllocLC();
+                HBufC8* data8 = HBufC8::NewLC(data->Size());
+                TPtr8 dataPtr8 = data8->Des();
+                //FFS
+                CnvUtfConverter::ConvertFromUnicodeToUtf8(dataPtr8,
+                        data->Des());
+
+                aObject.InsertL(0, dataPtr8);
+                status = CSmlDmAdapter::EOk;
+
+                CleanupStack::PopAndDestroy(2); //data, data8
+                }
+            }
+        else
+            {
+
+            HBufC* data = iSettings->SSID.AllocLC();
+            HBufC8* data8 = HBufC8::NewLC(data->Size());
+            TPtr8 dataPtr8 = data8->Des();
+            //FFS
+            CnvUtfConverter::ConvertFromUnicodeToUtf8(dataPtr8, data->Des());
+
+            aObject.InsertL(0, dataPtr8);
+            status = CSmlDmAdapter::EOk;
+
+            CleanupStack::PopAndDestroy(2); //data, data8
+
+            }
+
+        }
+
+    else if (lastUriSeg.Compare(KNSmlWLanUsedSsid) == 0)
+        {
+
+        if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*"))
+                != KErrNotFound)
+            {
+            RArray<TSecondarySSID> secondarySSIDs;
+            CleanupClosePushL(secondarySSIDs);
+            iWlanSettings->GetSecondarySSIDListL(luid, secondarySSIDs);
+            TSecondarySSID ssid;
+            ssid.Id = 0;
+            TUint32 id = GetSecSSIDFromUriL(aURI);
+            TInt count = secondarySSIDs.Count();
+            for (TInt i = 0; i < count; i++)
+                {
+                if (id == secondarySSIDs[i].Id)
+                    {
+                    ssid = secondarySSIDs[i];
+                    break;
+                    }
+                }
+            CleanupStack::PopAndDestroy(&secondarySSIDs);
+            if (ssid.Id == 0)
+                {
+                status = CSmlDmAdapter::ENotFound;
+                }
+            else
+                {
+                HBufC* data = ssid.UsedId.AllocLC();
+                HBufC8* data8 = HBufC8::NewLC(data->Size());
+                TPtr8 dataPtr8 = data8->Des();
+                //FFS
+                CnvUtfConverter::ConvertFromUnicodeToUtf8(dataPtr8,
+                        data->Des());
+
+                aObject.InsertL(0, dataPtr8);
+                status = CSmlDmAdapter::EOk;
+
+                CleanupStack::PopAndDestroy(2); //data, data8
+                }
+            }
+        else
+            {
+
+            HBufC* data = iSettings->UsedSSID.AllocLC();
+            HBufC8* data8 = HBufC8::NewLC(data->Size());
+            TPtr8 dataPtr8 = data8->Des();
+            //FFS
+            CnvUtfConverter::ConvertFromUnicodeToUtf8(dataPtr8, data->Des());
+
+            aObject.InsertL(0, dataPtr8);
+            status = CSmlDmAdapter::EOk;
+
+            CleanupStack::PopAndDestroy(2); //data, data8
+
+            }
+
+        }
+
+    else if (lastUriSeg.Compare(KNSmlWLanSsidHidden) == 0)
+        {
+        if (iSettings->ScanSSID == 1)
+            {
+            aObject.InsertL(0, _L8("True"));
+            }
+        else
+            {
+            aObject.InsertL(0, _L8("False"));
+            }
+        status = CSmlDmAdapter::EOk;
+        }
+
+    else if (lastUriSeg.Compare(KNSmlWLanNetworkMode) == 0)
+        {
+        status = CSmlDmAdapter::EOk;
+
+        switch (iSettings->ConnectionMode)
+            {
+            case 0:
+                aObject.InsertL(0, KNSmlWLanAdHoc8);
+                break;
+            case 1:
+                aObject.InsertL(0, KNSmlWLanInfrastructure8);
+                break;
+            default:
+                status = CSmlDmAdapter::ENotFound;
+                break;
+            }
+        }
+    else if (lastUriSeg.Compare(KNSmlWLanSecurityMode) == 0)
+        {
+        status = CSmlDmAdapter::EOk;
+
+        switch (iSettings->SecurityMode)
+            {
+            case EAllowUnsecure:
+                aObject.InsertL(0, KNSmlWLanAllowUnsecure8);
+                break;
+            case EWep:
+                aObject.InsertL(0, KNSmlWLanWep8);
+                break;
+            case EWlan8021x:
+                aObject.InsertL(0, KNSmlWLan8021x8);
+                break;
+            case EWpa:
+                aObject.InsertL(0, KNSmlWLanWpa8);
+                break;
+            case EWpa2:
+                aObject.InsertL(0, KNSmlWLanWpa28);
+                break;
+            default:
+                status = CSmlDmAdapter::ENotFound;
+                break;
+            }
+        }
+
+    else if (lastUriSeg.Compare(KNSmlWLanWpaPreSharedKey) == 0)
+        {
+        aObject.InsertL(0, iSettings->WPAPreSharedKey);
+        status = CSmlDmAdapter::EOk;
+        }
+
+    else if (lastUriSeg.Compare(KNSmlWLanUseWPAPSK) == 0)
+        {
+        if (iSettings->UseWPAPSK == 1)
+            {
+            aObject.InsertL(0, _L8("True"));
+            }
+        else
+            {
+            aObject.InsertL(0, _L8("False"));
+            }
+        status = CSmlDmAdapter::EOk;
+        }
+
+    else if (lastUriSeg.Compare(KNSmlWLanWepIndex) == 0)
+        {
+        HBufC8* data = IntToDes8LC(iSettings->WepIndex);
+        aObject.InsertL(0, data->Des());
+
+        CleanupStack::PopAndDestroy(data); //data
+        status = CSmlDmAdapter::EOk;
+        }
+
+    else if (lastUriSeg.Compare(KNSmlWLanEapList) == 0)
+        {
+        HBufC* data = iSettings->EapList.AllocLC();
+        HBufC8* data8 = HBufC8::NewLC(data->Size());
+        TPtr8 dataPtr8 = data8->Des();
+        //FFS
+        CnvUtfConverter::ConvertFromUnicodeToUtf8(dataPtr8, data->Des());
+
+        aObject.InsertL(0, dataPtr8);
+        status = CSmlDmAdapter::EOk;
+
+        CleanupStack::PopAndDestroy(2); //data, data8
+
+        }
+
+    else if (lastUriSeg.Compare(KNSmlWLanAuthMode) == 0)
+        {
+        HBufC8* data = IntToDes8LC(iSettings->AuthMode);
+        aObject.InsertL(0, data->Des());
+
+        CleanupStack::PopAndDestroy(data); //data
+        status = CSmlDmAdapter::EOk;
+        }
+
+    else if (lastUriSeg.Compare(KNSmlWLanWepKeyData) == 0)
+        {
+        TInt wepKeyIndex = GetWepKeyIdFromLuid(aLUID);
+        if (wepKeyIndex == KErrNotFound)
+            {
+            wepKeyIndex = GetWepKeyIdFromUri(aURI);
+            TBuf8<80> addLUID; // AP/<x>/NapDef/<x>/WLAN/<x>/WEPKey/WKIdnnn
+            addLUID.AppendNum(wepKeyIndex);
+            addLUID.AppendNumFixedWidth(luid, EDecimal, 3);
+            DBG_ARGS8(
+                    _S8(
+                            "WLanAdapter::Fetchleaf object, set mapping uri: <%S> to luid: <%S>"),
+                    &aURI, &addLUID);
+            DBG_ARGS8(_S8("Parametrit - <%S> <%S>"), &aURI, &addLUID);
+            iCallBack->SetMappingL(aURI, addLUID);
+
+            }
+        status = CSmlDmAdapter::EOk;
+        switch (wepKeyIndex)
+            {
+            case 1:
+                aObject.InsertL(0, iSettings->WepKey1);
+                break;
+            case 2:
+                aObject.InsertL(0, iSettings->WepKey2);
+                break;
+            case 3:
+                aObject.InsertL(0, iSettings->WepKey3);
+                break;
+            case 4:
+                aObject.InsertL(0, iSettings->WepKey4);
+                break;
+            default:
+                status = CSmlDmAdapter::EError;
+            }
+        }
+    else if (lastUriSeg.Compare(KNSmlWLanWepKeyId) == 0)
+        {
+        TInt wepKeyIndex = GetWepKeyIdFromLuid(aLUID);
+        if (wepKeyIndex == KErrNotFound)
+            {
+            wepKeyIndex = GetWepKeyIdFromUri(aURI);
+            TBuf8<80> addLUID; // AP/<x>/NapDef/<x>/WLAN/<x>/WEPKey/WKIdnnn
+            addLUID.AppendNum(wepKeyIndex);
+            addLUID.AppendNumFixedWidth(luid, EDecimal, 3);
+            DBG_ARGS8(
+                    _S8(
+                            "WLanAdapter::Fetchleaf object, set mapping uri: <%S> to luid: <%S>"),
+                    &aURI, &addLUID);
+            DBG_ARGS8(_S8("Parametrit - <%S> <%S>"), &aURI, &addLUID);
+            iCallBack->SetMappingL(aURI, addLUID);
+            }
+        if (wepKeyIndex > 0)
+            {
+            HBufC8* data = IntToDes8LC(wepKeyIndex);
+            aObject.InsertL(0, data->Des());
+            CleanupStack::PopAndDestroy(data); //data
+            status = CSmlDmAdapter::EOk;
+            }
+        else
+            {
+            status = CSmlDmAdapter::EError;
+            }
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*")) != KErrNotFound)
+        {
+        TInt eapId = GetEAPIdFromUri(aURI);
+
+        // Check if the id contains encapsulating type as well
+        TInt encapsEapId = GetEncapsEAPIdFromUri(aURI);
+        if (encapsEapId == KErrNotFound)
+            {
+            encapsEapId = EEapNone;
+            }
+
+        ResetEAPStructL();
+        TEapExpandedType expandedTypecmbuf;
+        TEapExpandedType expandedTypeencapscmbuf;
+
+        GetExpandedType(eapId, encapsEapId, expandedTypecmbuf,
+                expandedTypeencapscmbuf);
+        TInt err = iWlanSettings->GetEAPSettings(luid, expandedTypecmbuf,
+                expandedTypeencapscmbuf, *iEAPSettings);
+
+        if (err != KErrNone || iEAPSettings == NULL)
+            {
+            status = CSmlDmAdapter::EError;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanEapType) == 0)
+            {
+            aObject.InsertL(0, *IntToDes8LC(eapId));
+            CleanupStack::PopAndDestroy(); // IntToDes8LC
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanUsername) == 0)
+            {
+            if (iEAPSettings->iUsernamePresent)
+                {
+                DesToBufferL(aObject, iEAPSettings->iUsername);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanPassword) == 0)
+            {
+            if (iEAPSettings->iPasswordPresent)
+                {
+                DesToBufferL(aObject, iEAPSettings->iPassword);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanRealm) == 0)
+            {
+            if (iEAPSettings->iRealmPresent)
+                {
+                DesToBufferL(aObject, iEAPSettings->iRealm);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanUsePseudonym) == 0)
+            {
+            if (iEAPSettings->iUsePseudonymsPresent
+                    && iEAPSettings->iUsePseudonyms)
+                {
+                aObject.InsertL(0, KTrue);
+                }
+            else
+                {
+                aObject.InsertL(0, KFalse);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanEncapsulation) == 0)
+            {
+            if (encapsEapId == EEapPeap)
+                {
+                aObject.InsertL(0, KEAPPEAP);
+                }
+            else if (encapsEapId == EEapTtls)
+                {
+                aObject.InsertL(0, KEAPTTLS);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanVerifyCertRealm) == 0)
+            {
+            if (iEAPSettings->iVerifyServerRealmPresent
+                    && iEAPSettings->iVerifyServerRealm)
+                {
+                aObject.InsertL(0, KTrue);
+                }
+            else
+                {
+                aObject.InsertL(0, KFalse);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanRequireClientAuthentication)
+                == 0)
+            {
+            if (iEAPSettings->iRequireClientAuthenticationPresent
+                    && iEAPSettings->iRequireClientAuthentication)
+                {
+                aObject.InsertL(0, KTrue);
+                }
+            else
+                {
+                aObject.InsertL(0, KFalse);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanSessionValidityTime) == 0)
+            {
+            if (iEAPSettings->iSessionValidityTimePresent)
+                {
+                aObject.InsertL(0, *IntToDes8LC(
+                        (TInt) iEAPSettings->iSessionValidityTime));
+                CleanupStack::PopAndDestroy(); // IntToDes8LC
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanCipherSuite) == 0)
+            {
+            FillCipherSuiteBufferL(aObject);
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanAllowPEAPv0) == 0)
+            {
+            if (iEAPSettings->iPEAPVersionsPresent
+                    && iEAPSettings->iPEAPv0Allowed)
+                {
+                aObject.InsertL(0, KTrue);
+                }
+            else
+                {
+                aObject.InsertL(0, KFalse);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanAllowPEAPv1) == 0)
+            {
+            if (iEAPSettings->iPEAPVersionsPresent
+                    && iEAPSettings->iPEAPv1Allowed)
+                {
+                aObject.InsertL(0, KTrue);
+                }
+            else
+                {
+                aObject.InsertL(0, KFalse);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanAllowPEAPv2) == 0)
+            {
+            if (iEAPSettings->iPEAPVersionsPresent
+                    && iEAPSettings->iPEAPv2Allowed)
+                {
+                aObject.InsertL(0, KTrue);
+                }
+            else
+                {
+                aObject.InsertL(0, KFalse);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+
+#ifdef FF_WLAN_EXTENSIONS 
+        else if (lastUriSeg.Compare(KNSmlWLanAuthProvMode) == 0)
+            {
+            if (iEAPSettings->iAuthProvModeAllowedPresent && iEAPSettings->iAuthProvModeAllowed)
+                {
+                aObject.InsertL(0, KTrue);
+                }
+            else
+                {
+                aObject.InsertL(0, KFalse);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanUnauthProvMode) == 0)
+            {
+            if (iEAPSettings->iUnauthProvModeAllowedPresent && iEAPSettings->iUnauthProvModeAllowed)
+                {
+                aObject.InsertL(0, KTrue);
+                }
+            else
+                {
+                aObject.InsertL(0, KFalse);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanPACGroupRef) == 0)
+            {
+            if (iEAPSettings->iPACGroupReferencePresent)
+                {
+                DesToBufferL(aObject, iEAPSettings->iPACGroupReference);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanWarnADHPNoPAC) == 0)
+            {
+            if (iEAPSettings->iWarnADHPNoPACPresent && iEAPSettings->iWarnADHPNoPAC)
+                {
+                aObject.InsertL(0, KTrue);
+                }
+            else
+                {
+                aObject.InsertL(0, KFalse);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanWarnADHPNoMatchPAC) == 0)
+            {
+            if (iEAPSettings->iWarnADHPNoMatchingPACPresent && iEAPSettings->iWarnADHPNoMatchingPAC)
+                {
+                aObject.InsertL(0, KTrue);
+                }
+            else
+                {
+                aObject.InsertL(0, KFalse);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+
+        else if (lastUriSeg.Compare(KNSmlWLanWarnNotDefaultSrv) == 0)
+            {
+            if (iEAPSettings->iWarnNotDefaultServerPresent && iEAPSettings->iWarnNotDefaultServer)
+                {
+                aObject.InsertL(0, KTrue);
+                }
+            else
+                {
+                aObject.InsertL(0, KFalse);
+                }
+            status = CSmlDmAdapter::EOk;
+            }
+
+#endif  
+
+        else if (lastUriSeg.Compare(KNSmlWLanIssuerName) == 0)
+            {
+            status = CSmlDmAdapter::ENotFound;
+
+            TInt certId = GetCertificateIdFromUri(aURI);
+
+            if (iEAPSettings->iCertificatesPresent
+                    && iEAPSettings->iCertificates.Count() >= certId
+                    && certId != KErrNotFound)
+                {
+                if (iEAPSettings->iCertificates[certId - 1]->GetIssuerNamePresent())
+                    {
+                    aObject.InsertL(0,
+                            ConvertTo8LC(*(iEAPSettings->iCertificates[certId
+                                    - 1]->GetIssuerName())));
+                    CleanupStack::PopAndDestroy(); // ConvertTo8LC
+                    status = CSmlDmAdapter::EOk;
+                    }
+                }
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanSubjectName) == 0)
+            {
+            status = CSmlDmAdapter::ENotFound;
+
+            TInt certId = GetCertificateIdFromUri(aURI);
+
+            if (iEAPSettings->iCertificatesPresent
+                    && iEAPSettings->iCertificates.Count() >= certId
+                    && certId != KErrNotFound)
+                {
+                if (iEAPSettings->iCertificates[certId - 1]->GetSubjectNamePresent())
+                    {
+                    aObject.InsertL(0,
+                            ConvertTo8LC(*(iEAPSettings->iCertificates[certId
+                                    - 1]->GetSubjectName())));
+                    CleanupStack::PopAndDestroy(); // ConvertTo8LC
+                    status = CSmlDmAdapter::EOk;
+                    }
+                }
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanCertType) == 0)
+            {
+            status = CSmlDmAdapter::ENotFound;
+
+            TInt certId = GetCertificateIdFromUri(aURI);
+
+            if (iEAPSettings->iCertificatesPresent
+                    && iEAPSettings->iCertificates.Count() >= certId
+                    && certId != KErrNotFound)
+                {
+                aObject.InsertL(
+                        0,
+                        *IntToDes8LC(
+                                iEAPSettings->iCertificates[certId - 1]->GetCertType()));
+                CleanupStack::PopAndDestroy(); // IntToDes8LC
+                status = CSmlDmAdapter::EOk;
+                }
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanSerialNumber) == 0)
+            {
+            status = CSmlDmAdapter::ENotFound;
+
+            TInt certId = GetCertificateIdFromUri(aURI);
+
+            if (iEAPSettings->iCertificatesPresent
+                    && iEAPSettings->iCertificates.Count() >= certId
+                    && certId != KErrNotFound)
+                {
+                if (iEAPSettings->iCertificates[certId - 1]->GetSerialNumberPresent())
+                    {
+                    aObject.InsertL(0,
+                            ConvertTo8LC(*(iEAPSettings->iCertificates[certId
+                                    - 1]->GetSerialNumber())));
+                    CleanupStack::PopAndDestroy(); // ConvertTo8LC
+                    status = CSmlDmAdapter::EOk;
+                    }
+                }
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanSubjectKeyId) == 0)
+            {
+            status = CSmlDmAdapter::ENotFound;
+
+            TInt certId = GetCertificateIdFromUri(aURI);
+
+            if (iEAPSettings->iCertificatesPresent
+                    && iEAPSettings->iCertificates.Count() >= certId
+                    && certId != KErrNotFound)
+                {
+                if (iEAPSettings->iCertificates[certId - 1]->GetSubjectKeyIdPresent())
+                    {
+                    _DBG_FILE(
+                            "CNSmlWLanAdapter::FetchLeafObject - Fetch subject key.");
+                    // check the lenght of the given subjectKeyId, if it is longer that 20, then we
+                    // update the status with error and will not go through the key
+                    if ((iEAPSettings->iCertificates[certId - 1]->GetSubjectKeyId().Length())
+                            > KKeyIdentifierLength)
+                        {
+                        status = CSmlDmAdapter::EError;
+                        }
+                    else
+                        {
+                        _DBG_FILE(
+                                "CNSmlWLanAdapter::FetchLeafObject - key is under max lenght");
+                        TBuf8<KKeyIdentifierLength>
+                                binKey = iEAPSettings->iCertificates[certId
+                                        - 1]->GetSubjectKeyId();
+                        TBuf8<2> idBuf;
+                        TBuf8<KKeyIdentifierLength * 2> key;
+                        TUint8 byte;
+
+                        // hexadecimal representation
+                        _LIT8(KFormat, "%02x");
+
+                        // looping the subject key through
+                        for (TInt i = 0; i < binKey.Length(); i++)
+                            {
+                            _DBG_FILE(
+                                    "CNSmlWLanAdapter::FetchLeafObject - Loop the key through.");
+                            // pick the next value from the buffer
+                            byte = binKey[i];
+                            // convert the value into hexadecimal format
+                            idBuf.Format(KFormat, byte);
+                            // store the hexa value into the key variable
+                            key.Append(idBuf);
+                            }
+                        // Copy the key to the aObject variable
+                        aObject.InsertL(0, key);
+                        status = CSmlDmAdapter::EOk;
+                        }
+                    }
+                }
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanFingerprint) == 0)
+            {
+            status = CSmlDmAdapter::ENotFound;
+
+            TInt certId = GetCertificateIdFromUri(aURI);
+
+            if (iEAPSettings->iCertificatesPresent
+                    && iEAPSettings->iCertificates.Count() >= certId
+                    && certId != KErrNotFound)
+                {
+                if (iEAPSettings->iCertificates[certId - 1]->GetThumbprintPresent())
+                    {
+                    aObject.InsertL(0,
+                            ConvertTo8LC(*(iEAPSettings->iCertificates[certId
+                                    - 1]->GetThumbprint())));
+                    CleanupStack::PopAndDestroy(); // ConvertTo8LC
+                    status = CSmlDmAdapter::EOk;
+                    }
+                }
+            }
+        else if (lastUriSeg.Compare(KNSmlWLanSerialNumber) == 0)
+            {
+            status = CSmlDmAdapter::ENotFound;
+
+            TInt certId = GetCertificateIdFromUri(aURI);
+
+            if (iEAPSettings->iCertificatesPresent
+                    && iEAPSettings->iCertificates.Count() >= certId
+                    && certId != KErrNotFound)
+                {
+                if (iEAPSettings->iCertificates[certId - 1]->GetSerialNumberPresent())
+                    {
+                    aObject.InsertL(0,
+                            ConvertTo8LC(*(iEAPSettings->iCertificates[certId
+                                    - 1]->GetSerialNumber())));
+                    CleanupStack::PopAndDestroy(); // ConvertTo8LC
+                    status = CSmlDmAdapter::EOk;
+                    }
+                }
+            }
+        }
+
+    DBG_ARGS(_S16("CNSmlWLanAdapter::FetchLeafObjectL - Status <%D>"), status);
+    _DBG_FILE("CNSmlWLanAdapter::FetchLeafObjectL(): end");
+    return status;
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::ChildURIListL( const TDesC& aURI, 
+// const TDesC& aLUID, const CArrayFix<TNSmlDmMappingInfo>& aPreviousURISegmentList, 
+// const TInt aResultsRef, const TInt aStatusRef )
+//-----------------------------------------------------------------------------
+void CNSmlWLanAdapter::ChildURIListL(const TDesC8& aURI, const TDesC8& aLUID,
+        const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList,
+        const TInt aResultsRef, const TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): begin");
+    DBG_ARGS8(_S8("WLanAdapter::ChildURIListL - <%S> <%S>"), &aURI, &aLUID);
+    CBufBase* currentUriSegmentList = CBufFlat::NewL(128);
+    CleanupStack::PushL(currentUriSegmentList);
+
+    TInt uriSegs = NumOfUriSegs(aURI);
+    TInt luid = GetIdFromLuid(aLUID);
+
+    //AP/<x>/NAPDef/<x>/
+    if (aURI.Match(_L8("AP/*/NAPDef/*")) != KErrNotFound && uriSegs == 4)
+        {
+        DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->NAPDef - <%S> <%S>"),
+                &aURI, &aLUID);
+        if (luid == KErrNotFound)
+            {
+            return;
+            }
+        if (iWlanSettings->RecordExists(luid) < 0)
+            {
+            currentUriSegmentList->InsertL(0, KNSmlNAPDefWlanNode);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                    KNullDesC8);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+            }
+        else
+            {
+            currentUriSegmentList->InsertL(0, KNSmlNAPDefWlanNode);
+            currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                    KNSmlWLan);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                    KNullDesC8);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+            }
+        }
+
+    //AP/<x>/NAPDef/<x>/WLAN
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN")) != KErrNotFound && uriSegs
+            == 5)
+        {
+        if (aPreviousURISegmentList.Count() > 0)
+            {
+            HBufC8 *uriSeg = HBufC8::NewLC(KNSmlMaxURISegLen);
+            TPtr8 uriSegPtr = uriSeg->Des();
+            uriSegPtr = aPreviousURISegmentList.At(0).iURISeg;
+            currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                    uriSegPtr);
+            CleanupStack::PopAndDestroy(uriSeg); //uriSeg
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                    KNullDesC8);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+            }
+        else
+            {
+            if (luid == KErrNotFound)
+                {
+                return;
+                }
+            if (iWlanSettings->RecordExists(luid) < 0)
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                _DBG_FILE(
+                        "CNSmlWLanAdapter::ChildURIListL(): status: Not found");
+                }
+            else
+                {
+                _LIT8(Kprev, "WLId");
+                TBuf8<9> addNAME(Kprev); // WLId
+                addNAME.AppendNumFixedWidth(luid, EDecimal, 3);
+
+                currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                        addNAME);
+                currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                        _L8("/"));
+
+                TBuf8<80> addURI; // AP/<x>/NapDef/<x>/WLAN/WLIdnnn , n=aLUID
+                addURI.Append(aURI);
+                addURI.Append(_L8("/WLId"));
+                addURI.AppendNumFixedWidth(luid, EDecimal, 3);
+
+                TBuf8<16> addLUID;
+                _LIT8(KFormat, "%d");
+                addLUID.Format(KFormat, luid);
+
+                // Also added to mapping
+                DBG_ARGS8(
+                        _S8(
+                                "WLanAdapter::ChildURIListL - mapping uri: <%S> to luid: <%S>"),
+                        &addURI, &addLUID);
+                DBG_ARGS8(_S8("Parameters - <%S> <%S>"), &aURI, &aLUID);
+                iCallBack->SetMappingL(addURI, addLUID);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+                iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                        KNullDesC8);
+                _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+                }
+            }
+        }
+
+    //AP/<x>/NAPDef/<x>/WLAN/<x>
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*")) != KErrNotFound
+            && uriSegs == 6)
+        {
+        DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->NAPDef - <%S> <%S>"),
+                &aURI, &aLUID);
+        if (luid == KErrNotFound)
+            {
+            return;
+            }
+        if (iWlanSettings->RecordExists(luid) < 0)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
+            }
+        else
+            {
+            currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                    KNSmlWLanListOfLeafs);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                    KNullDesC8);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+            }
+        }
+
+    //AP/<x>/NAPDef/<x>/WLAN/<x>/WEPKey
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/WEPKey")) != KErrNotFound
+            && uriSegs == 7)
+        {
+        DBG_ARGS8(_S8(
+                "WLanAdapter::ChildURIListL->WEPKey - <%S> <%S> <%D> <%D>"),
+                &aURI, &aLUID, aResultsRef, aStatusRef);
+
+        for (TInt i = 0; i < 4; i++)
+            {
+            if (aPreviousURISegmentList.Count() > i)
+                {
+                HBufC8 *uriSeg = HBufC8::NewLC(KNSmlMaxURISegLen);
+                TPtr8 uriSegPtr = uriSeg->Des();
+                uriSegPtr = aPreviousURISegmentList.At(i).iURISeg;
+
+                currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                        uriSegPtr);
+                currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                        _L8("/"));
+                CleanupStack::PopAndDestroy(); //uriSeg
+                }
+            else
+                {
+                TBuf8<25> addNAME;
+                addNAME.Append(_L8("WKId"));
+                addNAME.AppendNum(i + 1);
+                addNAME.Append(_L8("/"));
+
+                currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                        addNAME);
+                }
+            }
+
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                KNullDesC8);
+        _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+        }
+
+    //AP/<x>/NAPDef/<x>/WEPKey/<x>
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*")) != KErrNotFound
+            && uriSegs == 8)
+        {
+        DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->WEPKey/* - <%S> <%D>"),
+                &aURI, luid);
+        if (luid == KErrNotFound)
+            {
+            return;
+            }
+        if (iWlanSettings->RecordExists(luid) < 0)
+            {
+            //wlan settings not found for aLUID
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
+            }
+        else
+            {
+            TInt wepKeyId = GetWepKeyIdFromLuid(aLUID);
+            if (wepKeyId == KErrNotFound)
+                {
+                wepKeyId = GetWepKeyIdFromUri(aURI);
+
+                TBuf8<80> addLUID; // AP/<x>/NapDef/<x>/WLAN/<x>/WEPKey/WKIdnnn
+                addLUID.AppendNum(wepKeyId);
+                addLUID.AppendNumFixedWidth(luid, EDecimal, 3);
+
+                DBG_ARGS8(
+                        _S8(
+                                "WLanAdapter::ChildURIListL - mapping uri: <%S> to luid: <%S>"),
+                        &aURI, &addLUID);
+                DBG_ARGS8(_S8("Parametrit - <%S> <%S>"), &aURI, &addLUID);
+                iCallBack->SetMappingL(aURI, addLUID);
+                }
+
+            currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                    KNSmlWLanListOfWepKeyLeafs);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                    KNullDesC8);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+            }
+        }
+
+    //AP/<x>/NAPDef/<x>/WLAN/<x>/SecondarySSID/
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID"))
+            != KErrNotFound && uriSegs == 7)
+        {
+        DBG_ARGS8(
+                _S8("WLanAdapter::ChildURIListL->EAP - <%S> <%S> <%D> <%D>"),
+                &aURI, &aLUID, aResultsRef, aStatusRef);
+        if (aPreviousURISegmentList.Count() > 0)
+            {
+            HBufC8 *uriSeg = HBufC8::NewLC(KNSmlMaxURISegLen);
+            TPtr8 uriSegPtr = uriSeg->Des();
+            uriSegPtr = aPreviousURISegmentList.At(0).iURISeg;
+            currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                    uriSegPtr);
+            CleanupStack::PopAndDestroy(uriSeg); //uriSeg
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                    KNullDesC8);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+            }
+        else
+            {
+            if (luid == KErrNotFound)
+                {
+                return;
+                }
+            if (iWlanSettings->RecordExists(luid) < 0)
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                _DBG_FILE(
+                        "CNSmlWLanAdapter::ChildURIListL(): status: Not found");
+                }
+            else
+                {
+                RArray<TSecondarySSID> secondarySSIDs;
+                CleanupClosePushL(secondarySSIDs);
+                iWlanSettings->GetSecondarySSIDListL(luid, secondarySSIDs);
+                TInt count = secondarySSIDs.Count();
+                _LIT8(KPrefixSSID, "SecSSID");
+                TBuf8<5> addNAME; // number
+                for (TInt i = 0; i < count; i++)
+                    {
+                    if (i != 0) // Don't do it in first iteration, but with all the following
+                        {
+                        currentUriSegmentList->InsertL(
+                                currentUriSegmentList->Size(), _L8("/"));
+                        }
+                    currentUriSegmentList->InsertL(
+                            currentUriSegmentList->Size(), KPrefixSSID);
+                    addNAME.Zero();
+                    addNAME.AppendNumFixedWidth(secondarySSIDs[i].Id,
+                            EDecimal, 3);
+                    currentUriSegmentList->InsertL(
+                            currentUriSegmentList->Size(), addNAME);
+                    }
+                CleanupStack::PopAndDestroy(&secondarySSIDs);
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+                iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                        KNullDesC8);
+                _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+                }
+            }
+        }
+    //AP/<x>/NAPDef/<x>/WLAN/<x>/SecondarySSID/*
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*"))
+            != KErrNotFound && uriSegs == 8)
+        {
+        DBG_ARGS8(_S8(
+                "WLanAdapter::ChildURIListL->SecondarySSID/* - <%S> <%D>"),
+                &aURI, luid);
+        if (luid == KErrNotFound)
+            {
+            return;
+            }
+        if (iWlanSettings->RecordExists(luid) < 0)
+            {
+            //wlan settings not found for aLUID
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
+            }
+        else
+            {
+            currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                    KNSmlWLanListOfSecondaryLeafs);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                    KNullDesC8);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+            }
+        }
+    //AP/<x>/NAPDef/<x>/WLAN/<x>/EAP
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP")) != KErrNotFound
+            && uriSegs == 7)
+        {
+        DBG_ARGS8(
+                _S8("WLanAdapter::ChildURIListL->EAP - <%S> <%S> <%D> <%D>"),
+                &aURI, &aLUID, aResultsRef, aStatusRef);
+
+        // Need to get the service id from parent node
+        luid = GetServiceIdFromUriL(aURI);
+
+        if (luid == KErrNotFound)
+            {
+            return;
+            }
+        if (iWlanSettings->RecordExists(luid) < 0)
+            {
+            //wlan settings not found for aLUID
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
+            }
+        else
+            {
+            iWlanSettings->InstalledEAPsL(*currentUriSegmentList);
+
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                    KNullDesC8);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+            }
+        }
+    //AP/<x>/NAPDef/<x>/WLAN/<x>/EAP/<x>
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*")) != KErrNotFound
+            && uriSegs == 8)
+        {
+        // Need to get the service id from parent node
+        luid = GetServiceIdFromUriL(aURI);
+
+        DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->EAP/* - <%S> <%D>"),
+                &aURI, luid);
+        if (iWlanSettings->RecordExists(luid) < 0)
+            {
+            //wlan settings not found for aLUID
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
+            }
+        else
+            {
+            currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                    KNSmlWLanListOfEAPLeafs);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                    KNullDesC8);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+            }
+        }
+    //AP/<x>/NAPDef/<x>/WLAN/<x>/EAP/<x>/Certificate
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate"))
+            != KErrNotFound && uriSegs == 9)
+        {
+        luid = GetServiceIdFromUriL(aURI);
+
+        DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->Certificate - <%S> <%D>"),
+                &aURI, luid);
+        if (iWlanSettings->RecordExists(luid) < 0)
+            {
+            //wlan settings not found for aLUID
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
+            }
+        else
+            {
+            TInt eapId = GetEAPIdFromUri(aURI);
+
+            // Check if the id contains encapsulating type as well
+            TInt encapsEapId = GetEncapsEAPIdFromUri(aURI);
+            if (encapsEapId == KErrNotFound)
+                {
+                encapsEapId = EEapNone;
+                }
+
+            ResetEAPStructL();
+            TEapExpandedType expandedTypecmbuf;
+            TEapExpandedType expandedTypeencapscmbuf;
+
+            GetExpandedType(eapId, encapsEapId, expandedTypecmbuf,
+                    expandedTypeencapscmbuf);
+
+            TInt err = iWlanSettings->GetEAPSettings(luid, expandedTypecmbuf,
+                    expandedTypeencapscmbuf, *iEAPSettings);
+            if (err != KErrNone || !iEAPSettings->iCertificatesPresent)
+                {
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+                _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
+                }
+            else
+                {
+                TInt certCount = iEAPSettings->iCertificates.Count();
+                HBufC8* pBuf = HBufC8::NewLC(KNSmlMaxURISegLen);
+                TPtr8 ptrCerts = pBuf->Des();
+                for (TInt i = 0; i < certCount; i++)
+                    {
+                    ptrCerts.Append(_L8("CertId"));
+                    ptrCerts.AppendNumFixedWidth(i + 1, EDecimal, 3);
+                    ptrCerts.Append(_L8("/"));
+                    }
+
+                currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                        ptrCerts);
+                CleanupStack::PopAndDestroy(pBuf); // pBuf
+                iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+                iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                        KNullDesC8);
+                _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+                }
+            }
+        }
+    //AP/<x>/NAPDef/<x>/WLAN/<x>/EAP/<x>/Certificate/<x>
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*"))
+            != KErrNotFound && uriSegs == 10)
+        {
+        DBG_ARGS8(_S8("WLanAdapter::ChildURIListL->EAP/* - <%S> <%D>"),
+                &aURI, luid);
+        TInt eapId = GetEAPIdFromUri(aURI);
+        // Check if the id contains encapsulating type as well
+        TInt encapsEapId = GetEncapsEAPIdFromUri(aURI);
+        if (encapsEapId == KErrNotFound)
+            {
+            encapsEapId = EEapNone;
+            }
+
+        ResetEAPStructL();
+        TEapExpandedType expandedTypecmbuf;
+        TEapExpandedType expandedTypeencapscmbuf;
+
+        GetExpandedType(eapId, encapsEapId, expandedTypecmbuf,
+                expandedTypeencapscmbuf);
+
+        TInt err = iWlanSettings->GetEAPSettings(luid, expandedTypecmbuf,
+                expandedTypeencapscmbuf, *iEAPSettings);
+        if (err != KErrNone || !iEAPSettings->iCertificatesPresent)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): ENotFound end");
+            }
+        else
+            {
+            currentUriSegmentList->InsertL(currentUriSegmentList->Size(),
+                    KNSmlWLanListOfCertificateLeafs);
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+            iCallBack->SetResultsL(aResultsRef, *currentUriSegmentList,
+                    KNullDesC8);
+            _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): status ok");
+            }
+        }
+
+    CleanupStack::PopAndDestroy(currentUriSegmentList);
+
+    _DBG_FILE("CNSmlWLanAdapter::ChildURIListL(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// void CNSmlWLanAdapter::AddNodeObjectL( const TDesC& aURI, const TDesC& aParentLUID, 
+// const TInt aStatusRef )
+//-----------------------------------------------------------------------------
+void CNSmlWLanAdapter::AddNodeObjectL(const TDesC8& aURI,
+        const TDesC8& aParentLUID, const TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::AddNodeObjectL(): begin");
+    DBG_ARGS8(_S8(
+            "WLanAdapter::AddNodeObjectL - uri: <%S> to aParentLuid: <%S>"),
+            &aURI, &aParentLUID);
+
+    TInt uriSegs = NumOfUriSegs(aURI);
+    if ((aURI.Match(_L8("AP/*/NAPDef/*/WLAN")) != KErrNotFound && uriSegs
+            == 5) || (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP"))
+            != KErrNotFound && uriSegs == 7) || (aURI.Match(_L8(
+            "AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate")) != KErrNotFound
+            && uriSegs == 9))
+        {
+        iCallBack->SetMappingL(aURI, aParentLUID);
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        return;
+        }
+
+    //Add new wlan settings
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*")) != KErrNotFound
+            && NumOfUriSegs(aURI) == 6)
+        {
+        TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+        TUint32 serviceId(NULL);
+        TUint32 lValue;
+        CCommsDbTableView* napdefView = iDatabase.OpenViewMatchingUintLC(
+                TPtrC(IAP), TPtrC(COMMDB_ID), DesToInt(aParentLUID));
+        TInt errorCode = napdefView->GotoFirstRecord();
+        if (errorCode == KErrNone)
+            {
+            napdefView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+            napdefView->ReadUintL(TPtrC(IAP_SERVICE), serviceId); // ID 
+            }
+        CCommsDbTableView* tableView = iDatabase.OpenViewMatchingUintLC(
+                serviceType, TPtrC(COMMDB_ID), serviceId);
+        errorCode = tableView->GotoFirstRecord();
+        if (errorCode == KErrNone)
+            {
+            tableView->ReadUintL(TPtrC(COMMDB_ID), lValue);
+            }
+        CleanupStack::PopAndDestroy();//tableview
+        CleanupStack::PopAndDestroy();//napdefview
+
+        iSettings->Id = 0;
+        iSettings->ServiceID = lValue;
+        iSettings->ConnectionMode = 0;
+        iSettings->SSID = TPtrC(KNSmlWLanDefaultSSID);
+        iSettings->UsedSSID = _L("");
+        iSettings->ScanSSID = 0;
+        iSettings->WepKey1 = _L8("");
+        iSettings->WepKey2 = _L8("");
+        iSettings->WepKey3 = _L8("");
+        iSettings->WepKey4 = _L8("");
+        iSettings->WepIndex = 0;
+        iSettings->SecurityMode = EAllowUnsecure;
+        iSettings->WPAPreSharedKey = _L8("");
+        iSettings->UseWPAPSK = 0;
+        iSettings->EapList = _L("");
+        iSettings->AuthMode = 0;
+
+        TInt err = iWlanSettings->WriteWlanSettings(*iSettings);
+        if (err != KErrNone)
+            {
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+            return;
+            }
+
+        DBG_ARGS8(
+                _S8(
+                        "WLanAdapter::AddNodeObjectL - mapping uri: <%S> to luid: <%S>"),
+                &aURI, &aParentLUID);
+        iCallBack->SetMappingL(aURI, aParentLUID);
+        iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/WEPKey")) != KErrNotFound
+            && uriSegs == 7)
+        {
+        if (iWlanSettings->RecordExists(DesToInt(aParentLUID)))
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EOk);
+        else
+            iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::ENotFound);
+        return;
+        }
+
+    //Add wep key for existing record
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*")) != KErrNotFound
+            && uriSegs == 8)
+        {
+        for (TInt i = 0; i < iBuffer->Count(); i++)
+            {
+            if (iBuffer->At(i).iUri->Match(aURI) != KErrNotFound)
+                {
+                iCallBack->SetStatusL(aStatusRef,
+                        CSmlDmAdapter::EAlreadyExists);
+
+                _DBG_FILE(
+                        "CNSmlWLanAdapter::AddNodeObjectL(): EAlreadyExists");
+                return;
+                }
+            }
+        DBG_ARGS8(_S8(
+                "WLanAdapter::Bufferiin - uri: <%S> to aParentLuid: <%S>"),
+                &aURI, &aParentLUID);
+
+        TNSmlWepKeyBufferElement newNode;
+        newNode.iUri = aURI.AllocLC();
+        newNode.iData = 0;
+        newNode.iWepKeyId = 0;
+        //newNode.iUseWPAPSK = 0;
+        newNode.iIdStatusRef = 0;
+        newNode.iDataStatusRef = 0;
+        newNode.iLengthStatusRef = 0;
+        newNode.iNodeStatusRef = aStatusRef;
+        newNode.iExecuted = EFalse;
+        newNode.iDataSet = EFalse;
+        newNode.iLuid = DesToInt(aParentLUID);
+        iBuffer->AppendL(newNode);
+
+        CleanupStack::Pop(); //newNode.iUri
+
+        _DBG_FILE("CNSmlWLanAdapter::AddNodeObjectL(): end");
+        return;
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*"))
+            != KErrNotFound && NumOfUriSegs(aURI) == 8)
+        {
+        /*
+         TSecondarySSID ssid;
+         ssid.ScannedId = KNullDesC;
+         ssid.UsedId = KNullDesC;
+         TInt luid = GetIdFromLuid( aParentLUID );
+         TInt retval = iWlanSettings->WriteSecondarySSIDL(luid, ssid, ETrue);*/
+
+        TNSmlSecondarySSIDBufferElement *newSecNode =
+                new (ELeave) TNSmlSecondarySSIDBufferElement;
+        ;
+        newSecNode->iUri = aURI.AllocLC();
+        newSecNode->ScannedId = KNullDesC;
+        newSecNode->UsedId = KNullDesC;
+        newSecNode->iExecuted = EFalse;
+        newSecNode->wlanLuid = GetIdFromLuid(aParentLUID);
+        iSecondaryBuffer.AppendL(newSecNode);
+        CleanupStack::Pop(); //newNode.iUri
+        return;
+        }
+
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*")) != KErrNotFound
+            && NumOfUriSegs(aURI) == 8)
+        {
+        TInt eapTypeId = GetEAPIdFromUri(aURI);
+        TInt encapsEapId = GetEncapsEAPIdFromUri(aURI);
+        if (encapsEapId == KErrNotFound)
+            {
+            encapsEapId = EEapNone;
+            }
+
+        TInt WLANServiceId = GetServiceIdFromUriL(aURI);
+
+        if (WLANServiceId == KErrNotFound)
+            {
+            _DBG_FILE(
+                    "CNSmlWLanAdapter::AddNodeObjectL(): Could not find WLAN service ID from URI.");
+            User::Leave(KErrNotFound);
+            }
+        // append it to the appropriate list ('+' enabled, '-' disabled)
+        _LIT8(KPadding, "\xFE\0\0\0\0\0\0");
+        _LIT8(KMsChapV2Padding, "\xFE\xFF\xFF\xFF\0\0\0");
+        const TInt KPlainMsChapV2ImplUid = 99;
+
+        TBuf8<KExpandedEapIdLength> cmpbuf;
+        if (eapTypeId == KPlainMsChapV2ImplUid)
+            {
+            cmpbuf.Append(KMsChapV2Padding);
+            }
+        else
+            {
+            cmpbuf.Append(KPadding);
+            }
+        cmpbuf.Append(eapTypeId);
+        TEapExpandedType expandedTypecmbuf(cmpbuf);
+
+        TBuf8<KExpandedEapIdLength> encapscmpbuf;
+        if (encapsEapId == KPlainMsChapV2ImplUid)
+            {
+            encapscmpbuf.Append(KMsChapV2Padding);
+            }
+        else
+            {
+            encapscmpbuf.Append(KPadding);
+            }
+        encapscmpbuf.Append(encapsEapId);
+        TEapExpandedType expandedTypeencapscmbuf(encapscmpbuf);
+
+        TInt i(0);
+        // Check if the buffer for this EAP already exists
+        for (i = 0; i < iEAPBuffer.Count(); i++)
+            {
+            if ((expandedTypecmbuf.Compare(
+                    iEAPBuffer[i]->iEAPSettings->iEAPExpandedType) == 0)
+                    && (expandedTypeencapscmbuf.Compare(
+                            iEAPBuffer[i]->iEncapsulatingExpandedEapId) == 0))
+                {
+                // The correct buffer was found.                
+                _DBG_FILE(
+                        "CNSmlWLanAdapter::AddNodeObjectL(): Found existing buffer.");
+                break;
+                }
+            }
+        // buffer did not exist. Update the existing buffer
+        if (i == iEAPBuffer.Count())
+            {
+            TNSmlEAPBufferElement* buffer =
+                    new (ELeave) TNSmlEAPBufferElement;
+            CleanupStack::PushL(buffer);
+
+            buffer->iEAPSettings = new (ELeave) EAPSettings;
+            CleanupStack::PushL(buffer->iEAPSettings);
+
+            TBuf8<KExpandedEapIdLength> tempbuf;
+            if (eapTypeId == KPlainMsChapV2ImplUid)
+                {
+                tempbuf.Append(KMsChapV2Padding);
+                }
+            else
+                {
+                tempbuf.Append(KPadding);
+                }
+            tempbuf.Append(eapTypeId);
+
+            buffer->iEAPSettings->iEAPExpandedType = tempbuf;
+            buffer->iStatusRefArray.AppendL(aStatusRef);
+            buffer->iWLANServiceId = WLANServiceId;
+            ConvertEAPStringToIds(buffer->iEapTypeString,
+                    buffer->iEAPSettings->iEAPExpandedType);
+            TBuf8<KExpandedEapIdLength> encapsTempbuf;
+            if (encapsEapId == KPlainMsChapV2ImplUid)
+                {
+                encapsTempbuf.Append(KMsChapV2Padding);
+                }
+            else
+                {
+                encapsTempbuf.Append(KPadding);
+                }
+            encapsTempbuf.Append(encapsEapId);
+            buffer->iEncapsulatingExpandedEapId = encapsTempbuf;
+            if (buffer->iEncapsulatingExpandedEapId
+                    != (*EapExpandedTypeNone.GetType()))
+                {
+                ConvertEAPStringToIds(buffer->iEncapsulatingString,
+                        buffer->iEncapsulatingExpandedEapId);
+                }
+            iEAPBuffer.AppendL(buffer);
+
+            CleanupStack::Pop(buffer->iEAPSettings);
+            CleanupStack::Pop(buffer);
+            }
+
+        // Set the mapping luid to be the index to the iEAPBuffer
+        TBuf8<2> luid;
+        luid.Num(iEAPBuffer.Count() - 1);
+        DBG_ARGS8(
+                _S8(
+                        "WLanAdapter::AddNodeObjectL - mapping uri: <%S> to luid: <%S>"),
+                &aURI, &luid);
+        iCallBack->SetMappingL(aURI, luid);
+
+        }
+    else if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*"))
+            != KErrNotFound && NumOfUriSegs(aURI) == 10)
+        {
+        TPtrC8 ptr = NSmlDmURI::ParentURI(aURI);
+        TPtrC8 ptr2 = NSmlDmURI::ParentURI(ptr);
+
+        HBufC8* eapLuidBuf = iCallBack->GetLuidAllocL(ptr2);
+
+        TInt index = GetIdFromLuid(*eapLuidBuf);
+
+        delete eapLuidBuf;
+
+        EapCertificateEntry *entry = new (ELeave) EapCertificateEntry;
+        iEAPBuffer[index]->iEAPSettings->iCertificates.Append(entry);
+        iEAPBuffer[index]->iEAPSettings->iCertificatesPresent = ETrue;
+        iEAPBuffer[index]->iStatusRefArray.AppendL(aStatusRef);
+
+        TBuf8<2> luid;
+        luid.Num(iEAPBuffer[index]->iEAPSettings->iCertificates.Count() - 1);
+
+        DBG_ARGS8(
+                _S8(
+                        "WLanAdapter::AddNodeObjectL - mapping uri: <%S> to luid: <%S>"),
+                &aURI, &luid);
+        iCallBack->SetMappingL(aURI, luid);
+        }
+    _DBG_FILE("CNSmlWLanAdapter::AddNodeObjectL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlWLanAdapter::ExecuteCommandL
+// not supported
+//------------------------------------------------------------------------------
+void CNSmlWLanAdapter::ExecuteCommandL(const TDesC8& /*aURI*/,
+        const TDesC8& /*aLUID*/, const TDesC8& /*aArgument*/,
+        const TDesC8& /*aType*/, TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::ExecuteCommandL(): begin");
+    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlWLanAdapter::ExecuteCommandL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlWLanAdapter::ExecuteCommandL ( .. RWriteStream ..)
+// not supported
+//------------------------------------------------------------------------------
+void CNSmlWLanAdapter::ExecuteCommandL(const TDesC8& /*aURI*/,
+        const TDesC8& /*aLUID*/, RWriteStream*& /*aStream*/,
+        const TDesC8& /*aType*/, TInt aStatusref)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::ExecuteCommandL(): begin");
+    iCallBack->SetStatusL(aStatusref, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlWLanAdapter::ExecuteCommandL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlWLanAdapter::CopyCommandL
+// not supported
+//------------------------------------------------------------------------------
+void CNSmlWLanAdapter::CopyCommandL(const TDesC8& /*aTargetURI*/,
+        const TDesC8& /*aTargetLUID*/, const TDesC8& /* aSourceURI*/,
+        const TDesC8& /*aSourceLUID*/, const TDesC8& /*aType*/,
+        TInt aStatusRef)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::CopyCommandL(): begin");
+    iCallBack->SetStatusL(aStatusRef, CSmlDmAdapter::EError);
+    _DBG_FILE("CNSmlWLanAdapter::CopyCommandL(): end");
+    }
+//------------------------------------------------------------------------------
+// CNSmlWLanAdapter::StartAtomicL
+// not supported
+//------------------------------------------------------------------------------
+void CNSmlWLanAdapter::StartAtomicL()
+    {
+    _DBG_FILE("CNSmlWLanAdapter::StartAtomicL(): begin");
+    _DBG_FILE("CNSmlWLanAdapter::StartAtomicL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlWLanAdapter::CommitAtomicL
+// not supported
+//------------------------------------------------------------------------------
+void CNSmlWLanAdapter::CommitAtomicL()
+    {
+    _DBG_FILE("CNSmlWLanAdapter::CommitAtomicL(): begin");
+    _DBG_FILE("CNSmlWLanAdapter::CommitAtomicL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlWLanAdapter::RollbackAtomicL
+// returns EError
+//------------------------------------------------------------------------------
+void CNSmlWLanAdapter::RollbackAtomicL()
+    {
+    _DBG_FILE("CNSmlWLanAdapter::RollbackAtomicL(): begin");
+    _DBG_FILE("CNSmlWLanAdapter::RollbackAtomicL(): end");
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlWLanAdapter::StreamingSupport
+// returns EFalse
+//------------------------------------------------------------------------------
+
+TBool CNSmlWLanAdapter::StreamingSupport(TInt& /*aItemSize*/)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::StreamingSupport(): begin");
+    _DBG_FILE("CNSmlWLanAdapter::StreamingSupport(): end");
+    return EFalse;
+    }
+
+//------------------------------------------------------------------------------
+// CNSmlWLanAdapter::StreamCommittedL
+// not used in this adapter
+//------------------------------------------------------------------------------
+
+void CNSmlWLanAdapter::StreamCommittedL()
+    {
+    _DBG_FILE("CNSmlWLanAdapter::StreamCommittedL(): begin");
+    _DBG_FILE("CNSmlWLanAdapter::StreamCommittedL(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// CNSmlWLanAdapter* CNSmlWLanAdapter::CompleteOutstandingCmdsL( )
+//-----------------------------------------------------------------------------
+void CNSmlWLanAdapter::CompleteOutstandingCmdsL()
+    {
+    _DBG_FILE("CNSmlWLanAdapter::CompleteOutStandingCmdsL(): begin");
+
+    ExecuteBufferL(ETrue);
+
+    _DBG_FILE("CNSmlWLanAdapter::CompleteOutStandingCmdsL(): end");
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC8 CNSmlWLanAdapter::GetLastUriSeg(const TDesC8& aURI)
+// Returns only the last uri segemnt
+// ------------------------------------------------------------------------------------------------
+TPtrC8 CNSmlWLanAdapter::GetLastUriSeg(const TDesC8& aURI)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::GetLastUriSeg(): begin");
+
+    TInt i;
+    for (i = aURI.Length() - 1; i >= 0; i--)
+        {
+        if (aURI[i] == '/')
+            {
+            break;
+            }
+        }
+
+    if (i == 0)
+        {
+        _DBG_FILE("CNSmlWLanAdapter::GetLastUriSeg(): end");
+        return aURI;
+        }
+    else
+        {
+        _DBG_FILE("CNSmlWLanAdapter::GetLastUriSeg(): end");
+        return aURI.Mid(i + 1);
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TPtrC16 CNSmlWLanAdapter::RemoveLastURISeg(const TDesC8& aURI)
+// returns parent uri, i.e. removes last uri segment
+// ------------------------------------------------------------------------------------------------
+TPtrC8 CNSmlWLanAdapter::RemoveLastUriSeg(const TDesC8& aURI)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::RemoveLastUriSeg(): begin");
+
+    TInt i;
+    for (i = aURI.Length() - 1; i >= 0; i--)
+        {
+        if (aURI[i] == '/')
+            {
+            break;
+            }
+        }
+
+    _DBG_FILE("CNSmlWLanAdapter::RemoveLastUriSeg(): end");
+    return aURI.Left(i);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlWLanAdapter::DesToInt( const TDesC8& aLuid )
+// Returns aLuid as integer value
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlWLanAdapter::DesToInt(const TDesC8& aLuid)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::DesToInt(): begin");
+
+    TLex8 lex(aLuid);
+    TInt value = 0;
+    lex.Val(value);
+
+    DBG_ARGS8(_S8("WLanAdapter::DesToInt() - Des: <%S> Int: <%D>"), &aLuid,
+            value);
+    _DBG_FILE("CNSmlWLanAdapter::DesToInt(): end");
+    return value;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// HBufC* CNSmlWLanAdapter::IntToDesLC(const TInt aLuid)
+// ------------------------------------------------------------------------------------------------
+HBufC* CNSmlWLanAdapter::IntToDesLC(const TInt aLuid)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::IntToDesLC(): begin");
+
+    HBufC* buf = HBufC::NewLC(10);
+    TPtr ptrBuf = buf->Des();
+    ptrBuf.Num(aLuid);
+
+    _DBG_FILE("CNSmlWLanAdapter::IntToDesLC(): end");
+    return buf;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// HBufC8* CNSmlWLanAdapter::IntToDes8LC(const TInt aLuid)
+// ------------------------------------------------------------------------------------------------
+HBufC8* CNSmlWLanAdapter::IntToDes8LC(const TInt aLuid)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::IntToDes8LC(): begin");
+
+    HBufC8* buf = HBufC8::NewLC(10);
+    TPtr8 ptrBuf = buf->Des();
+    ptrBuf.Num(aLuid);
+
+    _DBG_FILE("CNSmlWLanAdapter::IntToDes8LC(): end");
+    return buf;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlWLanAdapter::NumOfUriSegs( const TDesC8& aUri )
+// Return count of URI segments of aUri
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlWLanAdapter::NumOfUriSegs(const TDesC8& aUri)
+    {
+    _DBG_FILE("CNSmlWLanAdapter::NumOfUriSegs(): begin");
+
+    TInt count = 1;
+    for (TInt i = 0; i < aUri.Length(); i++)
+        {
+        if (aUri[i] == '/')
+            count++;
+        }
+
+    _DBG_FILE("CNSmlWLanAdapter::NumOfUriSegs(): end");
+    return count;
+    }
+
+// -------------------------------------------------------------------------------------
+// CNSmlWLanAdapter::FillNodeInfoL()
+// Fills the node info in ddf structure
+// -------------------------------------------------------------------------------------
+void CNSmlWLanAdapter::FillNodeInfoL(MSmlDmDDFObject& aNode,
+        TSmlDmAccessTypes aAccTypes, MSmlDmDDFObject::TOccurence aOccurrence,
+        MSmlDmDDFObject::TScope aScope, MSmlDmDDFObject::TDFFormat aFormat,
+        const TDesC8& aDescription)
+
+    {
+    aNode.SetAccessTypesL(aAccTypes);
+    aNode.SetOccurenceL(aOccurrence);
+    aNode.SetScopeL(aScope);
+    aNode.SetDFFormatL(aFormat);
+    if (aFormat != MSmlDmDDFObject::ENode)
+        {
+        aNode.AddDFTypeMimeTypeL(KNSmlMimeType);
+        }
+    aNode.SetDescriptionL(aDescription);
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlWLanAdapter::GetEAPIdFromUri( const TDesC8& aUri )
+// Return WLan ID number from URI
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlWLanAdapter::GetEAPIdFromUri(const TDesC8& aUri)
+    {
+    DBG_ARGS8(_S8("WLanAdapter::GetEAPIdFromUri - <%S>"), &aUri);
+
+    if (aUri.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*")) == KErrNotFound)
+        {
+        return KErrNotFound;
+        }
+
+    TInt begin = aUri.Find(_L8("/EAPId")) + 6;
+    if (begin == KErrNotFound)
+        {
+        return KErrNotFound;
+        }
+
+    TInt eapId = DesToInt(aUri.Mid(begin, 3));
+
+    return eapId;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlWLanAdapter::GetEncapsEAPIdFromUri( const TDesC8& aUri )
+// Return WLan ID number from URI
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlWLanAdapter::GetEncapsEAPIdFromUri(const TDesC8& aUri)
+    {
+    DBG_ARGS8(_S8("WLanAdapter::GetEncapsEAPIdFromUri - <%S>"), &aUri);
+
+    if (aUri.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/EAPId*-*")) == KErrNotFound)
+        {
+        return KErrNotFound;
+        }
+
+    TInt begin = aUri.Find(_L8("/EAPId")) + 9;
+    if (aUri[begin] != '-')
+        {
+        return KErrNotFound;
+        }
+    begin++;
+    TInt end = -1;
+    TInt count;
+
+    for (count = 0; count + begin < aUri.Length(); count++)
+        {
+        if (aUri[begin + count] == '/')
+            {
+            end = begin + count;
+            break;
+            }
+        else if (aUri.Length() == begin + count + 1)
+            {
+            count++;
+            end = begin + count;
+            break;
+            }
+        }
+
+    if (end > 0)
+        {
+        TInt eapId = DesToInt(aUri.Mid(begin, count));
+        return eapId;
+        }
+    return KErrNotFound;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlWLanAdapter::GetEAPIdFromUriL( const TDesC8& aUri )
+// Return WLan ID number from URI
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlWLanAdapter::GetServiceIdFromUriL(const TDesC8& aURI)
+    {
+    DBG_ARGS8(_S8("WLanAdapter::GetServiceIdFromUriL - <%S>"), &aURI);
+
+    if (aURI.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP*")) == KErrNotFound)
+        {
+        return KErrNotFound;
+        }
+
+    TInt end = aURI.Find(_L8("/EAP")) + 4;
+
+    if (end > 0)
+        {
+
+        HBufC8* luidBuf = iCallBack->GetLuidAllocL(aURI.Left(end));
+
+        TInt serviceId = GetIdFromLuid(*luidBuf);
+
+        delete luidBuf;
+
+        return serviceId;
+        }
+    return KErrNotFound;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlWLanAdapter::GetSecSSIDFromUriL( const TDesC8& aUri )
+// Return WLan ID number from URI
+// ------------------------------------------------------------------------------------------------
+TUint32 CNSmlWLanAdapter::GetSecSSIDFromUriL(const TDesC8& aUri)
+    {
+    DBG_ARGS8(_S8("WLanAdapter::GetSecSSIDFromUriL - <%S>"), &aUri);
+
+    if (aUri.Match(_L8("AP/*/NAPDef/*/WLAN/*/SecondarySSID/*"))
+            == KErrNotFound)
+        {
+        User::Leave(KErrNotFound);
+        }
+    _LIT8(KSSIDString, "/SecondarySSID/SecSSID");
+    TInt begin = aUri.Find(KSSIDString) + KSSIDString().Length();
+    TInt end = -1;
+    TInt count;
+
+    for (count = 0; count + begin < aUri.Length(); count++)
+        {
+        if (aUri[begin + count] == '/')
+            {
+            end = begin + count;
+            break;
+            }
+        else if (aUri.Length() == begin + count + 1)
+            {
+            count++;
+            end = begin + count;
+            break;
+            }
+        }
+
+    if (end > 0)
+        {
+        TLex8 lex(aUri.Mid(begin, count));
+        TUint32 value = 0;
+        lex.Val(value, EDecimal);
+        return value;
+        }
+    else
+        {
+        User::Leave(KErrNotFound);
+        }
+    return 0;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlWLanAdapter::GetEAPIdFromUri( const TDesC8& aUri )
+// Return WLan ID number from URI
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlWLanAdapter::GetCertificateIdFromUri(const TDesC8& aUri)
+    {
+    DBG_ARGS8(_S8("WLanAdapter::GetCertificateIdFromUri - <%S>"), &aUri);
+
+    if (aUri.Match(_L8("AP/*/NAPDef/*/WLAN/*/EAP/*/Certificate/*"))
+            == KErrNotFound)
+        {
+        return KErrNotFound;
+        }
+    _LIT8(KCertString, "/Certificate/CertId");
+
+    TInt begin = aUri.Find(KCertString);
+    if (begin == KErrNotFound)
+        {
+        return KErrNotFound;
+        }
+
+    begin += KCertString().Length();
+
+    TInt end = -1;
+    TInt count;
+
+    for (count = 0; count + begin < aUri.Length(); count++)
+        {
+        if (aUri[begin + count] == '/')
+            {
+            end = begin + count;
+            break;
+            }
+        else if (aUri.Length() == begin + count + 1)
+            {
+            count++;
+            end = begin + count;
+            break;
+            }
+        }
+
+    if (end > 0)
+        {
+        TInt certId = DesToInt(aUri.Mid(begin, count));
+        return certId;
+        }
+    return KErrNotFound;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlWLanAdapter::GetWepKeyIdFromUri( const TDesC8& aUri )
+// Returns WepKey ID number from URI
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlWLanAdapter::GetWepKeyIdFromUri(const TDesC8& aUri)
+    {
+    if (aUri.Match(_L8("AP/*/NAPDef/*/WLAN/*/WEPKey/*")) == KErrNotFound)
+        {
+        return KErrNotFound;
+        }
+
+    TInt begin = aUri.Find(_L8("WEPKey/WKId")) + 11;
+    TInt end = -1;
+    TInt count;
+
+    for (count = 0; count < aUri.Length() - 11; count++)
+        {
+        if (aUri[begin + count] == '/')
+            {
+            end = begin + count;
+            break;
+            }
+
+        else if (aUri.Length() == begin + count + 1)
+            {
+            count++;
+            end = begin + count;
+            break;
+            }
+        }
+
+    if (end > 0)
+        {
+        TInt wlanId = DesToInt(aUri.Mid(begin, count));
+        return wlanId;
+        }
+    return KErrNotFound;
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlWLanAdapter::GetWepKeyIdFromLuid( const TDesC8& aLuid )
+// Return id number of wepkey
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlWLanAdapter::GetWepKeyIdFromLuid(const TDesC8& aLuid)
+    {
+    TLex8 iLex(aLuid);
+
+    TInt luid;
+    if (iLex.Val(luid) == KErrNone)
+        {
+        if (luid > 1000)
+            {
+            return luid / 1000;
+            }
+        else
+            {
+            return KErrNotFound;
+            }
+        }
+    else
+        {
+        return KErrNotFound;
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// TInt CNSmlWLanAdapter::GetIdFromLuid( const TDesC& aLuid )
+// Return luid of wlan node
+// ------------------------------------------------------------------------------------------------
+TInt CNSmlWLanAdapter::GetIdFromLuid(const TDesC8& aLuid)
+    {
+    TLex8 iLex(aLuid);
+
+    TInt luid;
+    if (iLex.Val(luid) == KErrNone)
+        {
+        if (luid < 1000)
+            {
+            return luid;
+            }
+        else
+            {
+            TInt tmp = luid / 1000 * 1000; //First number of luid > 1000
+            return luid - tmp;
+            }
+        }
+    else
+        {
+        return KErrNotFound;
+        }
+    }
+
+// ------------------------------------------------------------------------------------------------
+// void CNSmlWLanAdapter::ExecuteBufferL( TBool aFinal )
+// Executes buffered commands from iBuffer
+// ------------------------------------------------------------------------------------------------
+void CNSmlWLanAdapter::ExecuteBufferL(TBool aFinal)
+    {
+    for (TInt index = 0; index < iBuffer->Count(); index++)
+        {
+        DBG_ARGS8(_S8(
+                "WLanAdapter::ExecuteBuffer(): Buf count: <%D> index: <%D>"),
+                iBuffer->Count(), index);
+
+        if (iBuffer->At(index).iExecuted)
+            {
+            continue;
+            }
+        TInt err = 0;
+
+        TInt luid = iBuffer->At(index).iLuid;
+        TInt wepKeyId = iBuffer->At(index).iWepKeyId;
+        if (!wepKeyId && !aFinal)
+            {
+            continue;
+            }
+
+        if (wepKeyId > 4 || !wepKeyId && aFinal)
+            {
+            if (iBuffer->At(index).iDataStatusRef)
+                iCallBack->SetStatusL(iBuffer->At(index).iDataStatusRef,
+                        CSmlDmAdapter::EError);
+            if (iBuffer->At(index).iNodeStatusRef)
+                iCallBack->SetStatusL(iBuffer->At(index).iNodeStatusRef,
+                        CSmlDmAdapter::EError);
+            if (iBuffer->At(index).iLengthStatusRef)
+                iCallBack->SetStatusL(iBuffer->At(index).iLengthStatusRef,
+                        CSmlDmAdapter::EError);
+
+            iBuffer->At(index).iIdStatusRef = 0;
+            iBuffer->At(index).iNodeStatusRef = 0;
+            iBuffer->At(index).iDataStatusRef = 0;
+            iBuffer->At(index).iLengthStatusRef = 0;
+            iBuffer->At(index).iExecuted = ETrue;
+
+            continue;
+            }
+
+        if (iBuffer->At(index).iDataSet && iBuffer->At(index).iWepKeyId > 0)
+            {
+            iWlanSettings->GetWlanSettings(luid, *iSettings);
+
+            switch (wepKeyId)
+                {
+                case 1:
+                    iSettings->WepKey1 = iBuffer->At(index).iData->Des();
+                    break;
+                case 2:
+                    iSettings->WepKey2 = iBuffer->At(index).iData->Des();
+                    break;
+                case 3:
+                    iSettings->WepKey3 = iBuffer->At(index).iData->Des();
+                    break;
+                case 4:
+                    iSettings->WepKey4 = iBuffer->At(index).iData->Des();
+                    break;
+                default:
+                    continue;
+                }
+
+            err = iWlanSettings->WriteWlanSettings(*iSettings);
+            if (err == KErrNone)
+                {
+                iCallBack->SetStatusL(iBuffer->At(index).iDataStatusRef,
+                        CSmlDmAdapter::EOk);
+                }
+            else
+                {
+                iCallBack->SetStatusL(iBuffer->At(index).iDataStatusRef,
+                        CSmlDmAdapter::EError);
+                }
+
+            iBuffer->At(index).iDataStatusRef = 0;
+            }
+
+        TBuf8<5> addLUID;
+        addLUID.AppendNum(wepKeyId);
+        addLUID.AppendNumFixedWidth(luid, EDecimal, 3);
+
+        iCallBack->SetMappingL(iBuffer->At(index).iUri->Des(), addLUID);
+        if (iBuffer->At(index).iIdStatusRef)
+            iCallBack->SetStatusL(iBuffer->At(index).iIdStatusRef,
+                    CSmlDmAdapter::EOk);
+        if (iBuffer->At(index).iNodeStatusRef)
+            iCallBack->SetStatusL(iBuffer->At(index).iNodeStatusRef,
+                    CSmlDmAdapter::EOk);
+        if (iBuffer->At(index).iLengthStatusRef)
+            iCallBack->SetStatusL(iBuffer->At(index).iLengthStatusRef,
+                    CSmlDmAdapter::EOk);
+
+        iBuffer->At(index).iIdStatusRef = 0;
+        iBuffer->At(index).iNodeStatusRef = 0;
+        iBuffer->At(index).iLengthStatusRef = 0;
+        iBuffer->At(index).iExecuted = ETrue;
+        }
+
+    //Clean executed command from buffer
+    for (TInt i = 0; i < iBuffer->Count(); i++)
+        {
+        if (iBuffer->At(i).iExecuted)
+            {
+            if (iBuffer->At(i).iUri)
+                {
+                delete iBuffer->At(i).iUri;
+                iBuffer->At(i).iUri = 0;
+                }
+            if (iBuffer->At(i).iData)
+                {
+                delete iBuffer->At(i).iData;
+                iBuffer->At(i).iData = 0;
+                }
+            iBuffer->Delete(i);
+            iBuffer->Compress();
+            }
+        }
+    // Secondary SSID Buffer 
+    for (TInt index = 0; index < iSecondaryBuffer.Count(); index++)
+        {
+        DBG_ARGS8(_S8(
+                "WLanAdapter::ExecuteBuffer(): Buf count: <%D> index: <%D>"),
+                iBuffer->Count(), index);
+
+        if (iSecondaryBuffer[index]->iExecuted)
+            {
+            continue;
+            }
+
+        TSecondarySSID ssid;
+        ssid.ScannedId = iSecondaryBuffer[index]->ScannedId;
+        ssid.UsedId = iSecondaryBuffer[index]->UsedId;
+
+        DBG_ARGS8(
+                _S8(
+                        "CWlanadaptes::Execute Buffer - WLAN_SEC_SSID_SCANNED_SSID uri: <%S> ad  WLAN_SEC_SSID_USED_SSID : <%S>"),
+                &iSecondaryBuffer[index]->ScannedId,
+                &iSecondaryBuffer[index]->UsedId);
+
+        TInt retval = iWlanSettings->WriteSecondarySSIDL(
+                iSecondaryBuffer[index]->wlanLuid, ssid, ETrue);
+        iSecondaryBuffer[index]->iExecuted = ETrue;
+
+        }
+    TBuf<KMaxLengthOfEapList> eapList;
+    eapList.Copy(KEapAll);
+    // EAP settings
+    for (TInt i = 0; i < iEAPBuffer.Count(); i++)
+        {
+
+        // Save EAP list
+        if (iEAPBuffer[i]->iEapTypeString.Length() > 0
+                && iEAPBuffer[i]->iEncapsulatingString.Length() == 0) // AND method is not encapsulated
+            {
+
+            TBuf8<3> buf;
+            _LIT8(KFormat, "%d");
+            // pick the last byte from the array
+            buf.Format(KFormat,
+                    iEAPBuffer[i]->iEapTypeString[KExpandedEapIdLength - 1]);
+            // search for the correct offset for the eap type from the KEapAll literal
+            TInt index = KEapAll().Find(buf);
+
+            const TUint8 offset = 2; //length = f "-0" string
+            // Add '+' to the correct offset, so that the eap is repsesented activated in the list
+            if (index >= offset)
+                {
+                eapList[index - offset] = KEapPlus;
+                }
+
+            }
+
+        // Check if this method has encapsulated methods
+        for (TInt j = 0; j < iEAPBuffer.Count(); j++)
+            {
+            if (iEAPBuffer[i]->iEAPSettings->iEAPExpandedType
+                    == iEAPBuffer[j]->iEncapsulatingExpandedEapId)
+                {
+                // j is encapsulated inside i
+                iEAPBuffer[i]->iEAPSettings->iEnabledEncapsulatedEAPExpandedTypes.Append(
+                        iEAPBuffer[j]->iEAPSettings->iEAPExpandedType);
+                iEAPBuffer[i]->iEAPSettings->iEnabledEncapsulatedEAPExpandedTypesPresent
+                        = ETrue;
+                }
+            }
+
+        TRAPD(err, iWlanSettings->GetEAPInterfaceL(
+                iEAPBuffer[i]->iWLANServiceId,
+                iEAPBuffer[i]->iEncapsulatingExpandedEapId,
+                iEAPBuffer[i]->iEAPSettings->iEAPExpandedType));
+        if (err == KErrNone)
+            {
+            err = iWlanSettings->WriteEAPSettings(
+                    *iEAPBuffer[i]->iEAPSettings);
+            }
+
+        MSmlDmAdapter::TError status;
+        switch (err)
+            {
+            case KErrNotFound:
+                {
+                status = CSmlDmAdapter::ENotFound;
+                break;
+                }
+            case KErrNone:
+                {
+                status = CSmlDmAdapter::EOk;
+                break;
+                }
+            default:
+                {
+                status = CSmlDmAdapter::EError;
+                }
+            }
+
+        for (TInt j = 0; j < iEAPBuffer[i]->iStatusRefArray.Count(); j++)
+            {
+            iCallBack->SetStatusL(iEAPBuffer[i]->iStatusRefArray[j], status);
+            }
+        }
+
+    // Expanded EAP types in use. Write the eap list to the new columns.
+
+    // generate appropriate entries in the new enabled and disabled list,
+    // overwriting those values 
+
+    // count the + and - signs to determine the size of enabled and 
+    // disabled descriptors
+
+    TLex lex(eapList);
+    TInt numPlus = 0;
+    TInt numMinus = 0;
+    TChar ch;
+    while (!lex.Eos())
+        {
+        ch = lex.Get();
+        if (ch == '+')
+            ++numPlus;
+        else if (ch == '-')
+            ++numMinus;
+        }
+    // load general EAP settings If
+    CEapGeneralSettings* genSettings;
+    genSettings = CEapGeneralSettings::NewL(ELan, iSettings->ServiceID);
+    CleanupStack::PushL(genSettings);
+
+    // get lists of enabled/disabled EAPs for the IAP
+
+    RArray<TEapExpandedType> enabledEapMethods;
+    RArray<TEapExpandedType> disabledEapMethods;
+
+    enabledEapMethods.Reset();
+    disabledEapMethods.Reset();
+
+    lex.Assign(eapList);
+
+    while (!lex.Eos())
+        {
+        // beginning of implementation UID
+        TInt16 implUid = 0;
+
+        if (lex.Val(implUid) != KErrNone || !implUid)
+            {
+            break;
+            }
+
+        // append it to the appropriate list ('+' enabled, '-' disabled)
+        _LIT8(KPadding, "\xFE\0\0\0\0\0\0");
+        _LIT8(KMsChapV2Padding, "\xFE\xFF\xFF\xFF\0\0\0");
+        const TInt KPlainMsChapV2ImplUid = 99;
+
+        if (implUid > 0)
+            {
+            TBuf8<KExpandedEapIdLength> tempbuf;
+            if (Abs(implUid) == KPlainMsChapV2ImplUid)
+                {
+                tempbuf.Append(KMsChapV2Padding);
+                }
+            else
+                {
+                tempbuf.Append(KPadding);
+                }
+            tempbuf.Append(Abs(implUid));
+            TEapExpandedType expandedTypebuf(tempbuf);
+            enabledEapMethods.Append(expandedTypebuf);
+            }
+
+        // swallow the delimiter (',')
+        lex.Get();
+        }
+
+    if (numPlus != NULL)
+        {
+        genSettings->SetEapMethods(enabledEapMethods, disabledEapMethods);
+        }
+
+    CleanupStack::PopAndDestroy(genSettings);
+
+    for (TInt i = 0; i < iEAPBuffer.Count(); i++)
+        {
+        iEAPBuffer[i]->iStatusRefArray.Close();
+        iEAPBuffer[i]->iEAPSettings->iEnabledEncapsulatedEAPExpandedTypes.Close();
+        iEAPBuffer[i]->iEAPSettings->iDisabledEncapsulatedEAPExpandedTypes.Close();
+        iEAPBuffer[i]->iEAPSettings->iCipherSuites.Close();
+        delete iEAPBuffer[i]->iEAPSettings;
+        iEAPBuffer[i]->iEAPSettings = NULL;
+        }
+    iEAPBuffer.ResetAndDestroy();
+    }
+
+//=============================================
+//      CNSmlWLanAdapter::ConvertTo8LC()
+//      Converts string value to 8-bit
+//      
+//=============================================
+TDesC8& CNSmlWLanAdapter::ConvertTo8LC(const TDesC& aSource)
+    {
+    HBufC8* buf = HBufC8::NewLC(aSource.Length() * 2);
+    TPtr8 bufPtr = buf->Des();
+    CnvUtfConverter::ConvertFromUnicodeToUtf8(bufPtr, aSource);
+
+    return *buf;
+    }
+
+//=============================================
+//      CNSmlWLanAdapter::ConvertTo16LC()
+//      Converts string value to 16-bit
+//      
+//=============================================
+TDesC16& CNSmlWLanAdapter::ConvertTo16LC(const TDesC8& aSource)
+    {
+    HBufC16* buf16 = HBufC16::NewLC(aSource.Length());
+    TPtr bufPtr16 = buf16->Des();
+
+    CnvUtfConverter::ConvertToUnicodeFromUtf8(bufPtr16, aSource);
+
+    return *buf16;
+    }
+
+void CNSmlWLanAdapter::ResetEAPStructL()
+    {
+    DeleteEAPStructL();
+    iEAPSettings = new (ELeave) EAPSettings;
+    }
+
+void CNSmlWLanAdapter::DeleteEAPStructL()
+    {
+    if (iEAPSettings != NULL)
+        {
+        if (iEAPSettings->iCertificatesPresent)
+            {
+            iEAPSettings->iCertificates.Reset();
+            }
+        iEAPSettings->iEnabledEncapsulatedEAPExpandedTypes.Close();
+        iEAPSettings->iDisabledEncapsulatedEAPExpandedTypes.Close();
+        iEAPSettings->iCipherSuites.Close();
+
+        delete iEAPSettings;
+        iEAPSettings = NULL;
+        }
+    }
+
+void CNSmlWLanAdapter::DesToBufferL(CBufBase& aTo, const TDesC& aFrom)
+    {
+    aTo.InsertL(0, ConvertTo8LC(aFrom));
+    CleanupStack::PopAndDestroy(); // ConvertTo8LC
+    }
+
+void CNSmlWLanAdapter::FillCipherSuiteBufferL(CBufBase& aBuffer)
+    {
+    if (iEAPSettings == NULL || !iEAPSettings->iCipherSuitesPresent)
+        {
+        return;
+        }
+    // 0    5    10   15   20   25   30   35
+    _LIT8(KPlus, "+");
+    aBuffer.InsertL(0, KSuitesDefault);
+    TInt count = iEAPSettings->iCipherSuites.Count();
+    for (TInt i = count - 1; i >= 0; --i)
+        {
+        switch (iEAPSettings->iCipherSuites[i])
+            {
+            case RSA_3DES_SHA:
+                {
+                aBuffer.Write(0, KPlus);
+                break;
+                }
+            case DHE_RSA_3DES_SHA:
+                {
+                aBuffer.Write(5, KPlus);
+                break;
+                }
+            case DHE_DSS_3DES_SHA:
+                {
+                aBuffer.Write(10, KPlus);
+                break;
+                }
+            case RSA_AES_SHA:
+                {
+                aBuffer.Write(15, KPlus);
+                break;
+                }
+            case DHE_RSA_AES_SHA:
+                {
+                aBuffer.Write(20, KPlus);
+                break;
+                }
+            case DHE_DSS_AES_SHA:
+                {
+                aBuffer.Write(25, KPlus);
+                break;
+                }
+            case RSA_RC4_MD5:
+                {
+                aBuffer.Write(30, KPlus);
+                break;
+                }
+            case RSA_RC4_SHA:
+                {
+                aBuffer.Write(35, KPlus);
+                break;
+                }
+            default:
+                {
+                break;
+                }
+
+            }
+        }
+
+    }
+
+void CNSmlWLanAdapter::FillCipherSuitesL(const TDesC8& aObject,
+        const TInt aLuid)
+    {
+    if (iEAPBuffer[aLuid] == NULL)
+        {
+        return;
+        }
+    iEAPBuffer[aLuid]->iEAPSettings->iCipherSuites.Reset();
+    iEAPBuffer[aLuid]->iEAPSettings->iCipherSuitesPresent = EFalse; // init to EFalse
+
+    TChar plus('+');
+
+    TInt length = aObject.Length();
+    for (TInt i = 0; i + 3 < length; i += 5)
+        {
+        if (aObject[i] == plus)
+            {
+            TLex8 lex(aObject.Mid(i + 1, 3));
+            TUint suite;
+            lex.Val(suite);
+            iEAPBuffer[aLuid]->iEAPSettings->iCipherSuites.Append(suite);
+            iEAPBuffer[aLuid]->iEAPSettings->iCipherSuitesPresent = ETrue;
+            }
+        }
+    }
+
+void CNSmlWLanAdapter::ConvertEAPStringToIds(TDes8& aEAPString,
+        TEapExpandedType& aId)
+    {
+    if (aId.Compare(*EapExpandedTypeSim.GetType()) == 0)
+        {
+        aEAPString.Copy(KEapSimTypeId, KExpandedEAPIdLength);
+        }
+    else if (aId.Compare(*EapExpandedTypeAka.GetType()) == 0)
+        {
+        aEAPString.Copy(KEapAkaTypeId, KExpandedEAPIdLength);
+        }
+    else if (aId.Compare(*EapExpandedTypeTtls.GetType()) == 0)
+        {
+        aEAPString.Copy(KEapTlsTypeId, KExpandedEAPIdLength);
+        }
+    else if (aId.Compare(*EapExpandedTypePeap.GetType()) == 0)
+        {
+        aEAPString.Copy(KEapPeapTypeId, KExpandedEAPIdLength);
+        }
+    else if (aId.Compare(*EapExpandedTypeTtls.GetType()) == 0)
+        {
+        aEAPString.Copy(KEapTtlsTypeId, KExpandedEAPIdLength);
+        }
+    else if (aId.Compare(*EapExpandedTypeLeap.GetType()) == 0)
+        {
+        aEAPString.Copy(KEapLeapTypeId, KExpandedEAPIdLength);
+        }
+    else if (aId.Compare(*EapExpandedTypeMsChapv2.GetType()) == 0)
+        {
+        aEAPString.Copy(KEapMschapv2TypeId, KExpandedEAPIdLength);
+        }
+    else if (aId.Compare(*EapExpandedPlainMsChapv2.GetType()) == 0)
+        {
+        aEAPString.Copy(KMschapv2TypeId, KExpandedEAPIdLength);
+        }
+    else if (aId.Compare(*EapExpandedTypeGtc.GetType()) == 0)
+        {
+        aEAPString.Copy(KEapGtcTypeId, KExpandedEAPIdLength);
+        }
+    else if (aId.Compare(*EapExpandedTypeFast.GetType()) == 0)
+        {
+        aEAPString.Copy(KEapFastTypeId, KExpandedEAPIdLength);
+        }
+    else if (aId.Compare(*EapExpandedTypeTtlsPap.GetType()) == 0)
+        {
+        aEAPString.Copy(KTtlspapTypeId, KExpandedEAPIdLength);
+        }
+    else
+        {
+        aEAPString.Copy(KEapNoneId, KExpandedEAPIdLength);
+        }
+
+    }
+
+void CNSmlWLanAdapter::GetExpandedType(const TInt aEapType,
+        const TInt aTunnelingType, TEapExpandedType& aExpanedId,
+        TEapExpandedType& aExpanedEncapsId)
+    {
+
+    // append it to the appropriate list ('+' enabled, '-' disabled)
+    _LIT8(KPadding, "\xFE\0\0\0\0\0\0");
+    _LIT8(KMsChapV2Padding, "\xFE\xFF\xFF\xFF\0\0\0");
+    const TInt KPlainMsChapV2ImplUid = 99;
+
+    TBuf8<KExpandedEapIdLength> cmpbuf;
+    if (aEapType == KPlainMsChapV2ImplUid)
+        {
+        cmpbuf.Append(KMsChapV2Padding);
+        }
+    else
+        {
+        cmpbuf.Append(KPadding);
+        }
+    cmpbuf.Append(aEapType);
+    aExpanedId = cmpbuf;
+
+    TBuf8<KExpandedEapIdLength> encapscmpbuf;
+    if (aTunnelingType == KPlainMsChapV2ImplUid)
+        {
+        encapscmpbuf.Append(KMsChapV2Padding);
+        }
+    else
+        {
+        encapscmpbuf.Append(KPadding);
+        }
+    encapscmpbuf.Append(aTunnelingType);
+    aExpanedEncapsId = encapscmpbuf;
+
+    }
+
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadmadapters/nsmldminternet/src/NSmlWlanSettings.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -0,0 +1,1721 @@
+/*
+ * Copyright (c) 2002-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:   Wlan Adapter DB handler
+ *
+ */
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <commsdat_partner.h>
+#endif
+#include <WlanCdbCols.h>
+#include "NSmlWlanSettings.h"
+#include "NSmlWLanAdapter.h"
+#include "nsmldebug.h"
+#include <comms-infras/commdb/protection/protectdb.h>
+#include <SettingEnforcementInfo.h> // vsettingenforcementinfo
+#include <featmgr.h>
+#include <EapExpandedType.h>
+#include <EapGeneralSettings.h>
+
+#ifndef __WINS__
+// This lowers the unnecessary compiler warning (armv5) to remark.
+// "Warning:  #174-D: expression has no effect..." is caused by 
+// DBG_ARGS8 macro in no-debug builds.
+#pragma diag_remark 174
+#endif
+
+const TUint KEAPListBufferSize = 128;
+const TUint KLengthOfOldStyleEAPListEntry = 5; // "+xxx,"
+
+const TInt KBeginTransRetryDelay = 1000000; // Delay for comms db begintransaction retry (microseconds)
+const TInt KBeginTransRetryCount = 7; // Maximum number of retries
+//-----------------------------------------------------------------------------
+// CWlanAdapter::CWlanSettings( CCommsDatabase& aDatabase )
+//-----------------------------------------------------------------------------
+CWlanSettings::CWlanSettings(CCommsDatabase& aDatabase) :
+    iDatabase(aDatabase), iExpandedEAPTypeFieldsUsed(ETrue)
+    {
+    _DBG_FILE("CWlanSettings::CWlanSettings(): begin");
+
+    iTableView = 0;
+    iEapType = NULL;
+    iSecondaryView = NULL;
+
+    _DBG_FILE("CWlanSettings::CWlanSettings(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// CWlanAdapter::~CWlanSettings( )
+//-----------------------------------------------------------------------------
+CWlanSettings::~CWlanSettings()
+    {
+
+    delete iEapType;
+    delete iSecondaryView;
+    delete iTableView;
+    }
+
+//-----------------------------------------------------------------------------
+// CWlanSettings* CWlanSettings::NewL( CCommsDatabase& aDatabase )
+//-----------------------------------------------------------------------------
+CWlanSettings* CWlanSettings::NewL(CCommsDatabase& aDatabase)
+    {
+    _DBG_FILE("CWlanSettings::NewL(): begin");
+
+    CWlanSettings* self = new (ELeave) CWlanSettings(aDatabase);
+
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    _DBG_FILE("CWlanSettings::NewL(): end");
+    return self;
+    }
+
+//-----------------------------------------------------------------------------
+// void CWlanSettings::ConstructL( )
+//-----------------------------------------------------------------------------
+void CWlanSettings::ConstructL()
+    {
+    _DBG_FILE("CWlanSettings::ConstructL(): begin");
+    _DBG_FILE("CWlanSettings::ConstructL(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// TInt CWlanSettings::GetWlanSettings( TUint32 aLuid, TWlanSettings& aWlanSettings )
+//-----------------------------------------------------------------------------
+TInt CWlanSettings::GetWlanSettings(TUint32 aLuid,
+        TWlanSettings& aWlanSettings)
+    {
+    _DBG_FILE("CWlanSettings::GetWlanSettings(): begin");
+
+    TRAPD(err, ConnectToDatabaseL());
+    if (err == KErrNone)
+        {
+        err = GoToRecord(aLuid);
+
+        if (err == KErrNone)
+            {
+            TRAP(err, GetDataFromRecordL(&aWlanSettings));
+            }
+        }
+
+    _DBG_FILE("CWlanSettings::GetWlanSettings(): end");
+    return err;
+    }
+
+//-----------------------------------------------------------------------------
+// TInt CWlanSettings::GetEapSettings( TInt aId, TWlanSettings& aWlanSettings )
+//-----------------------------------------------------------------------------
+TInt CWlanSettings::GetEAPSettings(const TInt aId,
+        TEapExpandedType& aExpandedId, TEapExpandedType& aEncapsId,
+        EAPSettings& aEapSettings)
+    {
+    _DBG_FILE("CWlanSettings::GetEapSettings(): begin");
+
+    TRAPD(err, GetEAPInterfaceL(aId, aEncapsId, aExpandedId));
+    DBG_ARGS(_S16("GetEAPInterfaceL leaved with %d"), err);
+    if (err == KErrNone)
+        {
+        TRAP(err, iEapType->GetConfigurationL(aEapSettings));
+        DBG_ARGS(_S16("iEapType->GetConfigurationL leaved with %d"), err);
+        }
+
+    _DBG_FILE("CWlanSettings::GetEAPSettings(): end");
+    return err;
+    }
+
+//-----------------------------------------------------------------------------
+// TInt CWlanSettings::DeleteWlanSettings( TUint32 aLuid )
+//-----------------------------------------------------------------------------
+TInt CWlanSettings::DeleteWlanSettings(TUint32 aLuid)
+    {
+    _DBG_FILE("CWlanSettings::DeleteWlanSettings(): begin");
+    TBool wlanEnforce = EFalse;
+    TInt tableLockError = KErrNone;
+
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        TInt enError = KErrNone;
+        TRAP(enError, wlanEnforce = CheckEnforcementL());
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::DeleteWLANSettings, check enforcement failed. error: <%D>"),
+                enError);
+        if (wlanEnforce)
+            {
+            _DBG_FILE(
+                    "CWlanSettings::WriteWlanSettings(): wlan enforce is ON ");
+            TRAPD(lockError, tableLockError = PerformLockWLANTablesL(EFalse));
+            if (lockError == KErrNone && tableLockError == KErrNone)
+                {
+                _DBG_FILE(
+                        "CWlanSettings::WriteWlanSettings(): Table unlcoked successfully ");
+                iWLANRelock = ETrue;
+                }
+            }
+        }
+
+    TRAPD(err, ConnectToDatabaseL());
+    if (err == KErrNone)
+        {
+        err = GoToRecord(aLuid);
+        if (err == KErrNone)
+            {
+
+            if (FeatureManager::FeatureSupported(
+                    KFeatureIdSapPolicyManagement))
+                {
+                if (wlanEnforce)
+                    {
+                    ((CCommsDbProtectTableView*) iTableView)->UnprotectRecord();
+                    }
+                }
+
+            TInt err = iTableView->UpdateRecord();
+            if (err == KErrLocked)
+                {
+                _DBG_FILE("DeleteWlanSettings: UpdateRecord was locked.");
+                TInt retry = KBeginTransRetryCount;
+                while (retry > 0 && err == KErrLocked)
+                    {
+                    User::After(KBeginTransRetryDelay);
+                    _DBG_FILE("DeleteWlanSettings: Slept 1 second. Try again");
+                    err = iTableView->UpdateRecord();
+                    retry--;
+                    }
+                if (err != KErrNone)
+                    {
+                    _DBG_FILE(
+                            "DeleteWlanSettings: UpdateRecord was unsuccessful");
+                    }
+                else
+                    {
+                    _DBG_FILE(
+                            "DeleteWlanSettings: UpdateRecord was successful");
+                    }
+                }
+
+            if (err == KErrNone)
+                {
+                TRAP(err, iTableView->WriteUintL(TPtrC(WLAN_SERVICE_ID), 0));
+                if (err != KErrNone)
+                    {
+                    if (FeatureManager::FeatureSupported(
+                            KFeatureIdSapPolicyManagement))
+                        {
+                        TInt tableLockError = KErrNone;
+                        if (iWLANRelock)
+                            {
+                            TInt lockError = KErrNone;
+                            TRAP(lockError, tableLockError
+                                    = PerformLockWLANTablesL(ETrue));
+                            ((CCommsDbProtectTableView*) iTableView)->ProtectRecord();
+                            DBG_ARGS(
+                                    _S16(
+                                            "CWlanSettings::DeleteWLANSettings, WLAN table Lock error. error: <%D>, <%D> "),
+                                    lockError, tableLockError);
+                            iWLANRelock = EFalse;
+                            }
+                        if (tableLockError != KErrNone) // to remove warnings
+                            {
+                            tableLockError = KErrNone;
+                            }
+                        }
+                    return err;
+                    }
+                }
+            err = iTableView->PutRecordChanges();
+            if (err == KErrLocked)
+                {
+                _DBG_FILE("DeleteWlanSettings: PutRecordChanges was locked.");
+                TInt retry = KBeginTransRetryCount;
+                while (retry > 0 && err == KErrLocked)
+                    {
+                    User::After(KBeginTransRetryDelay);
+                    _DBG_FILE("DeleteWlanSettings: Slept 1 second. Try again");
+                    err = iTableView->PutRecordChanges();
+                    retry--;
+                    }
+                if (err != KErrNone)
+                    {
+                    _DBG_FILE(
+                            "DeleteWlanSettings: PutRecordChanges was unsuccessful");
+                    }
+                else
+                    {
+                    _DBG_FILE(
+                            "DeleteWlanSettings: PutRecordChanges was successful");
+                    }
+                }
+
+            if (FeatureManager::FeatureSupported(
+                    KFeatureIdSapPolicyManagement))
+                {
+                TInt tableLockError = KErrNone;
+                if (iWLANRelock)
+                    {
+                    TInt lockError = KErrNone;
+                    TRAP(lockError, tableLockError = PerformLockWLANTablesL(
+                            ETrue));
+                    DBG_ARGS(
+                            _S16(
+                                    "CWlanSettings::DeleteWLANSettings, WLAN table Lock error. error: <%D>, <%D> "),
+                            lockError, tableLockError);
+                    ((CCommsDbProtectTableView*) iTableView)->ProtectRecord();
+                    iWLANRelock = EFalse;
+                    }
+                if (tableLockError != KErrNone) // to remove warnings
+                    {
+                    tableLockError = KErrNone;
+                    }
+                }
+
+            if (err == KErrNone)
+                {
+                // Ignore err on purpose
+                TRAP(err, DeleteSecondarySSIDsL(aLuid));
+
+                TRAP(err, DeleteWlanEapSettingsL(aLuid));
+                }
+            }
+        }
+
+    _DBG_FILE("CWlanSettings::DeleteWlanSettings(): end");
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        if (iWLANRelock)
+            {
+            TInt lockError = KErrNone;
+            TRAP(lockError, tableLockError = PerformLockWLANTablesL(ETrue));
+            DBG_ARGS(
+                    _S16(
+                            "CWlanSettings::DeleteWLANSettings, WLAN table Lock error. error: <%D>, <%D> "),
+                    lockError, tableLockError);
+            ((CCommsDbProtectTableView*) iTableView)->ProtectRecord();
+            iWLANRelock = EFalse;
+            }
+        }
+
+    if (wlanEnforce)
+        wlanEnforce = EFalse; // to get rid of warnings
+    return err;
+    }
+
+TInt CWlanSettings::DeleteOneSecondarySSIDL(TUint32 aWLANId, TUint32 asecId)
+    {
+
+    TInt retval = KErrNone;
+    SetSecondaryViewToRecordL(aWLANId);
+    retval = iSecondaryView->GotoFirstRecord();
+
+    while (retval == KErrNone)
+        {
+        TSecondarySSID ssid;
+        TRAP(retval, iSecondaryView->ReadUintL(TPtrC(WLAN_SEC_SSID_ID),
+                ssid.Id));
+        if (ssid.Id == asecId)
+            {
+            //retval = iSecondaryView->UpdateRecord();
+            //if( retval==KErrNone )
+            //  {
+            if (FeatureManager::FeatureSupported(
+                    KFeatureIdSapPolicyManagement))
+                {
+                TBool wlanEnforce = EFalse;
+                TInt enError = KErrNone;
+                TRAP(enError, wlanEnforce = CheckEnforcementL());
+                DBG_ARGS(
+                        _S16(
+                                "CWlanSettings::DeleteWLANSettings, check enforcement failed. error: <%D>"),
+                        enError);
+                if (wlanEnforce)
+                    {
+                    ((CCommsDbProtectTableView*) iSecondaryView)->UnprotectRecord();
+                    }
+                }
+
+            retval = iSecondaryView->DeleteRecord();
+            if (retval == KErrLocked)
+                {
+                _DBG_FILE("DeleteOneSecondarySSIDL: DeleteRecord was locked.");
+                TInt retry = KBeginTransRetryCount;
+                while (retry > 0 && retval == KErrLocked)
+                    {
+                    User::After(KBeginTransRetryDelay);
+                    _DBG_FILE(
+                            "DeleteOneSecondarySSIDL: Slept 1 second. Try again");
+                    retval = iSecondaryView->DeleteRecord();
+                    retry--;
+                    }
+                if (retval != KErrNone)
+                    {
+                    _DBG_FILE(
+                            "DeleteOneSecondarySSIDL: DeleteRecord was unsuccessful");
+                    }
+                else
+                    {
+                    _DBG_FILE(
+                            "DeleteOneSecondarySSIDL: DeleteRecord was successful");
+                    }
+                }
+            DBG_ARGS(
+                    _S16(
+                            "CWlanSettings::DeleteOneSecondarySSIDL, Secondaryssid delete error: <%D> "),
+                    retval);
+
+            //    iTableView->PutRecordChanges( );
+            //}
+
+            break;
+            }
+
+        retval = iSecondaryView->GotoNextRecord();
+        }
+
+    return retval;
+    }
+
+TInt CWlanSettings::DeleteSecondarySSIDsL(TUint32 aWLANId)
+    {
+    TInt retVal(KErrNone);
+    if (iSecondaryView == NULL)
+        {
+        SetSecondaryViewToRecordL(aWLANId);
+        }
+    else
+        {
+        retVal = iSecondaryView->GotoFirstRecord();
+        TUint32 secId = 0;
+        if (retVal == KErrNone)
+            {
+            iSecondaryView->ReadUintL(TPtrC(WLAN_SEC_SSID_SERVICE_ID), secId);
+            }
+        if (secId != aWLANId)
+            {
+            SetSecondaryViewToRecordL(aWLANId);
+            }
+        }
+
+    TInt err = iSecondaryView->GotoFirstRecord();
+    while (err == KErrNone)
+        {
+        if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+            {
+            TBool wlanEnforce = EFalse;
+            TInt enError = KErrNone;
+            TRAP(enError, wlanEnforce = CheckEnforcementL());
+            DBG_ARGS(
+                    _S16(
+                            "CWlanSettings::DeleteSecondarySSIDsL, check enforcement failed. error: <%D>"),
+                    enError);
+            if (wlanEnforce)
+                {
+                ((CCommsDbProtectTableView*) iSecondaryView)->UnprotectRecord();
+                }
+            }
+        retVal = iSecondaryView->DeleteRecord();
+        if (retVal == KErrLocked)
+            {
+            _DBG_FILE("DeleteSecondarySSIDsL: DeleteRecord was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && retVal == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("DeleteSecondarySSIDsL: Slept 1 second. Try again");
+                retVal = iSecondaryView->DeleteRecord();
+                retry--;
+                }
+            if (retVal != KErrNone)
+                {
+                _DBG_FILE(
+                        "DeleteSecondarySSIDsL: DeleteRecord was unsuccessful");
+                }
+            else
+                {
+                _DBG_FILE(
+                        "DeleteSecondarySSIDsL: DeleteRecord was successful");
+                }
+            }
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::DeleteSecondarySSIDsL, Secondaryssid delete error: <%D> "),
+                retVal);
+
+        err = iSecondaryView->GotoNextRecord();
+        }
+
+    return retVal;
+    }
+//-----------------------------------------------------------------------------
+// TInt CWlanSettings::DeleteEapSettings( TInt aWlanId )
+//-----------------------------------------------------------------------------
+TInt CWlanSettings::DeleteEAPSettings(TInt aWlanId)
+    {
+    _DBG_FILE("CWlanSettings::DeleteEAPSettings(): begin");
+
+    TInt err(KErrNone);
+
+    TRAP(err, iEapType->DeleteConfigurationL());
+    if (err != KErrNone)
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::DeleteEAPSettings, delete failed, error: <%D> "),
+                err);
+        return err;
+        }
+
+    _DBG_FILE("CWlanSettings::DeleteEAPSettings(): end");
+    return err;
+    }
+
+//-----------------------------------------------------------------------------
+// TInt CWlanSettings::DeleteWlanEapSettings( TInt aWlanId )
+// Deletes all EAPs from a Wlan
+//-----------------------------------------------------------------------------
+void CWlanSettings::DeleteWlanEapSettingsL(TInt aWlanId)
+    {
+    _DBG_FILE("CWlanSettings::DeleteWlanEapSettings(): begin");
+    TInt err(KErrNone);
+    err = DeleteEAPSettings(aWlanId);
+    User::LeaveIfError(err);
+
+    _DBG_FILE("CWlanSettings::DeleteWlanEapSettings(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// TInt CWlanSettings::WriteWlanSettings( TWlanSettings& aWlanSettings )
+//-----------------------------------------------------------------------------
+TInt CWlanSettings::WriteWlanSettings(TWlanSettings& aWlanSettings)
+    {
+    _DBG_FILE("CWlanSettings::WriteWlanSettings(): begin");
+
+    TInt err = 0;
+    TInt enError = KErrNone;
+    iServiceID = aWlanSettings.ServiceID;
+    TBool wlanEnforce = EFalse;
+
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        TRAP(enError, wlanEnforce = CheckEnforcementL());
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::WriteWlanSettings, check enforcement . error: <%D>"),
+                enError);
+        if (wlanEnforce)
+            {
+            TRAPD(lockError, enError = PerformLockWLANTablesL(EFalse));
+            if (lockError == KErrNone && enError == KErrNone)
+                {
+                iWLANRelock = ETrue;
+                }
+            }
+        }
+
+    if (RecordExists(aWlanSettings.ServiceID) <= 0)
+        {
+        err = iTableView->InsertRecord(aWlanSettings.Id);
+        if (err == KErrLocked)
+            {
+            _DBG_FILE("WriteWlanSettings InsertRecord: CommsDat was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && err == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("WriteWlanSettings: Slept 1 second. Try again");
+                err = iTableView->InsertRecord(aWlanSettings.Id);
+                retry--;
+                }
+            }
+
+        if (err != KErrNone)
+            {
+            DBG_ARGS(
+                    _S16(
+                            "CWlanSettings::WriteWlanSettings(): - InsertRecord failed. error: <%D>"),
+                    err);
+
+            if (FeatureManager::FeatureSupported(
+                    KFeatureIdSapPolicyManagement))
+                {
+                TInt tableLockError = KErrNone;
+                if (iWLANRelock)
+                    {
+                    TInt lockError = KErrNone;
+                    TRAP(lockError, tableLockError = PerformLockWLANTablesL(
+                            ETrue));
+                    DBG_ARGS(
+                            _S16(
+                                    "CWlanSettings::WriteWlanSettings, WLAN table Lock error. error: <%D>, <%D> "),
+                            lockError, tableLockError);
+                    iWLANRelock = EFalse;
+                    }
+                if (tableLockError != KErrNone) // to remove warnings
+                    {
+                    tableLockError = KErrNone;
+                    }
+                }
+            return err;
+            }
+        TRAP(err, InitialiseRecordL());
+        if (err != KErrNone)
+            {
+            DBG_ARGS(
+                    _S16(
+                            "CWlanSettings::WriteWlanSettings(): - InitialiseRecord failed. error: <%D>"),
+                    err);
+
+            if (FeatureManager::FeatureSupported(
+                    KFeatureIdSapPolicyManagement))
+                {
+                TInt tableLockError = KErrNone;
+                if (iWLANRelock)
+                    {
+                    TInt lockError = KErrNone;
+                    TRAP(lockError, tableLockError = PerformLockWLANTablesL(
+                            ETrue));
+                    DBG_ARGS(
+                            _S16(
+                                    "CWlanSettings::WriteWlanSettings, WLAN table Lock error. error: <%D>, <%D> "),
+                            lockError, tableLockError);
+                    iWLANRelock = EFalse;
+                    }
+                if (tableLockError != KErrNone) // to remove warnings
+                    {
+                    tableLockError = KErrNone;
+                    }
+                }
+            return err;
+            }
+        }
+    else
+        {
+        err = GoToRecord(aWlanSettings.ServiceID);
+        if (err == KErrNone)
+            {
+
+            if (FeatureManager::FeatureSupported(
+                    KFeatureIdSapPolicyManagement))
+                {
+                if (wlanEnforce)
+                    {
+                    _DBG_FILE(
+                            "CWlanSettings::WriteWlanSettings(): unprotect wlan");
+                    ((CCommsDbProtectTableView*) iTableView)->UnprotectRecord();
+                    }
+                }
+
+            err = iTableView->UpdateRecord();
+            if (err == KErrLocked)
+                {
+                _DBG_FILE("WriteWlanSettings: UpdateRecord was locked.");
+                TInt retry = KBeginTransRetryCount;
+                while (retry > 0 && err == KErrLocked)
+                    {
+                    User::After(KBeginTransRetryDelay);
+                    _DBG_FILE("WriteWlanSettings: Slept 1 second. Try again");
+                    err = iTableView->UpdateRecord();
+                    retry--;
+                    }
+                if (err != KErrNone)
+                    {
+                    _DBG_FILE(
+                            "WriteWlanSettings: UpdateRecord was unsuccessful");
+                    }
+                else
+                    {
+                    _DBG_FILE(
+                            "WriteWlanSettings: UpdateRecord was successful");
+                    }
+                }
+
+            if (err != KErrNone)
+                {
+                DBG_ARGS(
+                        _S16(
+                                "CWlanSettings::WriteWlanSettings(): - UpdateRecord failed. error: <%D>"),
+                        err);
+
+                if (FeatureManager::FeatureSupported(
+                        KFeatureIdSapPolicyManagement))
+                    {
+                    TInt tableLockError = KErrNone;
+                    if (iWLANRelock)
+                        {
+                        TInt lockError = KErrNone;
+                        TRAP(lockError, tableLockError
+                                = PerformLockWLANTablesL(ETrue));
+                        DBG_ARGS(
+                                _S16(
+                                        "CWlanSettings::WriteWlanSettings, WLAN table Lock error. error: <%D>, <%D> "),
+                                lockError, tableLockError);
+                        ((CCommsDbProtectTableView*) iTableView)->ProtectRecord();
+                        iWLANRelock = EFalse;
+                        }
+                    if (tableLockError != KErrNone) // to remove warnings
+                        {
+                        tableLockError = KErrNone;
+                        }
+                    }
+                return err;
+                }
+            }
+        }
+
+    TRAP(err, WriteDataToRecordL(&aWlanSettings));
+
+    if (err == KErrNone)
+        {
+        _DBG_FILE("CWlanSettings::WriteWlanSettings(): PutRecordChanges");
+        err = iTableView->PutRecordChanges();
+        if (err == KErrLocked)
+            {
+            _DBG_FILE("WriteWlanSettings: PutRecordChanges was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && err == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("WriteWlanSettings: Slept 1 second. Try again");
+                err = iTableView->PutRecordChanges();
+                retry--;
+                }
+            }
+        if (err != KErrNone)
+            {
+            _DBG_FILE("WriteWlanSettings: PutRecordChanges was unsuccessful");
+            }
+        else
+            {
+            _DBG_FILE("WriteWlanSettings: PutRecordChanges was successful");
+            }
+        }
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        if (iWLANRelock)
+            {
+            TInt lockError = KErrNone;
+            TRAP(lockError, enError = PerformLockWLANTablesL(ETrue));
+            DBG_ARGS(
+                    _S16(
+                            "CWlanSettings::WriteWlanSettings, WLAN table Lock error. error: <%D>, <%D> "),
+                    lockError, enError);
+            iWLANRelock = EFalse;
+            }
+        }
+    DBG_ARGS(_S16("CWlanSettings::WriteWlanSettings(): end. err: <%D>"), err);
+    return err;
+    }
+
+//-----------------------------------------------------------------------------
+// TInt CWlanSettings::WriteWlanSettings( TWlanSettings& aWlanSettings )
+//-----------------------------------------------------------------------------
+TInt CWlanSettings::WriteSecondarySSIDL(TUint32 aWlanID,
+        TSecondarySSID& aSettings, TBool aNew)
+    {
+
+    _DBG_FILE("CWlanSettings::WriteSecondarySSIDL(): begin");
+
+    TUint32 id = 0;
+    delete iSecondaryView;
+    iSecondaryView = NULL;
+
+    TInt retval = KErrNone;
+    TInt reLock = EFalse;
+    TBool apEnforce = EFalse;
+
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        TRAPD(eError,apEnforce=CheckEnforcementL())
+        DBG_ARGS8(_S8("CNSmlInternetAdapter::WriteSecondarySSIDL(): EError %d , APEnforcement is %d"),eError,apEnforce);
+        if (eError == KErrNone && apEnforce)
+            {
+            _DBG_FILE("CWlanSettings::WriteSecondarySSIDL(): set db protect");
+            TInt enError = KErrNone;
+            TInt lockError = KErrNone;
+            TRAP(lockError, enError = PerformLockWLANTablesL(EFalse));
+            reLock = ETrue;
+            if (enError != KErrNone) // to remove warnings
+                {
+                enError = KErrNone;
+                }
+            }
+        }
+
+    if (aNew)
+        {
+        _DBG_FILE("CWlanSettings::WriteSecondarySSIDL(): new table inserted");
+        iSecondaryView = iDatabase.OpenTableLC(TPtrC(WLAN_SECONDARY_SSID));
+        CleanupStack::Pop(iSecondaryView); // iSecondaryView
+        retval = iSecondaryView->InsertRecord(id);
+
+        if (retval == KErrLocked)
+            {
+            _DBG_FILE("WriteSecondarySSIDL: InsertRecord was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && retval == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("WriteSecondarySSIDL: Slept 1 second. Try again");
+                retval = iSecondaryView->InsertRecord(id);
+                retry--;
+                }
+            }
+        if (retval != KErrNone)
+            {
+            _DBG_FILE("WriteSecondarySSIDL: InsertRecord was unsuccessful");
+            }
+        else
+            {
+            _DBG_FILE("WriteSecondarySSIDL: InsertRecord was successful");
+            }
+
+        DBG_ARGS8(
+                _S8(
+                        "CNSmlInternetAdapter::WriteSecondarySSIDL(): Add record, error %d"),
+                retval);
+        if (retval == KErrNone)
+            {
+            _DBG_FILE(
+                    "CWlanSettings::WriteSecondarySSIDL(): table insertion went ok");
+            iSecondaryView->WriteUintL(TPtrC(WLAN_SEC_SSID_SERVICE_ID),
+                    aWlanID);
+            iSecondaryView->WriteUintL(TPtrC(WLAN_SEC_SSID_ID), id);
+            }
+        }
+    else
+        {
+        _DBG_FILE(
+                "CWlanSettings::WriteSecondarySSIDL(): table exists, find it");
+        iSecondaryView = iDatabase.OpenViewMatchingUintLC(TPtrC(
+                WLAN_SECONDARY_SSID), TPtrC(WLAN_SEC_SSID_ID), aSettings.Id);
+        CleanupStack::Pop(iSecondaryView); // iSecondaryView
+        TInt err = iSecondaryView->GotoFirstRecord();
+        if (err != KErrNone)
+            {
+            _DBG_FILE(
+                    "CWlanSettings::WriteSecondarySSIDL(): go to first record failed");
+            // most likely KErrNotFound, something wrong with the URI parsing probably
+            return err;
+            }
+        if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+            {
+            if (apEnforce)
+                {
+                ((CCommsDbProtectTableView*) iSecondaryView)->UnprotectRecord();
+                }
+            }
+        retval = iSecondaryView->UpdateRecord();
+        if (retval == KErrLocked)
+            {
+            _DBG_FILE("WriteSecondarySSIDL: UpdateRecord was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && retval == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("WriteSecondarySSIDL: Slept 1 second. Try again");
+                retval = iSecondaryView->UpdateRecord();
+                retry--;
+                }
+            }
+        if (retval != KErrNone)
+            {
+            _DBG_FILE("WriteSecondarySSIDL: UpdateRecord was unsuccessful");
+            }
+        else
+            {
+            _DBG_FILE("WriteSecondarySSIDL: UpdateRecord was successful");
+            }
+        }
+    if (retval == KErrNone)
+        {
+        DBG_ARGS8(
+                _S8(
+                        "CWlanSettings::writesecondaryssids - WLAN_SEC_SSID_SCANNED_SSID uri: <%S> ad  WLAN_SEC_SSID_USED_SSID : <%S>"),
+                &aSettings.ScannedId, &aSettings.UsedId);
+        iSecondaryView->WriteTextL(TPtrC(WLAN_SEC_SSID_SCANNED_SSID),
+                aSettings.ScannedId);
+        iSecondaryView->WriteTextL(TPtrC(WLAN_SEC_SSID_USED_SSID),
+                aSettings.UsedId);
+
+        retval = iSecondaryView->PutRecordChanges();
+        if (retval == KErrLocked)
+            {
+            _DBG_FILE("WriteSecondarySSIDL: PutRecordChanges was locked.");
+            TInt retry = KBeginTransRetryCount;
+            while (retry > 0 && retval == KErrLocked)
+                {
+                User::After(KBeginTransRetryDelay);
+                _DBG_FILE("WriteSecondarySSIDL: Slept 1 second. Try again");
+                retval = iSecondaryView->PutRecordChanges();
+                retry--;
+                }
+            }
+        if (retval != KErrNone)
+            {
+            _DBG_FILE(
+                    "WriteSecondarySSIDL: PutRecordChanges was unsuccessful");
+            }
+        else
+            {
+            _DBG_FILE("WriteSecondarySSIDL: PutRecordChanges was successful");
+            }
+        }
+
+    if (FeatureManager::FeatureSupported(KFeatureIdSapPolicyManagement))
+        {
+        if (reLock)
+            {
+            TInt enError = KErrNone;
+            TInt lockError = KErrNone;
+            TRAP(lockError, enError = PerformLockWLANTablesL(ETrue));
+            if (iSecondaryView != NULL)
+                {
+                ((CCommsDbProtectTableView*) iSecondaryView)->ProtectRecord();
+                }
+            if (enError != KErrNone) // to remove warnings
+                {
+                enError = KErrNone;
+                }
+            }
+        }
+
+    // This makes sure that there will be no calling to GotoFirstRecord() 
+    // before secondaryview is reinitialized, (causes a panic if that would happen)
+    delete iSecondaryView;
+    iSecondaryView = NULL;
+
+    if (reLock && apEnforce)
+        {
+        reLock = EFalse; // to get rid of warnings
+        apEnforce = EFalse;
+        }
+
+    return retval;
+
+    }
+
+TInt CWlanSettings::WriteEAPSettings(EAPSettings& aEapSettings)
+    {
+    TRAPD(err, iEapType->SetConfigurationL(aEapSettings));
+    return err;
+    }
+
+//-----------------------------------------------------------------------------
+// void CWlanSettings::ConnectToDatabaseL( )
+//-----------------------------------------------------------------------------
+void CWlanSettings::ConnectToDatabaseL()
+    {
+    _DBG_FILE("CWlanSettings::ConnectToDatabaseL(): begin");
+
+    if (!iTableView)
+        {
+        iTableView = iDatabase.OpenTableLC(TPtrC(WLAN_SERVICE));
+
+        if (iTableView == NULL)
+            {
+            _DBG_FILE(
+                    "CWlanSettings::ConnectToDatabaseL(): could not open table");
+            User::Leave(KErrCouldNotConnect);
+            }
+
+        CleanupStack::Pop(iTableView); //iTableView
+        }
+
+    _DBG_FILE("CWlanSettings::ConnectToDatabaseL(): end");
+    }
+
+void CWlanSettings::GetEAPInterfaceL(const TInt aId,
+        TEapExpandedType& aEncapsId, TEapExpandedType& aExpandedId)
+    {
+    if (aId < 0)
+        {
+        // Illegal input
+        User::Leave(KErrArgument);
+        }
+
+    if (iEapType)
+        {
+        delete iEapType;
+        iEapType = NULL;
+        }
+    TInt err = KErrNone;
+    TRAP(err, iEapType = CEapType::NewL(ELan, aId, aExpandedId));
+
+    if (err == KErrNone)
+        {
+        if (aEncapsId != (*EapExpandedTypeNone.GetType()))
+            {
+            iEapType->SetTunnelingType(aEncapsId);
+            }
+        }
+    }
+
+//-----------------------------------------------------------------------------
+// TInt CWlanSettings::GoToRecord( TUint32 aId )
+// Moves iTableView to point record whose id-number equals to aId
+//-----------------------------------------------------------------------------
+TInt CWlanSettings::GoToRecord(TUint32 aId)
+    {
+    _DBG_FILE("CWlanSettings::GoToRecord(): begin");
+    DBG_ARGS(
+            _S16("CWlanSettings::GoToRecord(): begin Search record id: <%D>"),
+            aId);
+
+    TInt err = iTableView->GotoFirstRecord();
+    if (err != KErrNone)
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GoToRecord(): end, GotoFirstRecord. err: <%D>"),
+                err);
+        return err;
+        }
+
+    TUint32 id = 0;
+    TRAP(err, iTableView->ReadUintL(TPtrC(WLAN_SERVICE_ID), id));
+    if (err != KErrNone)
+        {
+        DBG_ARGS(_S16(
+                "CWlanSettings::GoToRecord(): end, ReadUintL. err: <%D>"),
+                err);
+        return err;
+        }
+
+    while (aId != id)
+        {
+        err = iTableView->GotoNextRecord();
+        if (err != KErrNone)
+            {
+            DBG_ARGS(
+                    _S16(
+                            "CWlanSettings::GoToRecord(): end, GotoNextRecord. err: <%D>"),
+                    err);
+            return err;
+            }
+
+        TRAP(err, iTableView->ReadUintL(TPtrC(WLAN_SERVICE_ID), id));
+
+        if (err == KErrNone)
+            {
+            DBG_ARGS(_S16(
+                    "CWlanSettings::GoToRecord(): Found service id: <%D>"),
+                    id);
+            }
+        else
+            {
+            DBG_ARGS(
+                    _S16(
+                            "CWlanSettings::GoToRecord(): end, ReadUintL next. err: <%D>"),
+                    err);
+            return err;
+            }
+        }
+
+    TRAP(err, SetSecondaryViewToRecordL(aId));
+
+    DBG_ARGS(_S16("CWlanSettings::GoToRecord(): end. Final record id: <%D>"),
+            id);
+
+    return err;
+    }
+
+void CWlanSettings::SetSecondaryViewToRecordL(TUint32 aId)
+    {
+    // optional secondarySSID
+    if (iSecondaryView)
+        {
+        delete iSecondaryView;
+        iSecondaryView = NULL;
+        }
+
+    // first open a view to secondary ssid table, with all the rows with service id
+    // matching the wlan service id (count can be zero)        
+    iSecondaryView = iDatabase.OpenViewMatchingUintLC(TPtrC(
+            WLAN_SECONDARY_SSID), TPtrC(WLAN_SEC_SSID_SERVICE_ID), aId);
+    if (iSecondaryView == NULL)
+        {
+        // this should not happen in a normal situation
+        User::Leave(KErrCouldNotConnect);
+        }
+    CleanupStack::Pop(iSecondaryView);
+    }
+
+//-----------------------------------------------------------------------------
+// void CWlanSettings::GetDataFromRecordL( TWlanSettings* aWlanSettings )
+// Read settings from database to aWlanSettings structure
+//-----------------------------------------------------------------------------
+void CWlanSettings::GetDataFromRecordL(TWlanSettings* aWlanSettings)
+    {
+    _DBG_FILE("CWlanSettings::GetDataFromRecordL(): begin");
+
+    TInt leavecode = 0;
+
+    aWlanSettings->ServiceID = 0;
+    aWlanSettings->ConnectionMode = 0;
+    aWlanSettings->SSID = _L("");
+    aWlanSettings->UsedSSID = _L("");
+    aWlanSettings->ScanSSID = 0;
+    aWlanSettings->WepKey1 = _L8("");
+    aWlanSettings->WepKey2 = _L8("");
+    aWlanSettings->WepKey3 = _L8("");
+    aWlanSettings->WepKey4 = _L8("");
+    aWlanSettings->WepIndex = 0;
+    aWlanSettings->SecurityMode = EAllowUnsecure;
+    aWlanSettings->WPAPreSharedKey = _L8("");
+    aWlanSettings->UseWPAPSK = 0;
+    aWlanSettings->EapList = _L("");
+    aWlanSettings->AuthMode = 0;
+
+    TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_SERVICE_ID),
+            aWlanSettings->ServiceID));
+    if (leavecode != KErrNone)
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): WLAN_SERVICE_ID read error: <%D>"),
+                leavecode);
+        }
+
+    TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_CONNECTION_MODE),
+            aWlanSettings->ConnectionMode));
+    if (leavecode != KErrNone)
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): WLAN_CONNECTION_MODE read error: <%D>"),
+                leavecode);
+        }
+
+    TRAP(leavecode, iTableView->ReadUintL(TPtrC(NU_WLAN_AUTHENTICATION_MODE),
+            aWlanSettings->AuthMode));
+    if (leavecode != KErrNone)
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): NU_WLAN_AUTHENTICATION_MODE read error: <%D>"),
+                leavecode);
+        }
+
+    TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_WEP_INDEX),
+            aWlanSettings->WepIndex));
+    if (leavecode != KErrNone)
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): WLAN_WEP_INDEX read error: <%D>"),
+                leavecode);
+        }
+
+    TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_SECURITY_MODE),
+            aWlanSettings->SecurityMode));
+    if (leavecode != KErrNone)
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): WLAN_SECURITY_MODE read error: <%D>"),
+                leavecode);
+        }
+
+    TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_ENABLE_WPA_PSK),
+            aWlanSettings->UseWPAPSK));
+    if (leavecode != KErrNone)
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): WLAN_ENABLE_WPA_PSK read error: <%D>"),
+                leavecode);
+        }
+
+    TBuf8<KCommsDbSvrMaxFieldLength> columnValue8;
+    TRAP(leavecode, iTableView->ReadTextL(TPtrC(NU_WLAN_WEP_KEY1),
+            columnValue8));
+    if ((leavecode == KErrNone) && (columnValue8.Length() > 0))
+        {
+        aWlanSettings->WepKey1 = columnValue8;
+        }
+    else
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): NU_WLAN_WEP_KEY1 read error: <%D>"),
+                leavecode);
+        }
+
+    TRAP(leavecode, iTableView->ReadTextL(TPtrC(NU_WLAN_WEP_KEY2),
+            columnValue8));
+    if ((leavecode == KErrNone) && (columnValue8.Length() > 0))
+        {
+        aWlanSettings->WepKey2 = columnValue8;
+        }
+    else
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): NU_WLAN_WEP_KEY2 read error: <%D>"),
+                leavecode);
+        }
+
+    TRAP(leavecode, iTableView->ReadTextL(TPtrC(NU_WLAN_WEP_KEY3),
+            columnValue8));
+    if ((leavecode == KErrNone) && (columnValue8.Length() > 0))
+        {
+        aWlanSettings->WepKey3 = columnValue8;
+        }
+    else
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): NU_WLAN_WEP_KEY3 read error: <%D>"),
+                leavecode);
+        }
+
+    TRAP(leavecode, iTableView->ReadTextL(TPtrC(NU_WLAN_WEP_KEY4),
+            columnValue8));
+    if ((leavecode == KErrNone) && (columnValue8.Length() > 0))
+        {
+        aWlanSettings->WepKey4 = columnValue8;
+        }
+    else
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): NU_WLAN_WEP_KEY4 read error: <%D>"),
+                leavecode);
+        }
+
+    TBuf8<KMaxPSKLength> precolumnValue8;
+    TBuf<KCommsDbSvrMaxFieldLength> columnValue;
+
+    _DBG_FILE(
+            "CWlanSettings::GetDataFromRecordL(): Before getting WLAN_WPA_PRE_SHARED_KEY ");
+    TRAP(leavecode, iTableView->ReadTextL(TPtrC(WLAN_WPA_PRE_SHARED_KEY),
+            precolumnValue8));
+    DBG_ARGS(
+            _S16(
+                    "CWlanSettings::ReadTextL( TPtrC(WLAN_WPA_PRE_SHARED_KEY ),length of key: <%D>"),
+            precolumnValue8.Length());
+    if ((leavecode == KErrNone) && (precolumnValue8.Length() > 0))
+        {
+        aWlanSettings->WPAPreSharedKey = precolumnValue8;
+        }
+    else
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): WLAN_WPA_PRE_SHARED_KEY read error: <%D>"),
+                leavecode);
+        }
+
+    TRAP(leavecode, iTableView->ReadTextL(TPtrC(NU_WLAN_SSID), columnValue));
+    if ((leavecode == KErrNone) && (columnValue.Length() > 0))
+        {
+        aWlanSettings->SSID = columnValue;
+        }
+    else
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): NU_WLAN_SSID read error: <%D>"),
+                leavecode);
+        }
+
+    TRAP(leavecode, iTableView->ReadTextL(TPtrC(WLAN_USED_SSID), columnValue));
+    if ((leavecode == KErrNone) && (columnValue.Length() > 0))
+        {
+        aWlanSettings->UsedSSID = columnValue;
+        _DBG_FILE(
+                "CWlanSettings::GetDataFromRecordL(): WLAN_USED_SSID reading ok");
+        }
+    else
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): WLAN_USED_SSID read error: <%D>"),
+                leavecode);
+        }
+
+    iTableView->ReadTextL(TPtrC(WLAN_USED_SSID), aWlanSettings->UsedSSID);
+    _DBG_FILE("CWlanSettings::GetDataFromRecordL(): WLAN_USED_SSID");
+
+    TRAP(leavecode, iTableView->ReadUintL(TPtrC(WLAN_SCAN_SSID),
+            aWlanSettings->ScanSSID));
+    if (leavecode != KErrNone)
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::GetDataFromRecordL(): WLAN_SCAN_SSID read error: <%D>"),
+                leavecode);
+        }
+
+    TInt retval = iSecondaryView->GotoFirstRecord();
+    if (retval == KErrNone)
+        {
+        aWlanSettings->SecondarySSIDsExisting = ETrue;
+        }
+    else
+        {
+        aWlanSettings->SecondarySSIDsExisting = EFalse;
+        }
+
+    _DBG_FILE("CWlanSettings::GetDataFromRecordL(): WLAN_EAPS");
+
+    _DBG_FILE("CWlanSettings::GetDataFromRecordL(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// void CWlanSettings::GetSecondarySSIDListL(TUint32 aId, RArray<TSecondarySSID>& aSecondarySSIDs)
+// Fills the array with secondarySSIDs, which are associated with given WLANID
+//-----------------------------------------------------------------------------
+void CWlanSettings::GetSecondarySSIDListL(TUint32 aWlanId, RArray<
+        TSecondarySSID>& aSecondarySSIDs)
+    {
+    if (iSecondaryView == NULL)
+        {
+        // views haven't been initialized, in case of incorrect usage
+        User::Leave(KErrNotReady);
+        }
+
+    // set the view pointer into the first record
+    TInt retval = iSecondaryView->GotoFirstRecord();
+    if (retval != KErrNone)
+        {
+        return;
+        }
+
+    // check that given id matches the current rowset. If not, then reinitialize
+    TUint32 id;
+    TInt err(KErrNone);
+    TRAP(err, iSecondaryView->ReadUintL(TPtrC(WLAN_SEC_SSID_SERVICE_ID), id));
+    if (id != aWlanId)
+        {
+        SetSecondaryViewToRecordL(aWlanId);
+        retval = iSecondaryView->GotoFirstRecord();
+        }
+
+    TBuf<KMaxTextLength> columnValue;
+
+    while (retval == KErrNone)
+        {
+        TSecondarySSID ssid;
+        TRAP(retval, iSecondaryView->ReadUintL(TPtrC(WLAN_SEC_SSID_ID),
+                ssid.Id));
+        TRAP(retval, iSecondaryView->ReadTextL(TPtrC(
+                WLAN_SEC_SSID_SCANNED_SSID), ssid.ScannedId));
+        TRAP(retval, iSecondaryView->ReadTextL(
+                TPtrC(WLAN_SEC_SSID_USED_SSID), ssid.UsedId));
+        aSecondarySSIDs.Append(ssid);
+        retval = iSecondaryView->GotoNextRecord();
+        }
+    }
+
+//-----------------------------------------------------------------------------
+// void CWlanSettings::WriteDataToRecordL( TWlanSettings* aWlanSettings )
+// Writes settings to database from aWlanSettings structure
+//-----------------------------------------------------------------------------
+void CWlanSettings::WriteDataToRecordL(TWlanSettings* aWlanSettings)
+    {
+    _DBG_FILE("CWlanSettings::WriteDataToRecordL(): begin");
+
+    iTableView->WriteUintL(TPtrC(WLAN_SERVICE_ID), aWlanSettings->ServiceID);
+    iTableView->WriteUintL(TPtrC(WLAN_CONNECTION_MODE),
+            aWlanSettings->ConnectionMode);
+    iTableView->WriteUintL(TPtrC(WLAN_WEP_INDEX), aWlanSettings->WepIndex);
+    iTableView->WriteUintL(TPtrC(WLAN_SECURITY_MODE),
+            aWlanSettings->SecurityMode);
+    iTableView->WriteUintL(TPtrC(WLAN_ENABLE_WPA_PSK),
+            aWlanSettings->UseWPAPSK);
+    iTableView->WriteUintL(TPtrC(NU_WLAN_AUTHENTICATION_MODE),
+            aWlanSettings->AuthMode);
+    iTableView->WriteTextL(TPtrC(NU_WLAN_SSID), aWlanSettings->SSID);
+    iTableView->WriteTextL(TPtrC(WLAN_USED_SSID), aWlanSettings->UsedSSID);
+    iTableView->WriteUintL(TPtrC(WLAN_SCAN_SSID), aWlanSettings->ScanSSID);
+
+    iTableView->WriteTextL(TPtrC(NU_WLAN_WEP_KEY1), aWlanSettings->WepKey1);
+    iTableView->WriteTextL(TPtrC(NU_WLAN_WEP_KEY2), aWlanSettings->WepKey2);
+    iTableView->WriteTextL(TPtrC(NU_WLAN_WEP_KEY3), aWlanSettings->WepKey3);
+    iTableView->WriteTextL(TPtrC(NU_WLAN_WEP_KEY4), aWlanSettings->WepKey4);
+    iTableView->WriteUintL(TPtrC(WLAN_WEP_KEY1_FORMAT), 1); // 0 = Eascii, 1 = EHexadecimal
+    iTableView->WriteUintL(TPtrC(WLAN_WEP_KEY2_FORMAT), 1);
+    iTableView->WriteUintL(TPtrC(WLAN_WEP_KEY3_FORMAT), 1);
+    iTableView->WriteUintL(TPtrC(WLAN_WEP_KEY4_FORMAT), 1);
+
+    iTableView->WriteTextL(TPtrC(WLAN_WPA_PRE_SHARED_KEY),
+            aWlanSettings->WPAPreSharedKey);
+    iTableView->WriteUintL(TPtrC(WLAN_WPA_KEY_LENGTH),
+            aWlanSettings->WPAPreSharedKey.Length());
+
+    _DBG_FILE("CWlanSettings::WriteDataToRecordL(): end");
+    }
+
+//-----------------------------------------------------------------------------
+// TInt CWlanSettings::RecordExists( TUint32 aLuid )
+// Returns ETrue if record exists in database
+//-----------------------------------------------------------------------------
+TInt CWlanSettings::RecordExists(TUint32 aLuid)
+    {
+    _DBG_FILE("CWlanSettings::RecordExists(): begin");
+
+    TInt err = KErrNone;
+    TRAP(err, ConnectToDatabaseL());
+
+    // If the connection went ok, then we can go to the record
+    if (err == KErrNone)
+        {
+        err = GoToRecord(aLuid);
+        }
+
+    if (err == KErrNone)
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::RecordExists(): end. GoToRecord OK err: <%D>"),
+                err);
+        return ETrue;
+        }
+    else
+        {
+        DBG_ARGS(
+                _S16(
+                        "CWlanSettings::RecordExists(): end. GoToRecord error err: <%D>"),
+                err);
+        return err;
+        }
+    }
+
+//-----------------------------------------------------------------------------
+// void CWlanSettings::InitialiseRecordL( )
+// Inserts mandatory values for commsdb
+//-----------------------------------------------------------------------------
+void CWlanSettings::InitialiseRecordL()
+    {
+    _DBG_FILE("CWlanSettings::InitialiseRecordL(): begin");
+
+    iTableView->WriteUintL(TPtrC(WLAN_WPA_KEY_LENGTH), 0);
+    iTableView->WriteUintL(TPtrC(NU_WLAN_AUTHENTICATION_MODE), 0);
+
+    _DBG_FILE("CWlanSettings::InitialiseRecordL(): end");
+    }
+
+TInt CWlanSettings::InstalledEAPsL(CBufBase& aEAPList)
+    {
+    _DBG_FILE("CWlanSettings::InstalledEAPsL(): begin");
+
+    RImplInfoPtrArray ecomInfoArray;
+    REComSession::ListImplementationsL(KEapTypeInterfaceUid, ecomInfoArray);
+
+    TUint eapId(0);
+
+    // First sort the EAPIds
+    for (TInt i = 0; i < ecomInfoArray.Count(); i++)
+        {
+        if (ecomInfoArray[i]->DataType().Length() == KExpandedEAPIdLength)
+            {
+            // The EAP ID is in expanded type format
+            // Only handle the vendor type of 0
+            if ((ecomInfoArray[i]->DataType()[1] != 0
+                    || ecomInfoArray[i]->DataType()[2] != 0
+                    || ecomInfoArray[i]->DataType()[3] != 0)
+                    && ((ecomInfoArray[i]->DataType()[7]
+                            != KMschapv2TypeId[7])
+                            && (ecomInfoArray[i]->DataType()[7]
+                                    != KTtlspapTypeId[7])))
+                {
+                // This is some other vendor type than IETF
+                continue;
+                }
+            eapId = ecomInfoArray[i]->DataType()[7];
+            _DBG_FILE(
+                    "CWlanSettings::InstalledEAPsL(): Expanded EAP id found.");
+            }
+        else
+            {
+            // The EAP ID is in old 8-bit format (as string)
+            TLex8 lex(ecomInfoArray[i]->DataType());
+            if (lex.Val(eapId) != KErrNone)
+                {
+                // Unsupported format. Ignore this.
+                _DBG_FILE(
+                        "CWlanSettings::InstalledEAPsL(): Unsupported EAP id found.");
+                continue;
+                }
+            _DBG_FILE(
+                    "CWlanSettings::InstalledEAPsL(): Old style EAP id found.");
+            }
+
+        if (!IsDisallowedOutsidePEAP(*ecomInfoArray[i]))
+            {
+            aEAPList.InsertL(aEAPList.Size(), KNSmlWLanEapId); // EAPId
+            TBuf8<3> cue; // Max EAPId == 255
+            cue.AppendNumFixedWidth(eapId, EDecimal, 3);
+            aEAPList.InsertL(aEAPList.Size(), cue);
+            aEAPList.InsertL(aEAPList.Size(), KSlash);
+            }
+
+        // Check if the method is allowed inside PEAP
+        if (!IsDisallowedInsidePEAP(*ecomInfoArray[i]))
+            {
+            aEAPList.InsertL(aEAPList.Size(), KNSmlWLanEapId); // EAPId
+            TBuf8<3> cue; // Max EAPId == 255
+            cue.AppendNumFixedWidth(eapId, EDecimal, 3);
+            aEAPList.InsertL(aEAPList.Size(), cue);
+            aEAPList.InsertL(aEAPList.Size(), KDash);
+            cue.Zero();
+            cue.AppendNumFixedWidth(KEapPeapTypeId[7], EDecimal, 3);
+            aEAPList.InsertL(aEAPList.Size(), cue);
+            aEAPList.InsertL(aEAPList.Size(), KSlash);
+
+#ifdef FF_WLAN_EXTENSIONS
+            // same additions for EAP-FAST
+            aEAPList.InsertL(aEAPList.Size(), KNSmlWLanEapId); // EAPId
+            cue.Zero(); // Max EAPId == 255
+            cue.AppendNumFixedWidth( eapId, EDecimal, 3 );
+            aEAPList.InsertL(aEAPList.Size(), cue);
+            aEAPList.InsertL(aEAPList.Size(), KDash);
+            cue.Zero();
+            cue.AppendNumFixedWidth( KEapFastTypeId[7], EDecimal, 3 );
+            aEAPList.InsertL(aEAPList.Size(), cue);
+            aEAPList.InsertL(aEAPList.Size(), KSlash);
+#endif              
+            }
+        // Check if the method is allowed inside TTLS
+        if (!IsDisallowedInsideTTLS(*ecomInfoArray[i]))
+            {
+            aEAPList.InsertL(aEAPList.Size(), KNSmlWLanEapId); // EAPId
+            TBuf8<3> cue; // Max EAPId == 255
+            cue.AppendNumFixedWidth(eapId, EDecimal, 3);
+            aEAPList.InsertL(aEAPList.Size(), cue);
+            aEAPList.InsertL(aEAPList.Size(), KDash);
+            cue.Zero();
+            cue.AppendNumFixedWidth(KEapTtlsTypeId[7], EDecimal, 3);
+            aEAPList.InsertL(aEAPList.Size(), cue);
+            aEAPList.InsertL(aEAPList.Size(), KSlash);
+            }
+        }
+    // ECOM array is no longer needed.
+    ecomInfoArray.ResetAndDestroy();
+
+    // Cut the last slash
+    aEAPList.ResizeL(aEAPList.Size() - 1);
+
+    _DBG_FILE("CWlanSettings::InstalledEAPsL(): end");
+    return KErrNone;
+    }
+
+//-----------------------------------------------------------------------------
+// TBool CWlanSettings::CheckEnforcementL( )
+// Checks if wlan enforcement is On or Off
+//-----------------------------------------------------------------------------
+TBool CWlanSettings::CheckEnforcementL()
+    {
+    CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL();
+    CleanupStack::PushL(info);
+    TBool enforceWLANActive(EFalse);
+    User::LeaveIfError(info->EnforcementActive(EWLANEnforcement,
+            enforceWLANActive));
+    CleanupStack::PopAndDestroy(info);
+    return (enforceWLANActive);
+    }
+
+//-----------------------------------------------------------------------------
+// TBool CWlanSettings::CheckAPEnforcementL( )
+// Checks if AP enforcement is On or Off
+//-----------------------------------------------------------------------------
+
+TBool CWlanSettings::CheckAPEnforcementL()
+    {
+    CSettingEnforcementInfo* info = CSettingEnforcementInfo::NewL();
+    CleanupStack::PushL(info);
+    TBool enforceAPActive(EFalse);
+    User::LeaveIfError(info->EnforcementActive(EAPEnforcement,
+            enforceAPActive));
+    CleanupStack::PopAndDestroy(info);
+    return (enforceAPActive);
+    }
+//-----------------------------------------------------------------------------
+// TInt CWlanSettings::PerformLockWLANTablesL( )
+// Locks or unlocks the wlan tables depending on the 
+// aProtect value
+//-----------------------------------------------------------------------------
+TInt CWlanSettings::PerformLockWLANTablesL(TBool aProtect)
+    {
+
+    _DBG_FILE("CWlanSettings::PerformLockWLANTablesL(): BEGIN ");
+    CCommsDatabaseProtect* dbprotect = CCommsDatabaseProtect::NewL();
+    CleanupStack::PushL(dbprotect);
+    RArray<TPtrC> wlanTableList;
+    CleanupClosePushL(wlanTableList);
+    TBuf<KCommsDbSvrMaxFieldLength> serviceType;
+    TBool apEnforce = EFalse;
+    TInt err = KErrNone;
+
+    TRAP_IGNORE(apEnforce = CheckAPEnforcementL());
+    if (apEnforce)
+        {
+        _DBG_FILE(
+                "CWlanSettings::PerformLockWLANTablesL(): AP enforcement is TRUE");
+        wlanTableList.AppendL(TPtrC(WAP_ACCESS_POINT));
+        wlanTableList.AppendL(TPtrC(WAP_IP_BEARER));
+        wlanTableList.AppendL(TPtrC(IAP));
+        //condition when only ap is enforced and not wlan then its not 
+        //necessary to add wlanservice table
+        RDbRowSet::TAccess checkAccessType;
+        checkAccessType = dbprotect->GetTableAccessL(TPtrC(
+                WLAN_DEVICE_SETTINGS));
+        switch (checkAccessType)
+            {
+            case RDbRowSet::EReadOnly:
+                {
+                wlanTableList.AppendL(TPtrC(WLAN_SERVICE));
+                wlanTableList.AppendL(TPtrC(WLAN_SECONDARY_SSID));
+                }
+            default:
+                {
+                break;
+                }
+            }
+
+        }
+    else
+        {
+        _DBG_FILE(
+                "CWlanSettings::PerformLockWLANTablesL() Only wlan enforcement is ON");
+        wlanTableList.AppendL(TPtrC(WLAN_SERVICE));
+        wlanTableList.AppendL(TPtrC(WLAN_SECONDARY_SSID));
+        }
+
+    iDatabase.CommitTransaction();
+
+    for (TInt i(0); i < wlanTableList.Count(); i++)
+        {
+        if (!aProtect)
+            {
+            err = dbprotect->UnProtectTable(wlanTableList[i]);
+            DBG_ARGS(
+                    _S16(
+                            "CWlanSettings::PerformLockWLANTablesL(): Unprotect error  %D"),
+                    err);
+            //Check if current AP is locked , if yes , unprotect 
+            // lock = EFalse;
+            }
+        else
+            {
+            err = dbprotect->ProtectTable(wlanTableList[i]);
+            //Check if current ServiceID is not locked , if yes , protect
+            // lock = ETrue;
+            }
+        } //for loop
+
+    CleanupStack::PopAndDestroy(&wlanTableList);
+    CleanupStack::PopAndDestroy(dbprotect);
+    CCommsDatabase* commsDataBase = CCommsDatabase::NewL();
+    CleanupStack::PushL(commsDataBase);
+
+    // Open the IAP from IAP Table and protect 
+
+    TUint32 apIAPID = 0;
+    CCommsDbTableView* iapViews = commsDataBase->OpenViewMatchingUintLC(
+            TPtrC(IAP), TPtrC(IAP_SERVICE), iServiceID);
+    err = iapViews->GotoFirstRecord();
+    // Service ID can be same for GPRS or WLAN, hence check service type and get the iAPID
+    while (err == KErrNone)
+        {
+        iapViews->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
+        if (serviceType == TPtrC(LAN_SERVICE))
+            {
+            iapViews->ReadUintL(TPtrC(COMMDB_ID), apIAPID);
+            DBG_ARGS(_S16(
+                    "CWlanSettings::PerformLockWLANTablesL():  IAPId   %D"),
+                    apIAPID);
+            break;
+            }
+        err = iapViews->GotoNextRecord();
+        }
+
+    //iapViews->ReadUintL(TPtrC(COMMDB_ID), apIAPID);
+    DBG_ARGS(
+            _S16(
+                    "CWlanSettings::PerformLockWLANTablesL(): end. IAP ID being locked %d "),
+            apIAPID);
+    if (err == KErrNone)
+        {
+        CCommsDbTableView* iapUpdate = commsDataBase->OpenViewMatchingUintLC(
+                TPtrC(IAP), TPtrC(COMMDB_ID), apIAPID);
+        TInt iapExists = iapUpdate->GotoFirstRecord();
+
+        if (!aProtect)
+            {
+            ((CCommsDbProtectTableView*) iapViews)->UnprotectRecord();
+            if (iapExists)
+                {
+                ((CCommsDbProtectTableView*) iapUpdate)->UnprotectRecord();
+                }
+            }
+        else
+            {
+            ((CCommsDbProtectTableView*) iapViews)->ProtectRecord();
+            if (iapExists)
+                {
+                ((CCommsDbProtectTableView*) iapUpdate)->ProtectRecord();
+                }
+            }
+        CleanupStack::PopAndDestroy(); // iapUpdate
+        }
+
+    CleanupStack::PopAndDestroy(iapViews);
+    CleanupStack::PopAndDestroy(commsDataBase);
+
+    iDatabase.BeginTransaction();
+    return err;
+    }
+
+TBool CWlanSettings::IsDisallowedOutsidePEAP(
+        const CImplementationInformation& aImplInfo)
+    {
+
+    const TUint8 pluginOpaqueData = *(aImplInfo.OpaqueData().Ptr());
+
+    if (pluginOpaqueData & KNotOutsidePEAP)
+        {
+        return ETrue;
+        }
+    return EFalse;
+
+    }
+
+TBool CWlanSettings::IsDisallowedInsidePEAP(
+        const CImplementationInformation& aImplInfo)
+    {
+    const TUint8 pluginOpaqueData = *(aImplInfo.OpaqueData().Ptr());
+
+    if (pluginOpaqueData & KNotInsidePEAP)
+        {
+        return ETrue;
+        }
+    return EFalse;
+
+    }
+
+TBool CWlanSettings::IsDisallowedInsideTTLS(
+        const CImplementationInformation& aImplInfo)
+    {
+    const TUint8 pluginOpaqueData = *(aImplInfo.OpaqueData().Ptr());
+
+    if (pluginOpaqueData & KNotInsideTTLS)
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
--- a/omadmadapters/rom/omadmadapters.iby	Tue Jul 13 03:51:25 2010 +0530
+++ b/omadmadapters/rom/omadmadapters.iby	Tue Jul 13 04:01:20 2010 +0530
@@ -56,8 +56,8 @@
 #endif // __SYNCML_DM_MMS
 
 #ifdef __SYNCML_DM_FOTA // SyncML device management Firmware update plug-in
-REM ECOM_PLUGIN(nsmldmfotaadapter.dll,nsmldmfotaadapter.rsc)
-REM data=ABI_DIR\BUILD_DIR\z\private\100012a5\policy\101F9A02.SPD		private\100012a5\policy\101F9A02.SPD
+ECOM_PLUGIN(nsmldmfotaadapter.dll,nsmldmfotaadapter.rsc)
+data=ABI_DIR\BUILD_DIR\z\private\100012a5\policy\101F9A02.SPD		private\100012a5\policy\101F9A02.SPD
 #endif // __SYNCML_DM_FOTA
 
 
@@ -65,7 +65,7 @@
 // old internet adapter is not used in that case for access point provisioning.
 ECOM_PLUGIN(connmoadapter.dll,connmoadapter.rsc)
 #else
-REM ECOM_PLUGIN(nsmlinternetadapter.dll,nsmlinternetadapter.rsc)
+ECOM_PLUGIN(nsmlinternetadapter.dll,nsmlinternetadapter.rsc)
 #endif FF_DM_CONNMO_ADAPTER
 
 #ifdef __SYNCML_DM_WLAN 
@@ -79,7 +79,7 @@
 ECOM_PLUGIN( nsmldmbmadapter.dll, nsmldmbmadapter.rsc )
 
 #ifdef FF_RUNTIME_DEVICE_CAPABILITY_CONFIGURATION
-REM ECOM_PLUGIN(dcmodmadapter.dll,dcmodmadapter.rsc)
+ECOM_PLUGIN(dcmodmadapter.dll,dcmodmadapter.rsc)
 #endif
 
 #endif //__SYNCML_DM
--- a/omadmadapters/syncmldm12/src/NSmlDmSettingsAdapter12.cpp	Tue Jul 13 03:51:25 2010 +0530
+++ b/omadmadapters/syncmldm12/src/NSmlDmSettingsAdapter12.cpp	Tue Jul 13 04:01:20 2010 +0530
@@ -2044,7 +2044,7 @@
 		{
 			TInt pid = i + KMaxDataSyncID;
 			TInt index = profileList.Find(pid );
-			if( index >= i  )
+			if( index >= 0  )
 			{	    		
 	        	TInt rValue(KErrNone);
 	        	RSyncMLDevManProfile profile;