Revert incorrect RCL_3 drop: RCL_3 PDK_3.0.2 PDK_3.0.3
authorPat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:23:14 +0100
branchRCL_3
changeset 18 fbd2e7cec7ef
parent 17 2669f8761a99
Revert incorrect RCL_3 drop: Revision: 201027 Kit: 201035
XDMEngine/BWINSCW/XdmEngineU.DEF
XDMEngine/Conf/xdmengine.confml
XDMEngine/Conf/xdmengine_10207453.crml
XDMEngine/Conf/xdmengine_10282384.crml
XDMEngine/XdmDeviceManagement/inc/xdmdmadapter.h
XDMEngine/XdmDeviceManagement/src/xdmdmadapter.cpp
XDMEngine/XdmProvisioning/inc/xdmprovitem.h
XDMEngine/XdmProvisioning/src/xdmprovadapter.cpp
XDMEngine/XdmProvisioning/src/xdmprovitem.cpp
XDMEngine/XdmSettingsApi/src/XdmSettingsApi.cpp
XDMEngine/cenrep/backup_registration.xml
XDMEngine/cenrep/keys_xdmengine.xls
XDMEngine/eabi/XdmEngineU.DEF
XDMEngine/group/XdmEngine.mmp
XDMEngine/group/bld.inf
XDMEngine/group/bld_engine.inf
XDMEngine/inc/XdmEngineDefines.h
XDMEngine/inc/XdmLogWriter.h
XDMEngine/inc/XdmStaticUtils.h
XDMEngine/rom/XdmEngine.iby
XDMEngine/rom/XdmEngineResources.iby
XDMEngine/src/XdmCredentials.cpp
XDMEngine/src/XdmDirectory.cpp
XDMEngine/src/XdmDocument.cpp
XDMEngine/src/XdmDocumentNode.cpp
XDMEngine/src/XdmEngine.cpp
XDMEngine/src/XdmLogWriter.cpp
XDMEngine/src/XdmNodeAttribute.cpp
XDMEngine/src/XdmProtocol.cpp
XDMEngine/src/XdmProtocolInfo.cpp
XDMEngine/src/XdmStaticUtils.cpp
XDMSettingsUI/data/10207428.rss
XDMSettingsUI/data/XDMPluginRsc.rss
XDMSettingsUI/group/XDMPlugin.mmp
XDMSettingsUI/group/XDMPluginIcons.mk
XDMSettingsUI/group/bld.inf
XDMSettingsUI/help/data/xhtml.zip
XDMSettingsUI/help/group/bld.inf
XDMSettingsUI/help/inc/xdm.hlp.hrh
XDMSettingsUI/help/rom/xdmsettingsuihelps_variant.iby
XDMSettingsUI/inc/SettingsData.h
XDMSettingsUI/inc/XDMExternalInterface.h
XDMSettingsUI/inc/XDMPlugin.h
XDMSettingsUI/inc/XDMPlugin.hrh
XDMSettingsUI/inc/XDMPluginContainer.h
XDMSettingsUI/inc/XDMPluginSLContainer.h
XDMSettingsUI/inc/XDMPluginSettinglist.h
XDMSettingsUI/loc/GSXDMPlugin.loc
XDMSettingsUI/rom/GSXDMPlugin.iby
XDMSettingsUI/rom/GSXDMPluginResources.iby
XDMSettingsUI/src/SettingsData.cpp
XDMSettingsUI/src/XDMPlugin.cpp
XDMSettingsUI/src/XDMPluginContainer.cpp
XDMSettingsUI/src/XDMPluginImplementationTable.cpp
XDMSettingsUI/src/XDMPluginSLContainer.cpp
XDMSettingsUI/src/XDMPluginSettinglist.cpp
group/bld.inf
inc/xcapappusagedef.h
inc/xdmlogwriter.h
layers.sysdef.xml
msgconnmanager/bwinscw/msgconnmanagerU.DEF
msgconnmanager/eabi/msgconnmanagerU.DEF
msgconnmanager/group/bld.inf
msgconnmanager/group/msgconnmanager.mmp
msgconnmanager/inc/msgconnmanager.h
msgconnmanager/inc/msgconntimer.h
msgconnmanager/inc/msgconntimercallback.h
msgconnmanager/rom/msgconnmanager.iby
msgconnmanager/src/msgconnmanager.cpp
msgconnmanager/src/msgconntimer.cpp
package_definition.xml
package_map.xml
presencefwsimpleadpt/Conf/presencefwsimpleadpt.confml
presencefwsimpleadpt/Conf/presencefwsimpleadpt_10282C84.crml
presencefwsimpleadpt/cenrep/backup_registration.xml
presencefwsimpleadpt/cenrep/keys_presencefwsimpleadpt.xls
presencefwsimpleadpt/group/bld.inf
presencefwsimpleadpt/group/make_StubSis.bat
presencefwsimpleadpt/group/presencefwsimpleadptstub.SIS
presencefwsimpleadpt/group/presencefwsimpleadptstub.pkg
presencefwsimpleadpt/group/prfwsimpleplugin.hrh
presencefwsimpleadpt/group/simpleplugin.mmp
presencefwsimpleadpt/group/simpleplugin.rss
presencefwsimpleadpt/inc/msimplepluginconnectionobs.h
presencefwsimpleadpt/inc/msimplepluginsettings.h
presencefwsimpleadpt/inc/msimpleplugintestobs.h
presencefwsimpleadpt/inc/msimpleplugtestobs.h
presencefwsimpleadpt/inc/presencefwsimpleadptprivatecrkeys.h
presencefwsimpleadpt/inc/simpleplugin.h
presencefwsimpleadpt/inc/simplepluginauthorization.h
presencefwsimpleadpt/inc/simpleplugincommon.h
presencefwsimpleadpt/inc/simplepluginconnection.h
presencefwsimpleadpt/inc/simpleplugindata.h
presencefwsimpleadpt/inc/simpleplugindebugutils.h
presencefwsimpleadpt/inc/simpleplugindef.h
presencefwsimpleadpt/inc/simplepluginentitywatcher.h
presencefwsimpleadpt/inc/simpleplugingroups.h
presencefwsimpleadpt/inc/simplepluginpublisher.h
presencefwsimpleadpt/inc/simplepluginsession.h
presencefwsimpleadpt/inc/simplepluginvariation.h
presencefwsimpleadpt/inc/simplepluginwatcher.h
presencefwsimpleadpt/inc/simplepluginwinfo.h
presencefwsimpleadpt/inc/simplepluginxdmutils.h
presencefwsimpleadpt/rom/presencefwsimpleadpt.iby
presencefwsimpleadpt/src/simpleplugin.cpp
presencefwsimpleadpt/src/simplepluginauthorization.cpp
presencefwsimpleadpt/src/simplepluginconnection.cpp
presencefwsimpleadpt/src/simpleplugindata.cpp
presencefwsimpleadpt/src/simpleplugindebugutils.cpp
presencefwsimpleadpt/src/simplepluginentitywatcher.cpp
presencefwsimpleadpt/src/simpleplugingroups.cpp
presencefwsimpleadpt/src/simplepluginpublisher.cpp
presencefwsimpleadpt/src/simplepluginsession.cpp
presencefwsimpleadpt/src/simplepluginvariation.cpp
presencefwsimpleadpt/src/simplepluginwatcher.cpp
presencefwsimpleadpt/src/simplepluginwinfo.cpp
presencefwsimpleadpt/src/simplepluginxdmutils.cpp
presencesettingsui/data/10281ef0.rss
presencesettingsui/data/psuigspluginrsc.rss
presencesettingsui/group/bld.inf
presencesettingsui/group/psuigsplugin.mmp
presencesettingsui/group/psuigspluginicons.mk
presencesettingsui/help/data/xhtml.zip
presencesettingsui/help/group/bld.inf
presencesettingsui/help/inc/pre.hlp.hrh
presencesettingsui/help/rom/presencesettingsuihelps_variant.iby
presencesettingsui/inc/psuigsplugin.h
presencesettingsui/inc/psuigsplugin.hrh
presencesettingsui/inc/psuigsplugincontainer.h
presencesettingsui/inc/psuigspluginids.hrh
presencesettingsui/inc/psuigspluginmodel.h
presencesettingsui/inc/psuigspluginsettingview.h
presencesettingsui/inc/psuigspluginsettingviewcontainer.h
presencesettingsui/inc/psuiintegersettingitem.h
presencesettingsui/inc/psuisipxdmsettingitem.h
presencesettingsui/loc/psuigsplugin.loc
presencesettingsui/rom/psuigsplugin.iby
presencesettingsui/rom/psuigspluginresources.iby
presencesettingsui/src/psuigsplugin.cpp
presencesettingsui/src/psuigsplugincontainer.cpp
presencesettingsui/src/psuigspluginimplementationtable.cpp
presencesettingsui/src/psuigspluginmodel.cpp
presencesettingsui/src/psuigspluginsettingview.cpp
presencesettingsui/src/psuigspluginsettingviewcontainer.cpp
presencesettingsui/src/psuiintegersettingitem.cpp
presencesettingsui/src/psuisipxdmsettingitem.cpp
pressrv_plat/registration_api/inc/simplefactory.h
pressrv_plat/simple_documents_api/inc/msimplecontent.h
pressrv_plat/xdm_api/inc/XdmDocument.h
pressrv_plat/xdm_api/inc/XdmProtocolUidList.h
simpledatamodeladapter/group/10275464.rss
simpledatamodeladapter/group/bld.inf
simpledatamodeladapter/group/presenceplugin.mmp
simpledatamodeladapter/group/presenceplugin_resource.hrh
simpledatamodeladapter/inc/mpresencepluginconnectionobs.h
simpledatamodeladapter/inc/mpresrulesasynchandler.h
simpledatamodeladapter/inc/presenceconnectioninfo.h
simpledatamodeladapter/inc/presencecontactscontextbase.h
simpledatamodeladapter/inc/presencelogger.h
simpledatamodeladapter/inc/presenceplugin.h
simpledatamodeladapter/inc/presencepluginauthorization.h
simpledatamodeladapter/inc/presenceplugincommon.h
simpledatamodeladapter/inc/presencepluginconnection.h
simpledatamodeladapter/inc/presenceplugincontacts.h
simpledatamodeladapter/inc/presenceplugincontactsobs.h
simpledatamodeladapter/inc/presenceplugincontactstate.h
simpledatamodeladapter/inc/presenceplugincontactstateend.h
simpledatamodeladapter/inc/presenceplugincontactstatehandler.h
simpledatamodeladapter/inc/presenceplugincontactstateopen.h
simpledatamodeladapter/inc/presenceplugincontactstateresolve.h
simpledatamodeladapter/inc/presenceplugincontactstatesearch.h
simpledatamodeladapter/inc/presenceplugindata.h
simpledatamodeladapter/inc/presenceplugindef.h
simpledatamodeladapter/inc/presencepluginentitywatcher.h
simpledatamodeladapter/inc/presenceplugingroup.h
simpledatamodeladapter/inc/presencepluginlanguagecodes.h
simpledatamodeladapter/inc/presencepluginlocalstore.h
simpledatamodeladapter/inc/presencepluginpublisher.h
simpledatamodeladapter/inc/presencepluginsession.h
simpledatamodeladapter/inc/presencepluginutility.h
simpledatamodeladapter/inc/presencepluginvirtualgroup.h
simpledatamodeladapter/inc/presencepluginwatcher.h
simpledatamodeladapter/inc/presencepluginwatcherinfo.h
simpledatamodeladapter/inc/presencepluginwinfo.h
simpledatamodeladapter/inc/presencepluginxdmpresrules.h
simpledatamodeladapter/inc/presencepluginxdmutils.h
simpledatamodeladapter/install/sis/create_sis.bat
simpledatamodeladapter/install/sis/simpledatamodeladapter.SIS
simpledatamodeladapter/install/sis/simpledatamodeladapter.pkg
simpledatamodeladapter/rom/simpledatamodeladapter.iby
simpledatamodeladapter/simpleimplugin/data/20022d58.rss
simpledatamodeladapter/simpleimplugin/group/bld.inf
simpledatamodeladapter/simpleimplugin/group/simpleimplugin.mmp
simpledatamodeladapter/simpleimplugin/inc/simpleimconversation.h
simpledatamodeladapter/simpleimplugin/inc/simpleimfeatures.h
simpledatamodeladapter/simpleimplugin/inc/simpleimlogger.h
simpledatamodeladapter/simpleimplugin/inc/simpleimplugindefs.h
simpledatamodeladapter/simpleimplugin/inc/simpleimpluginuids.hrh
simpledatamodeladapter/simpleimplugin/rom/simpleimplugin.iby
simpledatamodeladapter/simpleimplugin/src/simpleimconversation.cpp
simpledatamodeladapter/simpleimplugin/src/simpleimfeatures.cpp
simpledatamodeladapter/simpleimplugin/src/simpleimpluginimplementationproxy.cpp
simpledatamodeladapter/src/presenceconnectioninfo.cpp
simpledatamodeladapter/src/presenceplugin.cpp
simpledatamodeladapter/src/presencepluginauthorization.cpp
simpledatamodeladapter/src/presencepluginconnection.cpp
simpledatamodeladapter/src/presenceplugincontacts.cpp
simpledatamodeladapter/src/presenceplugincontactstate.cpp
simpledatamodeladapter/src/presenceplugincontactstateend.cpp
simpledatamodeladapter/src/presenceplugincontactstatehandler.cpp
simpledatamodeladapter/src/presenceplugincontactstateopen.cpp
simpledatamodeladapter/src/presenceplugincontactstateresolve.cpp
simpledatamodeladapter/src/presenceplugincontactstatesearch.cpp
simpledatamodeladapter/src/presenceplugindata.cpp
simpledatamodeladapter/src/presencepluginentitywatcher.cpp
simpledatamodeladapter/src/presenceplugingroup.cpp
simpledatamodeladapter/src/presencepluginpublisher.cpp
simpledatamodeladapter/src/presencepluginsession.cpp
simpledatamodeladapter/src/presencepluginutility.cpp
simpledatamodeladapter/src/presencepluginvirtualgroup.cpp
simpledatamodeladapter/src/presencepluginwatcher.cpp
simpledatamodeladapter/src/presencepluginwatcherinfo.cpp
simpledatamodeladapter/src/presencepluginwinfo.cpp
simpledatamodeladapter/src/presencepluginxdmpresrules.cpp
simpledatamodeladapter/src/presencepluginxdmutils.cpp
simpledatamodeladapter/src/presensepluginlocalstore.cpp
simpleengine/engine/BWINS/simpleengineU.DEF
simpleengine/engine/EABI/simpleengineU.DEF
simpleengine/engine/inc/simpleconnection.h
simpleengine/engine/inc/simpleengineimhandler.h
simpleengine/engine/inc/simplepublisher.h
simpleengine/engine/src/simpleconnection.cpp
simpleengine/engine/src/simpleengineimhandler.cpp
simpleengine/engine/src/simplefactory.cpp
simpleengine/inc/simplecommon.h
simpleengine/presencedm/src/presencedmadapter.cpp
simpleengine/presenceprovisioning/inc/presenceprovitem.h
simpleengine/presenceprovisioning/src/presenceprovadapter.cpp
simpleengine/presenceprovisioning/src/presenceprovitem.cpp
simpleengine/presencesettingsapi/group/bld.inf
simpleengine/presencesettingsapi/group/presencesettingsapi.mmp
simpleengine/presencesettingsapi/src/pressettingsapi.cpp
simpleengine/rom/simpleengine.iby
simpleengine/rom/simpleengineresources.iby
simpleengine/siputils/BWINS/simplesiputilsU.DEF
simpleengine/siputils/EABI/simplesiputilsU.DEF
simpleengine/siputils/group/simplesiputils.mmp
simpleengine/siputils/inc/simplesettings.h
simpleengine/siputils/inc/simplesipconncallback.h
simpleengine/siputils/inc/simplesipconnection.h
simpleengine/siputils/inc/simplesipconnectionobserver.h
simpleengine/siputils/src/simpledebugutils.cpp
simpleengine/siputils/src/simplesettings.cpp
simpleengine/siputils/src/simplesipconnection.cpp
simpleengine/siputils/src/simplesipconnectionobserver.cpp
simpleengine/siputils/src/simplesipprofileobserver.cpp
simpleengine/xdmrlspres/eabi/rlspresxdmU.DEF
simpleengine/xdmrlspres/group/bld.inf
simpleengine/xdmrlspres/group/rlspresxdm.mmp
simpleengine/xdmrlspres/src/crlsxdm.cpp
simpleengine/xdmrlspres/src/prescondvalidity.cpp
simpleengine/xdmrlspres/src/presencetransformxdm.cpp
simpleengine/xmlutils/inc/simpleelement.h
simpleengine/xmlutils/src/simpledocument.cpp
simpleengine/xmlutils/src/simpleelement.cpp
sysdef_1_5_1.dtd
xdmprotocols/LocalProtocol/LocalOperations/BWINSCW/LocalOperationsU.DEF
xdmprotocols/LocalProtocol/LocalOperations/eabi/LocalOperationsU.DEF
xdmprotocols/LocalProtocol/LocalOperations/group/LocalOperations.mmp
xdmprotocols/LocalProtocol/LocalOperations/group/bld.inf
xdmprotocols/LocalProtocol/LocalOperations/inc/LocalAddition.h
xdmprotocols/LocalProtocol/LocalOperations/inc/LocalDeletion.h
xdmprotocols/LocalProtocol/LocalOperations/inc/LocalOperationBase.h
xdmprotocols/LocalProtocol/LocalOperations/inc/LocalOperationFactory.h
xdmprotocols/LocalProtocol/LocalOperations/inc/LocalReplacement.h
xdmprotocols/LocalProtocol/LocalOperations/inc/LocalRetrieval.h
xdmprotocols/LocalProtocol/LocalOperations/src/10275086.rss
xdmprotocols/LocalProtocol/LocalOperations/src/LocalAddition.cpp
xdmprotocols/LocalProtocol/LocalOperations/src/LocalDeletion.cpp
xdmprotocols/LocalProtocol/LocalOperations/src/LocalOperationBase.cpp
xdmprotocols/LocalProtocol/LocalOperations/src/LocalOperationFactory.cpp
xdmprotocols/LocalProtocol/LocalOperations/src/LocalReplacement.cpp
xdmprotocols/LocalProtocol/LocalOperations/src/LocalRetrieval.cpp
xdmprotocols/LocalProtocol/bwinscw/LocalProtocolU.DEF
xdmprotocols/LocalProtocol/eabi/LocalProtocolU.DEF
xdmprotocols/LocalProtocol/group/LocalProtocol.mmp
xdmprotocols/LocalProtocol/group/bld.inf
xdmprotocols/LocalProtocol/inc/LocalDirectory.h
xdmprotocols/LocalProtocol/inc/LocalDirectoryEntry.h
xdmprotocols/LocalProtocol/inc/LocalDocument.h
xdmprotocols/LocalProtocol/inc/LocalDocumentNode.h
xdmprotocols/LocalProtocol/inc/LocalNodeAttribute.h
xdmprotocols/LocalProtocol/inc/LocalProtocol.h
xdmprotocols/LocalProtocol/src/10207458.rss
xdmprotocols/LocalProtocol/src/LocalDirectory.cpp
xdmprotocols/LocalProtocol/src/LocalDirectoryEntry.cpp
xdmprotocols/LocalProtocol/src/LocalDocument.cpp
xdmprotocols/LocalProtocol/src/LocalDocumentNode.cpp
xdmprotocols/LocalProtocol/src/LocalNodeAttribute.cpp
xdmprotocols/LocalProtocol/src/LocalProtocol.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/BWINSCW/XcapAppUsageU.DEF
xdmprotocols/XcapProtocol/XcapAppUsage/XCapCommonPolicyCapsUsage/inc/XcapIetfCommonPolicyUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XCapCommonPolicyCapsUsage/inc/XcapOmaCommonPolicyUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XCapCommonPolicyCapsUsage/src/XcapIetfCPUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XCapCommonPolicyCapsUsage/src/XcapOmaCPUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XCapPocUserAccessUsage/inc/XcapPocUserAccessUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XCapPocUserAccessUsage/src/XcapPocUserAccessUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XcapC4/inc/XcapC4.h
xdmprotocols/XcapProtocol/XcapAppUsage/XcapC4/src/XcapC4.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XcapCapabilityUsage/inc/XcapCapabilityUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XcapCapabilityUsage/src/XcapCapabilityUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XcapDirectoryUsage/inc/XcapDirectoryUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XcapDirectoryUsage/src/XcapDirectoryUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XcapPocGroupUsage/inc/XcapPocGroupUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XcapPocGroupUsage/src/XcapPocGroupUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XcapPresenceRulesUsage/inc/XcapIetfPresRulesUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XcapPresenceRulesUsage/inc/XcapOmaPresRulesUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XcapPresenceRulesUsage/src/XcapIetfPresRulesUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XcapPresenceRulesUsage/src/XcapOmaPresRulesUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XcapResourceListsUsage/inc/XcapResourceListsUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XcapResourceListsUsage/src/XcapResourceListsUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XcapRlsServicesUsage/inc/XcapRlsServicesUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XcapRlsServicesUsage/src/XcapRlsServicesUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XcapSharedXDMUsage/inc/XcapSharedXDMUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XcapSharedXDMUsage/src/XcapSharedXDMUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/XcapTestAppUsage/inc/XcapTestAppUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/XcapTestAppUsage/src/XcapTestAppUsage.cpp
xdmprotocols/XcapProtocol/XcapAppUsage/eabi/XcapAppUsageU.DEF
xdmprotocols/XcapProtocol/XcapAppUsage/group/XcapAppUsage.mmp
xdmprotocols/XcapProtocol/XcapAppUsage/group/bld.inf
xdmprotocols/XcapProtocol/XcapAppUsage/inc/XcapAppUsage.h
xdmprotocols/XcapProtocol/XcapAppUsage/inc/XcapAppUsageDef.h
xdmprotocols/XcapProtocol/XcapAppUsage/src/10207416.rss
xdmprotocols/XcapProtocol/XcapAppUsage/src/XcapAppUsage.cpp
xdmprotocols/XcapProtocol/XcapCache/Client/BWINSCW/XcapCacheClientU.DEF
xdmprotocols/XcapProtocol/XcapCache/Client/eabi/XcapCacheClientU.DEF
xdmprotocols/XcapProtocol/XcapCache/Client/group/XcapCacheClient.mmp
xdmprotocols/XcapProtocol/XcapCache/Client/group/bld.inf
xdmprotocols/XcapProtocol/XcapCache/Client/src/XcapCache.cpp
xdmprotocols/XcapProtocol/XcapCache/Client/src/XcapCacheClient.cpp
xdmprotocols/XcapProtocol/XcapCache/Server/BWINSCW/XcapCacheServerU.DEF
xdmprotocols/XcapProtocol/XcapCache/Server/eabi/XcapCacheServerU.DEF
xdmprotocols/XcapProtocol/XcapCache/Server/group/XcapCache.mmp
xdmprotocols/XcapProtocol/XcapCache/Server/group/bld.inf
xdmprotocols/XcapProtocol/XcapCache/Server/inc/ServerDefines.h
xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheEntryProperty.h
xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheIndex.h
xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheIndexAdmin.h
xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheIndexEntry.h
xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheIndexTableEntry.h
xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheServer.h
xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheServerMain.h
xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheSession.h
xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapShutdownTimer.h
xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheEntryProperty.cpp
xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheIndex.cpp
xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheIndexAdmin.cpp
xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheIndexEntry.cpp
xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheIndexTableEntry.cpp
xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheServer.cpp
xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheServerMain.cpp
xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheSession.cpp
xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapShutdownTimer.cpp
xdmprotocols/XcapProtocol/XcapCache/inc/CommonDefines.h
xdmprotocols/XcapProtocol/XcapCache/inc/XcapCache.h
xdmprotocols/XcapProtocol/XcapHttpTransport/BWINSCW/XcapHttpTransportU.DEF
xdmprotocols/XcapProtocol/XcapHttpTransport/eabi/XcapHttpTransportU.DEF
xdmprotocols/XcapProtocol/XcapHttpTransport/group/XcapHttpTransport.mmp
xdmprotocols/XcapProtocol/XcapHttpTransport/group/bld.inf
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpAuthManager.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpConsts.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpContSupplier.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpHeaderModel.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpReqDelete.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpReqGet.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpReqHead.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpReqMkcol.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpReqPut.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpRequest.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpRequestTimer.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpRequestTimerCallback.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpResponse.h
xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpTransport.h
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpAuthManager.cpp
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpContSupplier.cpp
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpHeaderModel.cpp
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpReqDelete.cpp
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpReqGet.cpp
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpReqHead.cpp
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpReqMkcol.cpp
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpReqPut.cpp
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpRequest.cpp
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpRequestTimer.cpp
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpResponse.cpp
xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpTransport.cpp
xdmprotocols/XcapProtocol/XcapOperations/BWINSCW/XcapOperationsU.DEF
xdmprotocols/XcapProtocol/XcapOperations/eabi/XcapOperationsU.DEF
xdmprotocols/XcapProtocol/XcapOperations/group/XcapOperations.mmp
xdmprotocols/XcapProtocol/XcapOperations/group/bld.inf
xdmprotocols/XcapProtocol/XcapOperations/inc/XcapAddition.h
xdmprotocols/XcapProtocol/XcapOperations/inc/XcapDeletion.h
xdmprotocols/XcapProtocol/XcapOperations/inc/XcapHttpOperation.h
xdmprotocols/XcapProtocol/XcapOperations/inc/XcapInsertion.h
xdmprotocols/XcapProtocol/XcapOperations/inc/XcapOperationFactory.h
xdmprotocols/XcapProtocol/XcapOperations/inc/XcapReplacement.h
xdmprotocols/XcapProtocol/XcapOperations/inc/XcapRetrieval.h
xdmprotocols/XcapProtocol/XcapOperations/inc/XcapUriParser.h
xdmprotocols/XcapProtocol/XcapOperations/src/10207410.rss
xdmprotocols/XcapProtocol/XcapOperations/src/XcapAddition.cpp
xdmprotocols/XcapProtocol/XcapOperations/src/XcapDeletion.cpp
xdmprotocols/XcapProtocol/XcapOperations/src/XcapHttpOperation.cpp
xdmprotocols/XcapProtocol/XcapOperations/src/XcapInsertion.cpp
xdmprotocols/XcapProtocol/XcapOperations/src/XcapOperationFactory.cpp
xdmprotocols/XcapProtocol/XcapOperations/src/XcapReplacement.cpp
xdmprotocols/XcapProtocol/XcapOperations/src/XcapRetrieval.cpp
xdmprotocols/XcapProtocol/XcapOperations/src/XcapUriParser.cpp
xdmprotocols/XcapProtocol/XcapUtils/bwinscw/XcapUtilsU.DEF
xdmprotocols/XcapProtocol/XcapUtils/eabi/XcapUtilsU.DEF
xdmprotocols/XcapProtocol/XcapUtils/group/XcapUtils.mmp
xdmprotocols/XcapProtocol/XcapUtils/group/bld.inf
xdmprotocols/XcapProtocol/XcapUtils/inc/XcapEarlyIms.h
xdmprotocols/XcapProtocol/XcapUtils/inc/XcapStaticUtils.h
xdmprotocols/XcapProtocol/XcapUtils/inc/XcapUtilsInterface.h
xdmprotocols/XcapProtocol/XcapUtils/src/XcapEarlyIms.cpp
xdmprotocols/XcapProtocol/XcapUtils/src/XcapStaticUtils.cpp
xdmprotocols/XcapProtocol/bwinscw/XcapProtocolU.DEF
xdmprotocols/XcapProtocol/eabi/XcapProtocolU.DEF
xdmprotocols/XcapProtocol/group/XcapProtocol.mmp
xdmprotocols/XcapProtocol/group/bld.inf
xdmprotocols/XcapProtocol/inc/XcapDirectory.h
xdmprotocols/XcapProtocol/inc/XcapDocument.h
xdmprotocols/XcapProtocol/inc/XcapDocumentNode.h
xdmprotocols/XcapProtocol/inc/XcapEngineDefines.h
xdmprotocols/XcapProtocol/inc/XcapNodeAttribute.h
xdmprotocols/XcapProtocol/inc/XcapProtocol.h
xdmprotocols/XcapProtocol/inc/XcapUriInterface.h
xdmprotocols/XcapProtocol/src/1020740F.rss
xdmprotocols/XcapProtocol/src/XcapDirectory.cpp
xdmprotocols/XcapProtocol/src/XcapDocument.cpp
xdmprotocols/XcapProtocol/src/XcapDocumentNode.cpp
xdmprotocols/XcapProtocol/src/XcapNodeAttribute.cpp
xdmprotocols/XcapProtocol/src/XcapNodeSelector.cpp
xdmprotocols/XcapProtocol/src/XcapProtocol.cpp
xdmprotocols/XdmXmlParser/bwinscw/XdmXmlParserU.DEF
xdmprotocols/XdmXmlParser/eabi/XdmXmlParserU.DEF
xdmprotocols/XdmXmlParser/group/XdmXmlParser.mmp
xdmprotocols/XdmXmlParser/group/bld.inf
xdmprotocols/XdmXmlParser/inc/XdmXmlContentHandler.h
xdmprotocols/XdmXmlParser/inc/XdmXmlParser.h
xdmprotocols/XdmXmlParser/inc/XmlFormatter.h
xdmprotocols/XdmXmlParser/inc/XmlNodePathInterface.h
xdmprotocols/XdmXmlParser/inc/XmlParserDefines.h
xdmprotocols/XdmXmlParser/inc/XmlParserNodePath.h
xdmprotocols/XdmXmlParser/src/XdmXmlContentHandler.cpp
xdmprotocols/XdmXmlParser/src/XdmXmlParser.cpp
xdmprotocols/XdmXmlParser/src/XmlFormatter.cpp
xdmprotocols/XdmXmlParser/src/XmlParserNodePath.cpp
xdmprotocols/group/bld.inf
xdmprotocols/inc/XdmNamespace.h
xdmprotocols/inc/XdmShutdownSwitch.h
xdmprotocols/inc/XdmShutdownTimer.h
xdmprotocols/rom/XdmProtocols.iby
xdmprotocols/src/XdmNamespace.cpp
xdmprotocols/src/XdmShutdownTimer.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/BWINSCW/XdmEngineU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,115 @@
+EXPORTS
+	??0CXdmDirectory@@IAE@AAVCXdmEngine@@@Z @ 1 NONAME ; CXdmDirectory::CXdmDirectory(class CXdmEngine &)
+	??0CXdmDocument@@IAE@AAVCXdmEngine@@@Z @ 2 NONAME ; CXdmDocument::CXdmDocument(class CXdmEngine &)
+	??0CXdmDocumentNode@@IAE@AAVCXdmEngine@@AAVMXdmNodeFactory@@@Z @ 3 NONAME ; CXdmDocumentNode::CXdmDocumentNode(class CXdmEngine &, class MXdmNodeFactory &)
+	??0CXdmDocumentNode@@IAE@AAVCXdmEngine@@AAVMXdmNodeFactory@@PAV0@@Z @ 4 NONAME ; CXdmDocumentNode::CXdmDocumentNode(class CXdmEngine &, class MXdmNodeFactory &, class CXdmDocumentNode *)
+	??0CXdmDocumentNode@@IAE@HAAVCXdmEngine@@AAVMXdmNodeFactory@@PAV0@@Z @ 5 NONAME ; CXdmDocumentNode::CXdmDocumentNode(int, class CXdmEngine &, class MXdmNodeFactory &, class CXdmDocumentNode *)
+	??0CXdmNodeAttribute@@IAE@AAVCXdmEngine@@AAVMXdmNodeFactory@@@Z @ 6 NONAME ; CXdmNodeAttribute::CXdmNodeAttribute(class CXdmEngine &, class MXdmNodeFactory &)
+	??0CXdmNodeAttribute@@IAE@AAVCXdmEngine@@AAVMXdmNodeFactory@@PAVCXdmDocumentNode@@@Z @ 7 NONAME ; CXdmNodeAttribute::CXdmNodeAttribute(class CXdmEngine &, class MXdmNodeFactory &, class CXdmDocumentNode *)
+	??0TXdmCredentials@@QAE@ABVTDesC16@@0@Z @ 8 NONAME ; TXdmCredentials::TXdmCredentials(class TDesC16 const &, class TDesC16 const &)
+	??0TXdmCredentials@@QAE@XZ @ 9 NONAME ; TXdmCredentials::TXdmCredentials(void)
+	??1CXdmDirectory@@UAE@XZ @ 10 NONAME ; CXdmDirectory::~CXdmDirectory(void)
+	??1CXdmDocument@@UAE@XZ @ 11 NONAME ; CXdmDocument::~CXdmDocument(void)
+	??1CXdmDocumentNode@@UAE@XZ @ 12 NONAME ; CXdmDocumentNode::~CXdmDocumentNode(void)
+	??1CXdmEngine@@UAE@XZ @ 13 NONAME ; CXdmEngine::~CXdmEngine(void)
+	??1CXdmNodeAttribute@@UAE@XZ @ 14 NONAME ; CXdmNodeAttribute::~CXdmNodeAttribute(void)
+	??1CXdmProtocolInfo@@UAE@XZ @ 15 NONAME ; CXdmProtocolInfo::~CXdmProtocolInfo(void)
+	??8CXdmDocument@@QBEHAAV0@@Z @ 16 NONAME ; int CXdmDocument::operator==(class CXdmDocument &) const
+	??8CXdmDocumentNode@@QBEHABV0@@Z @ 17 NONAME ; int CXdmDocumentNode::operator==(class CXdmDocumentNode const &) const
+	?AccessPoint@CXdmProtocolInfo@@QBEHXZ @ 18 NONAME ; int CXdmProtocolInfo::AccessPoint(void) const
+	?AppendChileNodeL@CXdmDocumentNode@@QAEXPAV1@@Z @ 19 NONAME ; void CXdmDocumentNode::AppendChileNodeL(class CXdmDocumentNode *)
+	?AppendL@CXdmDocument@@QAEXPAVCXdmDocumentNode@@@Z @ 20 NONAME ; void CXdmDocument::AppendL(class CXdmDocumentNode *)
+	?AppendToModelL@CXdmDocument@@QAEXPAVCXdmDocumentNode@@0@Z @ 21 NONAME ; void CXdmDocument::AppendToModelL(class CXdmDocumentNode *, class CXdmDocumentNode *)
+	?Attribute@CXdmDocumentNode@@QBEPAVCXdmNodeAttribute@@ABVTDesC16@@@Z @ 22 NONAME ; class CXdmNodeAttribute * CXdmDocumentNode::Attribute(class TDesC16 const &) const
+	?Attribute@CXdmDocumentNode@@QBEPAVCXdmNodeAttribute@@H@Z @ 23 NONAME ; class CXdmNodeAttribute * CXdmDocumentNode::Attribute(int) const
+	?AttributeCount@CXdmDocumentNode@@QBEHXZ @ 24 NONAME ; int CXdmDocumentNode::AttributeCount(void) const
+	?AttributeValue@CXdmNodeAttribute@@QBE?AVTPtrC16@@XZ @ 25 NONAME ; class TPtrC16 CXdmNodeAttribute::AttributeValue(void) const
+	?BaseConstructL@CXdmDirectory@@IAEXABVTDesC16@@@Z @ 26 NONAME ; void CXdmDirectory::BaseConstructL(class TDesC16 const &)
+	?BaseConstructL@CXdmDocument@@IAEXHABVTDesC16@@@Z @ 27 NONAME ; void CXdmDocument::BaseConstructL(int, class TDesC16 const &)
+	?BaseConstructL@CXdmDocument@@IAEXHABVTDesC8@@@Z @ 28 NONAME ; void CXdmDocument::BaseConstructL(int, class TDesC8 const &)
+	?BaseConstructL@CXdmDocumentNode@@IAEXABVTDesC16@@@Z @ 29 NONAME ; void CXdmDocumentNode::BaseConstructL(class TDesC16 const &)
+	?BaseConstructL@CXdmNodeAttribute@@IAEXABVTDesC16@@@Z @ 30 NONAME ; void CXdmNodeAttribute::BaseConstructL(class TDesC16 const &)
+	?CancelUpdate@CXdmEngine@@QAEXPAVCXdmDirectory@@@Z @ 31 NONAME ; void CXdmEngine::CancelUpdate(class CXdmDirectory *)
+	?CancelUpdate@CXdmEngine@@QAEXPAVCXdmDocument@@@Z @ 32 NONAME ; void CXdmEngine::CancelUpdate(class CXdmDocument *)
+	?CheckFileExistsL@XdmStaticUtils@@SAHAAVRFs@@ABVTDesC16@@@Z @ 33 NONAME ; int XdmStaticUtils::CheckFileExistsL(class RFs &, class TDesC16 const &)
+	?ChileNode@CXdmDocumentNode@@QBEPAV1@H@Z @ 34 NONAME ; class CXdmDocumentNode * CXdmDocumentNode::ChileNode(int) const
+	?CleanUpDirectoryL@XdmStaticUtils@@SAXAAVRFs@@ABVTDesC16@@@Z @ 35 NONAME ; void XdmStaticUtils::CleanUpDirectoryL(class RFs &, class TDesC16 const &)
+	?CopyConstructL@CXdmDocumentNode@@MAEXABV1@0@Z @ 36 NONAME ; void CXdmDocumentNode::CopyConstructL(class CXdmDocumentNode const &, class CXdmDocumentNode const &)
+	?CreateAttributeL@CXdmDocumentNode@@QAEPAVCXdmNodeAttribute@@ABVTDesC16@@@Z @ 37 NONAME ; class CXdmNodeAttribute * CXdmDocumentNode::CreateAttributeL(class TDesC16 const &)
+	?CreateAttributeL@CXdmDocumentNode@@QAEPAVCXdmNodeAttribute@@XZ @ 38 NONAME ; class CXdmNodeAttribute * CXdmDocumentNode::CreateAttributeL(void)
+	?CreateChileNodeL@CXdmDocumentNode@@QAEPAV1@ABVTDesC16@@@Z @ 39 NONAME ; class CXdmDocumentNode * CXdmDocumentNode::CreateChileNodeL(class TDesC16 const &)
+	?CreateChileNodeL@CXdmDocumentNode@@QAEPAV1@XZ @ 40 NONAME ; class CXdmDocumentNode * CXdmDocumentNode::CreateChileNodeL(void)
+	?CreateDirectoryModelL@CXdmEngine@@QAEPAVCXdmDirectory@@ABVTDesC16@@@Z @ 41 NONAME ; class CXdmDirectory * CXdmEngine::CreateDirectoryModelL(class TDesC16 const &)
+	?CreateDocumentModelL@CXdmEngine@@QAEPAVCXdmDocument@@ABVTDesC16@@W4TXdmDocType@@@Z @ 42 NONAME ; class CXdmDocument * CXdmEngine::CreateDocumentModelL(class TDesC16 const &, enum TXdmDocType)
+	?CreateDocumentNodeL@CXdmEngine@@QAEPAVCXdmDocumentNode@@XZ @ 43 NONAME ; class CXdmDocumentNode * CXdmEngine::CreateDocumentNodeL(void)
+	?Credentials@CXdmProtocolInfo@@QBEABVTXdmCredentials@@XZ @ 44 NONAME ; class TXdmCredentials const & CXdmProtocolInfo::Credentials(void) const
+	?DeleteDataL@CXdmDocument@@QAEXPAVCXdmDocumentNode@@@Z @ 45 NONAME ; void CXdmDocument::DeleteDataL(class CXdmDocumentNode *)
+	?DeleteDirectoryModelL@CXdmEngine@@QAEXPBVCXdmDirectory@@@Z @ 46 NONAME ; void CXdmEngine::DeleteDirectoryModelL(class CXdmDirectory const *)
+	?DeleteDocumentModelL@CXdmEngine@@QAEXPBVCXdmDocument@@@Z @ 47 NONAME ; void CXdmEngine::DeleteDocumentModelL(class CXdmDocument const *)
+	?DirectoryCollection@CXdmEngine@@QBEABV?$RPointerArray@VCXdmDirectory@@@@XZ @ 48 NONAME ; class RPointerArray<class CXdmDirectory> const & CXdmEngine::DirectoryCollection(void) const
+	?DocumentCollection@CXdmEngine@@QBEABV?$RPointerArray@VCXdmDocument@@@@XZ @ 49 NONAME ; class RPointerArray<class CXdmDocument> const & CXdmEngine::DocumentCollection(void) const
+	?DocumentSubsetL@CXdmDocument@@QAEPAVCXdmDocumentNode@@ABVTDesC16@@@Z @ 50 NONAME ; class CXdmDocumentNode * CXdmDocument::DocumentSubsetL(class TDesC16 const &)
+	?EightBitNodeNameLC@CXdmDocumentNode@@QBEPAVHBufC8@@XZ @ 51 NONAME ; class HBufC8 * CXdmDocumentNode::EightBitNodeNameLC(void) const
+	?EightBitValueLC@CXdmNodeAttribute@@QBEPAVHBufC8@@XZ @ 52 NONAME ; class HBufC8 * CXdmNodeAttribute::EightBitValueLC(void) const
+	?ElementDataLC@CXdmDocumentNode@@QBEPAVHBufC8@@XZ @ 53 NONAME ; class HBufC8 * CXdmDocumentNode::ElementDataLC(void) const
+	?ElementType@CXdmDocumentNode@@UBE?AW4TXdmElementType@@XZ @ 54 NONAME ; enum TXdmElementType CXdmDocumentNode::ElementType(void) const
+	?ElementType@CXdmNodeAttribute@@UBE?AW4TXdmElementType@@XZ @ 55 NONAME ; enum TXdmElementType CXdmNodeAttribute::ElementType(void) const
+	?EscapeLeafNodeContentLC@CXdmDocumentNode@@QBEPAVHBufC8@@XZ @ 56 NONAME ; class HBufC8 * CXdmDocumentNode::EscapeLeafNodeContentLC(void) const
+	?EscapedValueLC@CXdmNodeAttribute@@QBEPAVHBufC8@@XZ @ 57 NONAME ; class HBufC8 * CXdmNodeAttribute::EscapedValueLC(void) const
+	?FetchDataL@CXdmDocument@@QAEXPAVCXdmDocumentNode@@@Z @ 58 NONAME ; void CXdmDocument::FetchDataL(class CXdmDocumentNode *)
+	?Find@CXdmDocument@@QBEHABVCXdmDocumentNode@@AAV?$RPointerArray@VCXdmDocumentNode@@@@@Z @ 59 NONAME ; int CXdmDocument::Find(class CXdmDocumentNode const &, class RPointerArray<class CXdmDocumentNode> &) const
+	?Find@CXdmDocument@@QBEHABVTDesC16@@AAV?$RPointerArray@VCXdmDocumentNode@@@@@Z @ 60 NONAME ; int CXdmDocument::Find(class TDesC16 const &, class RPointerArray<class CXdmDocumentNode> &) const
+	?Find@CXdmDocument@@QBEHABVTDesC16@@AAV?$RPointerArray@VCXdmDocumentNode@@@@ABV?$RPointerArray@USXdmAttribute16@@@@@Z @ 61 NONAME ; int CXdmDocument::Find(class TDesC16 const &, class RPointerArray<class CXdmDocumentNode> &, class RPointerArray<struct SXdmAttribute16> const &) const
+	?Find@CXdmDocument@@QBEHABVTDesC16@@AAV?$RPointerArray@VCXdmNodeAttribute@@@@@Z @ 62 NONAME ; int CXdmDocument::Find(class TDesC16 const &, class RPointerArray<class CXdmNodeAttribute> &) const
+	?Find@CXdmDocumentNode@@QBEHABV1@AAV?$RPointerArray@VCXdmDocumentNode@@@@@Z @ 63 NONAME ; int CXdmDocumentNode::Find(class CXdmDocumentNode const &, class RPointerArray<class CXdmDocumentNode> &) const
+	?Find@CXdmDocumentNode@@QBEHABVTDesC16@@AAV?$RPointerArray@VCXdmDocumentNode@@@@@Z @ 64 NONAME ; int CXdmDocumentNode::Find(class TDesC16 const &, class RPointerArray<class CXdmDocumentNode> &) const
+	?Find@CXdmDocumentNode@@QBEHABVTDesC16@@AAV?$RPointerArray@VCXdmDocumentNode@@@@ABV?$RPointerArray@USXdmAttribute16@@@@@Z @ 65 NONAME ; int CXdmDocumentNode::Find(class TDesC16 const &, class RPointerArray<class CXdmDocumentNode> &, class RPointerArray<struct SXdmAttribute16> const &) const
+	?GenerateFileNameL@XdmStaticUtils@@SAPAVHBufC16@@AAVRFs@@ABVTDesC16@@1@Z @ 66 NONAME ; class HBufC16 * XdmStaticUtils::GenerateFileNameL(class RFs &, class TDesC16 const &, class TDesC16 const &)
+	?HasAttribute@CXdmDocumentNode@@QBEHABVTDesC16@@@Z @ 67 NONAME ; int CXdmDocumentNode::HasAttribute(class TDesC16 const &) const
+	?InsertChileNodeL@CXdmDocumentNode@@QAEXHPAV1@@Z @ 68 NONAME ; void CXdmDocumentNode::InsertChileNodeL(int, class CXdmDocumentNode *)
+	?InsertL@CXdmDocument@@QAEXPAVCXdmDocumentNode@@@Z @ 69 NONAME ; void CXdmDocument::InsertL(class CXdmDocumentNode *)
+	?IsCacheEnabled@CXdmProtocolInfo@@QBEHXZ @ 70 NONAME ; int CXdmProtocolInfo::IsCacheEnabled(void) const
+	?IsEmptyNode@CXdmDocumentNode@@QBEHXZ @ 71 NONAME ; int CXdmDocumentNode::IsEmptyNode(void) const
+	?IsLeafNode@CXdmDocumentNode@@QBEHXZ @ 72 NONAME ; int CXdmDocumentNode::IsLeafNode(void) const
+	?IsSecure@CXdmProtocolInfo@@QBEHXZ @ 73 NONAME ; int CXdmProtocolInfo::IsSecure(void) const
+	?LeafNodeContent@CXdmDocumentNode@@QBE?AVTPtrC8@@XZ @ 74 NONAME ; class TPtrC8 CXdmDocumentNode::LeafNodeContent(void) const
+	?Match@CXdmDocumentNode@@QBEHABV1@@Z @ 75 NONAME ; int CXdmDocumentNode::Match(class CXdmDocumentNode const &) const
+	?Match@CXdmDocumentNode@@QBEHABVTDesC16@@ABV?$RPointerArray@USXdmAttribute8@@@@@Z @ 76 NONAME ; int CXdmDocumentNode::Match(class TDesC16 const &, class RPointerArray<struct SXdmAttribute8> const &) const
+	?Name@CXdmDocument@@QBE?AVTPtrC16@@XZ @ 77 NONAME ; class TPtrC16 CXdmDocument::Name(void) const
+	?NewL@CXdmEngine@@SAPAV1@ABVCXdmProtocolInfo@@@Z @ 78 NONAME ; class CXdmEngine * CXdmEngine::NewL(class CXdmProtocolInfo const &)
+	?NewL@CXdmLogWriter@@SAPAV1@ABVTDesC16@@@Z @ 79 NONAME ; class CXdmLogWriter * CXdmLogWriter::NewL(class TDesC16 const &)
+	?NewL@CXdmProtocolInfo@@SAPAV1@H@Z @ 80 NONAME ; class CXdmProtocolInfo * CXdmProtocolInfo::NewL(int)
+	?NewL@CXdmProtocolInfo@@SAPAV1@HHABVTDesC16@@@Z @ 81 NONAME ; class CXdmProtocolInfo * CXdmProtocolInfo::NewL(int, int, class TDesC16 const &)
+	?NextNode@CXdmDocumentNode@@QBEPAV1@XZ @ 82 NONAME ; class CXdmDocumentNode * CXdmDocumentNode::NextNode(void) const
+	?NodeCount@CXdmDocumentNode@@QBEHXZ @ 83 NONAME ; int CXdmDocumentNode::NodeCount(void) const
+	?NodeName@CXdmDocumentNode@@QBE?AVTPtrC16@@XZ @ 84 NONAME ; class TPtrC16 CXdmDocumentNode::NodeName(void) const
+	?Parent@CXdmDocumentNode@@QBEPAV1@XZ @ 85 NONAME ; class CXdmDocumentNode * CXdmDocumentNode::Parent(void) const
+	?Print@CXdmDocumentNode@@QAEXXZ @ 86 NONAME ; void CXdmDocumentNode::Print(void)
+	?ProtocolUid@CXdmProtocolInfo@@QBE?AVTUid@@XZ @ 87 NONAME ; class TUid CXdmProtocolInfo::ProtocolUid(void) const
+	?RemoveChileNodeL@CXdmDocumentNode@@QAEXPAV1@@Z @ 88 NONAME ; void CXdmDocumentNode::RemoveChileNodeL(class CXdmDocumentNode *)
+	?RemoveFromModelL@CXdmDocument@@QAEXPAVCXdmDocumentNode@@@Z @ 89 NONAME ; void CXdmDocument::RemoveFromModelL(class CXdmDocumentNode *)
+	?ReplaceChileNodeL@CXdmDocumentNode@@QAEXPAV1@0@Z @ 90 NONAME ; void CXdmDocumentNode::ReplaceChileNodeL(class CXdmDocumentNode *, class CXdmDocumentNode *)
+	?ReplaceInModelL@CXdmDocument@@QAEXPAVCXdmDocumentNode@@0@Z @ 91 NONAME ; void CXdmDocument::ReplaceInModelL(class CXdmDocumentNode *, class CXdmDocumentNode *)
+	?ReplaceL@CXdmDocument@@QAEXPAVCXdmDocumentNode@@0@Z @ 92 NONAME ; void CXdmDocument::ReplaceL(class CXdmDocumentNode *, class CXdmDocumentNode *)
+	?ReplaceL@CXdmDocument@@QAEXXZ @ 93 NONAME ; void CXdmDocument::ReplaceL(void)
+	?ResetSubset@CXdmDocument@@UAEXXZ @ 94 NONAME ; void CXdmDocument::ResetSubset(void)
+	?Root@CXdmProtocolInfo@@QBE?AVTPtrC16@@XZ @ 95 NONAME ; class TPtrC16 CXdmProtocolInfo::Root(void) const
+	?SetAttributeValueL@CXdmNodeAttribute@@QAEXABVTDesC16@@@Z @ 96 NONAME ; void CXdmNodeAttribute::SetAttributeValueL(class TDesC16 const &)
+	?SetAttributeValueL@CXdmNodeAttribute@@QAEXABVTDesC8@@@Z @ 97 NONAME ; void CXdmNodeAttribute::SetAttributeValueL(class TDesC8 const &)
+	?SetCacheUsage@CXdmProtocolInfo@@QAEXH@Z @ 98 NONAME ; void CXdmProtocolInfo::SetCacheUsage(int)
+	?SetCredentials@CXdmProtocolInfo@@QAEXVTXdmCredentials@@@Z @ 99 NONAME ; void CXdmProtocolInfo::SetCredentials(class TXdmCredentials)
+	?SetEmptyNode@CXdmDocumentNode@@QAEXH@Z @ 100 NONAME ; void CXdmDocumentNode::SetEmptyNode(int)
+	?SetLeafNode@CXdmDocumentNode@@QAEXH@Z @ 101 NONAME ; void CXdmDocumentNode::SetLeafNode(int)
+	?SetLeafNodeContentL@CXdmDocumentNode@@QAEXABVTDesC16@@@Z @ 102 NONAME ; void CXdmDocumentNode::SetLeafNodeContentL(class TDesC16 const &)
+	?SetLeafNodeContentL@CXdmDocumentNode@@QAEXABVTDesC8@@@Z @ 103 NONAME ; void CXdmDocumentNode::SetLeafNodeContentL(class TDesC8 const &)
+	?SetNameL@CXdmDocumentNode@@QAEXABVTDesC16@@@Z @ 104 NONAME ; void CXdmDocumentNode::SetNameL(class TDesC16 const &)
+	?SetNameL@CXdmDocumentNode@@QAEXABVTDesC8@@@Z @ 105 NONAME ; void CXdmDocumentNode::SetNameL(class TDesC8 const &)
+	?SetNextNode@CXdmDocumentNode@@QAEXPAV1@@Z @ 106 NONAME ; void CXdmDocumentNode::SetNextNode(class CXdmDocumentNode *)
+	?SetSecurity@CXdmProtocolInfo@@QAEXH@Z @ 107 NONAME ; void CXdmProtocolInfo::SetSecurity(int)
+	?SettingsID@CXdmProtocolInfo@@QBEHXZ @ 108 NONAME ; int CXdmProtocolInfo::SettingsID(void) const
+	?UpdateL@CXdmEngine@@QAEXAAVTRequestStatus@@PAVCXdmDirectory@@W4TDirUpdatePhase@@@Z @ 109 NONAME ; void CXdmEngine::UpdateL(class TRequestStatus &, class CXdmDirectory *, enum TDirUpdatePhase)
+	?UpdateL@CXdmEngine@@QAEXPAVCXdmDocument@@AAVTRequestStatus@@@Z @ 110 NONAME ; void CXdmEngine::UpdateL(class CXdmDocument *, class TRequestStatus &)
+	?WriteToLog@CXdmLogWriter@@QBEXABVTDesC16@@@Z @ 111 NONAME ; void CXdmLogWriter::WriteToLog(class TDesC16 const &) const
+	?WriteToLog@CXdmLogWriter@@QBEXABVTDesC8@@@Z @ 112 NONAME ; void CXdmLogWriter::WriteToLog(class TDesC8 const &) const
+	?XdmSettingsLC@CXdmEngine@@SAPAVCDesC16Array@@AAV?$RArray@H@@@Z @ 113 NONAME ; class CDesC16Array * CXdmEngine::XdmSettingsLC(class RArray<int> &)
+
Binary file XDMEngine/Conf/xdmengine.confml has changed
Binary file XDMEngine/Conf/xdmengine_10207453.crml has changed
Binary file XDMEngine/Conf/xdmengine_10282384.crml has changed
--- a/XDMEngine/XdmDeviceManagement/inc/xdmdmadapter.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/XDMEngine/XdmDeviceManagement/inc/xdmdmadapter.h	Wed Sep 01 12:23:14 2010 +0100
@@ -61,6 +61,7 @@
 _LIT8( KXdmDmUriDotSlash,   "./" );
 _LIT8( KXdmDmSeparator,     "/" );
 _LIT8( KXdmDmSipLinkPrefix, "./SIP" );
+_LIT8( KXdmDefaultSettingsName,"DMAdapterIns" );
 _LIT( KXdmDefaultId,        "-1" );
 _LIT( KXdmDmStartBracket,   "(" );
 _LIT( KXdmDmCloseBracket,   ")" );
@@ -70,6 +71,7 @@
 
 // CONSTANTS
 const TInt KXdmDmLogBufferMaxSize   = 2000;
+const TInt KXdmMaxUriLength         = 256;
 const TInt KXdmDefaultResultSize    = 255;
 const TInt KXdmDmLevel                = 2;
 const TInt KXdmDmIdTableSize        = 16;
--- a/XDMEngine/XdmDeviceManagement/src/xdmdmadapter.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/XDMEngine/XdmDeviceManagement/src/xdmdmadapter.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -235,13 +235,18 @@
             }
         Callback().SetResultsL( aResultsRef, *currentList, KNullDesC8 );
         Callback().SetStatusL( aStatusRef, retValue );
-        CleanupStack::PopAndDestroy( 3, currentList ); // >>> settingIds, names, currentList
+        CleanupStack::PopAndDestroy( names );       // >>> names
+        CleanupStack::PopAndDestroy();              // >>> settingIds
+        CleanupStack::PopAndDestroy( currentList ); // >>> currentList
         return;
         }   
 
     // ./OMA_XDM/X   
     if( NSmlDmURI::NumOfURISegs( aUri ) == KXdmDmLevel )   
         {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::ChildURIListL(): /OMA_XDM/X") );
+#endif 
         segmentName.Copy( KXdmDmAppId );
         currentList->InsertL( currentList->Size(), segmentName );
         currentList->InsertL( currentList->Size(), KXdmDmSeparator );
@@ -278,6 +283,9 @@
     // ./OMA_XDM/X/ToConRef   
     else if ( Match( lastUriSeg, KXdmDmToConRef ) ) 
         {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::ChildURIListL(): /OMA_XDM/X/ToConRef") );
+#endif
         segmentName.Copy( KXdmDmSip );
         currentList->InsertL( currentList->Size(), segmentName );
         currentList->InsertL( currentList->Size(), KXdmDmSeparator );
@@ -290,6 +298,9 @@
     // ./OMA_XDM/X/ToConRef/SIP
     else if( Match( lastUriSeg, KXdmDmSip ) ) 
         {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::ChildURIListL(): /OMA_XDM/X/ToConRef/SIP") );
+#endif
         segmentName.Copy( KXdmDmConRef );
         currentList->InsertL( currentList->Size(), segmentName );
         currentList->InsertL( currentList->Size(), KXdmDmSeparator );
@@ -298,6 +309,9 @@
     // ./OMA_XDM/X/ToConRef/TO-NAPID
     else if( Match ( lastUriSeg, KXdmDmToNapId ) ) 
         {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::ChildURIListL(): /OMA_XDM/X/ToConRef/TO-NAPID") );
+#endif
         segmentName.Copy( KXdmDmConRef );
         currentList->InsertL( currentList->Size(), segmentName );
         currentList->InsertL( currentList->Size(), KXdmDmSeparator );
@@ -305,6 +319,9 @@
     else
         {
         // if none of asked nodes found return error.
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::ChildURIListL(): return ENotFound") );
+#endif
         retValue = CSmlDmAdapter::ENotFound;
         }
        
@@ -502,6 +519,9 @@
     {
 #ifdef _DEBUG
     WriteToLog(_L8("CXdmDMAdapter::UpdateLeafObjectL(): begin") );
+    WriteToLog(_L8("CXdmDMAdapter::UpdateLeafObjectL() -    aUri: %S"), &aUri );
+    WriteToLog(_L8("CXdmDMAdapter::UpdateLeafObjectL() -   aLUID: %S"), &aLUID );
+    WriteToLog(_L8("CXdmDMAdapter::UpdateLeafObjectL() - aObject: %S"), &aObject );
 #endif   
     CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
 
@@ -521,6 +541,9 @@
         HBufC* current = NULL;
         TInt error( KErrNone );
         TRAP( error, ( current = TXdmSettingsApi::PropertyL( settingsId, EXdmPropName ) ) );
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::UpdateLeafObjectL() - EXdmPropName error: %d"), error );
+#endif 
         if ( error == KErrNone )
             {
             TBool same ( EFalse );
@@ -530,16 +553,20 @@
                 {
                 same = ETrue;
                 }
-            CleanupStack::PopAndDestroy( 2, current8 );  // >>> current, current8
+            CleanupStack::PopAndDestroy( current8 );  // >>> current8
+            CleanupStack::PopAndDestroy( current );  // >>> current
             if ( same )
                 {
                 Callback().SetStatusL( aStatusRef, status );
-                return;
+                return; // value was same, just return without change
                 }
             }
         // if the name is already in use, new name with index is created
         HBufC* value = CheckExistingNamesLC( aObject );     // << value
         TRAP( error, TXdmSettingsApi::UpdatePropertyL( settingsId, *value, EXdmPropName ) );
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::UpdateLeafObjectL() - EXdmPropName error: %d"), error );
+#endif
         CleanupStack::PopAndDestroy( value );                      // >>> value
         if ( error != KErrNone )
             {
@@ -647,14 +674,33 @@
         TInt id = TXdmSettingsApi::CreateCollectionL( *collection );
         HBufC8* luid = IntToDes8LC( id );   // << luid
         Callback().SetMappingL( aUri, *luid );
-        CleanupStack::PopAndDestroy( 2, luid );   // >>> collection, luid  
-        status =  CSmlDmAdapter::EOk;  
+        status =  CSmlDmAdapter::EOk;
 #ifdef _DEBUG
     WriteToLog(_L8("CXdmDMAdapter::AddNodeObjectL(): Settings created id=%d"), id );
 #endif
+        HBufC8* nameUri = HBufC8::NewLC( aUri.Length() +
+                                         KXdmDmSeparator().Length() +
+                                         KXdmDmName().Length() );
+        TPtr8 nameUriPtr = nameUri->Des();
+        nameUriPtr.Append( aUri );
+        nameUriPtr.Append( KXdmDmSeparator );
+        nameUriPtr.Append( KXdmDmName );
+
+        // Update Node's NAME to default so UI can recognize settings
+        UpdateLeafObjectL( nameUriPtr,
+                           *luid,
+                           KXdmDefaultSettingsName,
+                           KXdmDmName,
+                           aStatusRef );
+        CleanupStack::PopAndDestroy( nameUri );    // >> nameUri
+        CleanupStack::PopAndDestroy( luid );       // >> luid
+        CleanupStack::PopAndDestroy( collection ); // >> collection
         }
-    Callback().SetStatusL( aStatusRef, status );
-    
+    else
+        {
+        Callback().SetStatusL( aStatusRef, status );
+        }
+        
 #ifdef _DEBUG
     WriteToLog(_L8("CXdmDMAdapter::AddNodeObjectL(): end") );
 #endif
@@ -703,6 +749,9 @@
                                        const TDesC8& /*aType*/, 
                                        const TInt aStatusRef )
     {  
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::UpdateLeafObjectL( ): begin / end") );
+#endif
     // Update from stream not used
     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
     }
@@ -717,6 +766,9 @@
                                      const TDesC8& /*aType*/, 
                                      const TInt aStatusRef )
     {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::ExecuteCommandL( ): Not supported") );
+#endif
     // Not supported 
     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
     }
@@ -731,6 +783,9 @@
                                      const TDesC8& /*aType*/, 
                                      const TInt aStatusRef )
     {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::ExecuteCommandL( ): Not supported") );
+#endif
     // Not supported
     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
     }
@@ -746,6 +801,9 @@
                                   const TDesC8& /*aType*/, 
                                   TInt aStatusRef )
     {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::CopyCommandL( ): Not supported") );
+#endif
     // Not supported
     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
     }
@@ -757,6 +815,9 @@
 void CXdmDMAdapter::StartAtomicL()
     {
     // Not supported
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::StartAtomicL( ): Not supported") );
+#endif
     }
 
 // -----------------------------------------------------------------------------
@@ -766,6 +827,9 @@
 void CXdmDMAdapter::CommitAtomicL()
     {
     // Not supported
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::CommitAtomicL( ): Not supported") );
+#endif
     }
 
 // -----------------------------------------------------------------------------
@@ -775,6 +839,9 @@
 void CXdmDMAdapter::RollbackAtomicL()
     {
     // Not supported
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::RollBackAtomicL( ): Not supported") );
+#endif
     }
 
 // -----------------------------------------------------------------------------
@@ -783,6 +850,9 @@
 //
 TBool CXdmDMAdapter::StreamingSupport( TInt& /*aItemSize*/ )
     {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::StreamingSupport( ): Return EFalse") );
+#endif
     return EFalse;
     }
 
@@ -793,6 +863,9 @@
 void CXdmDMAdapter::StreamCommittedL()
     {
     // Not supported
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::StreamCommittedL( ): Not supported") );
+#endif
     }
     
 // -----------------------------------------------------------------------------
@@ -814,6 +887,9 @@
                                                    TXdmSettingsProperty aProperty, 
                                                    CBufBase& aObject )
     {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::GetPropertyL( ) - aSettingsId = %d"), &aSettingsId );
+#endif
     HBufC* value = NULL;
     TInt error( KErrNone );
     TRAP( error, ( value = TXdmSettingsApi::PropertyL( aSettingsId, aProperty ) ) );
@@ -822,9 +898,16 @@
         CleanupStack::PushL( value );           // << value
         HBufC8* utfValue = ConvertLC( *value ); // << utfValue
         aObject.InsertL( 0, *utfValue );
-        CleanupStack::PopAndDestroy( 2, utfValue );       // >>> value, utfValue
+        CleanupStack::PopAndDestroy( utfValue );       // >>> utfValue
+        CleanupStack::PopAndDestroy( value );       // >>> value
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::GetPropertyL( ): return EOk") );
+#endif
         return CSmlDmAdapter::EOk;
         }
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::GetPropertyL( ): return ENotFound") );
+#endif
     return CSmlDmAdapter::ENotFound;
     }
     
@@ -837,6 +920,9 @@
                                                       TXdmSettingsProperty aProperty, 
                                                       const TDesC8& aObject )
     {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::UpdatePropertyL( ): begin") );
+#endif
     HBufC* value = ConvertLC( aObject ); // << value
     TInt error( KErrNone );
     TRAP( error, TXdmSettingsApi::UpdatePropertyL( aSettingsId, *value, aProperty )  );
@@ -844,8 +930,14 @@
 
     if ( error == KErrNone )
         {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::UpdatePropertyL( ): return EOk") );
+#endif
         return CSmlDmAdapter::EOk;
         }
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::UpdatePropertyL( ): return ENotFound") );
+#endif
     return CSmlDmAdapter::ENotFound;
     }
           
@@ -861,6 +953,9 @@
                                    MSmlDmDDFObject::TDFFormat aFormat,
                                    const TDesC8& aDescription)
     {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::FillNodeInfoL( ): begin") );
+#endif
     aNode.SetAccessTypesL( aAccTypes );
     aNode.SetOccurenceL( aOccurrence );
     aNode.SetScopeL( aScope );
@@ -871,6 +966,9 @@
         aNode.AddDFTypeMimeTypeL( KXdmDmTextPlain );
         }
     aNode.SetDescriptionL( aDescription );
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::FillNodeInfoL( ): end") );
+#endif
     }
     
 
@@ -880,6 +978,9 @@
 //
 TInt CXdmDMAdapter::IapIdFromURIL( const TDesC8& aUri )
     {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::IapIdFromUriL( ): begin") );
+#endif
     TInt id( KErrNotFound );
     MSmlDmAdapter::TError status( MSmlDmAdapter::EError );
     CBufBase* result = CBufFlat::NewL(1);
@@ -901,6 +1002,9 @@
         }
 
     CleanupStack::PopAndDestroy( result );  // >>> result
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::IapIdFromUriL( ): end") );
+#endif
     return id;
     } 
 
@@ -910,6 +1014,9 @@
 //
 HBufC8* CXdmDMAdapter::URIFromIapIdL( TInt aId )
     {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::UriFromIapIdL( ): begin") );
+#endif
     CBufBase *allIds = CBufFlat::NewL(KXdmDmIdTableSize);
     CleanupStack::PushL( allIds );  // << allIds
     MSmlDmAdapter::TError status;
@@ -936,7 +1043,7 @@
             else
                 {
                 TPtrC8 uriSeg8Ptr = allIds->Ptr(segStart).Mid( 0, index );
-                uriSeg = uriSeg8Ptr.AllocLC();  // << uriSeg8Ptr
+                uriSeg = uriSeg8Ptr.AllocLC();  // << uriSeg
                 }
             // Construct the uri
             HBufC8* uri = HBufC8::NewLC( KXdmDmAP().Length() 
@@ -957,17 +1064,25 @@
                 if ( id == aId )
                     {
                     // The correct one found
-                    CleanupStack::Pop();  // >>> uri
-                    CleanupStack::PopAndDestroy( 2, allIds );  // >>> uriSeg, allIds
+                    CleanupStack::Pop();                     // >>> uri
+                    CleanupStack::PopAndDestroy( uriSeg );   // >>> uriSeg 
+                    CleanupStack::PopAndDestroy( allIds );   // >>> allIds
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::UriFromIapIdL( ): return uri") );
+#endif
                     return uri;
                     }
                 }
             // This was wrong, delete and get the next one
-            CleanupStack::PopAndDestroy( 2, uriSeg ); // >>> uri, uriSeg
+            CleanupStack::PopAndDestroy( uri );      // >>> uri
+            CleanupStack::PopAndDestroy( uriSeg );   // >>> uriSeg 
             segStart += index + 1;
             }        
         }
     CleanupStack::PopAndDestroy( allIds ); // >>> allIds
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::UriFromIapIdL( ): return NULL") );
+#endif
     return NULL;
     }  
 // -----------------------------------------------------------------------------
@@ -976,7 +1091,9 @@
 //
 TInt CXdmDMAdapter::GetSipIdL( const TDesC8& aUri )
     {
-
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::GetSipIdL( ): begin") );
+#endif
     CSmlDmAdapter::TError status = EOk;
     CBufBase* result = CBufFlat::NewL(1);
     CleanupStack::PushL( result );    // << result
@@ -991,10 +1108,16 @@
         TPtrC8 hexIndex = uri.Right( KXdmDmHexLength );
         TLex8 lexer( hexIndex );
         lexer.Val( id, EHex );
-        CleanupStack::PopAndDestroy( result );   // >>> result   
+        CleanupStack::PopAndDestroy( result );   // >>> result
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::GetSipIdL( ): return id: %d"), id );
+#endif
         return id;       
         }
-    CleanupStack::PopAndDestroy( result );   // >>> result   
+    CleanupStack::PopAndDestroy( result );   // >>> result
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::GetSipIdL( ): return KErrNotFound") );
+#endif
     return KErrNotFound;       
     }
 // -----------------------------------------------------------------------------
@@ -1004,7 +1127,9 @@
 CSmlDmAdapter::TError CXdmDMAdapter::FetchSipConRefL( TInt aSettingsId,
                                                       CBufBase& aObject)
     {
-
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::FetchSipConRefL( ): begin") );
+#endif
     CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
     TInt sipSettingsId( KErrNotFound );
     
@@ -1084,7 +1209,9 @@
         {
         status = CSmlDmAdapter::ENotFound;
         }
-    
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::FetchSipConRefL( ): return status") );
+#endif
     return status;
     }   
 
@@ -1094,10 +1221,16 @@
 //      
 TInt CXdmDMAdapter::FindSettingsIdL( const TDesC8& aLUID, const TDesC8& aUri )
     {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::FindSettingsIdL( ): begin") );
+#endif
     TInt settingsId(0);
     if ( aLUID.Length() > 0 )
         {
         settingsId = DesToInt( aLUID );
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::FindSettingsIdL( ): return settingsId: %d "), settingsId );
+#endif
         return settingsId;
         }
     else
@@ -1107,6 +1240,9 @@
         HBufC8* luid = IntToDes8LC( settingsId ); // << luid
         Callback().SetMappingL( aUri, *luid );
         CleanupStack::PopAndDestroy( luid ); // luid 
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::FindSettingsIdL( ): return settingsId: %d "), settingsId );
+#endif
         return settingsId;
         }
     }
@@ -1116,7 +1252,10 @@
 // -----------------------------------------------------------------------------
 // 
 HBufC* CXdmDMAdapter::CheckExistingNamesLC( const TDesC8& aName )
-    {    
+    {
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::CheckExistingNamesLC( ): begin") );
+#endif
     TBool ready( EFalse );  
     RArray<TInt> settingIds;
     CleanupClosePushL( settingIds );                // << settingIds
@@ -1147,8 +1286,12 @@
             ready = ETrue;
             }
         }
-    CleanupStack::PopAndDestroy( 2 );   // >>> settingNames, settingIds
+    CleanupStack::PopAndDestroy( settingNames );   // >>> settingNames
+    CleanupStack::PopAndDestroy();                 // >>> settingIds
     HBufC* newName = tempName.AllocLC();    // << newName
+#ifdef _DEBUG
+    WriteToLog(_L8("CXdmDMAdapter::CheckExistingNamesLC( ): end") );
+#endif
     return newName;
     }
     
--- a/XDMEngine/XdmProvisioning/inc/xdmprovitem.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/XDMEngine/XdmProvisioning/inc/xdmprovitem.h	Wed Sep 01 12:23:14 2010 +0100
@@ -137,7 +137,7 @@
         * @param aName Name of the parameter
         * @param aValue Value of the parameter
         */
-        void DetermineNamedParameter( const TDesC& aName, 
+        void DetermineNamedParameterL( const TDesC& aName, 
                                       const TDesC& aValue );
         
         /**
--- a/XDMEngine/XdmProvisioning/src/xdmprovadapter.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/XDMEngine/XdmProvisioning/src/xdmprovadapter.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -28,6 +28,8 @@
 #include "xdmprovitem.h"
 #include "xdmprovadapter.h"
 
+// for CleanupResetAndDestroyPushL
+#include <mmf/common/mmfcontrollerpluginresolver.h>
 
 #ifdef _DEBUG
     #include <flogger.h>
@@ -305,6 +307,9 @@
 #ifdef _DEBUG 
     WriteToLog( _L8( "CXdmProvAdapter::GetSavingInfoL" ) );
 #endif    
+
+    CleanupResetAndDestroyPushL( aSavingInfo ); 
+ 
     if ( aIndex < iProvItems.Count() - 1 )
         {
 #ifdef _DEBUG 
@@ -339,7 +344,9 @@
         CleanupStack::Pop( idBuf );                     // >> idBuf
         idBuf = NULL;
         }
-        
+    
+    CleanupStack::Pop( &aSavingInfo ); 
+    
 #ifdef _DEBUG 
     WriteToLog( _L8( "CXdmProvAdapter::GetSavingInfoL done" ) );
 #endif
--- a/XDMEngine/XdmProvisioning/src/xdmprovitem.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/XDMEngine/XdmProvisioning/src/xdmprovitem.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -270,7 +270,7 @@
             
         case EWPParameterToAppRef:
             {
-            iToAppReferences.Append( aParameter.Value() );  
+            iToAppReferences.AppendL( aParameter.Value() );  
 #ifdef _DEBUG 
     CXdmProvAdapter::WriteToLog( _L8( "CXdmProvItem::EWPParameterToAppRef" ) );
 #endif
@@ -332,7 +332,7 @@
             break;   
         default:
             {
-            DetermineNamedParameter( aParameter.Name(), aParameter.Value() );
+            DetermineNamedParameterL( aParameter.Name(), aParameter.Value() );
             }
             break;
         }
@@ -342,7 +342,7 @@
 // CXdmProvItem::DetermineNamedParameter
 // -----------------------------------------------------------------------------
 //
-void CXdmProvItem::DetermineNamedParameter( const TDesC& aName, const TDesC& aValue )
+void CXdmProvItem::DetermineNamedParameterL( const TDesC& aName, const TDesC& aValue )
     {
     if ( !aName.Compare( KXdmProvAppRef ) )
         {
@@ -350,7 +350,7 @@
         }
     else if ( !aName.Compare( KXdmProvToAppRef ) )
         {
-        iToAppReferences.Append( aValue ); 
+        iToAppReferences.AppendL( aValue );
         }
     }
 // -----------------------------------------------------------------------------
--- a/XDMEngine/XdmSettingsApi/src/XdmSettingsApi.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/XDMEngine/XdmSettingsApi/src/XdmSettingsApi.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -31,11 +31,11 @@
 EXPORT_C TInt TXdmSettingsApi::CreateCollectionL( const CXdmSettingsCollection& aCollection )
     {
     #ifdef _DEBUG
-        WriteToLog( _L8( "TXdmSettingsApi::CreateCollectionL()" ) );
+        WriteToLog( _L8( "TXdmSettingsApi::CreateCollectionL() - begin" ) );
     #endif
     TInt error = KErrArgument;
     CRepository* repository = CRepository::NewL( KCRUidXdmEngine );
-    CleanupStack::PushL( repository );
+    CleanupStack::PushL( repository );  // CS: 1
     TInt row = LastRow( repository );
     TInt count = aCollection.Count();
     __ASSERT_DEBUG( count > 0, User::Leave( KErrArgument ) );
@@ -364,8 +364,10 @@
 EXPORT_C CDesCArray* TXdmSettingsApi::CollectionNamesLC( RArray<TInt>& aSettingIds )
     {
     #ifdef _DEBUG
-        WriteToLog( _L8( "TXdmSettingsApi::CollectionNamesL()" ) );
+        WriteToLog( _L8( "TXdmSettingsApi::CollectionNamesLC() - begin" ) );
     #endif
+    TInt nameError = KErrNone;
+    TInt idError = KErrNone;
     TInt error = KErrNone;
     CDesCArrayFlat* propertySet = new ( ELeave ) CDesCArrayFlat( 10 );
     CleanupStack::PushL( propertySet );
@@ -390,9 +392,9 @@
             identifier.Zero();
             name = HBufC::NewLC( NCentralRepositoryConstants::KMaxUnicodeStringLength );
             TPtr desc( name->Des());
-            error = repository->Get( nameKeys[i], desc );
-            error = repository->Get( idKeys[i], identifier );
-            if( error == KErrNone && desc.Length() > 0 && identifier.Length() > 0 )
+            nameError = repository->Get( nameKeys[i], desc );
+            idError = repository->Get( idKeys[i], identifier );
+            if( idError == KErrNone && desc.Length() > 0 && identifier.Length() > 0 )
                 {
                 #ifdef _DEBUG
                     HBufC8* eightName = HBufC8::NewLC( desc.Length() );
@@ -404,18 +406,21 @@
                 propertySet->AppendL( desc );
                 TLex id( identifier );
                 error = id.Val( numId );
-                aSettingIds.Append( error == KErrNone ? numId : error );
+                aSettingIds.AppendL( error == KErrNone ? numId : error );
                 }
             else
                 {
                 #ifdef _DEBUG
-                    WriteToLog( _L8( " Fetching of the name no. %d failed with: %d" ), i, error );
+                    WriteToLog( _L8( " Fetching of the name no. %d failed with idError:%d & nameError:%d" ), i, idError, nameError );
                 #endif
                 }
             CleanupStack::PopAndDestroy();  //name
             }
         }
     CleanupStack::PopAndDestroy( 3 );   //idKeys, nameKeys, repository
+#ifdef _DEBUG
+        WriteToLog( _L8( "TXdmSettingsApi::CollectionNamesLC() - end" ) );
+#endif
     return propertySet;
     }
                                             
@@ -518,6 +523,7 @@
         User::Leave( error );
         }
     CleanupStack::PopAndDestroy( 2 );  //keys, repository
+    WriteToLog( _L8( "  Return:           %S" ), buf );
     return buf;
     }
             
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/cenrep/backup_registration.xml	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration version="1.0">
+    <proxy_data_manager sid = "0x10202BE9" />
+    <restore requires_reboot = "no"/>
+</backup_registration>
Binary file XDMEngine/cenrep/keys_xdmengine.xls has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/eabi/XdmEngineU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,140 @@
+EXPORTS
+	_ZN10CXdmEngine12CancelUpdateEP12CXdmDocument @ 1 NONAME
+	_ZN10CXdmEngine12CancelUpdateEP13CXdmDirectory @ 2 NONAME
+	_ZN10CXdmEngine13XdmSettingsLCER6RArrayIiE @ 3 NONAME
+	_ZN10CXdmEngine19CreateDocumentNodeLEv @ 4 NONAME
+	_ZN10CXdmEngine20CreateDocumentModelLERK7TDesC1611TXdmDocType @ 5 NONAME
+	_ZN10CXdmEngine20DeleteDocumentModelLEPK12CXdmDocument @ 6 NONAME
+	_ZN10CXdmEngine21CreateDirectoryModelLERK7TDesC16 @ 7 NONAME
+	_ZN10CXdmEngine21DeleteDirectoryModelLEPK13CXdmDirectory @ 8 NONAME
+	_ZN10CXdmEngine4NewLERK16CXdmProtocolInfo @ 9 NONAME
+	_ZN10CXdmEngine7UpdateLEP12CXdmDocumentR14TRequestStatus @ 10 NONAME
+	_ZN10CXdmEngine7UpdateLER14TRequestStatusP13CXdmDirectory15TDirUpdatePhase @ 11 NONAME
+	_ZN12CXdmDocument10FetchDataLEP16CXdmDocumentNode @ 12 NONAME
+	_ZN12CXdmDocument11DeleteDataLEP16CXdmDocumentNode @ 13 NONAME
+	_ZN12CXdmDocument11ResetSubsetEv @ 14 NONAME
+	_ZN12CXdmDocument14AppendToModelLEP16CXdmDocumentNodeS1_ @ 15 NONAME
+	_ZN12CXdmDocument14BaseConstructLEiRK6TDesC8 @ 16 NONAME
+	_ZN12CXdmDocument14BaseConstructLEiRK7TDesC16 @ 17 NONAME
+	_ZN12CXdmDocument15DocumentSubsetLERK7TDesC16 @ 18 NONAME
+	_ZN12CXdmDocument15ReplaceInModelLEP16CXdmDocumentNodeS1_ @ 19 NONAME
+	_ZN12CXdmDocument16RemoveFromModelLEP16CXdmDocumentNode @ 20 NONAME
+	_ZN12CXdmDocument7AppendLEP16CXdmDocumentNode @ 21 NONAME
+	_ZN12CXdmDocument7InsertLEP16CXdmDocumentNode @ 22 NONAME
+	_ZN12CXdmDocument8ReplaceLEP16CXdmDocumentNodeS1_ @ 23 NONAME
+	_ZN12CXdmDocument8ReplaceLEv @ 24 NONAME
+	_ZN12CXdmDocumentC2ER10CXdmEngine @ 25 NONAME
+	_ZN12CXdmDocumentD0Ev @ 26 NONAME
+	_ZN12CXdmDocumentD1Ev @ 27 NONAME
+	_ZN12CXdmDocumentD2Ev @ 28 NONAME
+	_ZN13CXdmDirectory14BaseConstructLERK7TDesC16 @ 29 NONAME
+	_ZN13CXdmDirectoryC2ER10CXdmEngine @ 30 NONAME
+	_ZN13CXdmDirectoryD0Ev @ 31 NONAME
+	_ZN13CXdmDirectoryD1Ev @ 32 NONAME
+	_ZN13CXdmDirectoryD2Ev @ 33 NONAME
+	_ZN13CXdmLogWriter4NewLERK7TDesC16 @ 34 NONAME
+	_ZN14XdmStaticUtils16CheckFileExistsLER3RFsRK7TDesC16 @ 35 NONAME
+	_ZN14XdmStaticUtils17CleanUpDirectoryLER3RFsRK7TDesC16 @ 36 NONAME
+	_ZN14XdmStaticUtils17GenerateFileNameLER3RFsRK7TDesC16S4_ @ 37 NONAME
+	_ZN15TXdmCredentialsC1ERK7TDesC16S2_ @ 38 NONAME
+	_ZN15TXdmCredentialsC1Ev @ 39 NONAME
+	_ZN15TXdmCredentialsC2ERK7TDesC16S2_ @ 40 NONAME
+	_ZN15TXdmCredentialsC2Ev @ 41 NONAME
+	_ZN16CXdmDocumentNode11SetLeafNodeEi @ 42 NONAME
+	_ZN16CXdmDocumentNode11SetNextNodeEPS_ @ 43 NONAME
+	_ZN16CXdmDocumentNode12SetEmptyNodeEi @ 44 NONAME
+	_ZN16CXdmDocumentNode14BaseConstructLERK7TDesC16 @ 45 NONAME
+	_ZN16CXdmDocumentNode14CopyConstructLERKS_S1_ @ 46 NONAME
+	_ZN16CXdmDocumentNode16AppendChileNodeLEPS_ @ 47 NONAME
+	_ZN16CXdmDocumentNode16CreateAttributeLERK7TDesC16 @ 48 NONAME
+	_ZN16CXdmDocumentNode16CreateAttributeLEv @ 49 NONAME
+	_ZN16CXdmDocumentNode16CreateChileNodeLERK7TDesC16 @ 50 NONAME
+	_ZN16CXdmDocumentNode16CreateChileNodeLEv @ 51 NONAME
+	_ZN16CXdmDocumentNode16InsertChileNodeLEiPS_ @ 52 NONAME
+	_ZN16CXdmDocumentNode16RemoveChileNodeLEPS_ @ 53 NONAME
+	_ZN16CXdmDocumentNode17ReplaceChileNodeLEPS_S0_ @ 54 NONAME
+	_ZN16CXdmDocumentNode19SetLeafNodeContentLERK6TDesC8 @ 55 NONAME
+	_ZN16CXdmDocumentNode19SetLeafNodeContentLERK7TDesC16 @ 56 NONAME
+	_ZN16CXdmDocumentNode5PrintEv @ 57 NONAME
+	_ZN16CXdmDocumentNode8SetNameLERK6TDesC8 @ 58 NONAME
+	_ZN16CXdmDocumentNode8SetNameLERK7TDesC16 @ 59 NONAME
+	_ZN16CXdmDocumentNodeC2ER10CXdmEngineR15MXdmNodeFactory @ 60 NONAME
+	_ZN16CXdmDocumentNodeC2ER10CXdmEngineR15MXdmNodeFactoryPS_ @ 61 NONAME
+	_ZN16CXdmDocumentNodeC2EiR10CXdmEngineR15MXdmNodeFactoryPS_ @ 62 NONAME
+	_ZN16CXdmDocumentNodeD0Ev @ 63 NONAME
+	_ZN16CXdmDocumentNodeD1Ev @ 64 NONAME
+	_ZN16CXdmDocumentNodeD2Ev @ 65 NONAME
+	_ZN16CXdmProtocolInfo11SetSecurityEi @ 66 NONAME
+	_ZN16CXdmProtocolInfo13SetCacheUsageEi @ 67 NONAME
+	_ZN16CXdmProtocolInfo14SetCredentialsE15TXdmCredentials @ 68 NONAME
+	_ZN16CXdmProtocolInfo4NewLEi @ 69 NONAME
+	_ZN16CXdmProtocolInfo4NewLEiiRK7TDesC16 @ 70 NONAME
+	_ZN16CXdmProtocolInfoD0Ev @ 71 NONAME
+	_ZN16CXdmProtocolInfoD1Ev @ 72 NONAME
+	_ZN16CXdmProtocolInfoD2Ev @ 73 NONAME
+	_ZN17CXdmNodeAttribute14BaseConstructLERK7TDesC16 @ 74 NONAME
+	_ZN17CXdmNodeAttribute18SetAttributeValueLERK6TDesC8 @ 75 NONAME
+	_ZN17CXdmNodeAttribute18SetAttributeValueLERK7TDesC16 @ 76 NONAME
+	_ZN17CXdmNodeAttributeC2ER10CXdmEngineR15MXdmNodeFactory @ 77 NONAME
+	_ZN17CXdmNodeAttributeC2ER10CXdmEngineR15MXdmNodeFactoryP16CXdmDocumentNode @ 78 NONAME
+	_ZN17CXdmNodeAttributeD0Ev @ 79 NONAME
+	_ZN17CXdmNodeAttributeD1Ev @ 80 NONAME
+	_ZN17CXdmNodeAttributeD2Ev @ 81 NONAME
+	_ZNK10CXdmEngine18DocumentCollectionEv @ 82 NONAME
+	_ZNK10CXdmEngine19DirectoryCollectionEv @ 83 NONAME
+	_ZNK12CXdmDocument4FindERK16CXdmDocumentNodeR13RPointerArrayIS0_E @ 84 NONAME
+	_ZNK12CXdmDocument4FindERK7TDesC16R13RPointerArrayI16CXdmDocumentNodeE @ 85 NONAME
+	_ZNK12CXdmDocument4FindERK7TDesC16R13RPointerArrayI16CXdmDocumentNodeERKS3_I15SXdmAttribute16E @ 86 NONAME
+	_ZNK12CXdmDocument4FindERK7TDesC16R13RPointerArrayI17CXdmNodeAttributeE @ 87 NONAME
+	_ZNK12CXdmDocument4NameEv @ 88 NONAME
+	_ZNK12CXdmDocumenteqERS_ @ 89 NONAME
+	_ZNK13CXdmLogWriter10WriteToLogERK6TDesC8 @ 90 NONAME
+	_ZNK13CXdmLogWriter10WriteToLogERK7TDesC16 @ 91 NONAME
+	_ZNK16CXdmDocumentNode10IsLeafNodeEv @ 92 NONAME
+	_ZNK16CXdmDocumentNode11ElementTypeEv @ 93 NONAME
+	_ZNK16CXdmDocumentNode11IsEmptyNodeEv @ 94 NONAME
+	_ZNK16CXdmDocumentNode12HasAttributeERK7TDesC16 @ 95 NONAME
+	_ZNK16CXdmDocumentNode13ElementDataLCEv @ 96 NONAME
+	_ZNK16CXdmDocumentNode14AttributeCountEv @ 97 NONAME
+	_ZNK16CXdmDocumentNode15LeafNodeContentEv @ 98 NONAME
+	_ZNK16CXdmDocumentNode18EightBitNodeNameLCEv @ 99 NONAME
+	_ZNK16CXdmDocumentNode23EscapeLeafNodeContentLCEv @ 100 NONAME
+	_ZNK16CXdmDocumentNode4FindERK7TDesC16R13RPointerArrayIS_E @ 101 NONAME
+	_ZNK16CXdmDocumentNode4FindERK7TDesC16R13RPointerArrayIS_ERKS3_I15SXdmAttribute16E @ 102 NONAME
+	_ZNK16CXdmDocumentNode4FindERKS_R13RPointerArrayIS_E @ 103 NONAME
+	_ZNK16CXdmDocumentNode5MatchERK7TDesC16RK13RPointerArrayI14SXdmAttribute8E @ 104 NONAME
+	_ZNK16CXdmDocumentNode5MatchERKS_ @ 105 NONAME
+	_ZNK16CXdmDocumentNode6ParentEv @ 106 NONAME
+	_ZNK16CXdmDocumentNode8NextNodeEv @ 107 NONAME
+	_ZNK16CXdmDocumentNode8NodeNameEv @ 108 NONAME
+	_ZNK16CXdmDocumentNode9AttributeERK7TDesC16 @ 109 NONAME
+	_ZNK16CXdmDocumentNode9AttributeEi @ 110 NONAME
+	_ZNK16CXdmDocumentNode9ChileNodeEi @ 111 NONAME
+	_ZNK16CXdmDocumentNode9NodeCountEv @ 112 NONAME
+	_ZNK16CXdmDocumentNodeeqERKS_ @ 113 NONAME
+	_ZNK16CXdmProtocolInfo10SettingsIDEv @ 114 NONAME
+	_ZNK16CXdmProtocolInfo11AccessPointEv @ 115 NONAME
+	_ZNK16CXdmProtocolInfo11CredentialsEv @ 116 NONAME
+	_ZNK16CXdmProtocolInfo11ProtocolUidEv @ 117 NONAME
+	_ZNK16CXdmProtocolInfo14IsCacheEnabledEv @ 118 NONAME
+	_ZNK16CXdmProtocolInfo4RootEv @ 119 NONAME
+	_ZNK16CXdmProtocolInfo8IsSecureEv @ 120 NONAME
+	_ZNK17CXdmNodeAttribute11ElementTypeEv @ 121 NONAME
+	_ZNK17CXdmNodeAttribute14AttributeValueEv @ 122 NONAME
+	_ZNK17CXdmNodeAttribute14EscapedValueLCEv @ 123 NONAME
+	_ZNK17CXdmNodeAttribute15EightBitValueLCEv @ 124 NONAME
+	_ZTI10CXdmEngine @ 125 NONAME ; #<TI>#
+	_ZTI12CXdmDocument @ 126 NONAME ; #<TI>#
+	_ZTI13CXdmDirectory @ 127 NONAME ; #<TI>#
+	_ZTI13CXdmLogWriter @ 128 NONAME ; #<TI>#
+	_ZTI16CXdmDocumentNode @ 129 NONAME ; #<TI>#
+	_ZTI16CXdmProtocolInfo @ 130 NONAME ; #<TI>#
+	_ZTI17CXdmNodeAttribute @ 131 NONAME ; #<TI>#
+	_ZTV10CXdmEngine @ 132 NONAME ; #<VT>#
+	_ZTV12CXdmDocument @ 133 NONAME ; #<VT>#
+	_ZTV13CXdmDirectory @ 134 NONAME ; #<VT>#
+	_ZTV13CXdmLogWriter @ 135 NONAME ; #<VT>#
+	_ZTV16CXdmDocumentNode @ 136 NONAME ; #<VT>#
+	_ZTV16CXdmProtocolInfo @ 137 NONAME ; #<VT>#
+	_ZTV17CXdmNodeAttribute @ 138 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/group/XdmEngine.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,64 @@
+/*
+* 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:   XDM Engine
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                          xdmengine.dll
+UID                             0x1000008d 0x1020740E
+CAPABILITY                      CAP_GENERAL_DLL
+VENDORID                        VID_DEFAULT
+TARGETTYPE                      DLL				
+
+SOURCEPATH                      ../src
+
+SOURCE                          XdmEngine.cpp
+SOURCE                          XdmDocument.cpp
+SOURCE                          XdmDirectory.cpp
+SOURCE                          XdmLogWriter.cpp
+SOURCE                          XdmStaticUtils.cpp
+SOURCE                          XdmCredentials.cpp
+SOURCE                          XdmProtocolInfo.cpp
+SOURCE                          XdmDocumentNode.cpp
+SOURCE                          XdmNodeAttribute.cpp
+
+USERINCLUDE                     ../inc
+USERINCLUDE                     ../../pressrv_dom/xdm_api/inc
+//USERINCLUDE                     ../XdmSettingsApi/inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE                   /epoc32/include/ecom
+
+LIBRARY                         ecom.lib
+LIBRARY                         efsrv.lib
+LIBRARY                         euser.lib
+LIBRARY                         charconv.lib
+LIBRARY                         flogger.lib
+LIBRARY                         xdmsettingsapi.lib
+LIBRARY                         inetprotutil.lib
+
+
+#if defined( ARMCC )
+DEFFILE ../eabi/ 
+#elif defined ( WINSCW )
+deffile ../BWINSCW/ 
+#elif defined (WINS )
+deffile ../bwins/ 
+#endif
+
+
--- a/XDMEngine/group/bld.inf	Tue Aug 31 15:35:50 2010 +0300
+++ b/XDMEngine/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -28,13 +28,29 @@
 PRJ_EXPORTS
 //--------------------
 
+../Conf/xdmengine.confml                 MW_LAYER_CONFML(xdmengine.confml)
+../Conf/xdmengine_10207453.crml	         MW_LAYER_CRML(xdmengine_10207453.crml)
+../Conf/xdmengine_10282384.crml	         MW_LAYER_CRML(xdmengine_10282384.crml)
+
+//For _DEBUG
+../inc/XdmLogWriter.h                                   |../../inc/xdmlogwriter.h
+
+//Backup registry
+../cenrep/backup_registration.xml                       z:/private/10207421/backup_registration.xml
+
+// IBYs
+../rom/XdmEngine.iby CORE_MW_LAYER_IBY_EXPORT_PATH(xdmengine.iby)
+../rom/XdmEngineResources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(xdmengineresources.iby)
+
 // LOC (note: This would be better in XdmProvisioning's bld.inf, but since it is not used, it is here.)
 ../XdmProvisioning/loc/xdmprovisioningadapter.loc MW_LAYER_LOC_EXPORT_PATH(xdmprovisioningadapter.loc)
+
 //--------------------
 PRJ_MMPFILES
 //--------------------
 
 ../XdmSettingsApi/group/XdmSettingsApi.mmp
+XdmEngine.mmp
 ../XdmProvisioning/group/xdmprovisioning.mmp
 ../XdmDeviceManagement/group/xdmdevicemanagementadapter.mmp
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/group/bld_engine.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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:  XDM Engine build file
+*
+*/
+
+
+
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+
+XdmEngine.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/inc/XdmEngineDefines.h	Wed Sep 01 12:23:14 2010 +0100
@@ -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:   XDM Engine defines
+*
+*/
+
+
+
+
+#ifndef __XdmENGINEDEFINES__
+#define __XdmENGINEDEFINES__
+
+#include <e32base.h>
+
+//General defines
+_LIT8( KGeneralEqualsAndQuotes,                        "=\""  );
+_LIT8( KGeneralQuotes,                                 "\""  );
+
+//Xdm specific defines 
+const TInt KXdmPathSeparator                           = 47;
+
+//XCAP specific defines
+_LIT8( KXCAPEquality,                                  "="  );
+_LIT8( KXCAPNodeSeparator,                             "~~" );
+_LIT8( KXCAPPathSeparator,                             "/"  );
+_LIT8( KXCAPAttributeIdentifier,                       "@"  );
+
+//HTTP specific defines
+_LIT8( KHTTPAngleBracketOpen,                          "%5b");
+_LIT8( KHTTPAngleBracketClose,                         "%5d");
+_LIT8( KHTTPAngleQuotationMark,                        "%22");
+
+//XML specific defines
+_LIT8( KXmlSpace,                                      " ");
+#endif    //__XdmENGINEDEFINES__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/inc/XdmLogWriter.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* 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:   XDM Engine log writer
+*
+*/
+
+
+
+
+#ifndef __XDMLOGWRITER__
+#define __XDMLOGWRITER__
+
+#include <e32base.h>
+
+_LIT( KXdmLogDir,                                  "XDM" );
+_LIT( KXdmLogFileExt,                              ".txt" );
+_LIT( KXdmLogRoot,                                 "C:\\logs\\" );
+
+//Determines how many log file instances are
+//retained until the directory is cleaned up
+/* E.g. XdmEngine1.txt, XdmEngine2.txt ... XdmEngine10.txt */
+const TInt KMaxLogFiles                            = 10;
+
+/* Default size of the log buffer */
+const TInt KLogBufferMaxSize		               = 2000;
+
+// CLASS DECLARATION
+class CXdmLogWriter : public CBase
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        *
+        * @param TDesC& The log file name
+        * @return CXdmLogWriter* A log writer instance
+        */ 
+        IMPORT_C static CXdmLogWriter* NewL( const TDesC& aLogName );
+        
+        /**
+        * Write a log string.
+        *
+        * @param TDesC& Log string in 16-bit
+        * @return void
+        */     
+        IMPORT_C void WriteToLog( const TDesC& aLogLine ) const;
+        
+        /**
+        * Write a log string.
+        *
+        * @param TDesC8& Log string in 8-bit
+        * @return void
+        */     
+        IMPORT_C void WriteToLog( const TDesC8& aLogLine  ) const;
+        
+        /**
+        * Destructor
+        */ 
+        virtual ~CXdmLogWriter();
+
+    private:
+        
+        /**
+        * C++ constructor is private
+        */ 
+        CXdmLogWriter();
+        
+        /**
+        * Symbian OS second-phase constructor
+        * @param TDesC& Name of the log file to write to
+        * @return void
+        */ 
+        void ConstructL( const TDesC& aLogName );
+        
+    private:  //Data
+        
+        HBufC*              iLogFileName;
+    
+    };
+
+#endif      //__XDMLOGWRITER__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/inc/XdmStaticUtils.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,70 @@
+/*
+* 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:   XDM Engine static utils
+*
+*/
+
+
+
+
+#ifndef __XDMSTATICUTILS__
+#define __XDMSTATICUTILS__
+
+#include <e32base.h>
+
+const TInt KBackSlash           = 92;
+
+class RFs;
+
+// CLASS DECLARATION
+class XdmStaticUtils
+
+    {
+    public:
+        
+        /**
+        * Check whether a file already exists.
+        *
+        * @param RFs& An opened file session
+        * @param TDesC& The file name to check
+        * @return TBool Is the file already there
+        */     
+        IMPORT_C static TBool CheckFileExistsL( RFs& aFileSession, const TDesC& aFileName );
+        
+        /**
+        * Generate a new file name unique in the context
+        * of the folder in which it resides
+        *
+        * @param RFs& An opened file session
+        * @param TDesC& The file name to check
+        * @param TDesC& The extension in the filename
+        * @return HBufC* The generated filename
+        */     
+        IMPORT_C static HBufC* GenerateFileNameL( RFs& aFileSession, const TDesC& aFileName,
+                                                  const TDesC& aExtension );
+        
+        /**
+        * Clean up a directory
+        *
+        * @param RFs& An opened file session
+        * @param TDesC& The directory to clean up
+        * @return void
+        */                                           
+        IMPORT_C static void CleanUpDirectoryL( RFs& aFileSession, const TDesC& aDirectory );
+    
+    };
+
+#endif      //__XDMCREDENTIALS__
+            
+// End of File
--- a/XDMEngine/rom/XdmEngine.iby	Tue Aug 31 15:35:50 2010 +0300
+++ b/XDMEngine/rom/XdmEngine.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -22,7 +22,9 @@
 #define __XDMENGINE_IBY__
 
 #ifdef __XDM
-    file=ABI_DIR\BUILD_DIR\XdmSettingsApi.dll                   SHARED_LIB_DIR\XdmSettingsApi.dll
+    file=ABI_DIR/BUILD_DIR/XdmEngine.dll                        SHARED_LIB_DIR/XdmEngine.dll
+    file=ABI_DIR/BUILD_DIR/XdmXmlParser.dll                     SHARED_LIB_DIR/XdmXmlParser.dll
+    file=ABI_DIR/BUILD_DIR/XdmSettingsApi.dll                   SHARED_LIB_DIR/XdmSettingsApi.dll
     ECOM_PLUGIN(                                                XdmDeviceManagementAdapter.dll, 10275112.rsc) 
     ECOM_PLUGIN(                                                XdmProvisioning.dll, 1028237A.rsc) 
 #endif //__XDM
--- a/XDMEngine/rom/XdmEngineResources.iby	Tue Aug 31 15:35:50 2010 +0300
+++ b/XDMEngine/rom/XdmEngineResources.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -23,7 +23,7 @@
 //
 // Settings provisioning adapter plugin resources
 //
-data=DATAZ_\RESOURCE_FILES_DIR\XdmProvisioningTexts.RSC RESOURCE_FILES_DIR\XdmProvisioningTexts.RSC
+data=DATAZ_/RESOURCE_FILES_DIR/XdmProvisioningTexts.RSC RESOURCE_FILES_DIR/XdmProvisioningTexts.RSC
 
 #endif //__XDMENGINE_RESOURCES_IBY__
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/src/XdmCredentials.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -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:   XDM Engine credentials
+*
+*/
+
+
+
+#include "XdmCredentials.h"
+
+// ---------------------------------------------------------
+// TXdmCredentials::TXdmCredentials
+//
+// ---------------------------------------------------------
+//
+EXPORT_C TXdmCredentials::TXdmCredentials()
+    {
+    }
+
+// ---------------------------------------------------------
+// TXdmCredentials::TXdmCredentials
+//
+// ---------------------------------------------------------
+//
+EXPORT_C TXdmCredentials::TXdmCredentials( const TDesC& aUserName,
+                                           const TDesC& aPassword )
+    {
+    iUserName.Copy( aUserName );
+    iPassword.Copy( aPassword );
+    }
+
+            
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/src/XdmDirectory.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,68 @@
+/*
+* 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:   XDM Engine directory
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XdmEngine.h"
+
+// ----------------------------------------------------------
+// CXdmDirectory::CXdmDirectory
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmDirectory::CXdmDirectory( CXdmEngine& aXdmEngine ) :
+                                       CActive( EPriorityStandard ),
+                                       iFileCount( KErrNotReady ),
+                                       iXdmEngine( aXdmEngine )
+    {   
+    }
+
+// ----------------------------------------------------------
+// CXdmDirectory::BaseConstructL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmDirectory::BaseConstructL( const TDesC& aDirectoryPath )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDirectory::ConstructL()" ) );
+    #endif
+    iDirectoryPath = aDirectoryPath.AllocL();
+    iDirectoryPath->Des().Copy( aDirectoryPath );
+    }
+       
+// ----------------------------------------------------------
+// CXdmDirectory::CXdmDirectory
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmDirectory::~CXdmDirectory()
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDirectory::~CXdmDirectory()" ) );
+    #endif
+    delete iDirectoryPath;
+    }
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/src/XdmDocument.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,505 @@
+/*
+* 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:   XDM Engine document
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include "XdmEngine.h"
+#include "XdmProtocol.h"
+#include "XdmDocument.h"
+#include "XdmOperation.h"
+#include "XdmDocumentNode.h"
+#include "XdmNodeAttribute.h"
+#include "XdmOperationFactory.h"
+
+// ----------------------------------------------------------
+// CXdmDocument::CXdmDocument
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmDocument::CXdmDocument( CXdmEngine& aXdmEngine ) :
+                                     CActive( EPriorityStandard ),
+                                     iDocSubset( EFalse ),
+                                     iXdmEngine( aXdmEngine )
+                                                
+    {
+    }
+
+// ----------------------------------------------------------
+// CXdmDocument::BaseConstructL( 16-bit )
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmDocument::BaseConstructL( TInt aOperationFactoryUid,
+                                            const TDesC& aDocumentName )
+    {
+    delete iDocumentName;
+    iDocumentName = NULL;
+    iDocumentName = HBufC::NewL( aDocumentName.Length() );
+    iDocumentName->Des().Copy( aDocumentName );
+    iOperationFactory = CXdmOperationFactory::NewL( aOperationFactoryUid );
+    }
+
+// ----------------------------------------------------------
+// CXdmDocument::BaseConstructL( 8-bit )
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmDocument::BaseConstructL( TInt aOperationFactoryUid,
+                                            const TDesC8& aDocumentName )
+    {
+    delete iDocumentName;
+    iDocumentName = NULL;
+    iDocumentName = HBufC::NewL( aDocumentName.Length() );
+    iDocumentName->Des().Copy( aDocumentName );
+    iOperationFactory = CXdmOperationFactory::NewL( aOperationFactoryUid );
+    }
+
+// ----------------------------------------------------
+// CXdmDocument::~CXdmDocument
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmDocument::~CXdmDocument()
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::~CXdmDocument()" ) );
+    #endif
+    delete iDocumentName;
+    EmptyOperationQueue();
+    iChangeRequests.Close();
+    delete iOperationFactory;
+    }
+
+// ---------------------------------------------------------
+// CXdmDocument::EmptyOperationQueue
+// 
+// ---------------------------------------------------------
+//
+void CXdmDocument::EmptyOperationQueue()
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::EmptyOperationQueue()" ) );
+    #endif
+    
+    while (iChangeRequests.Count())
+        {
+        MXdmOperation* operation = iChangeRequests[0];
+        iChangeRequests.Remove( 0 );    
+        operation->Destroy();
+        operation = NULL;
+        }
+    }
+    
+// ----------------------------------------------------
+// CXdmDocument::FetchDataL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocument::FetchDataL( CXdmDocumentNode* aDocNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::FetchDataL()" ) );
+    #endif
+    MXdmOperation* operation = iOperationFactory->FetchL( *this, aDocNode );
+    CleanupStack::PushL( operation );
+    User::LeaveIfError( iChangeRequests.Append( operation ) );
+    CleanupStack::Pop();  //operation
+    }
+
+// ----------------------------------------------------
+// CXdmDocument::ReplaceL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocument::ReplaceL( CXdmDocumentNode* aOldNode,
+                                      CXdmDocumentNode* aNewNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::ReplaceL()" ) );
+    #endif
+    if( aOldNode->Parent() == aNewNode->Parent() )
+        {
+        MXdmOperation* operation = iOperationFactory->ReplaceL(
+                                    *this, aOldNode, aNewNode );
+        CleanupStack::PushL( operation );
+        User::LeaveIfError( iChangeRequests.Append( operation ) );
+        CleanupStack::Pop();  //operation
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iXdmEngine.WriteToLog( _L8( "  Different parents, leaves!" ) );
+        #endif
+        User::Leave( KErrGeneral );
+        }
+    }
+
+// ----------------------------------------------------
+// CXdmDocument::ReplaceL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocument::ReplaceL()
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::ReplaceL()" ) );
+    #endif
+    MXdmOperation* operation = iOperationFactory->ReplaceL( *this, NULL, NULL ); 
+    CleanupStack::PushL( operation );
+    User::LeaveIfError( iChangeRequests.Append( operation ) );
+    CleanupStack::Pop();  //operation
+    }
+
+// ----------------------------------------------------
+// CXdmDocument::InsertL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocument::InsertL( CXdmDocumentNode* aDocNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::InsertL()" ) );
+    #endif
+    __ASSERT_DEBUG( aDocNode != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
+    MXdmOperation* operation = iOperationFactory->InsertL(
+                                *this, aDocNode );
+    CleanupStack::PushL( operation );
+    User::LeaveIfError( iChangeRequests.Append( operation ) );
+    CleanupStack::Pop();  //operation
+    }
+
+// ----------------------------------------------------
+// CXdmDocument::AppendL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocument::AppendL( CXdmDocumentNode* aDocNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::AppendL()" ) );
+    #endif
+    MXdmOperation* operation = 
+        iOperationFactory->AppendL( *this, aDocNode );
+    CleanupStack::PushL( operation );
+    User::LeaveIfError( iChangeRequests.Append( operation ) );
+    CleanupStack::Pop();  //operation
+    }
+      
+// ----------------------------------------------------
+// CXdmDocument::DeleteDataL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocument::DeleteDataL( CXdmDocumentNode* aDocNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::DeleteDataL()" ) );
+    #endif
+    MXdmOperation* operation = aDocNode == NULL ?
+        iOperationFactory->DeletionL( *this, NULL ) :
+        iOperationFactory->DeletionL( *this, aDocNode );
+    CleanupStack::PushL( operation );
+    User::LeaveIfError( iChangeRequests.Append( operation ) );
+    CleanupStack::Pop();  //operation
+    }
+
+// ----------------------------------------------------
+// CXdmDocument::Find
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TInt CXdmDocument::Find( const CXdmDocumentNode& aTargetNode,
+                                  RPointerArray<CXdmDocumentNode>& aResultArray ) const
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::Find()" ) );
+    #endif
+    TInt error = KErrNone;
+    CXdmDocumentNode* root = DocumentRoot();
+    __ASSERT_ALWAYS( root != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
+    if( root->NodeName().Compare( aTargetNode.NodeName() ) == 0 )
+        {
+        TBool found = EFalse;
+        TInt attrCount = root->AttributeCount();
+        TInt attrCount2 = aTargetNode.AttributeCount();
+        if( attrCount > 0 && attrCount == attrCount2 )
+            {
+            SXdmAttribute16 attribute;
+            for( TInt i = 0;i < attrCount;i++ )
+                {
+                attribute.iName.Set( aTargetNode.Attribute( i )->NodeName() );
+                attribute.iValue.Set( aTargetNode.Attribute( i )->AttributeValue() );
+                found = root->HasAttribute( attribute );
+                }
+            }
+        error = found ? aResultArray.Append( root ) : KErrNotFound;
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iXdmEngine.WriteToLog( _L8( " Root does not match, search child nodes" ) );
+        #endif
+        error = root->Find( aTargetNode, aResultArray ); 
+        }
+    TInt count = aResultArray.Count();
+    return error == KErrNone && count > 0 ? count : KErrNotFound;
+    }
+    
+// ----------------------------------------------------
+// CXdmDocument::Find
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TInt CXdmDocument::Find( const TDesC& aNodeName,
+                                  RPointerArray<CXdmDocumentNode>& aResultArray,
+                                  const RPointerArray<SXdmAttribute16>& aAttributeArray ) const
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::Find()" ) );
+    #endif
+    TInt error = KErrNone;
+    CXdmDocumentNode* root = DocumentRoot();
+    __ASSERT_ALWAYS( root != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
+    if( root->NodeName().Compare( aNodeName ) == 0 )
+        {
+        TBool found = EFalse;
+        TInt attrCount = root->AttributeCount();
+        if( attrCount > 0 )
+            {
+            for( TInt i = 0;i < attrCount;i++ )
+                found = root->HasAttribute( *aAttributeArray[i] );
+            }
+        error = found ? aResultArray.Append( root ) : KErrNotFound;
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iXdmEngine.WriteToLog( _L8( " Root does not match, search child nodes" ) );
+        #endif
+        error = root->Find( aNodeName, aResultArray, aAttributeArray ); 
+        }
+    TInt count = aResultArray.Count();
+    return error == KErrNone && count > 0 ? count : KErrNotFound;
+    }
+
+// ----------------------------------------------------
+// CXdmDocument::Find
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TInt CXdmDocument::Find( const TDesC& aNodeName,
+                                  RPointerArray<CXdmDocumentNode>& aResultArray ) const
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::Find()" ) );
+    #endif
+    TInt error = KErrNone;
+    CXdmDocumentNode* root = DocumentRoot();
+    __ASSERT_ALWAYS( root != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
+    if( root->NodeName().Compare( aNodeName ) == 0 )
+        error = aResultArray.Append( root );
+    else
+        {
+        #ifdef _DEBUG
+            iXdmEngine.WriteToLog( _L8( " Root does not match, search child nodes" ) );
+        #endif
+        error = root->Find( aNodeName, aResultArray ); 
+        }
+    TInt count = aResultArray.Count();
+    return error == KErrNone && count > 0 ? count : KErrNotFound;                            
+    }
+    
+// ----------------------------------------------------
+// CXcapDocument::operator==
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TBool CXdmDocument::operator==( CXdmDocument& aDocument ) const
+    {
+    CXdmDocumentNode* root1 = DocumentRoot();
+    CXdmDocumentNode* root2 = aDocument.DocumentRoot();
+    __ASSERT_ALWAYS( root1 != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
+    __ASSERT_ALWAYS( root2 != NULL, User::Panic( _L( "CXcapDocument" ), EDocNodeNull ) );
+    return Name().Compare( aDocument.Name() ) == 0 ? *root1 == *root2 : EFalse;
+    }
+    
+// ----------------------------------------------------
+// CXdmDocument::Name
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TPtrC CXdmDocument::Name() const
+    {
+    return iDocumentName != NULL ? iDocumentName->Des() : TPtrC();
+    }
+
+// ----------------------------------------------------
+// CXdmDocument::Find
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TInt CXdmDocument::Find( const TDesC& aAttributeName,
+                                  RPointerArray<CXdmNodeAttribute>& aResultArray ) const
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::Find()" ) );
+    #endif
+    TInt error = KErrNone;
+    CXdmDocumentNode* root = DocumentRoot();
+    __ASSERT_ALWAYS( root != NULL, User::Panic( _L( "CXdmDocument" ), EDocNodeNull ) );
+    error = DoFindAttributes( root, aAttributeName, aResultArray ); 
+    TInt count = aResultArray.Count();
+    return error == KErrNone && count > 0 ? count : KErrNotFound;                
+    }
+
+// ----------------------------------------------------
+// CXdmDocument::RemoveFromModelL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocument::RemoveFromModelL( CXdmDocumentNode* aChileNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::RemoveFromModel()" ) );
+    #endif
+    if( !iDocSubset )
+        {       
+        CXdmDocumentNode* parent = aChileNode->Parent();
+        parent != NULL ? parent->RemoveChileNodeL( aChileNode ) : User::Leave( KErrArgument);
+        }
+    else User::Leave( KErrGeneral );
+    }
+
+// ----------------------------------------------------
+// CXdmDocument::ResetSubset
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocument::ResetSubset()
+    {
+    iDocSubset = EFalse;
+    }
+      
+// ----------------------------------------------------
+// CXdmDocument::AppendToModelL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocument::AppendToModelL( CXdmDocumentNode* aNewNode,
+                                            CXdmDocumentNode* aParentNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::AppendToModelL()" ) );
+    #endif
+    if( !iDocSubset )
+        {
+        if( aNewNode != NULL && aParentNode != NULL )
+            aParentNode->AppendChileNodeL( aNewNode );
+        }
+    else User::Leave( KErrGeneral );
+    }
+        
+// ----------------------------------------------------
+// CXdmDocument::ReplaceInModelL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocument::ReplaceInModelL( CXdmDocumentNode* aNewNode,
+                                             CXdmDocumentNode* aTargetNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::ReplaceInModelL()" ) );
+    #endif
+    if( !iDocSubset )
+        {
+        CXdmDocumentNode* parent = aTargetNode->Parent();
+        parent != NULL ? parent->ReplaceChileNodeL( aNewNode, aTargetNode ) : User::Leave( KErrArgument);                                    
+        }
+    else User::Leave( KErrGeneral );
+    }
+                                       
+// ----------------------------------------------------
+// CXdmDocument::DocumentSubsetL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmDocumentNode* CXdmDocument::DocumentSubsetL( const TDesC& aNodePath )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::DocumentSubsetL()" ) );
+    #endif
+    TBool ready = EFalse;
+    HBufC* temp = HBufC::NewLC( aNodePath.Length() );
+    temp->Des().Copy( aNodePath );
+    TPtr nodePath( temp->Des() );
+    while( !ready && nodePath.Length() != 0 )
+        {
+        TPtrC part;
+        TInt index = nodePath.LocateF( KXdmPathSeparatorChar );
+        if( index > 0 )
+            part.Set( nodePath.Left( index ) );
+        else
+            {
+            part.Set( nodePath );
+            ready = ETrue;
+            }
+        AppendPathPartL( part );
+        nodePath.Delete( 0, index + 1 );
+        }
+    iDocSubset = ETrue;
+    CleanupStack::PopAndDestroy();  //temp
+    return CurrentExtent();
+    }
+        
+// ----------------------------------------------------
+// CXdmDocument::DoFindAttributes
+// 
+// ----------------------------------------------------
+//
+TInt CXdmDocument::DoFindAttributes( CXdmDocumentNode* aNode,
+								     const TDesC& aAttributeName,
+                                     RPointerArray<CXdmNodeAttribute>& aResultArray ) const
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocument::DoFindAttributes()" ) );
+    #endif
+    TInt error = KErrNone;
+	CXdmDocumentNode* node = aNode;
+	TInt attrCount = aNode->AttributeCount();
+    for( TInt i = 0; i < attrCount; i++ )
+        {
+		CXdmNodeAttribute* attr = node->Attribute( i );
+	   	if( !attr->NodeName().CompareF( aAttributeName ) )
+    	   	error = aResultArray.Append( attr );
+	   	}
+	TInt nodeCount = node->NodeCount();
+	for( TInt i = 0; i < nodeCount; i++ )
+		{
+		CXdmDocumentNode* child = node->ChileNode( i );
+	   	DoFindAttributes ( child, aAttributeName, aResultArray );
+		}  
+    TInt count = aResultArray.Count();
+    return error == KErrNone && count > 0 ? count : KErrNotFound;            
+    }
+        
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/src/XdmDocumentNode.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,1143 @@
+/*
+* 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:   XDM Engine document node
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XdmEngine.h"
+#include "XdmDocument.h"
+#include "XdmNodeFactory.h"
+#include "XdmDocumentNode.h"
+#include "XdmNodeAttribute.h"
+
+//XML Escape codes
+_LIT8( KXmlBracketOpenEsc,                             "&lt;");
+_LIT8( KXmlBracketCloseEsc,                            "&gt;");
+_LIT8( KXmlAmpersandEsc,                               "&amp;");
+      
+// ----------------------------------------------------------
+// CXdmDocumentNode::CXdmDocumentNode
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmDocumentNode::CXdmDocumentNode( CXdmEngine& aXdmEngine,
+                                             MXdmNodeFactory& aNodeFactory ) :
+                                             iPosition( KErrNotFound ),
+                                             iEmptyNode( EFalse ),
+                                             iXdmEngine( aXdmEngine ),
+                                             iNodeFactory( aNodeFactory )                                           
+    {
+    }
+
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::CXdmDocumentNode
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmDocumentNode::CXdmDocumentNode( CXdmEngine& aXdmEngine,
+                                             MXdmNodeFactory& aNodeFactory,
+                                             CXdmDocumentNode* aParentNode ) :
+                                             iEmptyNode( EFalse ),
+                                             iXdmEngine( aXdmEngine ),
+                                             iNodeFactory( aNodeFactory ),
+                                             iParentNode( aParentNode )
+                                                
+    {   
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::CXdmDocumentNode
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmDocumentNode::CXdmDocumentNode( const TBool aLeafNode,
+                                             CXdmEngine& aXdmEngine,
+                                             MXdmNodeFactory& aNodeFactory,
+                                             CXdmDocumentNode* aParentNode ) :
+                                             iLeafNode( aLeafNode ),
+                                             iEmptyNode( EFalse ),
+                                             iXdmEngine( aXdmEngine ),
+                                             iNodeFactory( aNodeFactory ),
+                                             iParentNode( aParentNode )
+                                                
+    {
+    
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::ConstructL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::BaseConstructL( const TDesC& aNodeName )
+    {
+    delete iNodeName;
+    iNodeName = NULL;
+    iNodeName = HBufC::NewL( aNodeName.Length() );
+    iNodeName->Des().Copy( aNodeName );
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::CopyConstructL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::CopyConstructL( const CXdmDocumentNode& aAnotherNode,
+		                                        const CXdmDocumentNode& aParentNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CopyConstructL()" ) );
+    #endif
+    if( aAnotherNode.ElementType() != EXdmElementAttribute )
+        {
+        ConstructChildrenL( aAnotherNode );
+        ConstructAttributesL( aAnotherNode );
+        }
+    iLeafNode = aAnotherNode.IsLeafNode();
+    iEmptyNode = aAnotherNode.IsEmptyNode();
+    if( iLeafNode )
+        {
+        iLeafContent = HBufC8::New( aAnotherNode.LeafNodeContent().Length() );
+        iLeafContent->Des().Copy( aAnotherNode.LeafNodeContent() );
+        }
+    iParentNode = CONST_CAST( CXdmDocumentNode*, &aParentNode ); 
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::ConstructAttributesL
+// 
+// ----------------------------------------------------------
+//
+void CXdmDocumentNode::ConstructAttributesL( const CXdmDocumentNode& aAnotherNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CopyConstructL()" ) );
+    #endif
+    TInt attrCount = aAnotherNode.AttributeCount();
+    for( TInt i = 0;i < attrCount;i++ )
+        {
+        TPtrC name = aAnotherNode.Attribute( i )->NodeName();
+        TPtrC value = aAnotherNode.Attribute( i )->AttributeValue();
+        CXdmNodeAttribute* attribute = iNodeFactory.AttributeL( name );
+        CleanupStack::PushL( attribute );
+        attribute->SetAttributeValueL( value );
+        User::LeaveIfError( iAttributes.Append( attribute ) );
+        CleanupStack::Pop();  //attribute
+        }
+    }
+    
+// ----------------------------------------------------------
+// CXdmDocumentNode::ConstructChildrenL
+// 
+// ----------------------------------------------------------
+//
+void CXdmDocumentNode::ConstructChildrenL( const CXdmDocumentNode& aAnotherNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::ConstructChildrenL()" ) );
+    #endif
+    TInt childCount = aAnotherNode.NodeCount();
+    for( TInt i = 0;i < childCount;i++ )
+        {
+        CXdmDocumentNode* node = aAnotherNode.ChileNode( i );
+        CXdmDocumentNode* copy = iNodeFactory.ChileNodeL( node );
+        CleanupStack::PushL( copy );
+        User::LeaveIfError( iChildren.Append( copy ) );
+        CleanupStack::Pop();  //copy
+        }
+    }
+       
+// ----------------------------------------------------
+// CXdmDocumentNode::~CXdmDocumentNode
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmDocumentNode::~CXdmDocumentNode()
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::~CXdmDocumentNode()" ) );
+    #endif
+    delete iNextNode;
+    iNextNode = NULL;
+    delete iLeafContent;
+    delete iNodeName;
+    iChildren.ResetAndDestroy();
+    iChildren.Close();
+    iAttributes.ResetAndDestroy();
+    iAttributes.Close();
+    }
+
+// ----------------------------------------------------
+// CXdmDocumentNode::CreateChileNodeL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmDocumentNode* CXdmDocumentNode::CreateChileNodeL()
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CreateChileNodeL()" ) );
+    #endif*/
+    __ASSERT_ALWAYS( !iEmptyNode, User::Panic( _L( "CXdmDocumentNode" ), ENodeNotEmpty ) );
+    CXdmDocumentNode* node = iNodeFactory.ChileNodeL();
+    CleanupStack::PushL( node );
+    User::LeaveIfError( iChildren.Append( node ) );
+    CleanupStack::Pop();  //node
+    return node;
+    }
+    
+// ----------------------------------------------------
+// CXdmDocumentNode::CreateChileNodeL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmDocumentNode* CXdmDocumentNode::CreateChileNodeL( const TDesC& aChildName )
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CreateChileNodeL() - Name: %S" ), &aChildName );
+    #endif*/
+    __ASSERT_ALWAYS( !iEmptyNode, User::Panic( _L( "CXdmDocumentNode" ), ENodeNotEmpty ) );
+    CXdmDocumentNode* node = iNodeFactory.ChileNodeL( aChildName );
+    CleanupStack::PushL( node );
+    User::LeaveIfError( iChildren.Append( node ) );
+    CleanupStack::Pop();  //node
+    return node;
+    }
+
+// ----------------------------------------------------
+// CXdmDocumentNode::SetLeafNode
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::SetLeafNode( const TBool aIsLeafNode )
+    {
+    iLeafNode = aIsLeafNode;
+    }
+        
+// ----------------------------------------------------
+// CXdmDocumentNode::IsLeafNode
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TBool CXdmDocumentNode::IsLeafNode() const
+    {
+    return iLeafNode;
+    }
+
+// ----------------------------------------------------
+// CXdmDocumentNode::SetEmptyNode
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::SetEmptyNode( const TBool aIsEmptyNode )
+    {
+    //Do nothing if the state is not being changed
+    if( aIsEmptyNode != iEmptyNode )
+        {    
+        if( aIsEmptyNode )
+            {
+            if( !iEmptyNode )
+                {
+                TInt count = iChildren.Count();
+                if( count > 0 )
+                    iChildren.ResetAndDestroy();
+                }
+            }
+        iEmptyNode = aIsEmptyNode;
+        }
+    }
+        
+// ----------------------------------------------------
+// CXdmDocumentNode::IsEmptyNode
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TBool CXdmDocumentNode::IsEmptyNode() const
+    {
+    return iEmptyNode;
+    }
+    
+// ----------------------------------------------------
+// CXdmDocumentNode::CreateAttributeL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmNodeAttribute* CXdmDocumentNode::CreateAttributeL()
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CreateAttributeL()" ) );
+    #endif*/
+    CXdmDocumentNode* node = iNodeFactory.AttributeL();
+    CleanupStack::PushL( node );
+    User::LeaveIfError( iAttributes.Append( ( CXdmNodeAttribute* )node ) );
+    CleanupStack::Pop();  //node
+    return ( CXdmNodeAttribute* )node;
+    }
+    
+// ----------------------------------------------------
+// CXdmDocumentNode::CreateAttributeL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmNodeAttribute* CXdmDocumentNode::CreateAttributeL( const TDesC& aAttributeName )
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CreateAttributeL() - Name: %S" ), &aAttributeName );
+    #endif*/
+    CXdmDocumentNode* node = iNodeFactory.AttributeL( aAttributeName );
+    CleanupStack::PushL( node );
+    User::LeaveIfError( iAttributes.Append( ( CXdmNodeAttribute* )node ) );
+    CleanupStack::Pop();  //node
+    return ( CXdmNodeAttribute* )node;
+    }
+    
+// ----------------------------------------------------
+// CXdmDocumentNode::SetLeafNodeContentL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::SetLeafNodeContentL( const TDesC& aLeafContent )
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::SetLeafNodeContentL( 16 ) - Content: %S" ),
+                                &aLeafContent );
+    #endif*/
+    if( iLeafNode )
+        {
+        delete iLeafContent;
+        iLeafContent = NULL;
+        iLeafContent = CXdmEngine::ConvertToUTF8L( aLeafContent );
+        }
+    else
+        User::Leave( KErrGeneral );
+    }
+
+// ----------------------------------------------------
+// CXdmDocumentNode::SetLeafNodeContentL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::SetLeafNodeContentL( const TDesC8& aLeafContent )
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::SetLeafNodeContentL( 8 ) - Content: %S" ),
+                                &aLeafContent );
+    #endif*/
+    if( iLeafNode )
+        {
+        delete iLeafContent;
+        iLeafContent = NULL;
+        iLeafContent = HBufC8::NewL( aLeafContent.Length() );
+        iLeafContent->Des().Copy( aLeafContent );
+        }
+    else
+        User::Leave( KErrGeneral );
+    }
+
+// ----------------------------------------------------
+// CXdmDocumentNode::ElementData
+// 
+// ----------------------------------------------------
+//
+EXPORT_C HBufC8* CXdmDocumentNode::ElementDataLC() const
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::ElementDataLC()" ) );
+    #endif*/
+    TInt position = 0;
+    CBufFlat* buffer = CBufFlat::NewL( 48 );
+    CleanupStack::PushL( buffer );
+    buffer->InsertL( position, EightBitNodeNameLC()->Des() );
+    CleanupStack::PopAndDestroy();   //EightBitNodeNameLC()
+    position = position + NodeName().Length();
+    TInt attributeCount = iAttributes.Count();
+    if( attributeCount > 0 )
+        {
+        for( TInt i = 0;i < attributeCount;i++ )
+            {
+            buffer->InsertL( position, KGeneralSpace );
+            position = position + KGeneralSpace().Length();
+            CXdmNodeAttribute* attribute = iAttributes[i];
+            TPtrC8 name( attribute->EightBitNodeNameLC()->Des() );
+            buffer->InsertL( position, name );
+            position = position + name.Length();
+            buffer->InsertL( position, KGeneralEqualsAndQuotes );
+            position = position + KGeneralEqualsAndQuotes().Length();
+            TPtrC8 value( attribute->EscapedValueLC()->Des() );
+            buffer->InsertL( position, value );
+            position = position + value.Length();
+            buffer->InsertL( position, KGeneralQuotes );
+            position = position + KGeneralQuotes().Length();
+            CleanupStack::PopAndDestroy( 2 );  //EscapedValueLC(),
+                                               //EightBitNodeNameLC()
+            }
+        }
+    HBufC8* ret = HBufC8::NewL( buffer->Size() );
+    TPtr8 pointer( ret->Des() );
+    buffer->Read( 0, pointer, buffer->Size() );
+    CleanupStack::PopAndDestroy();  //buffer
+    CleanupStack::PushL( ret );
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXdmNodeAttribute::NodeCount
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TInt CXdmDocumentNode::NodeCount() const
+    {
+    return iNextNode ? 1 : iChildren.Count();
+    }
+
+// ----------------------------------------------------------
+// CXdmNodeAttribute::NodeCount
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TInt CXdmDocumentNode::AttributeCount() const
+    {
+    return iAttributes.Count();
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::Parent
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmDocumentNode* CXdmDocumentNode::ChileNode( const TInt aPosition ) const
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::ChileNode() - Position: %d" ), aPosition );
+    #endif*/
+    if( iNextNode )
+        return iNextNode;
+    else
+        {   
+        TInt count = NodeCount();
+        if( count > 0 && aPosition >= 0 && aPosition < count )
+            return iChildren[aPosition];
+        else return NULL;
+        }
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::Attribute
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmNodeAttribute* CXdmDocumentNode::Attribute( const TInt aPosition ) const
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Attribute() - Position: %d" ), aPosition );
+    #endif*/
+    TInt count = iAttributes.Count();
+    if( count > 0 && aPosition >= 0 && aPosition < count )
+        return iAttributes[aPosition];
+    else return NULL;
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::Attribute
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmNodeAttribute* CXdmDocumentNode::Attribute( const TDesC& aAttributeName ) const
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Attribute() - Name: %S" ), &aAttributeName );
+    #endif*/
+    TInt count = iAttributes.Count();
+    if( count > 0 )
+        {
+        TBool found = EFalse;
+        CXdmNodeAttribute* target = NULL;
+        for( TInt i = 0;!found && i < count;i++ )
+            {
+            if( iAttributes[i]->NodeName().Compare( aAttributeName ) == 0 )
+                {
+                target = iAttributes[i];
+                found = ETrue;
+                }
+            }
+        return target;
+        }
+    else return NULL;
+    }
+    
+// ----------------------------------------------------------
+// CXdmDocumentNode::Parent
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TPtrC8 CXdmDocumentNode::LeafNodeContent() const
+    {
+    return iLeafNode && iLeafContent != NULL ? iLeafContent->Des() : TPtrC8();
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::Parent
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C HBufC8* CXdmDocumentNode::EscapeLeafNodeContentLC() const
+    {
+    return iLeafNode && iLeafContent != NULL ? EscapeDescLC( iLeafContent->Des() ) : NULL;
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::SetNextNode
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TPtrC CXdmDocumentNode::NodeName() const
+    {
+    return iNodeName != NULL ? iNodeName->Des() : TPtrC();
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::SetNextNode
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C HBufC8* CXdmDocumentNode::EightBitNodeNameLC() const
+    {
+    HBufC8* eightBit = CXdmEngine::ConvertToUTF8L( iNodeName->Des() );
+    CleanupStack::PushL( eightBit );
+    return eightBit;
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::SetNextNode
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::SetNameL( const TDesC& aNodeName )
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::SetNameL( 16-Bit ) - Name: %S" ),
+                                &aNodeName );
+    #endif*/
+    delete iNodeName;
+    iNodeName = NULL;
+    iNodeName = HBufC::NewL( aNodeName.Length() );
+    iNodeName->Des().Copy( aNodeName );
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::SetNextNode
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::SetNameL( const TDesC8& aNodeName )
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::SetNameL( 8-Bit ) - Name: %S" ),
+                                &aNodeName );
+    #endif*/
+    delete iNodeName;
+    iNodeName = NULL;
+    iNodeName = HBufC::NewL( aNodeName.Length() );
+    iNodeName->Des().Copy( aNodeName );
+    }
+        
+// ----------------------------------------------------------
+// CXdmNodeAttribute::ElementType
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmDocumentNode* CXdmDocumentNode::Parent() const
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Parent()" ) );
+    #endif*/
+    return iParentNode;
+    }
+
+// ----------------------------------------------------------
+// CXdmNodeAttribute::ElementType
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TXdmElementType CXdmDocumentNode::ElementType() const
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::ElementType()" ) );
+    #endif*/
+    return EXdmElementNode;
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::Match
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TBool CXdmDocumentNode::Match( const CXdmDocumentNode& aAnotherNode ) const
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Match()" ) );
+    #endif
+    if( NodeName().Compare( aAnotherNode.NodeName() ) == 0 )
+        {
+        TBool match = ETrue;
+        TInt attrCount = iAttributes.Count();
+        if( attrCount == aAnotherNode.AttributeCount() )
+            {
+            for( TInt i = 0;match && i < attrCount;i++ )
+                match = HasAttribute( *aAnotherNode.Attribute( i ) );
+            }
+        else match = EFalse;
+        return match;
+        }
+    else return EFalse;
+    }
+    
+// ----------------------------------------------------------
+// CXdmDocumentNode::Match
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TBool CXdmDocumentNode::Match( const TDesC& aNodeName,
+                                        const RPointerArray<SXdmAttribute8>&
+                                        aAttributeArray ) const
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Match()" ) );
+    #endif
+    if( NodeName().Compare( aNodeName ) == 0 )
+        {
+        TBool match = ETrue;
+        TInt attrCount = iAttributes.Count();
+        if( attrCount == aAttributeArray.Count() )
+            {
+            for( TInt i = 0;match && i < attrCount;i++ )
+                match = HasAttributeL( *aAttributeArray[i] );
+            }
+        else match = EFalse;
+        return match;
+        }
+    else return EFalse;
+    }
+
+// ---------------------------------------------------------
+// CXdmDocumentNode::HasAttribute
+// 
+// ---------------------------------------------------------
+//
+EXPORT_C TBool CXdmDocumentNode::HasAttribute( const TDesC& aAttributeName ) const
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::HasAttribute()" ) );
+    #endif
+    TInt count = iAttributes.Count();
+    for( TInt i = 0; i < count;i++ )
+        {
+        if( !iAttributes[i]->NodeName().Compare( aAttributeName ) )
+        	return ETrue;
+        }
+    return EFalse;
+    }  
+
+// ---------------------------------------------------------
+// CXdmDocumentNode::Print
+// !!! For debugging ONLY !!!
+// ---------------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::Print()
+	{
+    iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Print()" ) );
+	HBufC8* nameBuf = HBufC8::NewLC( iNodeName->Des().Length() );
+	TPtr8 name( nameBuf->Des() );
+	name.Copy( iNodeName->Des() );
+	if( ElementType() == EXdmElementAttribute )
+	    {
+	    CXdmNodeAttribute* attr = ( CXdmNodeAttribute* )this;
+	    TPtrC8 value( attr->EightBitValueLC()->Des() );
+	    iXdmEngine.WriteToLog( _L8( "* Name: %S  Value: %S" ), &name, &value );
+	    CleanupStack::PopAndDestroy();  //value
+	    }
+	else
+    	{
+	   	iXdmEngine.WriteToLog( _L8( "* Name: %S" ), &name );
+	    TInt count = iAttributes.Count();
+        if( count > 0 )
+            {
+            for( TInt i = 0;i < count;i++ )
+                {
+                CXdmNodeAttribute* attr = iAttributes[i];
+                TPtrC8 value( attr->EightBitValueLC()->Des() );
+                TPtrC8 name( attr->EightBitNodeNameLC()->Des() );
+                iXdmEngine.WriteToLog( _L8( "* Attribute %d - Name: %S  Value: %S" ), i, &name, &value );
+                CleanupStack::PopAndDestroy( 2 );  //name, value
+                }
+        
+            }
+        if( iLeafNode )
+            {
+            TPtr8 data( iLeafContent->Des() );
+            iXdmEngine.WriteToLog( _L8( "* Data: %S" ), &data );
+            }
+        CXdmDocumentNode* node = NULL;
+        TInt nodeCount = NodeCount();
+        for( TInt i = 0;i < nodeCount;i++ )
+            {
+            node = ChileNode( i );
+            node->Print();
+            }
+	    }
+    CleanupStack::PopAndDestroy();  //nameBuf
+	}
+
+// ---------------------------------------------------------
+// CXdmDocumentNode::Find
+// 
+// ---------------------------------------------------------
+//
+EXPORT_C TInt CXdmDocumentNode::Find( const TDesC& aNodeName,
+                                      RPointerArray<CXdmDocumentNode>& aResultArray ) const
+    {
+    TInt error = KErrNotFound;
+    TInt childCount = NodeCount();
+    if( childCount > 0 )
+        {
+        for( TInt i = 0;i < childCount;i++ )
+            error = ChileNode( i )->DoFind( aNodeName, aResultArray );
+        }
+    return error;
+    }
+
+// ---------------------------------------------------------
+// CXdmDocumentNode::DoFind
+// 
+// ---------------------------------------------------------
+//
+TInt CXdmDocumentNode::DoFind( const TDesC& aNodeName,
+                               RPointerArray<CXdmDocumentNode>& aResultArray ) const
+    {
+    TInt error = KErrNone;
+    if( NodeName().Compare( aNodeName ) == 0 )
+        error = aResultArray.Append( this );
+    if( error == KErrNone )
+        {
+        TInt childCount = NodeCount();
+        if( childCount > 0 )
+            {
+            for( TInt i = 0;i < childCount;i++ )
+                error = ChileNode( i )->DoFind( aNodeName, aResultArray );
+            }
+        }
+    return error;
+    }
+        
+// ---------------------------------------------------------
+// CXdmDocumentNode::Find
+// 
+// ---------------------------------------------------------
+//
+EXPORT_C TInt CXdmDocumentNode::Find( const CXdmDocumentNode& aTargetNode,
+                                      RPointerArray<CXdmDocumentNode>& aResultArray ) const
+    {
+    TInt error = KErrNotFound;
+    TInt childCount = NodeCount();
+    if( childCount > 0 )
+        {
+        for( TInt i = 0;i < childCount;i++ )
+            error = ChileNode( i )->DoFind( aTargetNode, aResultArray );
+        }
+    return error;                        
+    }
+
+// ---------------------------------------------------------
+// CXdmDocumentNode::Find
+// 
+// ---------------------------------------------------------
+//
+TInt CXdmDocumentNode::DoFind( const CXdmDocumentNode& aTargetNode,
+                               RPointerArray<CXdmDocumentNode>& aResultArray ) const
+    {
+    TInt error = KErrNone;
+    if( *this == aTargetNode )
+        error = aResultArray.Append( this );
+    if( error == KErrNone )
+        {
+        TInt childCount = NodeCount();
+        if( childCount > 0 )
+            {
+            for( TInt i = 0;i < childCount;i++ )
+                error = ChileNode( i )->DoFind( aTargetNode, aResultArray );
+            }
+        }
+    return error;                        
+    }
+       
+// ---------------------------------------------------------
+// CXdmDocumentNode::Find
+// 
+// ---------------------------------------------------------
+//
+EXPORT_C TInt CXdmDocumentNode::Find( const TDesC& aNodeName,
+                                      RPointerArray<CXdmDocumentNode>& aResultArray,
+                                      const RPointerArray<SXdmAttribute16>& aAttributeArray ) const
+    {
+    TInt error = KErrNone;
+    TInt childCount = NodeCount();
+    if( childCount > 0 )
+        {
+        for( TInt j = 0;j < childCount;j++ )
+            error = ChileNode( j )->DoFind( aNodeName, aResultArray, aAttributeArray );
+        }
+    return error;
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpOperation::RemoveNamespaceAttributes
+//
+// ---------------------------------------------------------
+//
+void CXdmDocumentNode::RemoveNamespaceAttributes()
+    {
+    _LIT( KXmlNamespaceAttr, "xmlns" );
+    for( TInt i( iAttributes.Count() - 1 ); i > KErrNotFound; i--  )
+        {
+        CXdmNodeAttribute* attr( iAttributes[i] );
+        if( attr->NodeName().Find( KXmlNamespaceAttr ) == 0 )
+            {
+            iAttributes.Remove( i );
+            delete attr;
+            attr = NULL;
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CXdmDocumentNode::DoFind
+// 
+// ---------------------------------------------------------
+//
+TInt CXdmDocumentNode::DoFind( const TDesC& aNodeName,
+                               RPointerArray<CXdmDocumentNode>& aResultArray,
+                               const RPointerArray<SXdmAttribute16>& aAttributeArray )
+    {
+    TBool match = EFalse;
+    TInt error = KErrNone;
+    if( NodeName().Compare( aNodeName ) == 0 )
+        {
+        match = ETrue;
+        RemoveNamespaceAttributes();
+        TInt attrCount = iAttributes.Count();
+        if( attrCount == aAttributeArray.Count() )
+            {
+            if( attrCount > 0 )
+                {
+                for( TInt i = 0;i < attrCount;i++ )
+                    match = HasAttribute( *aAttributeArray[i] );
+                }
+            }
+        else match = EFalse;
+        error = match ? aResultArray.Append( this ) : KErrNotFound;
+        }
+    TInt childCount = NodeCount();
+    if( childCount > 0 )
+        {
+        for( TInt j = 0;j < childCount;j++ )
+            error = ChileNode( j )->DoFind( aNodeName, aResultArray, aAttributeArray );
+        }
+    return error;
+    }
+   
+// ---------------------------------------------------------
+// CXdmDocumentNode::operator==
+// 
+// ---------------------------------------------------------
+//
+EXPORT_C TBool CXdmDocumentNode::operator==( const CXdmDocumentNode& aNode ) const
+    {
+    TBool match = EFalse;
+    if( NodeName().Compare( aNode.NodeName() ) == 0 )
+        {
+        match = ETrue;
+        TInt attrCount = iAttributes.Count();
+        if( attrCount == aNode.AttributeCount() )
+            {
+            if( attrCount > 0 )
+                {
+                for( TInt i = 0;i < attrCount;i++ )
+                    match = aNode.HasAttribute( *iAttributes[i] );
+                }
+            }
+        if( match )
+            {
+            TInt childCount = NodeCount();
+            if( childCount == aNode.NodeCount() )
+                {   
+                if( childCount > 0 )
+                    {
+                    for( TInt j = 0;j < childCount;j++ )
+                        {
+                        match = *ChileNode( j ) == *aNode.ChileNode( j );
+                        if( !match )
+                            break;
+                        }
+                    } 
+                }
+            else match = EFalse; 
+            }
+        else match = EFalse; 
+        }
+    return match;
+    }
+
+// ----------------------------------------------------
+// CXdmDocumentNode::AppendChileNodeL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::AppendChileNodeL( CXdmDocumentNode* aDocumentNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CLocalDocument::AppendChileNodeL()" ) );
+    #endif
+    CXdmDocumentNode* node = iNodeFactory.ChileNodeL( aDocumentNode );
+    CleanupStack::PushL( node );
+    User::LeaveIfError( iChildren.Append( node ) );
+    CleanupStack::Pop();  //node
+    }
+
+// ----------------------------------------------------
+// CXdmDocumentNode::InsertChileNodeL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::InsertChileNodeL( TInt aIndex, CXdmDocumentNode* aDocumentNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CLocalDocument::InsertChileNodeL()" ) );
+    #endif
+    __ASSERT_ALWAYS( aIndex >= 0, User::Panic( _L( "CXdmDocumentNode" ), EIndexOutOfBounds ) );
+    CXdmDocumentNode* node = iNodeFactory.ChileNodeL( aDocumentNode );
+    CleanupStack::PushL( node );
+    User::LeaveIfError( iChildren.Insert( node, aIndex ) );
+    CleanupStack::Pop();  //node
+    }
+    
+// ----------------------------------------------------
+// CXdmDocumentNode::ReplaceChileNodeL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::ReplaceChileNodeL( CXdmDocumentNode* aNewNode,
+                                                   CXdmDocumentNode* aTargetNode )
+    {
+    CXdmDocumentNode* remove = NULL;
+    TInt index = iChildren.Find( aTargetNode );
+    #ifdef _DEBUG
+        CXdmDocumentNode* a = NULL;
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::ReplaceChileNodeL()" ) );
+        iXdmEngine.WriteToLog( _L8( "  New node:    %x" ), aNewNode );
+        iXdmEngine.WriteToLog( _L8( "  Target node: %x" ), aTargetNode );
+        for( TInt i = 0;i < iChildren.Count();i++ )
+            {
+            a = iChildren[i];
+            iXdmEngine.WriteToLog( _L8( "  Child %d: %x" ), i, a );
+            }
+    #endif
+    __ASSERT_DEBUG( index >= 0, User::Panic( _L( "CXdmDocumentNode" ), EIndexOutOfBounds ) );
+    remove = iChildren[index];
+    iChildren.Remove( index );
+    delete remove;
+    remove = NULL;
+    CXdmDocumentNode* node = iNodeFactory.ChileNodeL( aNewNode );
+    CleanupStack::PushL( node );
+    User::LeaveIfError( iChildren.Insert( node, index ) );
+    CleanupStack::Pop();  //node
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::RemoveChileNodeL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::RemoveChileNodeL( CXdmDocumentNode* aChileNode )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::RemoveChileNodeL()" ) );
+    #endif
+    CXdmDocumentNode* remove = NULL;
+    switch( aChileNode->ElementType() )
+        {
+        case EXdmElementNode:
+            {
+            #ifdef _DEBUG
+                iXdmEngine.WriteToLog( _L8( "  Element is a node" ) );
+            #endif
+            TInt index( iChildren.Find( aChileNode ) );
+            __ASSERT_DEBUG( index >= 0, User::Panic( _L( "CXdmDocumentNode" ), EIndexOutOfBounds ) );
+            remove = iChildren[index];
+            iChildren.Remove( index );
+            delete remove;
+            remove = NULL;
+            }
+            break;
+        case EXdmElementAttribute:
+            {
+            #ifdef _DEBUG
+                iXdmEngine.WriteToLog( _L8( "  Element is an attribute" ) );
+            #endif
+            TInt index( iAttributes.Find( ( CXdmNodeAttribute* )aChileNode ) );
+            __ASSERT_DEBUG( index >= 0, User::Panic( _L( "CXdmDocumentNode" ), EIndexOutOfBounds ) );
+            remove = iAttributes[index];
+            iAttributes.Remove( index );
+            delete remove;
+            remove = NULL;
+            }
+            break;
+        default: 
+            #ifdef _DEBUG
+                iXdmEngine.WriteToLog( _L8( "  Element is of undefined type, ignore" ) );
+            #endif
+            break;
+        }
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::NextNode
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmDocumentNode* CXdmDocumentNode::NextNode() const
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXcapDocumentNode::NextNode()" ) );
+    #endif*/
+    return iNextNode;
+    }
+
+// ----------------------------------------------------------
+// CXcapDocumentNode::SetNextNode
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmDocumentNode::SetNextNode( CXdmDocumentNode* aNextNode )
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::SetNextNode()" ) );
+    #endif*/
+    __ASSERT_DEBUG( aNextNode != NULL, User::Panic( _L( "CXdmDocumentNode" ), EDocNodeNull ) );
+    iNextNode = aNextNode;
+    }
+    
+// ---------------------------------------------------------
+// CXdmDocumentNode::EscapeDescLC
+//
+// ---------------------------------------------------------
+//
+HBufC8* CXdmDocumentNode::EscapeDescLC( const TDesC8& aDescriptor ) const
+    {
+    /*#ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::EscapeDescLC()" ) );
+    #endif*/
+    TInt bufPos = 0;
+    TBuf8<10> format;
+    HBufC8* ret = NULL;
+    CBufFlat* buffer = CBufFlat::NewL( 50 );
+    CleanupStack::PushL( buffer );
+    for( TInt i = 0;i < aDescriptor.Length();i++ )
+        {
+        TUint8 byte = aDescriptor[i];
+        switch( byte )
+            {
+            case 0x26:                  //'&'
+                format.Append( KXmlAmpersandEsc );
+                break;
+            case 0x3C:                  //'<'
+                format.Append( KXmlBracketOpenEsc );
+                break;
+            case 0x3E:                  //'>'
+                format.Append( KXmlBracketCloseEsc );
+                break;
+            default:
+                format.Append( byte );
+                break;
+            }
+        buffer->InsertL( bufPos, format );
+        bufPos = bufPos + format.Length();
+        format.Zero();
+        }
+    ret = HBufC8::NewL( buffer->Size() );
+    ret->Des().Copy( buffer->BackPtr( buffer->Size() ) );
+    CleanupStack::PopAndDestroy();  //buffer
+    CleanupStack::PushL( ret );
+    return ret;
+    }
+           
+// ---------------------------------------------------------
+// CXdmDocumentNode::HasAttribute
+// 
+// ---------------------------------------------------------
+//
+TBool CXdmDocumentNode::HasAttribute( const CXdmNodeAttribute& aAttribute ) const
+    {
+    TBool ret = EFalse;
+    TInt count = iAttributes.Count();
+    for( TInt i = 0;i < count && !ret;i++ )
+        {
+        ret = iAttributes[i]->NodeName().Compare( aAttribute.NodeName() ) == 0 &&
+              iAttributes[i]->AttributeValue().Compare( aAttribute.AttributeValue() ) == 0;
+        }
+    return ret;
+    }
+
+// ---------------------------------------------------------
+// CXdmDocumentNode::HasAttribute
+// 
+// ---------------------------------------------------------
+//
+TBool CXdmDocumentNode::HasAttributeL( const SXdmAttribute8& aAttribute ) const
+    {
+    TBool ret = EFalse;
+    TInt count = iAttributes.Count();
+    for( TInt i = 0;i < count && !ret;i++ )
+        {
+        HBufC8* name = CXdmEngine::ConvertToUTF8L( iAttributes[i]->NodeName() );
+        CleanupStack::PushL( name );
+        HBufC8* value = CXdmEngine::ConvertToUTF8L( iAttributes[i]->AttributeValue() );
+        CleanupStack::PushL( value );
+        ret = name->Des().Compare( aAttribute.iName ) == 0 &&
+              value->Des().Compare( aAttribute.iValue ) == 0;
+        CleanupStack::PopAndDestroy( 2 );  //value, name
+        }
+    return ret;
+    }  
+       
+// ---------------------------------------------------------
+// CXdmDocumentNode::HasAttribute
+// 
+// ---------------------------------------------------------
+//
+TBool CXdmDocumentNode::HasAttribute( const SXdmAttribute16& aAttribute ) const
+    {
+    TBool ret = EFalse;
+    TInt count = iAttributes.Count();
+    for( TInt i = 0;i < count && !ret;i++ )
+        {
+        ret = iAttributes[i]->NodeName().Compare( aAttribute.iName ) == 0 &&
+              iAttributes[i]->AttributeValue().Compare( aAttribute.iValue ) == 0;
+        }
+    return ret;
+    }  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/src/XdmEngine.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,446 @@
+/*
+* 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:   XDM Engine
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <utf.h>
+#include <ecom.h>
+#include <f32file.h>
+#include <flogger.h>
+#include "XdmEngine.h"
+#include "XdmDocument.h"
+#include "XdmProtocol.h"
+#include "XdmDirectory.h"
+#include "XdmLogWriter.h"
+#include "XdmStaticUtils.h"
+#include "XdmSettingsApi.h"
+#include "XdmProtocolInfo.h"
+
+// ----------------------------------------------------------
+// CXdmEngine::CXdmEngine
+// 
+// ----------------------------------------------------------
+//
+CXdmEngine::CXdmEngine() : CActive( EPriorityStandard )                                           
+    {  
+    }
+
+// ----------------------------------------------------------
+// CXdmEngine::NewL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmEngine* CXdmEngine::NewL( const CXdmProtocolInfo& aProtocolInfo )
+    {
+    CXdmEngine* self = new ( ELeave ) CXdmEngine();
+    CleanupStack::PushL( self );
+    self->ConstructL( CONST_CAST( CXdmProtocolInfo&, aProtocolInfo ) );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXdmEngine::XdmSettingsLC
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CDesC16Array* CXdmEngine::XdmSettingsLC( RArray<TInt>& aSettingIds )
+    {
+    return TXdmSettingsApi::CollectionNamesLC( aSettingIds );
+    }
+    
+// ----------------------------------------------------------
+// CXdmEngine::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXdmEngine::ConstructL( CXdmProtocolInfo& aProtocolInfo )
+    {
+    #ifdef _DEBUG
+        iLogWriter = CXdmLogWriter::NewL( KXdmEngLogFile );
+        WriteToLog( _L8( "CXdmEngine::ConstructL()" ) );
+    #endif
+    TRAPD( error, iXdmProtocol = CXdmProtocol::NewL( *this, aProtocolInfo ) );
+    if( error == KErrNone && iXdmProtocol != NULL )
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( " Protocol implementation created successfully" ) );
+        #endif
+        CActiveScheduler::Add( this );
+        }
+    else
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( " Protocol creation failed - Error: %d  Protocol: %x" ), error, iXdmProtocol );
+        #endif
+        User::Leave( KErrUnknown );
+        }
+    }
+
+// ----------------------------------------------------
+// CXdmEngine::~CXdmEngine
+// 
+// ----------------------------------------------------
+//
+CXdmEngine::~CXdmEngine()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::~CXdmEngine()" ) );
+    #endif
+    iDocUpdateQueue.Close();
+    iDirUpdateQueue.Close();
+    iDocumentQueue.Close();
+    iDirectoryQueue.Close();
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  Queues closed" ) );
+    #endif
+    delete iXdmProtocol;
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  Protocol deleted" ) );
+    #endif
+    REComSession::FinalClose();
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  Destructor finished" ) );
+    #endif
+    delete iLogWriter;
+    }
+
+// ----------------------------------------------------------
+// CXdmEngine::WriteToLog
+// 
+// ----------------------------------------------------------
+//
+void CXdmEngine::WriteToLog( TRefByValue<const TDesC8> aFmt,... ) const                                 
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf8<KLogBufferMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    iLogWriter->WriteToLog( buf );
+    }
+    
+// ----------------------------------------------------
+// CXdmEngine::DirectoryCollection
+// 
+// ----------------------------------------------------
+//
+EXPORT_C const RPointerArray<CXdmDocument>& CXdmEngine::DocumentCollection() const
+    {
+    return iDocumentQueue;
+    }
+
+// ----------------------------------------------------
+// CXdmEngine::DirectoryCollection
+// 
+// ----------------------------------------------------
+//
+EXPORT_C const RPointerArray<CXdmDirectory>& CXdmEngine::DirectoryCollection() const
+    {
+    return iDirectoryQueue;
+    }
+        
+    
+// ----------------------------------------------------
+// CXdmEngine::CancelUpdate
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmEngine::CancelUpdate( CXdmDocument* aDocument )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::CancelUpdate( document )" ) );
+    #endif
+    TInt index = iDocumentQueue.Find( aDocument );
+    if( IsActive() )
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( " Transfer media init pending, cancel self" ) );
+        #endif
+        Cancel();
+        }
+    else if( index != KErrNotFound && aDocument->IsActive() )
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( " Cancel document update" ) );
+        #endif
+        aDocument->CancelUpdate();
+        if( iDocUpdateQueue.Find( aDocument ) == KErrNone )
+            iDocUpdateQueue.Remove( index );
+        }
+    }
+
+// ----------------------------------------------------
+// CXdmEngine::CancelUpdate
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmEngine::CancelUpdate( CXdmDirectory* aDirectory )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::CancelUpdate( directory )" ) );
+    #endif
+    TInt index = iDirectoryQueue.Find( aDirectory );
+    if( IsActive() )
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( " Transfer media init pending, cancel self" ) );
+        #endif
+        Cancel();
+        }
+    else if( index != KErrNotFound && aDirectory->IsActive() )
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( " Cancel directory update" ) );
+        #endif
+        aDirectory->CancelUpdate();
+        if( iDirUpdateQueue.Find( aDirectory ) == KErrNone )
+            iDirUpdateQueue.Remove( index );
+        }
+    }
+    
+// ----------------------------------------------------
+// CXdmEngine::CreateDocumentModelL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmDocument* CXdmEngine::CreateDocumentModelL( const TDesC& aDocumentName,
+                                                         const TXdmDocType aDocumentType )                                 
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::CreateDocumentModelL()" ) );
+    #endif
+    CXdmDocument* document = iXdmProtocol->CreateDocumentL( aDocumentName, aDocumentType );
+    CleanupStack::PushL( document );
+    User::LeaveIfError( iDocumentQueue.Append( document ) );
+    CleanupStack::Pop();  //document
+    return document;
+    }
+    
+// ----------------------------------------------------
+// CXdmEngine::DeleteDocumentModelL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmEngine::DeleteDocumentModelL( const CXdmDocument* aDocument )                                 
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::DeleteDocumentModelL()" ) );
+    #endif
+    TInt index = iDocumentQueue.Find( aDocument );
+    __ASSERT_ALWAYS( index != KErrNotFound, User::Leave( KErrNotFound ) );
+    iDocumentQueue.Remove( index );
+    delete aDocument;
+    aDocument = NULL;
+    }
+
+// ----------------------------------------------------
+// CXdmEngine::CreateDirectoryModelL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmDirectory* CXdmEngine::CreateDirectoryModelL( const TDesC& aDirectoryPath )                                 
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::CreateDirectoryModelL()" ) );
+    #endif
+    CXdmDirectory* directory = iXdmProtocol->CreateDirectoryL( aDirectoryPath );
+    CleanupStack::PushL( directory );
+    User::LeaveIfError( iDirectoryQueue.Append( directory ) );
+    CleanupStack::Pop();  //document
+    return directory;
+    }
+
+// ----------------------------------------------------
+// CXdmEngine::DeleteDirectoryModelL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmEngine::DeleteDirectoryModelL( const CXdmDirectory* aDirectory )                                 
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::DeleteDirectoryModelL()" ) );
+    #endif
+    TInt index = iDirectoryQueue.Find( aDirectory );
+    __ASSERT_ALWAYS( index != KErrNotFound, User::Panic( _L( "CXdmEngine" ), EDirModelNotFound ) );
+    iDirectoryQueue.Remove( index );
+    delete aDirectory;
+    aDirectory = NULL;
+    }
+
+// ----------------------------------------------------
+// CXdmEngine::CreateDocumentNodeL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmDocumentNode* CXdmEngine::CreateDocumentNodeL()                                 
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::CreateDocumentNodeL()" ) );
+    #endif
+    return iXdmProtocol->CreateDocumentNodeL();
+    }
+        
+// ----------------------------------------------------
+// CXdmEngine::UpdateL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmEngine::UpdateL( CXdmDocument* aDocument,
+                                   TRequestStatus& aStatus )                                 
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::UpdateL( document )" ) );
+    #endif
+    iClientStatus = &aStatus;
+    aStatus = KRequestPending;
+    aDocument->SaveClientStatus( aStatus );
+    User::LeaveIfError( iDocUpdateQueue.Append( aDocument ) );
+    if( !IsActive() )
+        {
+        iXdmProtocol->InitTransferMedium( KDefaultIdleTimeout, iStatus );
+        SetActive();
+        }
+    }
+
+// ----------------------------------------------------
+// CXdmEngine::UpdateL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmEngine::UpdateL( TRequestStatus& aStatus,
+                                   CXdmDirectory* aDirectory,
+                                   TDirUpdatePhase aUpdatePhase )                                 
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::UpdateL( directory )" ) );
+    #endif
+    iClientStatus = &aStatus;
+    aStatus = KRequestPending;
+    aDirectory->SaveRequestData( aUpdatePhase, aStatus );
+    User::LeaveIfError( iDirUpdateQueue.Append( aDirectory ) ); 
+    if( !IsActive() )
+        {
+        iXdmProtocol->InitTransferMedium( KDefaultIdleTimeout, iStatus );
+        SetActive();
+        }
+    }
+    
+// ---------------------------------------------------------
+// CXdmEngine::RunL
+// 
+// ---------------------------------------------------------
+//
+void CXdmEngine::RunL()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::RunL() - Status: %d" ), iStatus.Int() );
+    #endif
+    if( iStatus == KErrCancel )
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( " Update cancelled, complete client request" ) );
+        #endif
+        if( iClientStatus )
+            {
+            iDocUpdateQueue.Reset();
+            iDirUpdateQueue.Reset();
+            User::RequestComplete( iClientStatus, KErrCancel );
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Request complete" ) );
+            #endif
+            }
+        }  
+    else
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( " Transfer media initialised, start update" ) );
+        #endif
+        TInt dirCount( iDirUpdateQueue.Count() );
+        TInt docCount( iDocUpdateQueue.Count() );
+        #ifdef _DEBUG
+            WriteToLog( _L8( "  Document queue count:  %d" ), docCount );
+            WriteToLog( _L8( "  Directory queue count: %d" ), dirCount );
+        #endif
+        //First check the document queue
+        for( TInt i = 0;i < docCount;i++ )
+            {
+            iDocUpdateQueue[0]->StartUpdateL();
+            iDocUpdateQueue.Remove( 0 );
+            }
+        //Then the directory queue
+        for( TInt j = 0;j < dirCount;j++ )
+            {
+            iDirUpdateQueue[0]->StartUpdateL();
+            iDirUpdateQueue.Remove( 0 );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CXdmEngine::DoCancel
+// 
+// ---------------------------------------------------------
+//
+void CXdmEngine::DoCancel()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::DoCancel()" ) );
+    #endif
+    iXdmProtocol->CancelTransferMediumInit();
+    if( iClientStatus )
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( "  Client request pending => Complete" ) );
+        #endif
+        iDocUpdateQueue.Reset();
+        iDirUpdateQueue.Reset();
+        User::RequestComplete( iClientStatus, KErrCancel );
+        }
+    }
+
+// ---------------------------------------------------------
+// CXdmEngine::XdmProtocol
+// 
+// ---------------------------------------------------------
+//
+CXdmProtocol* CXdmEngine::XdmProtocol() const
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::XdmProtocol()" ) );
+    #endif
+    return iXdmProtocol;
+    }
+
+// ---------------------------------------------------------
+// CXdmEngine::ConvertToUTF8L
+// 
+// ---------------------------------------------------------
+//
+HBufC8* CXdmEngine::ConvertToUTF8L( const TDesC& aUnicodeDesc )
+    {
+    /*#ifdef _DEBUG
+        WriteToLog( _L8( "CXdmEngine::ConvertToUTF8L()" ) );
+    #endif*/
+    return CnvUtfConverter::ConvertFromUnicodeToUtf8L( aUnicodeDesc );
+    }
+    
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/src/XdmLogWriter.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,123 @@
+/*
+* 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:   XDM Engine log writer
+*
+*/
+
+
+
+#include <f32file.h>
+#include <flogger.h>
+#include <e32debug.h>
+#include "XdmLogWriter.h"
+#include "XdmStaticUtils.h"
+
+
+// ----------------------------------------------------------
+// XdmStaticUtils::CheckFileExistsL
+// 
+// ----------------------------------------------------------
+//
+CXdmLogWriter::CXdmLogWriter()
+    {         
+    }
+
+// ----------------------------------------------------------
+// CXdmLogWriter::NewL
+// 
+// ----------------------------------------------------------
+//      
+EXPORT_C CXdmLogWriter* CXdmLogWriter::NewL( const TDesC& aLogName )
+    {
+    CXdmLogWriter* self = new ( ELeave ) CXdmLogWriter();
+    CleanupStack::PushL( self );
+    self->ConstructL( aLogName );
+    CleanupStack::Pop();
+    return self;        
+    }
+
+// ----------------------------------------------------------
+// CXdmLogWriter::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXdmLogWriter::ConstructL( const TDesC& aLogName )
+    {
+    RFs session;
+    HBufC* full = NULL;
+    User::LeaveIfError( session.Connect() );
+    CleanupClosePushL( session );
+    HBufC* concat = HBufC::NewLC( KXdmLogRoot().Length() + 
+                                  KXdmLogDir().Length()  +
+                                  aLogName.Length() + 1 );
+    TPtr path( concat->Des() );
+    path.Copy( KXdmLogRoot ); 
+    path.Append( KXdmLogDir );
+    path.Append( _L( "\\") );
+    path.Append( aLogName );
+    TRAPD( error, full = XdmStaticUtils::GenerateFileNameL( session, path, KXdmLogFileExt ) );
+    if( full && error == KErrNone )
+    	{
+    	CleanupStack::PushL( full );
+    	TPtrC fullDes( full->Des() );
+    	iLogFileName = fullDes.Mid( fullDes.LocateReverse( 92 ) + 1 ).AllocL();
+    	CleanupStack::PopAndDestroy();  //full
+    	}
+   	else iLogFileName = NULL;
+    CleanupStack::PopAndDestroy( 2 );  //concat, session 
+    }
+
+// ----------------------------------------------------------
+// CXdmLogWriter::~CXdmLogWriter
+// 
+// ----------------------------------------------------------
+//     
+CXdmLogWriter::~CXdmLogWriter()
+    {
+    delete iLogFileName;
+    }
+
+// ----------------------------------------------------------
+// CXdmLogWriter::WriteToLog
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmLogWriter::WriteToLog( const TDesC& aLogLine ) const
+    {
+    if( iLogFileName )
+    	{
+    	RFileLogger::Write( KXdmLogDir, *iLogFileName, EFileLoggingModeAppend, aLogLine ); 
+    	}
+	RDebug::Print( aLogLine );
+    }
+     
+// ----------------------------------------------------------
+// CXdmLogWriter::WriteToLog
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmLogWriter::WriteToLog( const TDesC8& aLogLine ) const
+    {
+    if( iLogFileName )
+    	{
+    	RFileLogger::Write( KXdmLogDir, *iLogFileName, EFileLoggingModeAppend, aLogLine );
+    	}
+	RDebug::RawPrint( aLogLine );
+    }
+    
+// End of File
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/src/XdmNodeAttribute.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,162 @@
+/*
+* 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:   XDM Engine node attribute
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <escapeutils.h>
+
+#include "XdmEngine.h"
+#include "XdmNodeFactory.h"
+#include "XdmNodeAttribute.h"
+
+// ----------------------------------------------------------
+// CXdmNodeAttribute::CXdmNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmNodeAttribute::CXdmNodeAttribute( CXdmEngine& aXdmEngine,
+                                               MXdmNodeFactory& aNodeFactory ) :
+                                               CXdmDocumentNode( aXdmEngine, aNodeFactory )
+                                                
+    {    
+    }
+    
+// ----------------------------------------------------------
+// CXdmNodeAttribute::CXdmNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmNodeAttribute::CXdmNodeAttribute( CXdmEngine& aXdmEngine,
+                                               MXdmNodeFactory& aNodeFactory,
+                                               CXdmDocumentNode* aParentNode ) :
+                                               CXdmDocumentNode( aXdmEngine, aNodeFactory, aParentNode )                                          
+    {  
+    }
+       
+// ----------------------------------------------------------
+// CXdmNodeAttribute::ConstructL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmNodeAttribute::BaseConstructL( const TDesC& aAttributeName )
+    {
+    SetNameL( aAttributeName );
+    }
+
+// ----------------------------------------------------------
+// CXdmNodeAttribute::ElementType
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TXdmElementType CXdmNodeAttribute::ElementType() const
+    {
+    return EXdmElementAttribute;
+    }
+
+// ----------------------------------------------------
+// CXdmNodeAttribute::~CXdmNodeAttribute
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmNodeAttribute::~CXdmNodeAttribute()
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmNodeAttribute::~CXdmNodeAttribute()" ) );
+    #endif
+    delete iAttributeValue;
+    }
+
+// ----------------------------------------------------
+// CXdmNodeAttribute::AttributeValue
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TPtrC CXdmNodeAttribute::AttributeValue() const
+    {
+    return iAttributeValue != NULL ? iAttributeValue->Des() : TPtrC();
+    }
+
+// ----------------------------------------------------
+// CXdmNodeAttribute::AttributeValue
+// 
+// ----------------------------------------------------
+//
+EXPORT_C HBufC8* CXdmNodeAttribute::EightBitValueLC() const
+    {
+    HBufC8* eightBit = CXdmEngine::ConvertToUTF8L( iAttributeValue->Des() );
+    CleanupStack::PushL( eightBit );
+    return eightBit;
+    }
+
+// ----------------------------------------------------
+// CXdmNodeAttribute::EscapedValueLC
+// 
+// ----------------------------------------------------
+//
+EXPORT_C HBufC8* CXdmNodeAttribute::EscapedValueLC() const
+    {
+    HBufC8* eightBit = CXdmEngine::ConvertToUTF8L( iAttributeValue->Des() );
+    CleanupStack::PushL( eightBit );
+    HBufC8* escape = EscapeDescLC( eightBit->Des() );
+    CleanupStack::Pop();  //escape
+    CleanupStack::PopAndDestroy();  //eightBit
+    CleanupStack::PushL( escape );
+    return escape;
+    }
+    
+// ----------------------------------------------------
+// CXdmNodeAttribute::SetAttributeValue
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmNodeAttribute::SetAttributeValueL( const TDesC& aAttributeValue )
+    {
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmNodeAttribute::SetAttributeValueL() - Value: %S" ),
+                                &aAttributeValue );
+    #endif
+    delete iAttributeValue;
+    iAttributeValue = NULL;
+    iAttributeValue = HBufC::NewL( aAttributeValue.Length() );
+    iAttributeValue->Des().Copy( aAttributeValue );
+    }
+
+// ----------------------------------------------------
+// CXdmNodeAttribute::SetAttributeValue
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXdmNodeAttribute::SetAttributeValueL( const TDesC8& aAttributeValue )
+    {
+    // change to UNICODE from UTF8 format
+    HBufC* unicode = EscapeUtils::ConvertToUnicodeFromUtf8L( aAttributeValue );
+    CleanupStack::PushL( unicode );
+    
+    #ifdef _DEBUG
+        iXdmEngine.WriteToLog( _L8( "CXdmNodeAttribute::SetAttributeValueL() - Value: %S" ),
+                                unicode );
+    #endif
+    delete iAttributeValue;
+    iAttributeValue = NULL;
+    iAttributeValue = HBufC::NewL( unicode->Length() );
+    iAttributeValue->Des().Copy( *unicode );
+    CleanupStack::PopAndDestroy( unicode );
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/src/XdmProtocol.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  XDM Engine protocol
+*
+*/
+
+
+
+#include <ecom.h>
+#include "XdmProtocol.h"
+#include "XdmProtocolInfo.h"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/src/XdmProtocolInfo.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,228 @@
+/*
+* 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:   XDM Engine protocol info
+*
+*/
+
+
+
+#include "XdmProtocol.h"
+#include "XdmDocument.h"
+#include "XdmSettingsApi.h"
+#include "XdmProtocolInfo.h"
+#include "XdmProtocolUidList.h"
+#include "XdmSettingsProperty.h"
+#include "XdmSettingsCollection.h"
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::CXdmProtocolInfo
+// 
+// ----------------------------------------------------------
+//
+CXdmProtocolInfo::CXdmProtocolInfo() : iSecure( EFalse ),
+                                       iUseCache( ETrue )
+    {   
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::CXdmProtocolInfo
+// 
+// ----------------------------------------------------------
+//
+CXdmProtocolInfo::CXdmProtocolInfo( TInt aProtocolUid ) :
+                                    iProtocolUid( TUid::Uid( aProtocolUid ) ),
+                                    iSecure( EFalse ),
+                                    iUseCache( ETrue )
+    {   
+    }
+       
+// ----------------------------------------------------------
+// CXdmProtocolInfo::CXdmProtocolInfo
+// 
+// ----------------------------------------------------------
+//
+CXdmProtocolInfo::CXdmProtocolInfo( TInt aAccessPoint,
+                                    TInt aProtocolUid ) :
+                                    iProtocolUid( TUid::Uid( aProtocolUid ) ),
+                                    iAccessPoint( aAccessPoint ),
+                                    iSecure( EFalse ),
+                                    iUseCache( ETrue )
+    {   
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::NewL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmProtocolInfo* CXdmProtocolInfo::NewL( TInt aAccessPoint,
+                                                   TInt aProtocolUid,
+                                                   const TDesC& aRootLocation )
+    {
+    CXdmProtocolInfo* self = new ( ELeave ) CXdmProtocolInfo( aAccessPoint, aProtocolUid );
+    CleanupStack::PushL( self );
+    self->ConstructL( aRootLocation );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::NewL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmProtocolInfo* CXdmProtocolInfo::NewL( TInt aSettingsId )
+    {
+    CXdmProtocolInfo* self = new ( ELeave ) CXdmProtocolInfo( KXcapProtocol );
+    self->Construct( aSettingsId );
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXdmProtocolInfo::ConstructL( const TDesC& aRootLocation )
+    {
+    delete iRootLocation;
+    iRootLocation = NULL;
+    iRootLocation = HBufC::NewL( aRootLocation.Length() );
+    iRootLocation->Des().Copy( aRootLocation );
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::Construct
+// 
+// ----------------------------------------------------------
+//
+void CXdmProtocolInfo::Construct( TInt aSettingsId )
+    {
+    iSettingsId = aSettingsId;
+    }
+        
+// ----------------------------------------------------------
+// CXdmProtocolInfo::~CXdmProtocolInfo
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmProtocolInfo::~CXdmProtocolInfo()
+    {
+    delete iRootLocation;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::SetCredentials
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmProtocolInfo::SetCredentials( const TXdmCredentials aCredentials )
+    {
+    iCredentials = aCredentials;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::SetCacheUsage
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmProtocolInfo::SetCacheUsage( const TBool aCacheUsage )
+    {
+    iUseCache = aCacheUsage;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::CacheUsage
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TBool CXdmProtocolInfo::IsCacheEnabled() const
+    {
+    return iUseCache;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::Credentials
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C const TXdmCredentials& CXdmProtocolInfo::Credentials() const
+    {
+    return iCredentials;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::SetCredentials
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXdmProtocolInfo::SetSecurity( const TBool aSecure )
+    {
+    iSecure = aSecure;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::SetCredentials
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TBool CXdmProtocolInfo::IsSecure() const
+    {
+    return iSecure;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::Root
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TUid CXdmProtocolInfo::ProtocolUid() const
+    {
+    return iProtocolUid;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::AccessPoint
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TInt CXdmProtocolInfo::AccessPoint() const
+    {
+    return iAccessPoint;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocolInfo::AccessPoint
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TInt CXdmProtocolInfo::SettingsID() const
+    {
+    return iSettingsId;
+    }
+    
+// ----------------------------------------------------------
+// CXdmProtocolInfo::Root
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TPtrC CXdmProtocolInfo::Root() const
+    {
+    return iRootLocation != NULL ? iRootLocation->Des() : TPtrC();
+    }
+
+              
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMEngine/src/XdmStaticUtils.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,100 @@
+/*
+* 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:   XDM Engine static utils
+*
+*/
+
+
+
+
+#include <f32file.h>
+#include "XdmStaticUtils.h"
+#include "XdmLogWriter.h"
+
+// ----------------------------------------------------------
+// XdmStaticUtils::CheckFileExistsL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TBool XdmStaticUtils::CheckFileExistsL( RFs& aFileSession, const TDesC& aFileName )
+    {
+    TBool found = EFalse;
+    CDir* directory = NULL;
+    TInt index = aFileName.LocateReverse( KBackSlash );
+    TPtrC dir( aFileName.Left( index + 1 ) );
+    TPtrC name( aFileName.Right( aFileName.Length() - index - 1 ) );
+    User::LeaveIfError( aFileSession.GetDir( dir, KEntryAttNormal, ESortNone, directory ) );
+    CleanupStack::PushL( directory );
+    const TInt count = directory->Count();
+    for( TInt i = 0;!found && i < count;i++ )
+        {
+        if( name.CompareF( ( *directory )[i].iName ) == 0 )
+            found = ETrue;
+        }
+	CleanupStack::PopAndDestroy();  //directory
+    return found;
+    }
+
+// ----------------------------------------------------------
+// XdmStaticUtils::GenerateFileNameLC
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C HBufC* XdmStaticUtils::GenerateFileNameL( RFs& aFileSession, const TDesC& aFileName,
+                                                   const TDesC& aExtension )
+    {
+    TInt i = 1;
+    TBuf<KMaxFileName> name;
+    name.Copy( aFileName );
+    name.Append( aExtension );
+    TBool exists = XdmStaticUtils::CheckFileExistsL( aFileSession, name );
+    for( ;exists && i <= KMaxLogFiles;i++ )
+        {
+        name.Zero();
+        name.Copy( aFileName );
+        name.AppendNum( i );
+        name.Append( aExtension );
+        exists = XdmStaticUtils::CheckFileExistsL( aFileSession, name );
+        }
+    if( i >= KMaxLogFiles )
+        {
+        TPtrC dir( aFileName.Left( aFileName.LocateReverse( KBackSlash ) ) );
+        CleanUpDirectoryL( aFileSession, dir );
+        name.Zero();
+        name.Copy( aFileName );
+        name.Append( aExtension );
+        }
+    return name.AllocL();
+    }
+
+// ----------------------------------------------------------
+// XdmStaticUtils::CleanUpDirectoryL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void XdmStaticUtils::CleanUpDirectoryL( RFs& aFileSession, const TDesC& aDirectory )
+    {
+    TBuf<KMaxFileName> allFiles;
+    allFiles.Copy( aDirectory );
+    allFiles.Append( _L( "\\*.*") );
+    CFileMan* manager = CFileMan::NewL( aFileSession );
+    manager->Delete( allFiles );
+    delete manager;
+    manager = NULL;
+    }
+         
+// End of File  
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/data/10207428.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* 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 plugin resource file for GS XDM plugin.
+*
+*/
+
+
+
+#include <registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid     = 0x10207428; // Plugin dll UID
+    interfaces  = 
+        {
+        INTERFACE_INFO
+            {
+            interface_uid   = 0x10207236; // UID for CGSPluginInterface
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid  = 0x10207429; // Plugin UID
+                    version_no          = 1;
+                    display_name        = "XDM Settings Plugin"; // Plugin debug name
+                    
+                    #ifdef RD_CONTROL_PANEL // for control panel change (5.0)
+                        default_data        = "0x10283341"; // Parent UID adminstrative settings
+                        opaque_data         = "50"; // Order number
+                    #else // for normal 3.0 without control panel change
+                        default_data        = "0x10207250"; // Parent UID connection settings
+                        opaque_data         = "140"; // Order number
+                    #endif //RD_CONTROL_PANEL
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/data/XDMPluginRsc.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,444 @@
+/*
+* Copyright (c) 2005-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:    Resource file for XDMPlugin
+*
+*/
+
+
+
+
+//  RESOURCE IDENTIFIER
+NAME    GSXD // 4 letter ID
+
+//  INCLUDES
+#include    <bldvariant.hrh>
+#include    <avkon.rh>
+#include    <avkon.rsg>
+#include    <avkon.mbg>
+#include    <EIKCORE.RSG>
+#include    <eikon.rh>
+#include    <eikon.rsg>
+#include    <avkon.loc>
+#include    <data_caging_paths_strings.hrh>
+#include    <appinfo.rh>
+
+#include    <gsxdmplugin.loc>
+#include    "XDMPlugin.hrh"
+
+// CONSTANTS
+//----------------------------------------------------
+//   
+//    
+//    Needed or loading the resource fails!
+//
+//----------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE
+    {
+    }
+    
+//----------------------------------------------------
+//   
+//    r_gs_xdm_settings_main_menubar
+//    Menu when main list is visible
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_BAR r_gs_xdm_settings_main_menubar
+    {
+    titles =
+        {
+        MENU_TITLE { menu_pane = r_gs_xdm_settings_main_menu;}
+        };
+    }
+
+//----------------------------------------------------
+//   
+//    r_gs_xdm_settings_main_menu
+//    Main menu when we enter in XDM settings
+//
+//----------------------------------------------------
+//
+RESOURCE MENU_PANE r_gs_xdm_settings_main_menu
+    {
+    items =
+        {
+        MENU_ITEM
+            { 
+            command = EGSXDMPluginCmdChange;
+            txt = qtn_xdm_settings_change;
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM 
+            { 
+            command = EGSXDMPluginCmdEdit;
+            txt = qtn_xdm_options_edit_set;
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM 
+            {
+            command = EGSXDMPluginCmdNewSettings;
+            cascade = r_gs_xdm_new_settings_menu; 
+            txt = qtn_xdm_options_new_set;
+            },
+        MENU_ITEM
+            { 
+            command = EGSXDMPluginCmdDelete;
+            txt = qtn_xdm_options_delete;
+            },
+        MENU_ITEM 
+            { 
+            command = EAknCmdHelp;
+            txt = qtn_options_help;
+            },   
+        MENU_ITEM 
+            { 
+            command = EGSXDMPluginCmdExitFromSL;
+            txt = qtn_options_exit;
+            },     
+        MENU_ITEM 
+            { 
+            command = EAknCmdExit;
+            txt = qtn_options_exit;
+            }     
+        };
+    }
+
+//----------------------------------------------------
+//   
+//    r_gs_xdm_new_settings_menu
+//    case menu
+//
+//----------------------------------------------------
+//    
+RESOURCE MENU_PANE r_gs_xdm_new_settings_menu
+    {
+    items =
+        {
+        MENU_ITEM 
+            { 
+            command = EGSXDMPluginCmdNewDefault;
+            txt = qtn_xdm_options_new_sub_default;
+            },
+        MENU_ITEM 
+            { 
+            command = EGSXDMPluginCmdNewExisting;
+            txt = qtn_xdm_options_new_sub_existing;
+            }        
+        };
+    }
+    
+//----------------------------------------------------
+//   
+//    r_gs_xdm_main_view_title
+//    XDM view's title.
+//
+//----------------------------------------------------
+//
+RESOURCE TITLE_PANE r_gs_xdm_main_view_title
+    {
+    txt = qtn_xdm_title;
+    }
+    
+//----------------------------------------------------
+//   
+//    r_gs_xdm_main_view
+//    XDM plugin main view.
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_gs_xdm_main_view
+    {
+    menubar = r_gs_xdm_settings_main_menubar;
+    cba = r_xdmui_mainview_softkeys;//R_AVKON_SOFTKEYS_OPTIONS_BACK;  
+    }
+    
+//----------------------------------------------------
+//   
+//    r_xdmui_mainview_softkeys
+//    XDM plugin main view softkeys.
+//
+//----------------------------------------------------
+//  
+RESOURCE CBA r_xdmui_mainview_softkeys
+    {
+    flags = 0;
+    buttons = 
+        {
+        CBA_BUTTON {id=EAknSoftkeyOptions; txt= text_softkey_option;},
+        CBA_BUTTON {id=EAknSoftkeyBack; txt= text_softkey_back;},
+        CBA_BUTTON {id=EGSXDMPluginCmdEdit; txt= qtn_msk_edit;}
+        };
+     }
+     
+//----------------------------------------------------
+//   
+//    r_xdmui_mainview_softkeys_sl
+//    XDM plugin main view softkeys for settings list
+//
+//----------------------------------------------------
+//  
+RESOURCE CBA r_xdmui_mainview_softkeys_sl
+    {
+    flags = 0;
+    buttons = 
+        {
+        CBA_BUTTON {id=EAknSoftkeyOptions; txt= text_softkey_option;},
+        CBA_BUTTON {id=EAknSoftkeyBack; txt= text_softkey_back;},
+        CBA_BUTTON {id=EGSXDMPluginCmdChange; txt= qtn_msk_change;}
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+// r_settings
+//
+// settings list - collection of all setting types
+//   
+// ---------------------------------------------------------
+//
+RESOURCE LISTBOX r_gs_xdm_main_list
+    {
+    flags = EAknListBoxSelectionList;        
+    }   
+
+    
+// ---------------------------------------------------------
+//   
+// r_settings
+//
+// settings list - collection of all setting types
+//   
+// ---------------------------------------------------------
+//   
+
+RESOURCE AVKON_SETTING_ITEM_LIST r_settings
+    {
+    flags = EAknSettingItemIncludeHiddenInOrdinal;
+    title = qtn_xdm_title;
+    items = 
+        {
+        AVKON_SETTING_ITEM
+            {
+            identifier = ESettingItemSettingName;
+            setting_page_resource = r_server_name_editor_page;
+            name = qtn_xdm_settings_set_name;
+            compulsory_ind_string = qtn_xdm_compulsory_indicator;
+            empty_item_text = qtn_xdm_settings_must_define;
+            },
+        AVKON_SETTING_ITEM
+            {
+            identifier = ESettingItemAccessPoint;
+            setting_page_resource = r_accesspoint_editor_page;
+            name = qtn_xdm_settings_access_point;
+            compulsory_ind_string = qtn_xdm_compulsory_indicator;
+            empty_item_text = qtn_xdm_settings_must_define;
+            },
+        AVKON_SETTING_ITEM
+            {
+            identifier = ESettingItemServerAddress;
+            setting_page_resource = r_server_address_editor_page;
+            name = qtn_xdm_settings_address;
+            compulsory_ind_string = qtn_xdm_compulsory_indicator;
+            empty_item_text = qtn_xdm_settings_must_define;
+            },
+        AVKON_SETTING_ITEM
+            {
+            identifier = ESettingItemSipURL;
+            setting_page_resource = r_sip_url_editor_page;
+            name = qtn_xdm_settings_sip;
+            },
+        AVKON_SETTING_ITEM
+            {
+            identifier = ESettingItemUserID;
+            setting_page_resource = r_user_id_editor_page;
+            name = qtn_xdm_settings_username;
+            compulsory_ind_string = qtn_xdm_compulsory_indicator;
+            empty_item_text = qtn_xdm_settings_must_define;
+            },
+        AVKON_SETTING_ITEM
+            {
+            identifier = ESettingItemPassword;
+            setting_page_resource = r_password_editor_page;
+            name = qtn_xdm_settings_password;
+            empty_item_text = qtn_xdm_text_password;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//   
+// Settings Pages
+//
+// defines the AVKON_SETTING_PAGE structures referred to in 
+// setting_page_resource fields above.
+// 
+// These structures define the way in which the editors used
+// to change the setting data are presented.
+// 
+// ---------------------------------------------------------
+//   
+RESOURCE AVKON_SETTING_PAGE r_server_name_editor_page
+    {
+    label= qtn_xdm_settings_set_name;
+    type = EEikCtEdwin;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    editor_resource_id = r_server_name_editor;
+    }
+  
+RESOURCE AVKON_SETTING_PAGE r_server_address_editor_page
+    {
+    label= qtn_xdm_settings_address;
+    type = EEikCtEdwin;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    editor_resource_id = r_server_address_editor;
+    }
+
+
+RESOURCE AVKON_SETTING_PAGE r_accesspoint_editor_page
+    {
+    label= qtn_xdm_settings_access_point;
+    type = EEikCtEdwin;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    editor_resource_id = r_accesspoint_editor;
+    }
+    
+RESOURCE AVKON_SETTING_PAGE r_sip_url_editor_page
+    {
+    label= qtn_xdm_settings_sip;
+    type = EEikCtEdwin;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    editor_resource_id = r_sip_url_editor;
+    }
+  
+RESOURCE AVKON_SETTING_PAGE r_user_id_editor_page
+    {
+    label= qtn_xdm_settings_username;
+    type = EEikCtEdwin;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    editor_resource_id = r_user_id_editor;
+    }
+  
+RESOURCE AVKON_SETTING_PAGE r_password_editor_page
+    {
+    label= qtn_xdm_settings_password;
+    type = EEikCtSecretEd;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    editor_resource_id = r_password_editor;
+    }
+
+RESOURCE EDWIN r_user_id_editor
+    {
+    flags = EEikEdwinAutoSelection | EAknEditorLowerCase | EEikEdwinNoLineOrParaBreaks;
+    allowed_case_modes = EAknEditorLowerCase | EAknEditorUpperCase;
+    numeric_keymap=EAknEditorCalculatorNumberModeKeymap;
+    allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode;
+    default_input_mode = EAknEditorTextInputMode;
+    special_character_table = R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG;
+    default_case = EAknEditorLowerCase;
+    avkon_flags = EAknEditorFlagLatinInputModesOnly;
+    width = 0;
+    lines = 0;
+    maxlength = KMaxUserIDLength;
+    }
+  
+RESOURCE SECRETED r_password_editor
+    {
+    num_letters = KMaxPasswordLength;
+    }
+
+RESOURCE EDWIN r_server_address_editor
+    {
+    flags = EEikEdwinAutoSelection | EAknEditorLowerCase | EEikEdwinNoLineOrParaBreaks;
+    allowed_case_modes = EAknEditorLowerCase | EAknEditorUpperCase;
+    numeric_keymap=EAknEditorCalculatorNumberModeKeymap;
+    allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode;
+    default_input_mode = EAknEditorTextInputMode;
+    special_character_table = R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG;
+    default_case = EAknEditorLowerCase;
+    avkon_flags = EAknEditorFlagLatinInputModesOnly;
+    width = 0;
+    lines = 0;
+    maxlength = KMaxServerAddressLength;
+    }
+  
+RESOURCE EDWIN r_accesspoint_editor
+    {
+    maxlength = KMaxAccessPointNameLength;
+    }
+  
+RESOURCE EDWIN r_server_name_editor
+    {
+    width = 0;
+    lines = 0;
+    flags = EEikEdwinNoLineOrParaBreaks;
+    maxlength = KMaxSettingSetNameLength;
+    }
+  
+RESOURCE EDWIN r_sip_url_editor
+    {
+    width = 0;
+    lines = 0;
+    maxlength = KMaxSIPURLLength;
+    }
+
+
+RESOURCE DIALOG r_confirmation_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_YES_NO;
+    items=
+        {
+        DLG_LINE 
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY
+                {
+                layout =EConfirmationQueryLayout;
+                };
+            }
+        };
+    }
+  
+//----------------------------------------------------
+//   
+//    string resouces
+//    the strings can be localized in loc file
+//
+//----------------------------------------------------
+//    
+RESOURCE TBUF r_str_xdm_settings { buf = qtn_xdm_title; }
+RESOURCE TBUF r_str_xdm_compulsory { buf = qtn_selec_setting_compulsory; }
+RESOURCE TBUF r_str_xdm_must_define { buf = qtn_poc_settings_must_define; }
+RESOURCE TBUF r_str_xdm_use_existing { buf = qtn_xdm_propmt_use_exist; }
+RESOURCE TBUF r_str_xdm_empty_text { buf = qtn_xdm_main_empty_info_text; }
+RESOURCE TBUF r_str_xdm_empty_text_sec { buf = qtn_xdm_main_empty_info_text_secondary; }
+RESOURCE TBUF r_str_xdm_new_set { buf = qtn_xdm_text_new_set; }
+RESOURCE TBUF r_str_xdm_new_set_many { buf = qtn_xdm_text_new_set_many; }
+RESOURCE TBUF r_str_xdm_conf_delete_last { buf = qtn_xdm_conf_delete_last; }
+RESOURCE TBUF r_str_xdm_conf_delete { buf = qtn_query_common_conf_delete; }
+RESOURCE TBUF r_str_xdm_conf_compulsory { buf = qtn_xdm_compulsory_query_info_text; }
+RESOURCE TBUF r_str_xdm_title_pane_text { buf = qtn_xdm_title; }
+RESOURCE TBUF r_str_xdm_name_already_exist { buf = qtn_xdm_set_already_exist_info; }
+RESOURCE TBUF r_str_xdm_ap_name_for_debug_only { buf = qtn_xdm_settings_access_point;}
+
+// ******  PDATA RESOURCES END     ******
+//End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/group/XDMPlugin.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    This is project specification file for GS XDMPlugin.
+*
+*/
+
+
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+CAPABILITY          CAP_ECOM_PLUGIN
+TARGET              gsxdmplugin.dll
+TARGETTYPE          PLUGIN
+UID                 0x10009D8D 0x10207428
+VENDORID            VID_DEFAULT
+
+SOURCEPATH          ../src
+SOURCE              XDMPluginImplementationTable.cpp
+SOURCE              XDMPlugin.cpp
+SOURCE              XDMPluginContainer.cpp
+SOURCE              SettingsData.cpp
+SOURCE              XDMPluginSettinglist.cpp
+SOURCE              XDMPluginSLContainer.cpp
+
+USERINCLUDE         ../inc
+USERINCLUDE         ../data
+
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE       /epoc32/include/ecom
+
+SOURCEPATH          ../data
+
+//ECOM resource definition
+START RESOURCE      10207428.rss
+    TARGET              gsxdmplugin.rsc
+END // ECOM resource definition
+
+//XDMPlugin resources
+START RESOURCE      XDMPluginRsc.rss
+    HEADER
+    TARGETPATH          RESOURCE_FILES_DIR
+    LANGUAGE_IDS
+END // XDMPlugin resources
+
+LIBRARY             euser.lib
+LIBRARY             ecom.lib
+LIBRARY             efsrv.lib
+LIBRARY             avkon.lib
+LIBRARY             bafl.lib 
+LIBRARY             cone.lib 
+LIBRARY             eikcoctl.lib 
+LIBRARY             eikcore.lib
+LIBRARY             eikctl.lib
+LIBRARY             commonengine.lib//For RConeResourceLoader
+
+LIBRARY             egul.lib // CGulIcon
+LIBRARY             aknskins.lib // AknsUtils.h
+LIBRARY             apsettingshandlerui.lib  // access point UI
+LIBRARY             commdb.lib
+LIBRARY             apengine.lib  //AP engine
+LIBRARY             xdmsettingsapi.lib
+LIBRARY             gsecomplugin.lib //GS Ecom plugin
+LIBRARY             agentdialog.lib // To show access points only in emulator
+
+LIBRARY		        featmgr.lib // Feature Manager
+LIBRARY		        hlplch.lib // HlpLauncher
+LIBRARY             inetprotutil.lib // conversions
+
+// This is optional - used only by Codewarrior for convenience.
+DOCUMENT            10207428.rss
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/group/XDMPluginIcons.mk	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,71 @@
+#
+# 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:   XDM Settings UI
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+HEADERDIR=\epoc32\include
+ICONTARGETFILENAME=$(TARGETDIR)\gsxdmplugin.mif
+HEADERFILENAME=$(HEADERDIR)\gsxdmplugin.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# TODO: Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2, \s60\bitmaps.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+		/c8,8 qgn_prop_set_conn_xdm.bmp
+
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Build information file GS XDM Plugin
+*
+*/
+
+
+
+
+#include <platform_paths.hrh>
+
+#ifdef __XDM
+
+// Platforms
+PRJ_PLATFORMS
+DEFAULT
+// Help exports
+#include "../help/group/bld.inf"
+
+PRJ_EXPORTS
+// IBYs
+../rom/GSXDMPlugin.iby CORE_MW_LAYER_IBY_EXPORT_PATH(gsxdmplugin.iby)
+../rom/GSXDMPluginResources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(gsxdmpluginresources.iby)
+// LOC
+../loc/gsxdmplugin.loc MW_LAYER_LOC_EXPORT_PATH(gsxdmplugin.loc)
+
+PRJ_EXTENSIONS
+START EXTENSION s60/mifconv
+	OPTION TARGETFILE gsxdmplugin.mif
+	OPTION HEADERFILE gsxdmplugin.mbg
+	OPTION SOURCES -c8,8 qgn_prop_set_conn_xdm
+END  
+
+
+// MMP Files
+PRJ_MMPFILES
+XDMPlugin.mmp
+
+PRJ_TESTMMPFILES
+//../internal/tsrc/test/group/ut_xdmplugin.mmp
+
+  
+#endif //__XDM
+
+//  End of File
+
+
Binary file XDMSettingsUI/help/data/xhtml.zip has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/help/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -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:
+* Export help related files.
+*
+*/
+
+#include <platform_paths.hrh>				
+PRJ_EXPORTS
+:zip ../data/xhtml.zip   /epoc32/data/z/resource/ overwrite
+:zip ../data/xhtml.zip   /epoc32/winscw/c/resource/ overwrite
+
+../inc/xdm.hlp.hrh	MW_LAYER_PLATFORM_EXPORT_PATH(csxhelp/xdm.hlp.hrh)
+../rom/xdmsettingsuihelps_variant.iby		CUSTOMER_APP_LAYER_IBY_EXPORT_PATH(xdmsettingsuihelps_variant.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/help/inc/xdm.hlp.hrh	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description:
+*
+*/
+	
+//
+// xdm.hlp.hrh generated by CSXHelp Utilities.
+//           
+
+#ifndef __XDM_HLP_HRH__
+#define __XDM_HLP_HRH__
+
+_LIT(KXDM_HLP_LIST_VIEW, "XDM_HLP_LIST_VIEW"); // 
+_LIT(KXDM_HLP_EDIT_SET, "XDM_HLP_EDIT_SET"); // 
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/help/rom/xdmsettingsuihelps_variant.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __XDMSETTINGSUIHELPS_VARIANT_IBY__
+#define __XDMSETTINGSUIHELPS_VARIANT_IBY__
+
+#if defined(FF_S60_HELPS_IN_USE)
+    data=LOCALISE(DATAZ_/resource/xhtml/%02d/0x10207429/contents.zip, RESOURCE_FILES_DIR/xhtml/%02d/0x10207429/contents.zip)
+    data=LOCALISE(DATAZ_/resource/xhtml/%02d/0x10207429/index.xml, RESOURCE_FILES_DIR/xhtml/%02d/0x10207429/index.xml)
+    data=LOCALISE(DATAZ_/resource/xhtml/%02d/0x10207429/keywords.xml, RESOURCE_FILES_DIR/xhtml/%02d/0x10207429/keywords.xml)
+    data=LOCALISE(DATAZ_/resource/xhtml/%02d/0x10207429/meta.xml, RESOURCE_FILES_DIR/xhtml/%02d/0x10207429/meta.xml)
+#endif
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/inc/SettingsData.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    XDM GS plugin data holding class for XDM setting list
+*
+*/
+
+
+
+
+#ifndef __SettingsData_H__
+#define __SettingsData_H__
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <in_sock.h>
+
+#include "XDMPlugin.hrh"
+
+
+/**
+*  CSettingsData data holding class for an XDM set
+*/
+class CSettingsData : public CBase
+    {
+    public:
+
+        /**
+        * Default 1st phase factory method.
+        * Creates an instance of CSettingsData
+        */
+      static CSettingsData* NewL();
+      
+        /**
+        * Default 1st phase factory method.
+        * Creates an instance of CSettingsData, leaves it on stack
+        */
+        static CSettingsData* NewLC();
+        
+        /**
+        * Destructor
+        */
+      virtual ~CSettingsData();
+      
+        /**
+        * Resets all data to initial values
+        */
+      void Reset();
+      
+    private:
+
+        /**
+        * 2nd Phase constructor
+        */
+      void ConstructL();
+      
+        /**
+        * C++ Constructor
+        */
+      CSettingsData();
+      
+    public:
+        
+        // Buffer holding the XDM set name
+      TBuf<KMaxSettingSetNameLength>  iSettingName;
+
+      // Buffer holding the XDM set name with localized digits for display
+      TBuf<KMaxSettingSetNameLength>  iSettingNameDisp;
+
+        // Buffer holding the XDM set server address
+      TBuf<KMaxServerAddressLength>   iServerAddress;
+      
+      // Access point number
+      TInt32                          iAccessPoint;
+      
+      // Buffer holding the access point number as a descriptor
+      TBuf<KMaxAccessPointDesLength>  iAccessPointDes;
+      
+      // Buffer holding the SIP URL
+      TBuf<KMaxSIPURLLength>          iSipURL;
+
+        // Buffer holding the User ID
+      TBuf<KMaxUserIDLength>          iUserID;
+      
+      // Buffer holding the password
+      TBuf<KMaxPasswordLength>        iPassword;
+      
+      // Buffer holding the access point name
+      TBuf<KMaxAccessPointNameLength> iAccessPointName;
+      
+      // XDM setting, settings id, used to identify in XDM settings API
+      TInt32                          iSettingId;
+    };
+
+#endif // __SettingsData_H__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/inc/XDMExternalInterface.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* 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:    Header file with UID definitions
+ *
+*/
+
+
+
+#ifndef XDMEXTERNALINTERFACE_H
+#define XDMEXTERNALINTERFACE_H
+
+#include <e32std.h>
+#include <bldvariant.hrh>
+#include <xdmpluginrsc.rsg>
+#include "XDMPlugin.h"
+#define XDM_PLUGIN
+
+/** 
+* This UID is used for both the view UID and the ECOM plugin implementation 
+* UID.
+*/
+const TUid KGSXDMPluginUid = { 0x10207429 };
+
+// View UIDs
+const TUid KViewId= {0x1028236B};
+
+#endif // XDMEXTERNALINTERFACE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/inc/XDMPlugin.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,184 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    XDM GS plugin, UI(CAknView) interface header
+*
+*/
+
+
+
+
+#ifndef GS_XDMPLUGIN_H
+#define GS_XDMPLUGIN_H
+
+// INCLUDES
+#include <aknview.h>
+#include <eikclb.h>
+#include <ConeResLoader.h>
+#include <gsplugininterface.h>
+
+#include "XDMPlugin.hrh"
+
+// FORWARD DECLARATIONS
+class CXDMPluginContainer;
+class CXDMPluginSLContainer;
+class CAknViewAppUi;
+class CSettingsData;
+
+/** 
+* This UID is used for both the view UID and the ECOM plugin implementation 
+* UID.
+*/
+//const TUid KGSXDMPluginUid = { 0x10207429 };
+  
+// CLASS DECLARATION
+
+/**
+*  CXDMPlugin view class (CAknView).
+*
+* This is XDM GS plugin.
+*/
+class CXDMPlugin : public CGSPluginInterface
+    {
+    
+    public: // Constructors and destructor
+        
+        /**
+        * Symbian OS two-phased constructor
+        * @return 
+        */
+        static CXDMPlugin* NewL( TAny* aInitParams );
+    
+        /**
+        * Destructor.
+        */
+        ~CXDMPlugin();
+        
+        /**
+        * Load the SettingsView with specified XDM set and type of loading
+        * The types are EEditExisting, ENewDefault, ENewFromExisting
+        */
+        void LoadSettingsViewL(TXDMSettingsViewType aType, TDesC& aXDMSetName);
+
+        /**
+        * Loads the Main View where list of XDM sets are visible
+        */
+        void LoadMainViewL();
+
+         /**
+         * Manual resource change method
+         * @param aType ype of resource
+         */
+         void HandleResourceChangeManual(TInt aType);
+
+        /**
+        * Hides MSK if not needed
+        */
+        void UpdateMskL();
+
+    public: // From CAknView
+        
+        /**
+        * This function is used for identifying the plugin
+        */
+        TUid Id() const;
+        
+        /**
+        * See CAknView
+        */
+        //void HandleClientRectChange();
+        void HandleViewRectChange();
+        
+        /**
+        * See CAknView
+        */
+        void DoActivateL( const TVwsViewId& aPrevViewId,
+                          TUid aCustomMessageId,
+                          const TDesC8& aCustomMessage );
+        /**
+        * See CAknView
+        */
+        void DoDeactivate();
+
+        /**
+        * See CAknView
+        */
+        void HandleCommandL( TInt aCommand );
+        
+ 
+
+    protected:
+
+        /**
+        * C++ default constructor.
+        */
+        CXDMPlugin( );
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+        
+    private:
+    
+        /**
+        * See base classes
+        */
+        void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane);
+        
+    public: // From CGSPluginInterface
+    
+        /**
+        * See CGSPluginInterface
+        */
+        void GetCaptionL( TDes& aCaption ) const;
+
+        /**
+        * See CGSPluginInterface
+        */
+        TInt PluginProviderCategory() const;
+        
+        /**
+        * @see CGSPluginInterface
+        */
+        CGulIcon* CreateIconL( const TUid aIconType );
+        
+        
+    protected: //Data        
+        
+        // Reference to application UI - not owned.
+        CAknViewAppUi* iAppUi;
+        
+        // RConeResourceLoader
+        RConeResourceLoader iResources;
+        
+        // Previous View ID
+        TVwsViewId iPrevViewId; // Previous view.
+        
+    private:
+    
+        // Pointer to the main list container - owned
+        CXDMPluginContainer* iMainListContainer;
+        
+        // Pointer to the setting list container - owned.
+        CXDMPluginSLContainer* iSettingListContainer;
+        
+        // Pointer to the current container - not owned.
+        CCoeControl* iCurrentContainer;   
+        
+#ifdef _DEBUG
+    friend class UT_CXDMPluginContainer;
+#endif
+    };
+
+#endif // GS_XDMPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/inc/XDMPlugin.hrh	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2009-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:  XDM Settings enumerations
+*
+*/
+
+
+#ifndef XDM_PLUGIN_HRH
+#define XDM_PLUGIN_HRH
+
+/**
+ * TSettingItems - identifiers for individual setting items
+ */
+enum TSettingItems
+    {
+    ESettingItemSettingName = 1,
+    ESettingItemAccessPoint,
+    ESettingItemServerAddress,
+    ESettingItemSipURL,
+    ESettingItemUserID,
+    ESettingItemPassword  
+    };
+    
+/**
+ * TGSXDMPluginCommandIds - GSXDMPlugin menu commands
+ */
+enum TGSXDMPluginCommandIds
+    {
+    EGSXDMPluginCmdChange = 0x06000,
+    EGSXDMPluginCmdEdit,
+    EGSXDMPluginCmdNewSettings,
+    EGSXDMPluginCmdNewExisting,
+    EGSXDMPluginCmdNewDefault,
+    EGSXDMPluginCmdDelete,
+    EGSXDMPluginCmdExitFromSL
+    };
+    
+/**
+ * TXDMSettingsViewType - Used inside UI to differentiate
+ * different kinds of editing
+ */ 
+enum TXDMSettingsViewType
+    {
+    EEditExisting,
+    ENewDefault,
+    ENewFromExisting        
+    };
+
+/**
+ * Constants used in application
+ */
+enum TXDMSettingsIndex
+    {
+    ESettingNameIndex = 0,
+    EAccessPointIndex,    
+    EServerAddressIndex,
+    ESipURLIndex,
+    EUserIDIndex,
+    EPasswordIndex
+    };
+    
+/**
+ * Constants used in resources and in application
+ */
+#define KMaxSettingSetNameLength 32
+#define KMaxSettingSetNameArrayGran 10
+#define KMaxUserIDLength 100
+#define KMaxServerAddressLength 100
+#define KMaxPasswordLength 100
+#define KMaxSIPURLLength 100
+#define KMaxAccessPointNameLength 32
+#define KMaxAccessPointDesLength 32
+#define KMaxMessageToDisplayLength 100
+
+
+#endif // XDM_PLUGIN_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/inc/XDMPluginContainer.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,230 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    XDM GS plugin main list container.
+*
+*/
+
+
+
+
+#ifndef GS_XDMPLUGIN_CONTAINER_H
+#define GS_XDMPLUGIN_CONTAINER_H
+
+// INCLUDES
+#include    <bldvariant.hrh>
+#include    <coeccntx.h>
+#include    <eikclb.h>
+#include    <eikmobs.h>
+#include    <akntitle.h>
+#include    <aknview.h>
+
+#include    "XDMPlugin.hrh"
+
+
+// FORWARD DECLARATION
+class CGSListBoxItemTextArray;
+class CEikTextListBox;
+class CAknSingleStyleListBox;
+class CXDMPluginMainList;
+class CAknColumnListBox;
+class CAknViewAppUi;
+class CXDMPlugin;
+class CMainView;
+
+// CLASS DECLARATION
+
+/**
+*  CXDMPluginContainer main list container class
+*/
+class CXDMPluginContainer : public CCoeControl, 
+                            public MEikListBoxObserver,
+                            public MEikMenuObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Constructor
+        */
+        CXDMPluginContainer(CAknView* aView);
+
+        /**
+        * Symbian OS constructor.
+        *
+        * @param aRect Listbox's rect.
+        */
+        void ConstructL( const TRect& aRect );
+
+        /**
+        * Destructor.
+        */
+        ~CXDMPluginContainer();
+    
+    public: // From CCoeControl
+        
+        /**
+        * See CCoeControl
+        */
+        TInt CountComponentControls() const;
+        
+        /**
+        * See CCoeControl
+        */
+        CCoeControl* ComponentControl( TInt aIndex ) const;
+
+        /**
+        * See CCoeControl
+        */
+        TKeyResponse OfferKeyEventL( 
+            const TKeyEvent& aKeyEvent, TEventCode aType );
+
+        /**
+        * See CCoeControl
+        */
+        void SizeChanged();
+
+        /**
+        * See CCoeControl
+        */
+        void HandleResourceChange( TInt aType );
+        
+        /**
+         * Gets help context
+         */
+        void GetHelpContext( TCoeHelpContext& aContext ) const;
+
+        /**
+         * See CCoeControl
+         */
+        void FocusChanged(TDrawNow aDrawNow);
+
+ 
+    public: // own methods
+        
+        /**
+        * Invokes editing on current item, in response to UI Edit command
+        */
+        void EditCurrentItemL();
+        
+        /**
+        * See MEikListBoxObserver
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+        
+        /**
+         * From MEikMenuObserver
+         */
+        void SetEmphasis( CCoeControl* /*aMenuControl*/, TBool /*aEmphasis*/ ){};
+      
+        
+        /**
+         * From MEikMenuObserver
+         */
+        void ProcessCommandL( TInt /*aCommandId*/ ){};
+        
+        /**
+        * Finds whether main list is empty
+        * @return ETrue if main list is empty.
+        */
+        TBool IsListEmpty();
+        
+        /**
+        * Finds whether the current item is the last item in main list
+        * @return ETrue if current item is last in main list.
+        */
+        TBool IsLastItem();
+        
+        /**
+        * Delete the currently focused set. Also deletes it using XDM API
+        */
+        void DeleteCurrentSetL();
+        
+        /**
+        * Load the main list using XDM API, and perform other necessary tasks
+        */
+        void LoadSettingsListArrayL();
+        
+        /**
+        * Get the name of currently focused set. Usually called by UI.
+        * The pointer to buffer remains on heap, which is deleted by caller.
+        * @return HBufC* pointer to currently focused set name
+        */
+        HBufC* GetCurrentSetNameLC();
+        
+        /**
+        * This function starts the deleting current XDM set. All sub functions
+        * are called through this function.
+        */
+        void DeleteSetProcedureL();
+
+        /**
+        * This function does necessary action on layout change, it is called from
+        * actual resource change function.
+        * @param aType type of resource
+        */
+        void HandleResourceChangeManual(TInt aType);
+
+        /**
+        * Set the focus to the given set name if it exist
+        * @param aSetName Set name to set focus
+        */
+        void SetFocusIfExist(TDes& aSetName);
+
+        
+    private: // own methods
+    
+        /**
+        * Perform the initial setup of the main list. Called by Constructor
+        */
+      void SetupListL();
+      
+        /**
+        * Get the Setting ID of the current set
+        * @return TInt setting ID of the current set
+        */
+      TInt CXDMPluginContainer::GetCurrentSetIdL();
+      
+        /**
+        * Load XDM Collection names with trap, useful when list doesnt have anything
+        * @param Reference to setting ids
+        * @return CDesCArray collection names
+        */
+      CDesCArray* LoadCollectionNamesL(RArray<TInt>& aSettingIDs);
+      
+      
+      
+    private: // data
+      
+        // Pointer to the main list, owned
+      CAknColumnListBox* iMainList;
+  
+      // Pointer to the application view, not owned
+      CAknView* iView; // not owned
+      
+      // The XDM set names list array, not owned
+      CDesCArray* iSettingListArray;
+      
+      // Buffer for holding new XDM set name
+      TBuf<KMaxSettingSetNameLength>  iSettingNewName;
+      
+      // Title for menu pane
+      TBuf<KMaxSettingSetNameLength>  iTitle;
+      
+      // Pointer to title pane, not owned
+      CAknTitlePane* iTitlePane;
+      
+      // Menubar, owned
+      CEikMenuBar* iEikMenuBar;
+    };
+
+#endif //GS_XDMPLUGIN_CONTAINER_H   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/inc/XDMPluginSLContainer.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,306 @@
+/*
+* Copyright (c) 2005-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:    XDM GS plugin Settings list container.
+*
+*/
+
+
+
+
+#ifndef GS_XDMPLUGIN_SL_CONTAINER_H
+#define GS_XDMPLUGIN_SL_CONTAINER_H
+
+// INCLUDES
+#include    <bldvariant.hrh>
+#include    <coeccntx.h>
+#include    <eikclb.h>
+#include    <aknview.h>
+
+#include    "XDMPlugin.hrh"
+
+// FORWARD DECLARATION
+class CGSListBoxItemTextArray;
+class CEikTextListBox;
+class CSettingsData;
+class CXDMPluginSettinglist;
+class CAknColumnListBox;
+class CAknViewAppUi;
+
+/**
+*  CXDMPluginSLContainer Settings list container class
+*/
+class CXDMPluginSLContainer : public CCoeControl, MEikListBoxObserver
+    {
+    public:
+    
+        /**
+        * C++ Constructor
+        */
+        CXDMPluginSLContainer(CAknView* aView);
+        
+        /**
+        * Symbian OS constructor.
+        * @param aRect Listbox's rect.
+        */
+        void ConstructL( const TRect& aRect);
+
+        /**
+        * Destructor.
+        */
+        ~CXDMPluginSLContainer();
+    
+    public: // From CCoeControl
+    
+        /**
+        * See CCoeControl.
+        */
+        TInt CountComponentControls() const;
+        
+        /**
+        * See CCoeControl.
+        */
+        CCoeControl* ComponentControl( TInt aIndex ) const;
+        
+        /**
+        * See CCoeControl.
+        */
+        TKeyResponse OfferKeyEventL( 
+            const TKeyEvent& aKeyEvent, TEventCode aType );
+            
+        /**
+        * See CCoeControl.
+        */
+        void SizeChanged();
+        
+        /**
+        * See CCoeControl.
+        */
+        void Draw(const TRect& aRect) const;
+        
+        /**
+        * See CCoeControl
+        */
+        void HandleResourceChange( TInt aType );
+
+        /**
+         * Gets help context
+         */
+        void GetHelpContext( TCoeHelpContext& aContext ) const;
+
+        /**
+         * See CCoeControl
+         */
+        void FocusChanged(TDrawNow aDrawNow);
+        
+    public:
+    
+        /**
+        * Edit currently focused item on settings list. called from UI
+        */
+        void EditCurrentItemL();
+        
+        /**
+        * See MEikListBoxObserver
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+        
+        /**
+        * Prepare the XDM set with given name for editing
+        * @param aXDMSetName reference to the XDM set name to be edited
+        */
+        void PrepareXDMSetForEditingL(TDesC& aXDMSetName);
+        
+        /**
+        * Prepare the a new XDM set with default values
+        * @param none
+        */
+        void PrepareXDMSetNewDefaultL();
+        
+        /**
+        * Prepare the a new XDM set with values from an existing set
+        * @param aXDMSetName reference to the new XDM set name
+        */
+        void PrepareNewXDMSetFromExistingL(TDesC& aXDMSetName);
+        
+        /**
+        * Display the dialog to the user to select the creation of new set
+        * from existing sets. Saves the selected name to iData
+        * @return ETrue if user has choosen a set, return EFalse if user cancels
+        */
+        TBool DisplayNewXDMSetOptionsL();
+        
+        /**
+        * Called by the UI when back button is pressed, to perform needed steps
+        * @return ETrue if settings list is allowed to close
+        */
+        TBool IsExitProcessingOKL();
+        
+        /**
+        * Handle manual resource change with its type
+        * @param aType, type of resource
+        */
+        void HandleResourceChangeManual(TInt aType);
+
+        /**
+        * Save settings if possible, without any user interaction.
+        * this is useful for force exit, e.g. when mmc taken out
+        */
+        void SaveSettingsIfPossibleL();
+        
+        /**
+        * Return the name of current set in iData
+        * @return TDes reference to current set
+        */
+        TDes& GetCurrentSetName();
+               
+        /**
+        * Returns ETrue is AP used by XDM settings is in use
+        * @return ETrue if ap in use
+        */
+        TBool SettingsApInUseL(TDesC& aXDMSetName);
+        
+        
+    private: // Most of these methods perform operations using iData
+    
+        /**
+        * Sets the title pane text with given discriptor
+        * @param aTitleText text to be shown on title pane
+        */
+        void SetTitlePaneTextL( const TDesC& aTitleText ) const;
+        
+        /**
+        * Finds out whether compulsory items are filled
+        * @return ETrue if compulsory items are filled
+        */
+        TBool AreCompulsoryItemsFilled();
+        
+        /**
+        * Display a query dialog to user that compulsory settings are not
+        * filled, and if user wants to delete the settings
+        * @return ETrue if user wants to delete the settings
+        */
+        TBool DisplayDeleteOrDontSaveDialogL();
+        
+        /**
+        * Update an XDM set if it already exist or create it if it doesnt exist
+        * @param aShowDialog whether dialog will be displayed or not
+        * @return ETrue if save procedure goes ok
+        */
+        TBool SaveOrCreateAndSaveXDMSetL(TBool aShowDialog);
+        
+        /**
+        * Deletes the XDM set if it exist in the XDM settings API
+        */
+        void DeleteXDMSetIfExistL();
+        
+        /**
+        * Gets the setting id of the given set name
+        * @param aXDMSetName reference to XDM set name
+        * @return settingid of the given xdm set
+        */
+        TInt GetSettingIdL(TDesC& aXDMSetName);
+        
+        /**
+        * If the given XDM set name with given ID is exist or not
+        * @param aXDMSetName reference to XDM set name
+        * aSettingId settings id of the XDM
+        * @return ETrue of XDM set exist with given name
+        */
+        TBool IsXDMSetNameExistL(TDesC& aXDMSetName, TInt32& aSettingId);
+        
+        /**
+        * Load XDM Collection names with trap, useful when list doesnt have anything
+        * @param Reference to setting ids
+        * @return CDesCArray collection names
+        */
+        CDesCArray* LoadCollectionNamesL(RArray<TInt>& aSettingIDs, TBool aDisp);
+        
+        /**
+        * Check the given name and returns the possible altered name. NULL 
+        * pointer is returned no change is needed in aName, so aName can be
+        * used if NULL pointer is returned. If some valid pointer is returned
+        * then that pointer is owned by client, and needed to be deleted after
+        * usage. 
+        * @param aName, the name from which to start suggestion.
+        * @param aChanged, returns ETrue if an alternate name is returned.
+        * @return HBufC* pointer to the new name, can be NULL if not needed.
+        */
+        HBufC* DoMakeValidNameL(HBufC* aName, TBool& aChanged);
+        
+        /**
+        * Ensures that the passed name is valid, length > 0 & length < max.
+        * If length == 0, leaves with KErrInvalidName
+        * If name is only whitespace, leaves with KErrInvalidName
+        * If name is longer than max, name is truncated
+        * It copies the name, pushes it onto the CleanupStack and passes
+        * ownership.
+
+        * @param aName The name
+        * @param aChanged A reference to a boolean to hold whether the name 
+        *   had been changed or not.
+        * @return The valid-length name
+        */
+        HBufC* EnsureMaxLengthLC( const TDesC* aName, TBool& aChanged);
+        
+        /**
+        * Given aName in the format <prefix> or
+        * <prefix><brace><integer><brace>, return a
+        * pointer to the leading part. That is, if there is
+        * trailing <space><integer>, then that is excluded;
+        * if there is no trailing part, then the original
+        * decriptor is returned.
+        * Examples:
+        *   - "Foo" returns "Foo";
+        *   - "Foo 12" returns "Foo 12";
+        *   - "Foo(12)" returns "Foo";
+        *   - "Foo 12 (34)" returns "Foo 12 ";
+        *   - "Foo bar" returns "Foo bar";
+        *   - "Foo " returns "Foo ".
+        * @param aName  The name to get the prefix from
+        * @return The prefix
+        */        
+        TPtrC GetPrefix( const TDesC& aName );
+        
+        
+        /**
+        * If aName is constructed from aPrefix with a postfix, get the numeric
+        * value of the postfix, e.g:
+        *   - GetPostfix( "Foo (3)", "Foo" ) == 3
+        *   - GetPostfix( "Foo 23 (45)", "Foo 23" ) == 45
+        * If aName is the same as aPrefix, return 0, e.g.:
+        *   - GetPostfix( "Foo", "Foo" ) == 0
+        * If aName is not constructed from aPrefix, return -1, e.g.:
+        *   - GetPostfix( "Foobar", "Foo" ) == -1
+        *   - GetPostfix( "Fo 23 45", "Foo" ) == -1
+        * @param aName  The name to get the postfix from
+        * @param aPrefix The prefix
+        * @return The postfix
+        */
+        TInt GetPostfix( const TDesC& aName, const TDesC& aPrefix );
+
+        
+   private: // data
+        
+        // CXDMPluginSettinglist owned
+      CXDMPluginSettinglist* iSettingList;        
+  
+      // Pointer to settings data owned
+      CSettingsData* iData;
+
+      // Pointer to the application view, not owned
+      CAknView* iView; // not owned
+
+    };
+
+#endif //GS_XDMPLUGIN_SL_CONTAINER_H   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/inc/XDMPluginSettinglist.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2005-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:    XDM GS plugin, Setting List class
+*
+*/
+
+
+
+
+#ifndef CXDMPLUGINSETTINGLIST_H
+#define CXDMPLUGINSETTINGLIST_H
+
+// INCLUDE FILES
+#include <coecntrl.h>
+#include <aknsettingitemlist.h>
+#include <agentdialog.h>
+
+// FORWARD DECLARATIONS
+class CSettingsData;
+
+/**
+*  CXDMPluginSettinglist derived from CAknSettingItemList
+*/
+class CXDMPluginSettinglist : public CAknSettingItemList
+    {
+    
+    public:
+        
+        /**
+        * Symbian OS two-phased constructor
+        * @param reference to CSettingsData from which data to be displayed
+        */
+        static CXDMPluginSettinglist* NewL(CSettingsData &aData);
+        
+        /**
+        * Symbian OS two-phased constructor, leave pointer to stack
+        * @param reference to CSettingsData from which data to be displayed
+        */
+        static CXDMPluginSettinglist* NewLC(CSettingsData &aData);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CXDMPluginSettinglist();
+
+        /**
+        * Inherited from base classes. See CCoeControl
+        */
+        void SizeChanged();
+      
+        /**
+        * Edit the indexed item. This probably came as a result of UI command
+        * @param aIndex index to the item
+        * aCalledFromMenu ETrue of this call resulted from UI command
+        */
+        void EditItemL (TInt aIndex, TBool aCalledFromMenu);
+      
+        /**
+        * Actual editing of item done here, from whereever the call is made from
+        */
+        void EditCurrentItemL();
+      
+        /**
+        * Gets the Access point name
+        * @param aAP Access point number as integer
+        * aAccessPoint reference to TDes, doesnt change if AP not found
+        * otherwise access point name returns here
+        */
+        void GetAccessPointNameL(TInt32 aAP, TDes& aAccessPoint);
+        
+        /**
+        * For checking if access point is in use
+        * @param aAP Access point number as integer
+        * return ETrue if access point is in use
+        */
+        TBool IsAccessPointInUseL(TInt32 aAP);
+      
+        /**
+        * Sets the focus to the first item of the settings list
+        */
+        void ResetItemIndex();
+
+    private:
+        
+        /**
+        * C++ constructor
+        * @param reference to CSettingsData
+        */
+        CXDMPluginSettinglist(CSettingsData &aData);
+
+        /**
+        * See CAknSettingItemList
+        */
+        CAknSettingItem* CreateSettingItemL (TInt aSettingId);
+      
+        /**
+        * Edit the AccessPoint, We edit the access point differently than other
+        * settings. We bypass the list's text editor and open the S60 standard
+        * access point editor 
+        */
+        void EditAccessPointL();
+      
+        /**
+        * Saves the changed settings to the list's data
+        * @param aIndex index of the setting to be saved
+        */
+        void SaveSettingL(TInt aIndex);
+      
+        /**
+        * Sets the title pane text with given discriptor
+        * @param aTitleText text to be shown on title pane
+        */
+        void SetTitlePaneTextL( const TDesC& aTitleText ) const;
+
+    private:
+    
+        // Reference to the data owned by container
+        CSettingsData& iSettingsData;
+        
+    };
+
+#endif // CXDMPLUGINSETTINGLIST_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/loc/GSXDMPlugin.loc	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,185 @@
+/*
+* 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:    Localization strings for GS XDM Plugin
+*
+*/
+
+
+
+
+//  LOCALISATION STRINGS
+
+//d:Caption string for AIF file (short)
+//d:GS XDM Settings plugin
+//l:cell_app_pane_t1
+//r:3.0
+#define qtn_apps_xdm_grid                       "XDMSettingsApp"
+
+//d:Caption string for AIF file (long)
+//d:GS XDM Settings plugin
+//l:list_single_large_graphic_pane_t1
+//r:3.0
+#define qtn_apps_xdm_list                       "XDMSettingsApp"
+
+//d:Popup confirmation dialog text when deleting the last XDM set of the list
+//d:GS XDM Settings plugin
+//l:popup_note_window
+//r:3.1
+#define qtn_xdm_conf_delete_last "%U is the last XDM set. Are you sure to delete it?"
+
+//d:Popup confirmation dialog text when deleting a XDM set, not the last.
+//d:GS XDM Settings plugin
+//l:popup_note_window
+//r:3.1
+#define qtn_xdm_conf_delete "Delete %U?"
+
+//d:Menu Item use existing set
+//d:GS XDM Settings plugin
+//l:heading_pane_t1
+//r:3.1
+#define qtn_xdm_propmt_use_exist "Use existing set"
+
+//d:Menu Item to change a specific setting in an XDM set
+//d:GS XDM Settings plugin
+//l:list_single_pane_t1_cp2
+//r:3.1
+#define qtn_xdm_settings_change "Change"
+
+//d:Default text in password setting field
+//d:GS XDM Settings plugin
+//l:list_set_graphic_pane_t1
+//r:3.1
+#define qtn_xdm_text_password "****"
+
+//d:Title for password setting field
+//d:GS XDM Settings plugin
+//l:list_setting_pane_t1
+//r:3.1
+#define qtn_xdm_settings_password "HTTP password"
+
+//d:Title for SIP setting field
+//d:GS XDM Settings plugin
+//l:list_setting_pane_t1
+//r:3.1
+#define qtn_xdm_settings_sip "SIP in use"
+
+//d:Title for user id settings
+//d:GS XDM Settings plugin
+//l:list_setting_pane_t1
+//r:3.1
+#define qtn_xdm_settings_username "HTTP username"
+
+//d:Title of the service address setting field
+//d:GS XDM Settings plugin
+//l:list_setting_pane_t1
+//r:3.1
+#define qtn_xdm_settings_address "XDM service address"
+
+//d:Default text in compulsory setting fields
+//d:GS XDM Settings plugin
+//l:list_set_graphic_pane_t1
+//r:3.1
+#define qtn_xdm_settings_must_define "Must be defined"
+
+//d:Title of the access point setting field
+//d:GS XDM Settings plugin
+//l:list_setting_pane_t1
+//r:3.1
+#define qtn_xdm_settings_access_point "Access point"
+
+//d:Default xdm set name
+//d:GS XDM Settings plugin
+//l:list_set_graphic_pane_t1
+//r:3.1
+#define qtn_xdm_text_new_set_many "New XDM set(%N)"
+
+//d:Menu item for setting up a new XDM set
+//d:GS XDM Settings plugin
+//l:list_single_pane_t1_cp2
+//r:3.1
+#define qtn_xdm_text_new_set "New XDM set"
+
+//d:Title of XDM set name setting
+//d:GS XDM Settings plugin
+//l:list_setting_pane_t1
+//r:3.1
+#define qtn_xdm_settings_set_name "XDM set name"
+
+//d:Menu item delete, to delete an specific XDM set
+//d:GS XDM Settings plugin
+//l:list_single_pane_t1_cp2
+//r:3.1
+#define qtn_xdm_options_delete "Delete"
+
+//d:Title of the popup sub menu
+//d:GS XDM Settings plugin
+//l:list_single_popup_submenu_pane_t1
+//r:3.1
+#define qtn_xdm_options_new_sub_existing "Use existing set"
+
+//d:Menu item to edit an XDM set
+//d:GS XDM Settings plugin
+//l:list_single_pane_t1_cp2
+//r:3.1
+#define qtn_xdm_options_edit_set "Edit XDM set"
+
+//d: Menu Item to use default set template for a new set
+//d:GS XDM Settings plugin
+//l:list_single_popup_submenu_pane_t1
+//r:3.1
+#define qtn_xdm_options_new_sub_default "Use default set"
+
+//d:Menu item New XDM set
+//d:GS XDM Settings plugin
+//l:list_single_pane_t1_cp2/opt3
+//r:3.1
+#define qtn_xdm_options_new_set "New XDM set"
+
+//d:Compulsory setting item indicator
+//d:GS XDM Settings plugin
+//l:list_set_graphic_pane_t1
+//r:3.1
+#define qtn_xdm_compulsory_indicator "*"
+
+//d:XDM sets, empty list primary text
+//d:GS XDM Settings plugin
+//l:main_pane_empty_t1/opt2
+//r:3.1
+#define qtn_xdm_main_empty_info_text "No XDM settings"
+
+//d:XDM sets, empty list secondary text
+//d:GS XDM Settings plugin
+//l:main_list_empty_pane/opt2
+//r:3.1
+#define qtn_xdm_main_empty_info_text_secondary "Create new settings from Options menu"
+
+//d:Text in main title pane
+//d:GS XDM Settings plugin
+//l:title_pane_t2/opt12
+//r:3.1
+#define qtn_xdm_title "XDM settings"
+
+//d:Text in pop up query dialog for reminding compulsory settings
+//d:GS XDM Settings plugin
+//l:popup_note_window
+//r:3.1
+#define qtn_xdm_compulsory_query_info_text "Incomplete XDM setting set. Delete set?"
+
+//d:Text in info note that a given xdm set name is already exist
+//d:GS XDM Settings plugin
+//l:popup_note_window
+//r:3.1
+#define qtn_xdm_set_already_exist_info "Name already in use: %U"
+
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/rom/GSXDMPlugin.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  GS XDM Plugin UI
+*
+*/
+
+
+#ifndef __GS_XDM_Plugin_IBY__
+#define __GS_XDM_Plugin_IBY__
+
+#include <bldvariant.hrh>
+#ifdef __XDM
+
+//GS plugin in use
+#ifdef RD_GS_RENOVATION
+
+// GS XDM Plugin UI
+ECOM_PLUGIN(GSXDMPlugin.dll,10207428.rsc) // this publishes the DLL and the 
+            // resource file to the correct location
+data=DATAZ_/BITMAP_DIR/GSXDMplugin.mif BITMAP_DIR/GSXDMplugin.mif
+
+#endif //RD_GS_RENOVATION
+
+#endif        //__XDM
+
+#endif //__GS_XDM_Plugin_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/rom/GSXDMPluginResources.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  GS XDM Plugin UI Resources
+*
+*/
+
+
+#ifndef __GS_XDM_Plugin_Resources_IBY__
+#define __GS_XDM_Plugin_Resources_IBY__
+
+#include <bldvariant.hrh>
+#ifdef __XDM
+
+//GS plugin in use
+#ifdef RD_GS_RENOVATION
+
+// GS XDM Plugin UI
+
+data=DATAZ_/RESOURCE_FILES_DIR/XDMPluginRsc.RSC       RESOURCE_FILES_DIR/XDMPluginRsc.RSC
+
+#endif //RD_GS_RENOVATION
+
+#endif        //__XDM
+
+#endif //__GS_XDM_Plugin_Resources_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/src/SettingsData.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    XDM GS plugin data holding class for XDM setting list
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "SettingsData.h"
+
+// -----------------------------------------------------------------------------
+// CSettingsData::NewL
+// -----------------------------------------------------------------------------
+//
+CSettingsData *CSettingsData::NewL()
+    {
+    CSettingsData *self = CSettingsData::NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSettingsData::NewLC()
+// -----------------------------------------------------------------------------
+//
+CSettingsData *CSettingsData::NewLC()
+    {
+    CSettingsData *self = new (ELeave) CSettingsData();
+    CleanupStack::PushL(self);
+
+    self->ConstructL();
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CSettingsData::~CSettingsData()
+// -----------------------------------------------------------------------------
+//
+CSettingsData::~CSettingsData()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSettingsData::CSettingsData()
+// -----------------------------------------------------------------------------
+//
+CSettingsData::CSettingsData()
+    {
+    // initialise local data
+    Reset();
+    }
+
+// -----------------------------------------------------------------------------
+// CSettingsData::ConstructL() 
+// -----------------------------------------------------------------------------
+//
+void CSettingsData::ConstructL() 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CSettingsData::Reset()
+// -----------------------------------------------------------------------------
+//
+void CSettingsData::Reset()
+    {
+    iSettingName = KNullDesC;
+    iSettingNameDisp = KNullDesC;
+    iServerAddress = KNullDesC;
+    iAccessPoint = -1;
+    iAccessPointDes = KNullDesC;
+    iSipURL = KNullDesC;
+    iUserID= KNullDesC;
+    iPassword = KNullDesC;
+    iAccessPointName = KNullDesC;
+    iSettingId = -1;    
+    }
+
+//  End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/src/XDMPlugin.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,510 @@
+/*
+* Copyright (c) 2005-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:    XDMPlugin Implementation
+*
+*/
+
+
+
+
+// Includes
+#include "XDMExternalInterface.h"
+
+#include <aknViewAppUi.h>
+#include <StringLoader.h>
+#include <gsprivatepluginproviderids.h>
+#include <eikmenub.h>
+#include <aknlists.h>
+#include <aknPopup.h>
+#include <XdmSettingsApi.h>
+#include <AknQueryDialog.h>
+#include <featmgr.h>
+#include <hlplch.h>
+#include <csxhelp/xdm.hlp.hrh>
+#include <gsxdmplugin.mbg>
+#include <bautils.h>
+
+#include "XDMPlugin.h"
+#include "XDMPluginContainer.h"
+#include "XDMPluginSLContainer.h"
+#include "XDMPlugin.hrh"
+
+
+// Constants
+
+const TInt KMaxNameLength = 255;
+
+_LIT( KGSXDMPluginResourceFileName, "z:\\resource\\XDMPluginRsc.rsc" );
+
+#ifdef __SCALABLE_ICONS
+// bitmap
+_LIT( KGSXDMPluginIconFileName, "\\resource\\apps\\GSXDMplugin.mif");
+#else //__SCALABLE_ICONS
+// svg file
+_LIT( KGSXDMPluginIconFileName, "\\resource\\apps\\GSXDMplugin.mbm");
+#endif //__SCALABLE_ICONS
+
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::CXDMPlugin()
+// Constructor
+//
+// ---------------------------------------------------------------------------
+//
+CXDMPlugin::CXDMPlugin( )
+    : iAppUi( CAknView::AppUi() ), iResources( *CCoeEnv::Static() )
+    {
+    
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::~CXDMPlugin()
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CXDMPlugin::~CXDMPlugin()
+    {
+    if (iCurrentContainer)
+        {
+        if(iAppUi)
+        iAppUi->RemoveFromViewStack( *this, iCurrentContainer );
+        iCurrentContainer = NULL;
+        }
+
+    if( iMainListContainer )
+        {
+        delete iMainListContainer;
+        iMainListContainer=NULL;
+        }
+        
+    if (iSettingListContainer)
+        {
+        delete iSettingListContainer;
+        iSettingListContainer=NULL;
+        }
+
+    iResources.Close();
+    /** Nice to know when the plugin is cleaned up */
+    #ifdef _DEBUG
+    RDebug::Print( _L( "[CXDMPlugin] ~CXDMPlugin()" ) );
+    #endif
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::ConstructL()
+// Symbian OS two-phased constructor
+// ---------------------------------------------------------------------------
+//
+void CXDMPlugin::ConstructL()
+    {
+    // To know if the plugin is loaded (for debugging)
+    #ifdef _DEBUG
+    RDebug::Print(_L("[CXDMPlugin] ConstructL()" ));
+    RDebug::Print( _L( "[CXDMPlugin] Loading resource from :" ) );
+    RDebug::Print( KGSXDMPluginResourceFileName );
+    #endif
+    
+    TFileName fileName( KGSXDMPluginResourceFileName );
+    BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
+    iResources.OpenL( fileName );
+    BaseConstructL( R_GS_XDM_MAIN_VIEW );
+        
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::NewL()
+// Static constructor
+// ---------------------------------------------------------------------------
+//
+CXDMPlugin* CXDMPlugin::NewL( TAny* /*aInitParams*/ )
+    {
+    CXDMPlugin* self = new(ELeave) CXDMPlugin( );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::Id() const
+// ---------------------------------------------------------------------------
+//
+TUid CXDMPlugin::Id() const
+    {
+    return KGSXDMPluginUid;
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::HandleClientRectChange()
+// ---------------------------------------------------------------------------
+void CXDMPlugin::HandleViewRectChange()
+    {
+    if ( iMainListContainer->IsVisible() )
+        {
+        iMainListContainer->SetRect( ClientRect() );
+        }
+        
+    if ( iSettingListContainer->IsVisible() )
+        {
+        iSettingListContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::DoActivateL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPlugin::DoActivateL( const TVwsViewId& aPrevViewId,
+                                  TUid /*aCustomMessageId*/,
+                                  const TDesC8& /*aCustomMessage*/ )
+    {
+    iPrevViewId = aPrevViewId;
+    if (iCurrentContainer)
+        {
+        iAppUi->RemoveFromViewStack( *this, iCurrentContainer );
+        iCurrentContainer = NULL;
+        }
+        
+
+    if( iMainListContainer )
+        {
+        delete iMainListContainer;
+        iMainListContainer=NULL;
+        }
+
+    if( iSettingListContainer )
+        {
+        delete iSettingListContainer;
+        iSettingListContainer = NULL;
+        }
+
+    iMainListContainer = new( ELeave ) CXDMPluginContainer(this);
+    iMainListContainer->SetMopParent(this);
+    TRAPD( error, iMainListContainer->ConstructL( ClientRect() ) );
+    if (error)
+        {
+        delete iMainListContainer;
+        iMainListContainer = NULL;
+        User::Leave( error );
+        }
+        
+    iSettingListContainer = new( ELeave ) CXDMPluginSLContainer(this);
+    iSettingListContainer->SetMopParent(this);
+    TRAPD( error1, iSettingListContainer->ConstructL( ClientRect()));
+    if (error1)
+        {
+        delete iSettingListContainer;
+        iSettingListContainer = NULL;
+        User::Leave( error1 );
+        }
+
+    // switching control
+    iSettingListContainer->MakeVisible(EFalse);    
+    iCurrentContainer = iMainListContainer;
+    iAppUi->AddToViewStackL( *this, iCurrentContainer );
+    UpdateMskL();
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::DoDeactivate()
+// ---------------------------------------------------------------------------
+//
+void CXDMPlugin::DoDeactivate()
+    {
+    // try to save settings if in settings list container
+    TInt err;
+    if (iCurrentContainer == iSettingListContainer)
+        TRAP(err, iSettingListContainer->SaveSettingsIfPossibleL());
+    if (iCurrentContainer)
+        iAppUi->RemoveFromViewStack( *this, iCurrentContainer );
+    iCurrentContainer = NULL;
+
+    if( iMainListContainer )
+        {
+        delete iMainListContainer;
+        iMainListContainer = NULL;
+        }
+        
+    if( iSettingListContainer )
+        {
+        delete iSettingListContainer;
+        iSettingListContainer = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::HandleCommandL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPlugin::HandleCommandL( TInt aCommand )
+    {
+    switch ( aCommand )
+        {
+        case EAknSoftkeyBack:
+            if (iCurrentContainer == iSettingListContainer)
+                {
+                if (iSettingListContainer->IsExitProcessingOKL())
+                    LoadMainViewL();    
+                }
+            else 
+                iAppUi->ActivateLocalViewL( iPrevViewId.iViewUid );
+            break;
+        case EGSXDMPluginCmdChange:
+            iSettingListContainer->EditCurrentItemL();                       
+            break;
+        case EGSXDMPluginCmdEdit:
+            iMainListContainer->EditCurrentItemL();
+            break;
+        case EGSXDMPluginCmdNewExisting:
+            if(iSettingListContainer->DisplayNewXDMSetOptionsL()) // if user ok
+                LoadSettingsViewL(ENewFromExisting, iSettingListContainer->GetCurrentSetName());
+            break;
+        case EGSXDMPluginCmdNewDefault:
+            LoadSettingsViewL(ENewDefault, iSettingListContainer->GetCurrentSetName());
+            break;
+        case EGSXDMPluginCmdDelete:
+            iMainListContainer->DeleteSetProcedureL();
+            UpdateMskL();
+            break;
+        case EAknCmdHelp:
+            HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), AppUi()->AppHelpContextL ());
+            break;
+        case EGSXDMPluginCmdExitFromSL:
+            if (iCurrentContainer == iSettingListContainer)
+                {
+                if (iSettingListContainer->IsExitProcessingOKL())
+                    iAppUi->HandleCommandL( EAknCmdExit ); 
+                }
+            break;
+        case EAknCmdExit:
+        case EEikCmdExit:
+            if (iCurrentContainer == iSettingListContainer)
+                iSettingListContainer->SaveSettingsIfPossibleL();
+            iAppUi->HandleCommandL( EAknCmdExit );
+            break;    
+        default:
+            iAppUi->HandleCommandL( aCommand );
+            break;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::GetCaptionL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPlugin::GetCaptionL( TDes& aCaption ) const
+    {
+    StringLoader::Load( aCaption, R_STR_XDM_SETTINGS );
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::PluginProviderCategory()
+// ---------------------------------------------------------------------------
+//
+TInt CXDMPlugin::PluginProviderCategory() const
+    {
+    return KGSPluginProviderInternal;
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::LoadSettingsViewL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPlugin::LoadSettingsViewL(TXDMSettingsViewType aType, TDesC& aXDMSetName)
+    {
+    switch(aType)
+        {
+        case EEditExisting:
+            iSettingListContainer->PrepareXDMSetForEditingL(aXDMSetName);
+            break;
+        case ENewDefault:
+            iSettingListContainer->PrepareXDMSetNewDefaultL();
+            break;
+        case ENewFromExisting:
+            iSettingListContainer->PrepareNewXDMSetFromExistingL(aXDMSetName);
+            break;
+        default:
+            break;
+        }
+    if (iCurrentContainer)
+        iAppUi->RemoveFromViewStack( *this, iCurrentContainer );
+    iCurrentContainer = iSettingListContainer;
+    iAppUi->AddToViewStackL( *this, iCurrentContainer );
+    iMainListContainer->MakeVisible(EFalse);
+    iSettingListContainer->MakeVisible(ETrue);
+    UpdateMskL();
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPlugin::LoadMainViewL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPlugin::LoadMainViewL()
+    {
+    TInt err(KErrNone);
+    TRAP(err,iMainListContainer->LoadSettingsListArrayL()); // update main container
+    if (iCurrentContainer)
+        iAppUi->RemoveFromViewStack( *this, iCurrentContainer );
+    iCurrentContainer = iMainListContainer;
+    iAppUi->AddToViewStackL( *this, iCurrentContainer );
+    
+    iMainListContainer->SetFocusIfExist(iSettingListContainer->GetCurrentSetName());
+    
+    iSettingListContainer->MakeVisible(EFalse);  
+    iMainListContainer->MakeVisible(ETrue);
+    UpdateMskL();
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPlugin::DynInitMenuPaneL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPlugin::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
+    {
+    if (!FeatureManager::FeatureSupported(KFeatureIdHelp))
+    	{
+    	aMenuPane->SetItemDimmed(EAknCmdHelp, ETrue);
+    	}
+    
+    if (aResourceId == R_GS_XDM_SETTINGS_MAIN_MENU)
+        {
+        if (iCurrentContainer == iMainListContainer)
+            {
+            aMenuPane->SetItemDimmed(EGSXDMPluginCmdChange, ETrue);
+            aMenuPane->SetItemDimmed(EGSXDMPluginCmdExitFromSL, ETrue);
+            if (iMainListContainer->IsListEmpty())
+                {
+                aMenuPane->SetItemDimmed(EGSXDMPluginCmdEdit, ETrue);
+                aMenuPane->SetItemDimmed(EGSXDMPluginCmdDelete, ETrue);
+                }
+            }
+        else
+            {
+            aMenuPane->SetItemDimmed(EGSXDMPluginCmdEdit, ETrue);
+            aMenuPane->SetItemDimmed(EGSXDMPluginCmdDelete, ETrue);
+            aMenuPane->SetItemDimmed(EGSXDMPluginCmdNewSettings, ETrue);
+            aMenuPane->SetItemDimmed(EAknCmdExit, ETrue);
+            }
+        }
+    
+    if (aResourceId == R_GS_XDM_NEW_SETTINGS_MENU)
+        {
+        if (iMainListContainer->IsListEmpty())
+            {
+            aMenuPane->SetItemDimmed(EGSXDMPluginCmdNewExisting, ETrue);
+            }
+        }
+    
+    if ( iSettingListContainer && !iMainListContainer->IsListEmpty() )
+        {
+        TBool inUse( EFalse );
+        HBufC* currentSetName = iMainListContainer->GetCurrentSetNameLC();
+        TBuf<KMaxNameLength> setName;
+        setName.Copy( currentSetName->Des() );
+        TRAP_IGNORE( inUse = iSettingListContainer->SettingsApInUseL( setName ) );
+        CleanupStack::PopAndDestroy( currentSetName );
+    
+        if ( inUse )
+            {
+            TInt pos( KErrNotFound );
+            if ( aMenuPane->MenuItemExists( EGSXDMPluginCmdDelete, pos ) )
+                {
+                aMenuPane->SetItemSpecific( EGSXDMPluginCmdDelete, EFalse );
+                aMenuPane->SetItemDimmed(EGSXDMPluginCmdDelete, ETrue);
+                }
+            }
+        else
+            {
+            TInt pos( KErrNotFound );
+            if ( aMenuPane->MenuItemExists( EGSXDMPluginCmdDelete, pos ) )
+                {
+                aMenuPane->SetItemSpecific( EGSXDMPluginCmdDelete, ETrue );
+                aMenuPane->SetItemDimmed(EGSXDMPluginCmdDelete, EFalse);
+                }
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CXDMPlugin::HandleResourceChangeManual()
+// ---------------------------------------------------------
+//
+void CXDMPlugin::HandleResourceChangeManual(TInt aType)
+    {
+    if ( iSettingListContainer )
+        iSettingListContainer->HandleResourceChangeManual(aType);    
+    if ( iMainListContainer )
+        iMainListContainer->HandleResourceChangeManual(aType);
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPlugin::CreateIconL
+// ---------------------------------------------------------------------------
+//
+CGulIcon* CXDMPlugin::CreateIconL( const TUid aIconType )
+    {
+    CGulIcon* icon;
+       
+    if( aIconType == KGSIconTypeLbxItem )
+        {
+        icon = AknsUtils::CreateGulIconL(
+        AknsUtils::SkinInstance(), 
+        KAknsIIDQgnPropSetConnXdm, 
+        KGSXDMPluginIconFileName,
+        EMbmGsxdmpluginQgn_prop_set_conn_xdm,
+        EMbmGsxdmpluginQgn_prop_set_conn_xdm_mask);
+        }
+     else
+        {
+        icon = CGSPluginInterface::CreateIconL( aIconType );
+        }
+
+    return icon;
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPlugin::UpdateMskL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPlugin::UpdateMskL()
+    {
+    if ( !Cba() )
+        {
+        return;
+        }
+    
+    CEikCba* cba = static_cast< CEikCba* >( Cba()->ButtonGroup() );
+    if(iCurrentContainer==iMainListContainer)
+        {
+        TBool showEdit = !(iMainListContainer->IsListEmpty());
+        cba->SetCommandSetL(R_XDMUI_MAINVIEW_SOFTKEYS);
+        cba->MakeCommandVisible( EGSXDMPluginCmdEdit, showEdit );
+        }
+    else if(iCurrentContainer==iSettingListContainer)
+        {
+        cba->SetCommandSetL(R_XDMUI_MAINVIEW_SOFTKEYS_SL);
+        cba->MakeCommandVisible( EGSXDMPluginCmdChange, ETrue);
+        if ( iSettingListContainer->IsVisible() )
+            {
+            iCurrentContainer->DrawNow();
+            }
+        }
+    cba->DrawNow();
+    }
+    
+// End of file
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/src/XDMPluginContainer.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,462 @@
+/*
+* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    XDM GS plugin main list container.
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XDMExternalInterface.h"
+
+#include <aknappui.h> 
+#include <akntitle.h>
+#include <eikspane.h>
+#include <barsread.h>
+#include <eiktxlbm.h>
+#include <StringLoader.h>
+#include <aknlists.h>
+#include <AknUtils.h>
+#include <eiksbfrm.h>
+#include <AknQueryDialog.h>
+#include <XdmSettingsApi.h>
+
+#include "SettingsData.h"
+#include "XDMPluginContainer.h"
+
+#include <csxhelp/xdm.hlp.hrh>
+
+
+
+   
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::CXDMPluginContainer()
+// ---------------------------------------------------------------------------
+//
+CXDMPluginContainer::CXDMPluginContainer(CAknView* aView) : iView(aView)
+    {
+    SetComponentsToInheritVisibility( ETrue );
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::ConstructL(const TRect& aRect)
+// Symbian OS two phased constructor
+// 
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginContainer::ConstructL( const TRect& aRect )
+    {
+    #ifdef _DEBUG  
+    RDebug::Print( _L( "[CXDMPluginContainer] ConstructL()" ) );
+	#endif
+
+    CEikStatusPane* sp = static_cast<CAknAppUi*> 
+        ( CEikonEnv::Static()->EikAppUi() )->StatusPane();
+    iTitlePane = static_cast<CAknTitlePane*> 
+        ( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+
+    // Set title
+    
+    StringLoader::Load ( iTitle, R_STR_XDM_TITLE_PANE_TEXT );
+    iTitlePane->SetTextL(iTitle);// FromResourceL( rReader );
+    CreateWindowL(); // Makes the control a window-owning control
+
+    // Main List creation and initialization
+    iMainList = new(ELeave) CAknSingleStyleListBox();
+    iMainList->SetContainerWindowL(*this);
+    iMainList->ConstructL(this, EAknListBoxLoopScrolling);
+
+    // Main list scroll bar issues
+    iMainList->CreateScrollBarFrameL(EFalse);
+    iMainList->ScrollBarFrame()->SetScrollBarVisibilityL(
+    CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+    
+    // Empty text processing
+    _LIT (KStringHeader, "%S\n%S");
+    HBufC* emptyText = iEikonEnv->AllocReadResourceLC( R_STR_XDM_EMPTY_TEXT );
+    HBufC* emptyText2 = iEikonEnv->AllocReadResourceLC( R_STR_XDM_EMPTY_TEXT_SEC);   
+    HBufC* emptyFinal = HBufC::NewLC( 
+        emptyText->Length() + emptyText2->Length() + 2 );// 2 is length of "\n" 
+    emptyFinal->Des().Format(KStringHeader, emptyText, emptyText2);
+    
+    iMainList->SetListBoxObserver(this);
+    iMainList->View()->SetListEmptyTextL(*emptyFinal);
+    CleanupStack::PopAndDestroy(3, emptyText);//emptyText, emptyText2, emptyFinal
+
+    // This call fails if Problems in XDM API, so leave if error
+    TRAPD(err,SetupListL());
+    User::LeaveIfError(err);
+
+    SetRect( aRect );
+    ActivateL();
+    
+    iEikMenuBar = new ( ELeave ) CEikMenuBar();
+    iEikMenuBar->ConstructL( this, NULL, R_GS_XDM_SETTINGS_MAIN_MENUBAR );
+    
+    #ifdef _DEBUG           
+    RDebug::Print( _L( "[CXDMPluginContainer] Construct done" ) );
+	#endif
+
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::~CXDMPluginContainer()
+// Destructor
+//  
+// ---------------------------------------------------------------------------
+//
+CXDMPluginContainer::~CXDMPluginContainer()
+    {
+    if (iMainList)
+        {
+         delete iMainList;
+        }
+    
+    delete iEikMenuBar;
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::SizeChanged()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginContainer::SizeChanged()
+    {
+    iMainList->SetRect(Rect());
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::CountComponentControls() const
+// ---------------------------------------------------------------------------
+//
+TInt CXDMPluginContainer::CountComponentControls() const
+    {
+    return 1;
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::ComponentControl() const
+// ---------------------------------------------------------------------------
+//
+CCoeControl* CXDMPluginContainer::ComponentControl( TInt aIndex ) const
+    {
+    switch ( aIndex )
+        {
+        case 0:
+            return iMainList;
+        default:
+            return NULL;
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::EditCurrentItemL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginContainer::EditCurrentItemL()
+    {
+    TPtrC16 xDMSetName;
+    TPtrC16 xDMSetNameClipped;
+    xDMSetName.Set(iSettingListArray->MdcaPoint(iMainList->CurrentItemIndex()));
+    xDMSetNameClipped.Set(xDMSetName.Mid(1)); // remove '/t' from the begining
+        CXDMPlugin* iTempView = static_cast<CXDMPlugin*> (iView);    
+    iTempView->LoadSettingsViewL(EEditExisting, xDMSetNameClipped);      
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::GetCurrentSetNameLC()
+// ---------------------------------------------------------------------------
+//
+HBufC* CXDMPluginContainer::GetCurrentSetNameLC()
+    {
+    TPtrC16 xDMSetName;
+    TPtrC16 xDMSetNameClipped;
+    xDMSetName.Set(iSettingListArray->MdcaPoint(iMainList->CurrentItemIndex()));
+    xDMSetNameClipped.Set(xDMSetName.Mid(1)); // remove '/t' from the begining
+    
+    HBufC* name = xDMSetNameClipped.AllocLC();
+    TPtr ptr(name->Des());
+    AknTextUtils::ConvertDigitsTo(ptr, EDigitTypeWestern );
+    
+    return name;    
+    }
+    
+   
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::OfferKeyEventL()
+// ---------------------------------------------------------------------------
+//
+TKeyResponse CXDMPluginContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, 
+                                                            TEventCode aType )
+    {
+    if (iMainList)
+        {
+        // if cancel key is pressed and list is not empty, invoke deletion
+        if ((aKeyEvent.iCode == EKeyBackspace ) && (aType == EEventKey) &&
+            iEikMenuBar->ItemSpecificCommandsEnabled() )
+            {
+            if(!IsListEmpty())
+                DeleteSetProcedureL();
+            CXDMPlugin* iTempView = static_cast<CXDMPlugin*> (iView);
+            iTempView->UpdateMskL();
+            return EKeyWasConsumed;
+            }
+        else
+            {
+            return iMainList->OfferKeyEventL (aKeyEvent, aType);
+            }        
+        }
+    return EKeyWasNotConsumed;
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::HandleListBoxEventL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
+    {
+    // if the Select Key has been pressed
+    if ((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) ||
+    (aListBoxEvent == MEikListBoxObserver::EEventItemSingleClicked))
+        {
+        EditCurrentItemL();           
+        }
+    }
+  
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::SetupListL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginContainer::SetupListL()
+    {
+    CTextListBoxModel* model = iMainList->Model();
+    model->SetOwnershipType(ELbmOwnsItemArray);
+    
+    iSettingListArray = STATIC_CAST(CDesCArray*,model->ItemTextArray());
+    LoadSettingsListArrayL();
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::LoadSettingsListArrayL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginContainer::LoadSettingsListArrayL()
+    {
+    iTitlePane->SetTextL(iTitle);
+    _LIT (KStringHeader, "\t%S");
+    TBuf <KMaxSettingSetNameLength+2> myString; // maximum name + \t
+    RArray<TInt> settingIds;
+    CleanupClosePushL(settingIds);
+    CDesCArray* xdmSetList = NULL;
+    TRAPD(err, xdmSetList = LoadCollectionNamesL(settingIds));
+    if(err!=KErrNone)    
+        {
+        CleanupStack::PopAndDestroy(1); //settingIds
+        return;
+        }
+    CleanupStack::PushL(xdmSetList);
+    TInt xdmSetListCount = xdmSetList->Count();
+    iSettingListArray->Reset();
+    for (TInt i = 0; i< xdmSetListCount; i++)
+        {
+        myString.Format(KStringHeader, &(xdmSetList->MdcaPoint(i)));
+        AknTextUtils::LanguageSpecificNumberConversion(myString);
+        iSettingListArray->AppendL (myString);
+        }
+    iSettingListArray->Sort(ECmpCollated);
+    CleanupStack::PopAndDestroy(2); //xdmSetList,settingIds
+    iMainList->HandleItemRemovalL();
+    iMainList->HandleItemAdditionL();
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::IsListEmpty()
+// ---------------------------------------------------------------------------
+//
+TBool CXDMPluginContainer::IsListEmpty()
+    {
+    if (iSettingListArray->Count())
+        return EFalse;
+    return ETrue;    
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::IsLastItem()
+// ---------------------------------------------------------------------------
+//
+TBool CXDMPluginContainer::IsLastItem()
+    {
+    if (iSettingListArray->Count() == 1)
+        return ETrue;
+    return EFalse;    
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::DeleteCurrentSetL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginContainer::DeleteCurrentSetL()
+    {
+    TXdmSettingsApi::RemoveCollectionL( GetCurrentSetIdL() );    
+    TInt deletedItemIndex = iMainList->CurrentItemIndex();
+    iSettingListArray->Delete( deletedItemIndex );
+    
+    AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(
+        iMainList, deletedItemIndex, ETrue );
+    iMainList->DrawNow();
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::GetCurrentSetIdL()
+// ---------------------------------------------------------------------------
+//
+TInt CXDMPluginContainer::GetCurrentSetIdL()
+    {
+    TInt myId(-1);
+    RArray<TInt> settingIds;
+    CleanupClosePushL(settingIds);
+    CDesCArray* xdmSetList = NULL;
+
+    TRAPD(err, xdmSetList = LoadCollectionNamesL(settingIds));
+    if(err!=KErrNone)    
+        {
+        CleanupStack::PopAndDestroy(1); //settingIds
+        return myId;
+        }
+    CleanupStack::PushL(xdmSetList);
+
+    TInt xdmSetListCount = xdmSetList->Count();
+    HBufC* currentSetName = GetCurrentSetNameLC();
+    for (TInt i = 0; i< xdmSetListCount; i++)
+        {
+        if (!((xdmSetList->MdcaPoint(i)).Compare(*currentSetName))) // if equal
+            {
+            myId = settingIds[i];
+            break;
+            }
+        }
+    CleanupStack::PopAndDestroy(3); //xdmSetList,settingIds,currentSetName
+    return myId;
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::LoadCollectionNamesL()
+// ---------------------------------------------------------------------------
+//
+CDesCArray* CXDMPluginContainer::LoadCollectionNamesL(RArray<TInt>& aSettingIDs)
+    {
+    CDesCArray* myArray = TXdmSettingsApi::CollectionNamesLC(aSettingIDs);
+    CleanupStack::Pop(1); // will be pop if above doesnt leave
+    return myArray;
+    }
+
+// ---------------------------------------------------------
+// CXDMPluginContainer::GetHelpContext
+// This function is called when Help application is launched
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+void CXDMPluginContainer::GetHelpContext( TCoeHelpContext& aContext ) const
+    {
+    aContext.iMajor = KGSXDMPluginUid;
+    aContext.iContext = KXDM_HLP_LIST_VIEW;
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::DeleteSetProcedureL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginContainer::DeleteSetProcedureL()
+    {
+    HBufC* myDisplayMessage = NULL;
+    HBufC* currentSetName = GetCurrentSetNameLC();
+    TPtr myname(currentSetName->Des());
+    AknTextUtils::LanguageSpecificNumberConversion(myname); 
+    
+    CAknQueryDialog* query = CAknQueryDialog::NewL(CAknQueryDialog::EConfirmationTone);
+    if (IsLastItem())
+        myDisplayMessage = StringLoader::LoadLC(R_STR_XDM_CONF_DELETE_LAST, *currentSetName );
+    else
+        myDisplayMessage = StringLoader::LoadLC(R_STR_XDM_CONF_DELETE, *currentSetName );
+    
+    if ( query->ExecuteLD( R_CONFIRMATION_QUERY, *myDisplayMessage ) )
+        {
+        DeleteCurrentSetL();
+        }
+    CleanupStack::PopAndDestroy(2); //currentSetName, myDisplayMessage
+    }
+  
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::HandleResourceChange()
+// ---------------------------------------------------------------------------
+void CXDMPluginContainer::HandleResourceChange( TInt aType )
+    {
+    if ( aType == KAknsMessageSkinChange ||
+         aType == KEikDynamicLayoutVariantSwitch )
+        {
+        CXDMPlugin* iTempView = static_cast<CXDMPlugin*> (iView);    
+        iTempView->HandleResourceChangeManual(aType);      
+        }
+    CCoeControl::HandleResourceChange( aType );
+    }
+  
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::HandleResourceChangeManual()
+// ---------------------------------------------------------------------------
+void CXDMPluginContainer::HandleResourceChangeManual(TInt aType)
+    {
+    TRect mainPaneRect;
+    AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
+                                       mainPaneRect);
+    SetRect( mainPaneRect );
+    //DrawNow();
+    
+    iMainList->HandleResourceChange(aType);
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::FocusChanged
+// Set focus on the selected listbox. For animated skins feature.
+// ---------------------------------------------------------------------------
+void CXDMPluginContainer::FocusChanged(TDrawNow aDrawNow)
+    {
+    if(iMainList)
+        {
+        iMainList->SetFocus( IsFocused(),aDrawNow );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginContainer::SetFocusIfExist
+// Set focus on the given set name
+// ---------------------------------------------------------------------------
+void CXDMPluginContainer::SetFocusIfExist(TDes& aSetName)
+    {
+    _LIT (KStringHeader, "\t%S");
+    TBuf <KMaxSettingSetNameLength+2> myString; // maximum name + \t
+    myString.Format(KStringHeader, &aSetName);
+    AknTextUtils::LanguageSpecificNumberConversion(myString);
+
+    TInt xdmSetListCount = iSettingListArray->Count();
+    for (TInt i = 0; i< xdmSetListCount; i++)
+        {
+        if (!((iSettingListArray->MdcaPoint(i)).Compare(myString))) // if equal
+            {
+            iMainList->SetCurrentItemIndex(i);
+            break;
+            }
+        }
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/src/XDMPluginImplementationTable.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* 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:    ECOM proxy table for this plugin
+*
+*/
+
+
+
+
+// System includes
+#include <e32std.h>
+#include <implementationproxy.h>
+
+// User includes
+#include "XDMPlugin.h"
+
+// Constants
+const TImplementationProxy KXDMPluginImplementationTable[] = 
+  {
+  IMPLEMENTATION_PROXY_ENTRY(0x10207429,  CXDMPlugin::NewL)
+  };
+
+
+// ---------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Gate/factory function
+//
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+  {
+  aTableCount = sizeof(KXDMPluginImplementationTable) 
+        / sizeof(TImplementationProxy);
+  return KXDMPluginImplementationTable;
+  }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/src/XDMPluginSLContainer.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,1035 @@
+/*
+* Copyright (c) 2005-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:    XDM GS plugin Settins list container
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XDMExternalInterface.h"
+
+#include    <aknappui.h> 
+#include    <akntitle.h>
+#include    <eikspane.h>
+#include    <barsread.h>
+#include    <eiktxlbm.h>
+#include    <aknlists.h>
+#include    <AknUtils.h>
+#include    <eiksbfrm.h>
+#include    <XdmSettingsApi.h>
+#include    <aknPopup.h>
+#include    <StringLoader.h>
+#include    <XdmSettingsCollection.h>
+#include    <AknQueryDialog.h>
+#include    <aknnotewrappers.h>
+#include    <aknnotedialog.h>
+#include    <escapeutils.h>
+
+#include    "XDMPluginSLContainer.h"
+#include    "XDMPluginSettinglist.h"
+#include    "SettingsData.h"
+
+#include    <csxhelp/xdm.hlp.hrh>
+
+// LOCAL CONSTANTS AND MACROS
+_LIT(KFormatPostfix, "%S(%02d)");
+_LIT(KFormatNoPostfix, "%S");
+_LIT(KFormatLargePostfix, "%S(%d)");
+const TInt KMaxPostfixLength = 5;
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::CXDMPluginSLContainer()
+// ---------------------------------------------------------------------------
+//
+CXDMPluginSLContainer::CXDMPluginSLContainer(CAknView* aView) : iView(aView)
+    {
+    SetComponentsToInheritVisibility( ETrue );
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::ConstructL(const TRect& aRect)
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginSLContainer::ConstructL( const TRect& aRect)
+    {
+    #ifdef _DEBUG
+    RDebug::Print( _L( "[CXDMPluginSLContainer] ConstructL()" ) );
+	#endif
+
+    CEikStatusPane* sp = static_cast<CAknAppUi*> 
+        ( CEikonEnv::Static()->EikAppUi() )->StatusPane();
+    CAknTitlePane* title = static_cast<CAknTitlePane*> 
+        ( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+
+    // Set the proper title of this list
+    TResourceReader rReader;
+    iCoeEnv->CreateResourceReaderLC( rReader, R_GS_XDM_MAIN_VIEW_TITLE );
+    title->SetFromResourceL( rReader );
+    CleanupStack::PopAndDestroy(); //rReader
+
+    CreateWindowL(); // Makes the control a window-owning control
+
+    // construct the data object the settings list will use
+    iData = CSettingsData::NewL();
+    // construct control and set parent
+    iSettingList = CXDMPluginSettinglist::NewL(*iData);
+    iSettingList->SetContainerWindowL(*this);
+
+    // CreateResourceReaderLC will allocate a buffer to be used by
+    // the TResourceReader. This buffer is pushed onto the cleanup
+    // stack - not the TResourceReader itself
+    CEikonEnv::Static()->CreateResourceReaderLC(rReader, R_SETTINGS);
+    iSettingList->ConstructFromResourceL(rReader);
+
+    // Clean up the buffer allocated above, NOT the reader itself.
+    // Cannot use expected item overload of PopAndDestroy() as buffer 
+    // is inaccessible. 
+    CleanupStack::PopAndDestroy();
+    iSettingList->ActivateL();
+
+    SetRect( aRect );
+    ActivateL();
+    
+    #ifdef _DEBUG        
+    RDebug::Print( _L( "[CXDMPluginSLContainer] Construct done" ) );
+	#endif
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::~CXDMPluginSLContainer()
+// ---------------------------------------------------------------------------
+//
+CXDMPluginSLContainer::~CXDMPluginSLContainer()
+    {
+    if (iData)
+        delete iData;
+    if(iSettingList)  // if setting list has been created
+        {
+        delete iSettingList;
+        iSettingList = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::SizeChanged()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginSLContainer::SizeChanged()
+    {
+    iSettingList->SetRect(Rect());
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::CountComponentControls() const
+// ---------------------------------------------------------------------------
+//
+TInt CXDMPluginSLContainer::CountComponentControls() const
+    {
+    return 1;
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::ComponentControl( TInt aIndex ) const
+// ---------------------------------------------------------------------------
+//
+CCoeControl* CXDMPluginSLContainer::ComponentControl( TInt aIndex ) const
+    {
+    switch ( aIndex )
+        {
+        case 0:
+            return iSettingList;
+        default:
+            return NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::EditCurrentItemL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginSLContainer::EditCurrentItemL()
+    {
+    iSettingList->EditCurrentItemL();    
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::OfferKeyEventL()
+// ---------------------------------------------------------------------------
+//
+TKeyResponse CXDMPluginSLContainer::OfferKeyEventL( 
+    const TKeyEvent& aKeyEvent, 
+    TEventCode aType )
+    {
+    if (iSettingList)
+        return iSettingList->OfferKeyEventL(aKeyEvent, aType);
+    else
+        return EKeyWasNotConsumed;
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::Draw(const TRect& aRect) const
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginSLContainer::Draw(const TRect& aRect) const
+    {
+    CWindowGc& gc = SystemGc();
+    gc.Clear(aRect);
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::HandleListBoxEventL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginSLContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
+    {
+    // if the Select Key has been pressed
+    if ((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) ||
+    (aListBoxEvent == MEikListBoxObserver::EEventItemClicked))
+        {
+        iSettingList->EditCurrentItemL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::PrepareXDMSetForEditingL(TDesC& aXDMSetName)
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginSLContainer::PrepareXDMSetForEditingL(TDesC& aXDMSetName)
+    {
+    TLex16 myLex;
+    iData->Reset();
+    
+    iData->iSettingName = aXDMSetName;
+    AknTextUtils::ConvertDigitsTo(iData->iSettingName, EDigitTypeWestern );    
+    iData->iSettingId = GetSettingIdL(iData->iSettingName);
+    
+    CXdmSettingsCollection* xDMSet = NULL;
+    
+    // read the source setting
+    xDMSet = TXdmSettingsApi::SettingsCollectionL(iData->iSettingId);
+    CleanupStack::PushL(xDMSet);
+    
+    iData->iSettingNameDisp = aXDMSetName;
+    iData->iServerAddress = xDMSet->Property(EXdmPropUri);
+    
+    // AccessPoint handling
+    iData->iAccessPointDes = xDMSet->Property(EXdmPropToNapId);
+    myLex.Assign(iData->iAccessPointDes);
+    myLex.Val(iData->iAccessPoint);
+    
+    iSettingList->GetAccessPointNameL(iData->iAccessPoint, iData->iAccessPointName);
+    if ( (iData->iAccessPointName) == KNullDesC) // if name is not found
+        {
+        iData->iAccessPoint = -1;
+        }
+    
+    TBuf<KMaxUserIDLength> username = xDMSet->Property( EXdmPropAuthName );
+    
+    // to show special chars in UI correctly
+    _LIT( KProcent, "%" );
+    if ( username.Find( KProcent ) != KErrNotFound )
+        {
+        // convert to 8 bit
+        HBufC8* tmp = HBufC8::NewLC( username.Length() );
+        tmp->Des().Copy( username );
+        
+        // Decode encoded username
+        HBufC8* decodedUsername = EscapeUtils::EscapeDecodeL( *tmp );
+        CleanupStack::PopAndDestroy( tmp );
+        CleanupStack::PushL( decodedUsername );
+        
+        // convert to unicode
+        HBufC* userName16 =
+             EscapeUtils::ConvertToUnicodeFromUtf8L( decodedUsername->Des() );
+        CleanupStack::PopAndDestroy( decodedUsername );        
+        username = userName16->Des();
+        delete userName16;
+        }
+    
+    iData->iUserID = username;
+    iData->iPassword = xDMSet->Property(EXdmPropAuthSecret);
+    
+    CleanupStack::PopAndDestroy(1); //xDMSet
+    iSettingList->LoadSettingsL();
+    SetTitlePaneTextL(iData->iSettingName);
+    iSettingList->ResetItemIndex();
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::PrepareXDMSetNewDefaultL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginSLContainer::PrepareXDMSetNewDefaultL()
+    {
+    iData->Reset();
+    
+    HBufC* defName = StringLoader::LoadL( R_STR_XDM_NEW_SET );
+    CleanupStack::PushL( defName );
+    
+    TBool changed;
+
+    HBufC* newName = DoMakeValidNameL(defName, changed);
+        
+    if ( newName )
+        // name converted to unique
+        {
+        (iData->iSettingName).Copy(newName->Des());
+        delete newName;
+        }
+    else
+        {
+        (iData->iSettingName).Copy(defName->Des());
+        }
+    CleanupStack::PopAndDestroy( defName );
+    
+    iData->iSettingNameDisp = iData->iSettingName;
+    AknTextUtils::LanguageSpecificNumberConversion(iData->iSettingNameDisp);
+    
+    iSettingList->LoadSettingsL();
+    iSettingList->ResetItemIndex();
+    iSettingList->DrawNow();
+    SetTitlePaneTextL(iData->iSettingName);
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::PrepareNewXDMSetFromExistingL(TDesC& aXDMSetName)
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginSLContainer::PrepareNewXDMSetFromExistingL(TDesC& aXDMSetName)
+    {
+    TLex16 myLex;
+    
+    // iData is already resetted in this case and iSettingId has id of 
+    // existing list from which data to be copied
+    // we need to find the new name, from given name
+    HBufC* originalName = aXDMSetName.AllocL();
+    CleanupStack::PushL( originalName );
+    
+    // aXDMSetName is in disp format, need to convert to western format
+    TPtr corrFormat(originalName->Des());
+    AknTextUtils::ConvertDigitsTo(corrFormat, EDigitTypeWestern );
+    
+    TBool changed;
+
+    HBufC* newName = DoMakeValidNameL(originalName, changed);
+        
+    if ( newName )
+        // name converted to unique
+        {
+        (iData->iSettingName).Copy(newName->Des());
+        delete newName;
+        }
+    else
+        {
+        (iData->iSettingName).Copy(originalName->Des());
+        }
+
+    CleanupStack::PopAndDestroy( originalName );
+    
+    
+    CXdmSettingsCollection* xDMSet = NULL;
+    
+    // Displayable name
+    iData->iSettingNameDisp = iData->iSettingName;
+    AknTextUtils::LanguageSpecificNumberConversion(iData->iSettingNameDisp);
+    
+    // read the source setting
+    xDMSet = TXdmSettingsApi::SettingsCollectionL(iData->iSettingId);
+    CleanupStack::PushL(xDMSet);
+    
+    iData->iServerAddress = xDMSet->Property(EXdmPropUri);
+    
+    // AccessPoint handling
+    iData->iAccessPointDes = xDMSet->Property(EXdmPropToNapId);
+    myLex.Assign(iData->iAccessPointDes);
+    myLex.Val(iData->iAccessPoint);
+    
+    iSettingList->GetAccessPointNameL(iData->iAccessPoint, iData->iAccessPointName);
+    if ( (iData->iAccessPointName) == KNullDesC) // if name is not found
+        {
+        iData->iAccessPoint = -1;
+        }
+
+    iData->iUserID = xDMSet->Property(EXdmPropAuthName);
+    iData->iPassword = xDMSet->Property(EXdmPropAuthSecret);
+    
+    // also overwrite the setting id now since we dont need it anymore
+    iData->iSettingId = -1;
+    CleanupStack::PopAndDestroy(1); //xDMSet
+    iSettingList->LoadSettingsL();
+    SetTitlePaneTextL(iData->iSettingNameDisp);
+    iSettingList->ResetItemIndex();
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::DisplayNewXDMSetOptions()
+// ---------------------------------------------------------------------------
+//
+TBool CXDMPluginSLContainer::DisplayNewXDMSetOptionsL()
+    {
+    // First phase construction of menu list
+    CAknSinglePopupMenuStyleListBox* newXDMsetMenuList =
+    new (ELeave) CAknSinglePopupMenuStyleListBox;
+    CleanupStack::PushL(newXDMsetMenuList);
+
+    // Create a popuplist to show the menu list in
+    CAknPopupList* popupList = CAknPopupList::NewL(
+                  newXDMsetMenuList, 
+                  R_AVKON_SOFTKEYS_OK_CANCEL);
+
+    CleanupStack::PushL(popupList);
+
+    // Second phase construction of menulist
+    newXDMsetMenuList->ConstructL(popupList,EAknListBoxMenuList);
+    // Set up scroll bars
+    newXDMsetMenuList->CreateScrollBarFrameL(ETrue);
+    newXDMsetMenuList->ScrollBarFrame()->SetScrollBarVisibilityL(
+    CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
+
+    // Set up menu items
+    CTextListBoxModel* model = newXDMsetMenuList->Model();  // not taking ownership
+    model->SetOwnershipType (ELbmOwnsItemArray); // list'll delete with listbox
+    RArray<TInt> settingIDs;
+    CleanupClosePushL(settingIDs);
+    CDesCArray* newXDMsetMenuListArray = NULL;
+
+    TRAPD(err, newXDMsetMenuListArray = LoadCollectionNamesL(settingIDs, ETrue));
+    if(err!=KErrNone)    
+        {
+        CleanupStack::PopAndDestroy(3); //newXDMsetMenuList, popupList, settingIDs
+        return EFalse;
+        }
+    CleanupStack::PushL(newXDMsetMenuListArray);
+
+    newXDMsetMenuListArray->Sort(ECmpCollated);
+    model->SetItemTextArray(newXDMsetMenuListArray);
+    CleanupStack::Pop(1); // newXDMsetMenuListArray owned by model
+    CleanupStack::PopAndDestroy(1); //settingIDs
+
+    // Set title
+    HBufC* title;
+    title = StringLoader::LoadLC(R_STR_XDM_USE_EXISTING);
+    popupList->SetTitleL(*title);
+    CleanupStack::PopAndDestroy(1); //title
+
+    // Show the menu in the popup list
+    TInt popupOk = popupList->ExecuteLD();
+
+    CleanupStack::Pop(popupList);
+
+    // if the user selected some set
+    if (popupOk)
+        {
+        iData->Reset();
+        TPtrC setName = newXDMsetMenuListArray->MdcaPoint
+                                    (newXDMsetMenuList->CurrentItemIndex());
+        
+        iData->iSettingId = GetSettingIdL(setName);
+        (iData->iSettingNameDisp).Copy(setName);
+        (iData->iSettingName).Copy(setName);
+        AknTextUtils::ConvertDigitsTo(iData->iSettingName, EDigitTypeWestern );
+        CleanupStack::PopAndDestroy(newXDMsetMenuList);
+        return ETrue;
+        }
+    // otherwise return false
+    CleanupStack::PopAndDestroy(1); //newXDMsetMenuList
+    return EFalse;      
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::IsAccessPointInUseL(TDesC& aXDMSetName)
+// ---------------------------------------------------------------------------
+//
+TBool CXDMPluginSLContainer::SettingsApInUseL(TDesC& aXDMSetName)
+    {
+    TBool inUse( EFalse );   
+    TLex16 myLex;
+     
+    iData->iSettingName = aXDMSetName;
+    AknTextUtils::ConvertDigitsTo(iData->iSettingName, EDigitTypeWestern );    
+    iData->iSettingId = GetSettingIdL(iData->iSettingName);
+       
+    CXdmSettingsCollection* xDMSet = NULL;
+       
+    // read the source setting
+    xDMSet = TXdmSettingsApi::SettingsCollectionL(iData->iSettingId);
+    CleanupStack::PushL(xDMSet);
+    iData->iAccessPointDes = xDMSet->Property(EXdmPropToNapId);
+    myLex.Assign(iData->iAccessPointDes);
+    myLex.Val(iData->iAccessPoint);
+    CleanupStack::PopAndDestroy(xDMSet);
+    
+    inUse = iSettingList->IsAccessPointInUseL( iData->iAccessPoint );
+	
+    return inUse;
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::SetTitlePaneTextL( const TDesC& aTitleText ) const
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginSLContainer::SetTitlePaneTextL( const TDesC& aTitleText ) const
+    {
+    CAknTitlePane* title = static_cast< CAknTitlePane* >
+        ( CEikonEnv::Static()->AppUiFactory()->StatusPane()->ControlL(
+                                        TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    if ( !title )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    title->SetTextL( aTitleText );
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::AreCompulsoryItemsFilled()
+// ---------------------------------------------------------------------------
+//
+TBool CXDMPluginSLContainer::AreCompulsoryItemsFilled()
+    {
+    if ( (iData->iAccessPoint > -1) && ((iData->iServerAddress)!=KNullDesC) && 
+        ((iData->iUserID)!=KNullDesC) )
+        {
+        return ETrue;
+        }
+    
+    return EFalse;   
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::DisplayDeleteOrDontSaveDialog()
+// ---------------------------------------------------------------------------
+//
+TBool CXDMPluginSLContainer::DisplayDeleteOrDontSaveDialogL()
+    {
+    TBuf<KMaxMessageToDisplayLength> myDisplayMessage;
+    CAknQueryDialog* query = CAknQueryDialog::NewL
+                                        (CAknQueryDialog::EConfirmationTone);
+    StringLoader::Load ( myDisplayMessage, R_STR_XDM_CONF_COMPULSORY );
+    return (query->ExecuteLD( R_CONFIRMATION_QUERY, myDisplayMessage ));
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::DeleteXDMSetIfExistL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginSLContainer::DeleteXDMSetIfExistL()
+    {
+    TRAPD(err, TXdmSettingsApi::RemoveCollectionL(iData->iSettingId));
+    if ( (err!=KErrNone) && (err!=KErrNotFound) )
+        {
+        User::LeaveIfError(err);        
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::IsExitProcessingOKL()
+// ---------------------------------------------------------------------------
+//
+TBool CXDMPluginSLContainer::IsExitProcessingOKL()
+    {
+    if (AreCompulsoryItemsFilled())
+        {
+        return SaveOrCreateAndSaveXDMSetL(ETrue);
+        }
+    else
+        {
+        if (DisplayDeleteOrDontSaveDialogL())
+            {
+            DeleteXDMSetIfExistL();
+            }
+        else
+            {
+             return EFalse;
+            }
+        }
+    return ETrue;
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::SaveSettingsIfPossibleL()
+// ---------------------------------------------------------------------------
+//
+void CXDMPluginSLContainer::SaveSettingsIfPossibleL()
+    {
+    if (AreCompulsoryItemsFilled())
+        SaveOrCreateAndSaveXDMSetL(EFalse);    
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::SaveOrCreateAndSaveXDMSetL()
+// ---------------------------------------------------------------------------
+//
+TBool CXDMPluginSLContainer::SaveOrCreateAndSaveXDMSetL(TBool aShowDialog)
+    {
+    TBool ret = ETrue;
+    CXdmSettingsCollection* myXDMSet(NULL);
+    TInt err(KErrNotFound); // Initialize such that id not found in settings API
+    
+    // take the saveable name
+    iData->iSettingName = iData->iSettingNameDisp;
+    AknTextUtils::ConvertDigitsTo(iData->iSettingName, EDigitTypeWestern ); 
+    
+    // check whether this is a new set or an existing set was edited
+    if ((iData->iSettingId) > NULL) // is there is valid id
+        {
+        TRAP(err, myXDMSet = TXdmSettingsApi::SettingsCollectionL
+                                                (iData->iSettingId));
+        }
+    if(myXDMSet)
+        {
+         delete myXDMSet; // we dont need it
+        }
+        
+    // check if the setting name is already exist
+    // ask user to change name
+    if (IsXDMSetNameExistL(iData->iSettingName, iData->iSettingId))
+        {
+        if (!aShowDialog) // if we cant display dialog than return.
+            return EFalse;
+        HBufC* myDisplayMessage = NULL;
+        CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue );
+        note->SetTimeout( CAknNoteDialog::ELongTimeout  );
+        myDisplayMessage = StringLoader::LoadLC(R_STR_XDM_NAME_ALREADY_EXIST, iData->iSettingNameDisp);
+        note->ExecuteLD( *myDisplayMessage );
+        CleanupStack::PopAndDestroy(1); //myDisplayMessage
+        iSettingList->EditItemL(ESettingNameIndex,EFalse);
+        return EFalse;                
+        }
+        
+    if(err == KErrNone) // if set exists update it
+        {
+        TXdmSettingsApi::UpdatePropertyL(iData->iSettingId, 
+                                        iData->iSettingName, EXdmPropName);
+        TXdmSettingsApi::UpdatePropertyL(iData->iSettingId, 
+                                        iData->iAccessPointDes, EXdmPropToNapId);
+        TXdmSettingsApi::UpdatePropertyL(iData->iSettingId, 
+                                        iData->iServerAddress, EXdmPropUri);
+        TXdmSettingsApi::UpdatePropertyL(iData->iSettingId, 
+                                        iData->iUserID, EXdmPropAuthName);
+        TXdmSettingsApi::UpdatePropertyL(iData->iSettingId, 
+                                        iData->iPassword, EXdmPropAuthSecret);
+        ret = ETrue;    
+        }
+
+    else if (err == KErrNotFound) // if set doenst exists create and save it
+        {
+        myXDMSet = new (ELeave) CXdmSettingsCollection();
+        CleanupStack::PushL(myXDMSet);
+        myXDMSet->AppendL(iData->iSettingName, EXdmPropName);
+        myXDMSet->AppendL(iData->iServerAddress, EXdmPropUri);
+        myXDMSet->AppendL(iData->iAccessPointDes, EXdmPropToNapId);
+        myXDMSet->AppendL(iData->iUserID, EXdmPropAuthName);
+        myXDMSet->AppendL(iData->iPassword, EXdmPropAuthSecret);
+        TRAPD(err,TXdmSettingsApi::CreateCollectionL(*myXDMSet));
+        err = err; //just to satisfy compiler
+        CleanupStack::PopAndDestroy(1); // myXDMSet
+        ret = ETrue;        
+        }
+        
+    else
+        {
+        User::LeaveIfError(err);            
+        }
+    
+    return ret;
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::GetSettingIdL(TDesC& aXDMSetName)
+// ---------------------------------------------------------------------------
+//
+TInt CXDMPluginSLContainer::GetSettingIdL(TDesC& aXDMSetName)
+    {
+    TInt myId(-1);
+    RArray<TInt> settingIds;
+    CleanupClosePushL(settingIds);
+    CDesCArray* xdmSetList =NULL;
+
+    TBuf<KMaxSettingSetNameLength> setName = aXDMSetName;
+    AknTextUtils::ConvertDigitsTo(setName, EDigitTypeWestern );  
+    
+    TRAPD(err, xdmSetList = LoadCollectionNamesL(settingIds, EFalse));
+    if(err!=KErrNone)    
+        {
+        CleanupStack::PopAndDestroy(1); //settingIds
+        return myId;
+        }
+    CleanupStack::PushL(xdmSetList);
+
+    TInt xdmSetListCount = xdmSetList->Count();
+    for (TInt i = 0; i< xdmSetListCount; i++)
+        {
+        if (!((xdmSetList->MdcaPoint(i)).Compare(setName))) // if equal
+            {
+            myId = settingIds[i];
+            break;
+            }
+        }
+    CleanupStack::PopAndDestroy(2); //xdmSetList,settingIds
+    return myId;
+    }
+        
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::IsXDMSetNameExistL(TDesC& aXDMSetName, TInt32& aSettingId)
+// ---------------------------------------------------------------------------
+//
+TBool CXDMPluginSLContainer::IsXDMSetNameExistL(TDesC& aXDMSetName, TInt32& aSettingId)
+    {
+    TBool ret(EFalse);
+    RArray<TInt> settingIds;
+    CleanupClosePushL(settingIds);
+    CDesCArray* xdmSetList = NULL;
+
+    TBuf<KMaxSettingSetNameLength> setName = aXDMSetName;
+    AknTextUtils::ConvertDigitsTo(setName, EDigitTypeWestern );  
+
+    TRAPD(err, xdmSetList = LoadCollectionNamesL(settingIds, EFalse));
+    if(err!=KErrNone)    
+        {
+        CleanupStack::PopAndDestroy(1); //settingIds
+        return EFalse;
+        }
+    CleanupStack::PushL(xdmSetList);
+
+    TInt xdmSetListCount = xdmSetList->Count();
+    for (TInt i = 0; i< xdmSetListCount; i++)
+        {
+        if (!((xdmSetList->MdcaPoint(i)).Compare(setName))) // if equal
+            {
+            if (settingIds[i] != aSettingId) // if the set is not itself
+                {
+                 ret = ETrue;
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy(2); //xdmSetList,settingIds
+    return ret;
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::LoadCollectionNamesL
+// ---------------------------------------------------------------------------
+//
+CDesCArray* CXDMPluginSLContainer::LoadCollectionNamesL(RArray<TInt>& aSettingIDs
+                                                                    , TBool aDisp)
+    {
+    CDesCArray* myArray = TXdmSettingsApi::CollectionNamesLC(aSettingIDs);
+    TBuf<KMaxSettingSetNameLength> name;
+    if(aDisp) // convert all names to disp names
+        {
+        TInt count = myArray->Count();
+        CDesCArray* dispArray = new CDesCArrayFlat(count+1);
+        CleanupStack::PushL(dispArray);
+        for(TInt i=0;i<count;i++)
+            {
+            name.Copy(myArray->MdcaPoint(i));
+            AknTextUtils::LanguageSpecificNumberConversion(name);
+            TPtrC16 ptr = name;
+            dispArray->AppendL(ptr);                
+            }
+        CleanupStack::Pop(2);
+        return dispArray;        
+        }
+    CleanupStack::Pop(1); // myArray
+    return myArray;
+    }
+
+// ---------------------------------------------------------
+// CXDMPluginSLContainer::GetHelpContext
+// This function is called when Help application is launched
+// (other items were commented in a header).
+// ---------------------------------------------------------
+//
+void CXDMPluginSLContainer::GetHelpContext( TCoeHelpContext& aContext ) const
+    {
+    aContext.iMajor = KGSXDMPluginUid;
+    aContext.iContext = KXDM_HLP_EDIT_SET;
+    }   
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::HandleResourceChange()
+// ---------------------------------------------------------------------------
+void CXDMPluginSLContainer::HandleResourceChange( TInt aType )
+    {
+    CCoeControl::HandleResourceChange( aType );
+    if ( aType == KAknsMessageSkinChange ||
+         aType == KEikDynamicLayoutVariantSwitch )
+        {
+        CXDMPlugin* iTempView = static_cast<CXDMPlugin*> (iView);    
+        iTempView->HandleResourceChangeManual(aType);      
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::HandleResourceChangeManual()
+// ---------------------------------------------------------------------------    
+void CXDMPluginSLContainer::HandleResourceChangeManual(TInt aType)
+    {
+    TRect mainPaneRect;
+    AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
+                                       mainPaneRect);
+    SetRect( mainPaneRect );
+	DrawDeferred();
+	
+	iSettingList->HandleResourceChange(aType);
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::FocusChanged
+// Set focus on the selected listbox. For animated skins feature.
+// ---------------------------------------------------------------------------
+void CXDMPluginSLContainer::FocusChanged(TDrawNow aDrawNow)
+    {
+    if(iSettingList)
+        {
+        iSettingList->SetFocus( IsFocused(), aDrawNow );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::GetCurrentSetName()
+// See header for details.
+// ---------------------------------------------------------------------------    
+// 
+TDes& CXDMPluginSLContainer::GetCurrentSetName()
+    {
+    return iData->iSettingName;    
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::DoMakeValidNameL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+HBufC* CXDMPluginSLContainer::DoMakeValidNameL(HBufC* aName, TBool& aChanged)
+    {
+    aChanged = EFalse;
+    HBufC* temp = HBufC::NewLC( KMaxSettingSetNameLength );
+    HBufC* temp2 = HBufC::NewLC( KMaxSettingSetNameLength );
+    
+    HBufC* corrname = EnsureMaxLengthLC( aName, aChanged);
+    *temp = *corrname;
+    TInt postfix( 0 );
+    TInt pf( 0 );
+    TInt i( 0 );
+    
+    
+    // Load the names
+    RArray<TInt> settingIDs;
+    CleanupClosePushL(settingIDs);
+    CDesCArray* xdmSetList = NULL;
+
+    TRAPD(err, xdmSetList = LoadCollectionNamesL(settingIDs, EFalse));
+    if(err!=KErrNone)    
+        {
+        CleanupStack::PopAndDestroy(4); //settingIds
+        return corrname; 
+        }
+    CleanupStack::PushL(xdmSetList);
+    
+    // do the actual checking of name
+    TInt found(0);
+    TInt pos(0);
+    
+    TPtrC prefix = GetPrefix( *corrname );
+    
+    postfix = GetPostfix( *temp, prefix );
+    postfix = -1;
+    do
+        {       
+        found = xdmSetList->Find( *temp, pos );
+        if ( found == KErrNone )
+            {
+            aChanged = ETrue;
+            postfix++;
+            // check the length of postfix, check text length accordingly
+            pf = postfix;
+            for (i=1; i<10; i++)
+                {
+                pf /= 10;
+                if ( !pf )
+                    break;
+                }
+            TPtr sgdptr( temp->Des() );
+            TPtr sgdptr2( temp2->Des() );
+            if ( postfix )
+                {
+                if ( postfix < 10 )
+        {
+                    sgdptr2 = prefix.Left( KMaxSettingSetNameLength - i - 3 );
+                    }
+                else
+            {
+                    sgdptr2 = prefix.Left( KMaxSettingSetNameLength - i - 2 );
+                    }
+                }
+            else
+                {
+                sgdptr2 = prefix.Left( KMaxSettingSetNameLength );
+                }
+            if ( postfix )
+                {
+                if ( postfix > 9 )
+                    {
+                    sgdptr.Format( KFormatLargePostfix, &sgdptr2,
+                                       postfix );
+                    }
+                else
+                    {
+                    sgdptr.Format( KFormatPostfix, &sgdptr2,
+                                       postfix );
+                }
+            }
+            else
+                {
+                sgdptr.Format( KFormatNoPostfix, &sgdptr2 );
+        }
+            }
+        } while (found == KErrNone);
+        
+    CleanupStack::PopAndDestroy(xdmSetList);
+    CleanupStack::PopAndDestroy(1); //settingIds
+    CleanupStack::PopAndDestroy( corrname );
+    CleanupStack::PopAndDestroy( temp2 );
+
+    if ( aChanged )
+        {
+        CleanupStack::Pop( temp );
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy( temp );
+        temp = NULL;
+        }
+    
+    return temp;
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::EnsureMaxLengthLC()
+// See header for details.
+// ---------------------------------------------------------------------------
+HBufC* CXDMPluginSLContainer::EnsureMaxLengthLC( const TDesC* aName, TBool& aChanged)
+    {
+    TInt length = aName->Length();
+    
+    aChanged = EFalse;
+    
+    if ( !length )
+        {
+        // Name is required.
+        User::Leave(KErrArgument);
+        }
+
+    HBufC* corrname;
+    if ( KMaxSettingSetNameLength < length )
+        { // name too long, truncate.
+        corrname = aName->Left( KMaxSettingSetNameLength ).AllocLC();
+        aChanged = ETrue;
+        }
+    else
+        {
+        corrname = aName->AllocLC();
+        corrname->Des().Trim();
+        if ( corrname->Length() == 0 )
+            {
+            User::Leave(KErrArgument);
+            }
+        // comes here only if name is valid
+        if ( corrname->Length() != aName->Length() )
+    {
+            aChanged = ETrue;
+            }
+        }
+
+    return corrname;
+    }
+    
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::GetPrefix()
+// See header for details.
+// ---------------------------------------------------------------------------
+TPtrC CXDMPluginSLContainer::GetPrefix( const TDesC& aName )
+    {
+    TPtrC prefix = aName;
+    TInt lastBrace = aName.LocateReverse('(');
+    if ( lastBrace != KErrNotFound )
+        {
+        // aName looks like "<prefix><brace><something>".
+        // See if <something> is an integer number.
+        TPtrC num = aName.Right( aName.Length() - lastBrace - 1 );
+        TInt val;
+        TLex lex( num );
+        if ( lex.Val( val ) == KErrNone )
+            {
+            // Yes, the trailer is an integer.
+            prefix.Set( aName.Left( lastBrace ) );
+            }
+        }
+    return prefix;
+    }
+
+// ---------------------------------------------------------------------------
+// CXDMPluginSLContainer::GetPostfix()
+// See header for details.
+// ---------------------------------------------------------------------------
+TInt CXDMPluginSLContainer::GetPostfix( const TDesC& aName, const TDesC& aPrefix )
+    {
+    TInt postfix( KErrNotFound );
+    TInt nameLength = aName.Length();
+    TInt prefixLength = aPrefix.Length();
+    if ( nameLength >= prefixLength && aName.FindF( aPrefix ) == 0 )
+        {
+        // aName is longer or equal length, and
+        // aPrefix can be found in the beginning of aName.
+        if ( nameLength == prefixLength )
+            {
+            // They have the same length; they equal.
+            postfix = 0;
+            }
+        else
+            {
+            if ( aName[ prefixLength ] == '(' )
+                {
+                // (Now we know that aName is longer than aPrefix.)
+                // aName looks like "aPrefix<brace><something>".
+                // See if <something> is an integer number.
+                TPtrC num = aName.Right( nameLength - prefixLength - 1 );
+                TBuf< KMaxPostfixLength > pf;
+                if (num.Length() <= pf.Length())
+                    pf = num;
+                TInt val;
+                TLex lex( pf );
+                if ( lex.Val( val ) == KErrNone )
+                    {
+                    // Yes, the trailer is an integer.
+                    if ( val > 0 )
+                        {
+                        postfix = val;
+                        }
+                    else
+                        {
+                        // signal that it is invalid...
+                        postfix = -1;
+                        }
+                    }
+                }
+            }
+        }
+    return postfix;
+    }
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/XDMSettingsUI/src/XDMPluginSettinglist.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,338 @@
+/*
+* Copyright (c) 2005-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:    XDM GS plugin, Setting List class implementation
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XDMExternalInterface.h"
+
+#include <barsread.h>
+#include <ApSettingsHandlerUI.h>
+#include <ApUtils.h>
+#include <commdb.h>
+#include <avkon.loc>
+#include <StringLoader.h>
+#include <akntitle.h>
+#include <eikspane.h>
+
+#include "XDMPlugin.hrh"
+#include "XDMPluginSettinglist.h"
+#include "SettingsData.h"
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::NewL(CSettingsData &aData)
+// -----------------------------------------------------------------------------
+// 
+CXDMPluginSettinglist *CXDMPluginSettinglist::NewL(CSettingsData &aData)
+    {
+    CXDMPluginSettinglist* self = CXDMPluginSettinglist::NewLC(aData);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::NewLC(CSettingsData &aData)
+// -----------------------------------------------------------------------------
+// 
+CXDMPluginSettinglist *CXDMPluginSettinglist::NewLC(CSettingsData &aData)
+    {
+    CXDMPluginSettinglist* self = new (ELeave) CXDMPluginSettinglist(aData);
+    CleanupStack::PushL(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::CXDMPluginSettinglist(CSettingsData &aData)
+// -----------------------------------------------------------------------------
+// 
+CXDMPluginSettinglist::CXDMPluginSettinglist(CSettingsData &aData) : 
+    CAknSettingItemList(),
+    iSettingsData(aData)  
+    {
+    SetComponentsToInheritVisibility( ETrue );
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::~CXDMPluginSettinglist()
+// -----------------------------------------------------------------------------
+// 
+CXDMPluginSettinglist::~CXDMPluginSettinglist()
+  {
+  // no specific destruction code required - no owned data
+  }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::SizeChanged()
+// -----------------------------------------------------------------------------
+// 
+void CXDMPluginSettinglist::SizeChanged()
+    {
+    // if size changes, make sure component takes whole available space
+    if (ListBox()) 
+        {
+        ListBox()->SetRect(Rect());
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::EditCurrentItemL()
+// -----------------------------------------------------------------------------
+// 
+void CXDMPluginSettinglist::EditCurrentItemL()
+    {
+    // invoke EditItemL on the current item
+    TInt index = ListBox()->CurrentItemIndex();
+
+    //Cause SIP setting is hidden
+    if(index >= 3) //ESipURLIndex == 3
+      index++;
+    
+    // if access point need to be edit
+    if (index == EAccessPointIndex)
+        {
+        EditAccessPointL();
+        SaveSettingL(index);
+        }
+    else 
+        EditItemL(index,ETrue); // invoked from menu
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::EditItemL (TInt aIndex, TBool aCalledFromMenu)
+// -----------------------------------------------------------------------------
+// 
+void CXDMPluginSettinglist::EditItemL (TInt aIndex, TBool aCalledFromMenu)
+    {
+    if (aIndex == EAccessPointIndex)
+      {
+      EditAccessPointL();
+      }
+    else
+        {
+         CAknSettingItemList::EditItemL(aIndex, aCalledFromMenu);
+        }
+    (*SettingItemArray())[aIndex]->StoreL();
+    SaveSettingL(aIndex);
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::SaveSettingL(TInt aIndex)
+// -----------------------------------------------------------------------------
+// 
+void CXDMPluginSettinglist::SaveSettingL(TInt aIndex)
+    {
+    
+    switch (aIndex)
+        {
+        case ESettingNameIndex:
+            SetTitlePaneTextL(iSettingsData.iSettingNameDisp);         
+            break;
+ 
+         case EAccessPointIndex:
+            if (iSettingsData.iAccessPoint > -1) // if Valid AP number
+                {
+                (iSettingsData.iAccessPointDes).Num(iSettingsData.iAccessPoint);
+                GetAccessPointNameL(iSettingsData.iAccessPoint, 
+                                                    iSettingsData.iAccessPointName);
+                }
+            LoadSettingsL();
+            break;
+ 
+        case EServerAddressIndex:
+            break;
+        
+        
+        case ESipURLIndex:
+            break;
+        case EUserIDIndex:
+            break;
+            
+        case EPasswordIndex:
+            break;
+            
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::CreateSettingItemL (TInt aIdentifier) 
+// -----------------------------------------------------------------------------
+// 
+CAknSettingItem * CXDMPluginSettinglist::CreateSettingItemL (TInt aIdentifier) 
+    {
+    // method is used to create specific setting item as required at run-time.
+    // aIdentifier is used to determine what kind of setting item should be 
+    // created
+
+    CAknSettingItem* settingItem = NULL;
+
+    switch (aIdentifier)
+        {
+        case ESettingItemSettingName:
+            
+            settingItem = new (ELeave) CAknTextSettingItem ( aIdentifier,
+                                                   iSettingsData.iSettingNameDisp);
+            break;
+
+        case ESettingItemAccessPoint:
+            GetAccessPointNameL(iSettingsData.iAccessPoint, iSettingsData.iAccessPointName);
+            settingItem = new (ELeave) CAknTextSettingItem (
+                          aIdentifier, iSettingsData.iAccessPointName);
+            break;
+
+        case ESettingItemServerAddress:
+            settingItem = new (ELeave) CAknTextSettingItem (
+                          aIdentifier, 
+                          iSettingsData.iServerAddress);
+            break;
+
+
+        
+        case ESettingItemSipURL:
+            settingItem = new (ELeave) CAknTextSettingItem (
+                          aIdentifier, 
+                          iSettingsData.iSipURL);
+                settingItem->SetHidden(ETrue);
+            break;
+        
+
+        case ESettingItemUserID:
+            settingItem = new (ELeave) CAknTextSettingItem (
+                          aIdentifier, 
+                          iSettingsData.iUserID);
+            break;
+        case ESettingItemPassword:
+            settingItem = new (ELeave) CAknPasswordSettingItem (
+                          aIdentifier, 
+                          CAknPasswordSettingItem::EAlpha,
+                          iSettingsData.iPassword);
+            break;
+        default:
+            break;
+        }
+    return settingItem;
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::EditAccessPoint()
+// -----------------------------------------------------------------------------
+// 
+void CXDMPluginSettinglist::EditAccessPointL()
+    {
+    // After dialog server for access point selection (RGenConAgentDialogServer)
+    // has deprecated wins emulator mode needs a different technique to show
+    // emulator-lan access point.
+    
+    CCommsDatabase* commsDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
+    CleanupStack::PushL(commsDb);
+    CApUtils* aPUtils = CApUtils::NewLC( *commsDb );
+
+    CApSettingsHandler *apUi = CApSettingsHandler::NewLC(
+                                                        ETrue, 
+                                                        EApSettingsSelListIsPopUp,
+                                                        EApSettingsSelMenuSelectNormal,
+                                                        KEApIspTypeAll,
+                                                        EApBearerTypeAllBearers,
+                                                        KEApSortNameAscending,
+                                                        EIPv4 | EIPv6
+                                                        );
+    TUint32 id;
+    
+    TRAP_IGNORE(id = aPUtils->WapIdFromIapIdL(iSettingsData.iAccessPoint));
+    
+    //err can also be in case this is new set, iSettingsData.iAccessPoint = -1
+    //so ignoring the error
+    
+    if ( apUi->RunSettingsL( id, id ) == KApUiEventSelected)
+        {
+    iSettingsData.iAccessPoint = aPUtils->IapIdFromWapIdL(id);
+        }
+    CleanupStack::PopAndDestroy(3, commsDb); //commsDb, aPUtils, apUi
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::GetAccessPointNameL(TInt32 aAP, TDes& aAccessPoint)
+// -----------------------------------------------------------------------------
+// 
+void CXDMPluginSettinglist::GetAccessPointNameL(TInt32 aAP, TDes& aAccessPoint)
+    {
+#if defined __WINS__ && defined _DEBUG // handled differently in wins+debug
+    if (aAP != KErrNotFound) // if access point is defined take a general name
+        StringLoader::Load ( aAccessPoint, R_STR_XDM_AP_NAME_FOR_DEBUG_ONLY);    
+#else
+    CCommsDatabase* commsDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
+    CleanupStack::PushL(commsDb);
+    CApUtils* aPUtils = CApUtils::NewLC( *commsDb );
+    TInt err(KErrNone);
+    // to remove id bug
+    TRAP(err, aAP = aPUtils->WapIdFromIapIdL(aAP)); 
+    TRAP(err, aPUtils->NameL(aAP, aAccessPoint));
+    // dont do anything if name not found or if some error occur
+    CleanupStack::PopAndDestroy(2); // commsDb, aPUtils
+#endif 
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::IsAccessPointInUseL(TInt32 aAP)
+// -----------------------------------------------------------------------------
+// 
+TBool CXDMPluginSettinglist::IsAccessPointInUseL(TInt32 aAP)
+    {
+    TBool inUse( EFalse );
+    
+    CCommsDatabase* commsDb = CCommsDatabase::NewL( EDatabaseTypeIAP );
+    CleanupStack::PushL(commsDb);
+    CApUtils* aPUtils = CApUtils::NewLC( *commsDb );
+    TInt err(KErrNone);
+    // to remove id bug
+    TRAP(err, aAP = aPUtils->WapIdFromIapIdL(aAP)); 
+    inUse = aPUtils->IsAPInUseL( aAP );   
+    // dont do anything if name not found or if some error occur
+    CleanupStack::PopAndDestroy(2); // commsDb, aPUtils
+    
+    return inUse;
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::SetTitlePaneTextL( const TDesC& aTitleText ) const
+// -----------------------------------------------------------------------------
+// 
+void CXDMPluginSettinglist::SetTitlePaneTextL( const TDesC& aTitleText ) const
+    {
+    CAknTitlePane* title = static_cast< CAknTitlePane* >
+        ( CEikonEnv::Static()->AppUiFactory()->StatusPane()->ControlL(
+                                        TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    if ( !title )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    title->SetTextL( aTitleText );
+    }
+
+// -----------------------------------------------------------------------------
+// CXDMPluginSettinglist::ResetItemIndex()
+// -----------------------------------------------------------------------------
+// 
+void CXDMPluginSettinglist::ResetItemIndex()
+    {
+    ListBox()->SetCurrentItemIndexAndDraw(NULL);
+    }
+
+// End of File
--- a/group/bld.inf	Tue Aug 31 15:35:50 2010 +0300
+++ b/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -19,4 +19,10 @@
 
 #include "../pressrv_plat/group/bld.inf"
 #include "../XDMEngine/group/bld.inf"
-//#include "../simpleengine/group/bld.inf"
\ No newline at end of file
+#include "../XDMSettingsUI/group/bld.inf"
+#include "../xdmprotocols/group/bld.inf"
+#include "../msgconnmanager/group/bld.inf"
+#include "../presencesettingsui/group/bld.inf"
+#include "../simpleengine/group/bld.inf"
+#include "../presencefwsimpleadpt/group/bld.inf"
+#include "../simpledatamodeladapter/group/bld.inf"
--- a/inc/xcapappusagedef.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/inc/xcapappusagedef.h	Wed Sep 01 12:23:14 2010 +0100
@@ -48,6 +48,9 @@
 _LIT8( KXdmPocGroupUsageAUID,              "/org.openmobilealliance.poc-groups/" );
 // add new AUID definitions here
 //_LIT8( KXdmTestAppUsageAUID,               "/org.foo.bar/" );
+// PRES-CONTENT starts
+_LIT8( KXdmPresContentAUID,                "/org.openmobilealliance.pres-content/" );
+// PRES-CONTENT ends
 
 // ContentTypes
 _LIT8( KXdmResourceListsUsageContType,     "application/resource-lists+xml" );
@@ -63,7 +66,10 @@
 _LIT8( KXdmPocGroupUsageContType,          "application/vnd.oma.poc.groups+xml" );
 // add new content types here
 //_LIT8( KXdmTestAppUsageContType,           "application/test-type+xml" );
-
+// PRES-CONTENT starts
+_LIT8( KXdmPresContentContType,            "application/vnd.oma.pres-content+xml" );
+_LIT8( KXdmPresContentContTypeOld,         "application/vnd.oma.content+xml" );
+// PRES-CONTENT ends
 
 // Namespaces
 _LIT8( KXdmResourceListsNamespace,         "urn:ietf:params:xml:ns:resource-lists" );
@@ -78,6 +84,9 @@
 _LIT8( KXdmPocUserAccessNamespace,         "urn:oma:xml:poc:poc-rules" );
 _LIT8( KXdmPocGroupNamespace,              "urn:oma:xml:poc:list-service" );
 // add new namespace definitions here
+// PRES-CONTENT starts
+_LIT8( KXdmPresContentNamespace,           "urn:oma:xml:prs:pres-content" );
+// PRES-CONTENT ends
 
 // Namespace prefixes
 _LIT8( KXdmSharedXDMUriUsageNsPrefix,       "ou" );
@@ -231,6 +240,15 @@
 _LIT(  KXdmPackage,                         "package" );
 _LIT8( KXdmPresence,                        "presence" );
 
+// PRES-CONTENT starts
+_LIT( KXdmMimeType,                         "mime-type");
+_LIT( KXdmEncoding,                         "encoding");
+_LIT( KXdmDescription,                      "description");
+_LIT( KXdmData,                             "data");
+_LIT( KXdmSvg,                              "svg");
+_LIT( KXdmRect,                             "rect");
+// PRES-CONTENT ends
+
 #endif      //__XCAPAPPUSAGEDEF__
             
 // End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/xdmlogwriter.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* 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:   XDM Engine log writer
+*
+*/
+
+
+
+
+#ifndef __XDMLOGWRITER__
+#define __XDMLOGWRITER__
+
+#include <e32base.h>
+
+_LIT( KXdmLogDir,                                  "XDM" );
+_LIT( KXdmLogFileExt,                              ".txt" );
+_LIT( KXdmLogRoot,                                 "C:\\logs\\" );
+
+//Determines how many log file instances are
+//retained until the directory is cleaned up
+/* E.g. XdmEngine1.txt, XdmEngine2.txt ... XdmEngine10.txt */
+const TInt KMaxLogFiles                            = 10;
+
+/* Default size of the log buffer */
+const TInt KLogBufferMaxSize		               = 2000;
+
+// CLASS DECLARATION
+class CXdmLogWriter : public CBase
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        *
+        * @param TDesC& The log file name
+        * @return CXdmLogWriter* A log writer instance
+        */ 
+        IMPORT_C static CXdmLogWriter* NewL( const TDesC& aLogName );
+        
+        /**
+        * Write a log string.
+        *
+        * @param TDesC& Log string in 16-bit
+        * @return void
+        */     
+        IMPORT_C void WriteToLog( const TDesC& aLogLine ) const;
+        
+        /**
+        * Write a log string.
+        *
+        * @param TDesC8& Log string in 8-bit
+        * @return void
+        */     
+        IMPORT_C void WriteToLog( const TDesC8& aLogLine  ) const;
+        
+        /**
+        * Destructor
+        */ 
+        virtual ~CXdmLogWriter();
+
+    private:
+        
+        /**
+        * C++ constructor is private
+        */ 
+        CXdmLogWriter();
+        
+        /**
+        * Symbian OS second-phase constructor
+        * @param TDesC& Name of the log file to write to
+        * @return void
+        */ 
+        void ConstructL( const TDesC& aLogName );
+        
+    private:  //Data
+        
+        HBufC*              iLogFileName;
+    
+    };
+
+#endif      //__XDMLOGWRITER__
+            
+// End of File
--- a/layers.sysdef.xml	Tue Aug 31 15:35:50 2010 +0300
+++ b/layers.sysdef.xml	Wed Sep 01 12:23:14 2010 +0100
@@ -1,10 +1,10 @@
 <?xml version="1.0"?>
 
-<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_5_1.dtd" [
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
   <!ENTITY layer_real_source_path "sf/mw/legacypresence" >
 ]>
 
-<SystemDefinition name="legacypresence" schema="1.5.1">
+<SystemDefinition name="legacypresence" schema="1.4.0">
   <systemModel>
     <layer name="mw_layer">
       <module name="legacypresence">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msgconnmanager/bwinscw/msgconnmanagerU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewMsgConnManagerL@@YAPAVMMsgConnManager@@H@Z @ 1 NONAME ; class MMsgConnManager * NewMsgConnManagerL(int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msgconnmanager/eabi/msgconnmanagerU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,7 @@
+EXPORTS
+	_Z18NewMsgConnManagerLi @ 1 NONAME
+	_ZTI13CMsgConnTimer @ 2 NONAME ; #<TI>#
+	_ZTI15CMsgConnManager @ 3 NONAME ; #<TI>#
+	_ZTV13CMsgConnTimer @ 4 NONAME ; #<VT>#
+	_ZTV15CMsgConnManager @ 5 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msgconnmanager/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* 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:  Connection manager build file
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+//--------------------
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_EXPORTS
+//--------------------
+// IBYs
+../rom/msgconnmanager.iby CORE_MW_LAYER_IBY_EXPORT_PATH(msgconnmanager.iby)
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+msgconnmanager.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msgconnmanager/group/msgconnmanager.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  Connection manager
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                          msgconnmanager.dll
+TARGETTYPE                      dll
+UID                             0x1000008d 0x101FB0C2
+CAPABILITY                      CAP_GENERAL_DLL
+
+SOURCEPATH                      ../src
+
+SOURCE                          msgconntimer.cpp
+SOURCE                          msgconnmanager.cpp
+
+USERINCLUDE                     ../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+DEBUGLIBRARY                    flogger.lib
+LIBRARY                         efsrv.lib
+LIBRARY                         euser.lib
+LIBRARY                         commdb.lib
+LIBRARY                         esock.lib
+
+#if defined( ARMCC )
+    DEFFILE ../eabi/ 
+#elif defined ( WINSCW )
+    deffile ../bwinscw/ 
+#elif defined (WINS )
+    deffile ../bwins/ 
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msgconnmanager/inc/msgconnmanager.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,365 @@
+/*
+* 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:   Connection manager
+*
+*/
+
+
+
+
+#ifndef __MSGCONNMANAGER__
+#define __MSGCONNMANAGER__
+
+// INCLUDES
+#include <commdb.h>
+#include <es_sock.h>
+#include <commdbconnpref.h>
+#include <msgconnmanagerapi.h>
+#include "msgconntimercallback.h"
+
+
+//CONSTANTS
+_LIT( KConnManLogDir,                           "MsgConnMan" );
+_LIT( KConnManLogFile,                          "MsgConnManager.txt" );
+const TInt KConnManLogBufferMaxSize		        = 2000;
+
+//FORWARD DECLARATIONS
+class CMsgConnTimer;
+class MMsgBearerObsCallback;
+
+// CLASS DECLARATION
+class CMsgConnManager : public CActive,
+                        public MMsgConnManager,
+                        public MMsgConnTimerCallback
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CMsgConnManager*
+        */     
+        static CMsgConnManager* NewL( const TInt aAccessPoint );
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CMsgConnManager();
+
+    public:   //New functions   
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TRequestStatus& Request status of the caller
+        * @return void
+        */  
+        virtual void StartConnection( TRequestStatus& aStatus );
+    
+        /**
+        * Stop a connection, synchronous version
+        * @return void
+        */  
+        virtual void StopConnection();
+        
+        /**
+        * Stop a connection, asynchronous version
+        * @return void
+        */  
+        virtual void StopConnection( TRequestStatus& aStatus );
+        
+        /**
+        * Cancel StartConnection(). The method may leave with
+        *   - KErrAbort if the TRequestStatus object the client
+        *     supplied is not active, hence, there is no pending
+        *     request that would require cancelling.
+        * In normal cases - when RConnection::Start() or its 
+        * progress notifications are pending - ConnMan completes
+        * the client's request with the "error" KErrCancel.
+        */
+        virtual void CancelStartL();
+
+        /**
+        * Set the ID of the Access Point to connect to.
+        * @param aAccessPointID
+        * @return void
+        */
+        virtual void SetAccessPointIDL( const TInt aAccessPointID );
+
+        /**
+        * Returns the number of connections presently active
+        * @return TInt
+        */
+        virtual TInt NumberOfActiveConns();
+        
+        /**
+        * Read from the Comms Database
+        * @param const TMsgSupportedCommDbRecords& aParameter
+        * @return HBufC8*
+        */
+        virtual HBufC* ReadFromCommsDbLC( const TSupportedCommDbRecords aParameter );
+        
+        /**
+        * Returns a reference to the active socket server.
+        * @return RConnection&
+        */
+        virtual RConnection& Connection();
+
+        /**
+        * Returns a reference to the active socket server.
+        * @return RSocketServ&
+        */
+        virtual RSocketServ& SocketSession();
+
+        /**
+        * Add an object to the queue of listeners. The object to be added
+        * must inplement the interface MMsgBearerObsCallback in order
+        * to receive events from the system agent. It is important to note
+        * that the call to the notification handler (HandleBearerEventL())
+        * takes place inside the RunL() method of this Connection Manager,
+        * so the listening object MUST return the control to the Manager
+        * AS SOON AS POSSIBLE in order not to clog the scheduler.
+        * @param MMsgBearerObsCallback* aClient
+        * @return void
+        */
+        virtual void AddEventSubscriberL( MMsgBearerObsCallback* aClient );
+        
+        /**
+        * Remove an object from the queue of listeners. It is no necessary
+        * to call this method at deletion time, as the destructor destroys
+        * the subscriber queue altogether. If, however, a listener object is
+        * destroyed before an instance of Connection Manager, it is mandatory
+        * to remove the listener from the queue prior to deleting the listener.
+        * @param MMsgBearerObsCallback* aClient
+        * @return void
+        */
+        virtual void RemoveEventSubscriber( MMsgBearerObsCallback* aClient );
+
+        /**
+        * Returns the status of the ConnMan: ETrue if sending is OK, EFalse otherwise
+        * @return TBool
+        */
+        virtual TBool Status() const;
+        
+        /**
+        * Destructor.
+        * @return void
+        */
+        virtual void Destroy();
+        
+    public:
+
+    #ifdef _DEBUG
+
+        /**
+        * A Global logging function
+        * @param TRefByValue<const TDesC8> aFmt,...
+        * @return void
+        */ 
+        static void WriteToLog( TRefByValue<const TDesC8> aFmt,... );
+
+    #endif
+
+    private:
+        
+        /**
+        * Start to keep an eye on the opened connection
+        * @return void
+        */ 
+        void StartNetworkObserver();
+        
+        /**
+        * Determine the state of the connection opening
+        * @return void
+        */ 
+        void WatchConnectionOpening();
+        
+        /**
+        * Determine the state of the (opened) connection
+        * @return void
+        */ 
+        void DetermineConnectionStatusL();
+        
+        /**
+        * Broadcast the bearer event to registered listeners
+        * @param TMsgBearerEvent aBearerEvent
+        * @return void
+        */ 
+        void BroadcastBearerEventL( const TMsgBearerEvent aBearerEvent );
+
+        /**
+        * Determine which value is to be fetched from the CommsDb
+        * @param TPtrC& aDbView
+        * @param TPtrC& TPtrC& aDbColumn
+        * @param TMsgSupportedCommDbRecords aParameter
+        * @return TBool
+        */ 
+        TInt DetermineRecordTypeLC( TPtrC& aDbColumn,
+                                    CCommsDbTableView*& aView,
+                                    const TSupportedCommDbRecords aParameter );
+
+        /**
+        * Broadcast the bearer event to registered listeners
+        * @param TMsgBearerEvent aBearerEvent
+        * @return void
+        */ 
+        TInt InitCommDbViewLC( TPtrC& aDbRecord,
+                               CCommsDbTableView*& aView,
+                               const TSupportedCommDbRecords aParameter );
+        
+        /**
+        * Broadcast the bearer event to registered listeners
+        * @param TMsgBearerEvent aBearerEvent
+        * @return void
+        */ 
+        TBool CheckProxyUsageLC( CCommsDbTableView*& aView );
+
+        /**
+        * Issue a new asynchronous request
+        * @return void
+        */
+        void IssueRequest();
+        
+        /**
+        * Check the availability of GPRS Network
+        * @return TBool Available or not
+        */
+        TBool IsValidApL( TUint32 aUid );
+        
+        /**
+        * Handle the opening of a new connection
+        * @return void
+        */
+        void HandleNewConnection();
+
+        /**
+        * Handle an existing connection
+        * @return void
+        */
+        void HandleExistingConnection();
+
+        /**
+        * Symbian OS second-phase constructor
+        * @param TInt aAccessPoint
+        * @return void
+        */ 
+        void ConstructL( const TInt aAccessPoint );
+        
+        /**
+        * Delete the log files
+        * @return void
+        */ 
+        void DeleteLogFileL();
+
+        /**
+        * C++ default constructor is private
+        * @return void
+        */      
+        CMsgConnManager();
+
+        /**
+        * From CActive
+        * @return void
+        */
+        void RunL();
+
+        /**
+        * From CActive
+        * @return void
+        */
+        void DoCancel();
+    
+    private:  //From MMsgConnectionTimerCallback
+        
+        /**
+        * Catch a timer event
+        * @param TInt aStatus
+        * @return void
+        */
+        virtual void HandleTimerEvent( TInt aStatus );
+        
+    private: //Data
+        
+        enum TMsgConnManState
+            {
+            EMsgConnManIdle = 0,
+            EMsgConnManWaitingForStartComplete,
+            EMsgConnManWaitingForNotifications,
+            EMsgConnManDisconnectingPrevious,
+            EMsgConnManObservingAccessPoint,
+            EMsgConnManBearerSuspended,
+            EMsgConnManBearerLost
+            };
+        
+        TInt                                            iAccessPointID;
+        TInt                                            iLastConnectionStage;
+        TBool                                           iProgressStarted;
+        TBool                                           iConnectionClosed;
+        TNifProgressBuf                                 iProgressBuffer;
+        TMsgConnManState                                iConnManStatus;
+        TRequestStatus*                                 iClientStatus;
+        TRequestStatus*                                 iPingRequestStatus;
+        TRequestStatus*                                 iTimedCompleteStatus;
+        CCommsDatabase*                                 iCommsDatabase;
+        CMsgConnTimer*                                  iConnectionTimer;
+        RConnection                                     iConnection;
+        TCommDbConnPref                                 iAccessPointSettings;     
+        RSocketServ                                     iSocketSession;
+        RPointerArray<MMsgBearerObsCallback>	        iEventSubscribers;
+    };
+
+// ---------------------------------------------------------
+// CMsgConnManager::StartBearerObserver
+// If the status is any other than EMsgConnManObservingAccessPoint
+// there is something fishy going on => do not send/receive anything
+// ---------------------------------------------------------
+//
+inline TBool CMsgConnManager::Status() const
+    {
+    return iConnManStatus == EMsgConnManObservingAccessPoint;
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::SocketSession
+// 
+// ---------------------------------------------------------
+//
+inline RSocketServ& CMsgConnManager::SocketSession()
+    {
+    return iSocketSession;
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::Connection
+// 
+// ---------------------------------------------------------
+//
+inline RConnection& CMsgConnManager::Connection()
+    {
+    return iConnection;
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::Destroy
+// 
+// ---------------------------------------------------------
+//
+inline void CMsgConnManager::Destroy()
+    {
+    delete this;
+    }
+
+#endif
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msgconnmanager/inc/msgconntimer.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,113 @@
+/*
+* 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:   Connection manager timer
+*
+*/
+
+
+
+
+#ifndef __MSGCONNTIMER__
+#define __MSGCONNTIMER__
+
+#include <e32base.h>
+
+class MMsgConnTimerCallback;
+
+// CLASS DECLARATION
+class CMsgConnTimer : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+		* @return CMsgConnTimer* 
+        */
+        static CMsgConnTimer* NewL();
+
+        /**
+        * Two-phased constructor.
+		* @param MMsgConnectionTimerCallback* aClient
+        * @return CMsgConnTimer*
+        */
+        static CMsgConnTimer* NewL( MMsgConnTimerCallback* aClient );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CMsgConnTimer();
+
+    public: // New functions
+        
+        /**
+        * Request to activate timer
+        * @param TRequestStatus& aStatus
+        * @param TTimeIntervalMicroSeconds32 aDelay
+		* @param TBool aCompleteIfCancel = EFalse
+        * @return void
+        */
+        void ActivateTimer( TRequestStatus& aStatus,
+                            TTimeIntervalMicroSeconds32 aDelay );
+
+        /**
+        * Request to activate timer
+        * @param TTimeIntervalMicroSeconds32 aDelay
+		* @param MMsgConnectionTimerCallback* aClient
+        * @return void
+        */
+        void ActivateTimer( MMsgConnTimerCallback* aClient,
+                            TTimeIntervalMicroSeconds32 aDelay );
+        
+    private:
+        
+        /**
+        * From CActive.
+        * @return void
+        */
+		void RunL();
+
+        /**
+        * From CActive.
+        * @return void
+        */
+		void DoCancel();
+
+        /**
+        * By default Symbian OS constructor is private.
+        * @return void
+        */
+        void ConstructL();
+
+        /**
+        * C++ constructor.
+        */
+		CMsgConnTimer();
+
+        /**
+        * C++ constructor.
+		* @param MMsgConnectionTimerCallback* aClient
+        */
+		CMsgConnTimer( MMsgConnTimerCallback* aClient );
+
+    private:    // Data
+        
+		RTimer							        iTimer;
+		TRequestStatus*	                        iClientStatus;
+        TBool                                   iCompleteIfCancel;
+        MMsgConnTimerCallback*                  iClient;
+    };
+
+#endif      //MSGCONNTIMER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msgconnmanager/inc/msgconntimercallback.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* 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:   Connection manager timer callback
+*
+*/
+
+
+
+
+#ifndef __MSGCONNTIMERCALLBACK__
+#define __MSGCONNTIMERCALLBACK__
+
+#include <e32base.h>
+
+// CLASS DECLARATION
+
+class MMsgConnTimerCallback
+    {
+    public:
+
+        /**
+        * Pure virtual callback function to be implemented in the
+        * derived class. This function is called when timer has
+        * compeleted.
+        * @param aStatus The integer value of iStatus of the timer class
+        * @return void
+        */
+        virtual void HandleTimerEvent( TInt aStatus ) = 0;
+    };
+
+#endif      //__MSGCONNTIMERCALLBACK__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msgconnmanager/rom/msgconnmanager.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Connection manager rom file
+*
+*/
+
+
+
+
+#ifndef __MSGCONNMANAGER_IBY__
+#define __MSGCONNMANAGER_IBY__
+
+    #ifdef __XDM
+        #define __INCLUDE_CM__
+    #endif //__XDM
+
+    #ifdef __IM
+        #define __INCLUDE_CM__
+    #endif //__IM
+
+    #ifdef __PRESENCE
+        #define __INCLUDE_CM__
+    #endif //__PRESENCE
+
+    #ifdef __INCLUDE_CM__
+        file=ABI_DIR/BUILD_DIR/msgconnmanager.dll       SHARED_LIB_DIR/msgconnmanager.dll
+    #endif //__INCLUDE_CM__
+
+#endif //__MSGCONNMANAGER_IBY__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msgconnmanager/src/msgconnmanager.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,1065 @@
+/*
+* 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:   Connection manager
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <in_sock.h>
+#include <es_enum.h>
+#include <f32file.h>
+#include <flogger.h>
+#include "msgconntimer.h"
+#include "msgconnmanager.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+
+// ----------------------------------------------------------
+// CMsgConnManager::CMsgConnManager
+// 
+// ----------------------------------------------------------
+//
+CMsgConnManager::CMsgConnManager() : CActive( EPriorityUserInput + 2 ),
+                                     iProgressStarted( EFalse ),
+                                     iConnectionClosed( ETrue )
+                                                
+    {
+    
+    }
+
+// ----------------------------------------------------------
+// CMsgConnManager::NewL
+// 
+// ----------------------------------------------------------
+//
+CMsgConnManager* CMsgConnManager::NewL( const TInt aAccessPoint )
+    {
+    CMsgConnManager* self = new ( ELeave ) CMsgConnManager();
+    CleanupStack::PushL( self );
+    self->ConstructL( aAccessPoint );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CMsgConnManager::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CMsgConnManager::ConstructL( const TInt aAccessPoint )
+    {
+    DeleteLogFileL();
+    iAccessPointID = aAccessPoint;
+    iConnectionTimer = CMsgConnTimer::NewL();
+    iCommsDatabase = CCommsDatabase::NewL( EDatabaseTypeUnspecified );
+    User::LeaveIfError( iSocketSession.Connect() );
+    User::LeaveIfError( iConnection.Open( iSocketSession ) );
+    iConnectionClosed = EFalse;
+    iAccessPointSettings.SetIapId( aAccessPoint );
+    iAccessPointSettings.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CONNMAN: LOGGING ENABLED" ) );
+    #endif
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------
+// CMsgConnManager::~CMsgConnManager
+// 
+// ----------------------------------------------------
+//
+CMsgConnManager::~CMsgConnManager()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::~CMsgConnManager(), Destructor." ) );
+    #endif
+    Cancel();
+    delete iCommsDatabase;
+    delete iConnectionTimer;
+    iConnection.Close();
+    iSocketSession.Close();
+    iEventSubscribers.Close();
+    }
+
+// ----------------------------------------------------------
+// CMsgConnManager::DeleteLogFileL
+// 
+// ----------------------------------------------------------
+//
+void CMsgConnManager::DeleteLogFileL()
+    {
+    RFs session;
+    User::LeaveIfError( session.Connect() );
+    CFileMan* manager = CFileMan::NewL( session );
+    manager->Delete( _L("C:\\logs\\MsgConnMan\\*.*") );
+    session.Close();
+    delete manager;
+    manager = NULL;
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::StartBearerObserver
+// 
+// ---------------------------------------------------------
+//
+void CMsgConnManager::StartNetworkObserver()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::StartNetworkObserver()  Closed: %d" ), iConnectionClosed );
+    #endif
+    #ifdef __WINS__
+        if( !iConnectionClosed )
+            {
+            iStatus = KRequestPending;
+            SetActive();
+            }
+    #else
+        if( !iConnectionClosed )
+            {
+            if( !IsActive() )
+                {
+                iStatus = KRequestPending;
+                iConnection.ProgressNotification( iProgressBuffer, iStatus );
+                SetActive();
+                }
+            }
+    #endif
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::RunL()
+// 
+// ---------------------------------------------------------
+//
+void CMsgConnManager::RunL()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::RunL(), iConnManStatus: %d  iStatus: %d  iStage: %d  iError: %d" ),
+                    iConnManStatus, iStatus.Int(), iProgressBuffer().iStage, iProgressBuffer().iError );
+    #endif
+    switch( iConnManStatus ) 
+        {
+        case EMsgConnManWaitingForStartComplete:
+            #ifdef _DEBUG
+                WriteToLog( _L8( " Current status is EMsgConnManWaitingForStartComplete." ) );
+            #endif
+            WatchConnectionOpening();
+            break;
+        case EMsgConnManWaitingForNotifications:
+            #ifdef _DEBUG
+                WriteToLog( _L8( " Current status is EMsgConnManWaitingForNotifications." ) );
+            #endif
+            WatchConnectionOpening();
+            break;
+        case EMsgConnManObservingAccessPoint:
+            #ifdef _DEBUG
+                WriteToLog( _L8( " Current status is EMsgConnManObservingAccessPoint." ) );
+            #endif
+            DetermineConnectionStatusL();
+            break;
+        case EMsgConnManBearerSuspended:
+            #ifdef _DEBUG
+                WriteToLog( _L8( " Current status is EMsgConnManBearerSuspended." ) );
+            #endif
+            DetermineConnectionStatusL();
+            break;
+        case EMsgConnManDisconnectingPrevious:
+            #ifdef _DEBUG
+                WriteToLog( _L8( " Timer expired, complete client's request." ) );
+            #endif
+            User::RequestComplete( iTimedCompleteStatus, KErrNone );
+            iConnManStatus = EMsgConnManIdle;
+            break;
+        case EMsgConnManIdle:
+            #ifdef _DEBUG
+                WriteToLog( _L8( " Idle, iStatus is %d." ), iStatus.Int() );
+            #endif
+            break;
+        default:
+            #ifdef _DEBUG
+                WriteToLog( _L8( " Default case, should not be here." ) );
+            #endif
+            break;
+        }
+    #ifdef _DEBUG
+        WriteToLog( _L8( " RunL() ends" ) );
+    #endif
+    }
+
+// ----------------------------------------------------
+// CMsgConnManager::WatchConnectionOpening()
+// 
+// ----------------------------------------------------
+//
+void CMsgConnManager::WatchConnectionOpening()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  CMsgConnManager::WatchConnectionOpening() - iProgressStarted: %d" ), iProgressStarted );
+    #endif
+    //Lets quit right away if it is an error
+    if( iStatus != KErrNone )
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( "   Something wrong, complete with error: %d." ), iStatus.Int() );
+        #endif
+        iConnectionTimer->Cancel();
+        if( iConnManStatus == EMsgConnManWaitingForNotifications )
+            iConnection.CancelProgressNotification();
+        iConnection.Close();
+        iConnectionClosed = ETrue;
+        User::RequestComplete( iClientStatus, iStatus.Int() );
+        iConnManStatus = EMsgConnManIdle;
+        }
+    else
+        {
+        if( iProgressStarted )
+            {
+            iLastConnectionStage = iProgressBuffer().iStage;
+            if( iLastConnectionStage == KLinkLayerOpen )  //we are done
+                {
+                #ifdef _DEBUG
+                    WriteToLog( _L8( "   Connected. Completing with KErrNone." ) );
+                #endif
+                iConnectionTimer->Cancel();
+                iConnManStatus = EMsgConnManObservingAccessPoint;
+                StartNetworkObserver();
+                User::RequestComplete( iClientStatus, KErrNone );
+                iProgressStarted = EFalse;
+                }
+            else
+                {
+                #ifdef _DEBUG
+                    WriteToLog( _L8( "   Keep on waiting for progress." ) );
+                #endif
+                IssueRequest();
+                }
+            }
+        else
+            {
+            #ifdef _DEBUG
+                WriteToLog( _L8( "   Start complete, watch progress." ) );
+            #endif
+            if( iConnManStatus == EMsgConnManWaitingForStartComplete )
+                {
+                iProgressStarted = ETrue;
+                iConnManStatus = EMsgConnManWaitingForNotifications;
+                }
+            IssueRequest();
+            }
+        }
+    }
+
+// ----------------------------------------------------
+// CMsgConnManager::DetermineConnectionStatus()
+// 
+// ----------------------------------------------------
+//
+void CMsgConnManager::DetermineConnectionStatusL()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  CMsgConnManager::DetermineConnectionStatus()" ) );
+    #endif
+    #ifdef __WINS__
+        Cancel();
+        switch( iStatus.Int() )
+    #else
+        switch( iProgressBuffer().iStage )
+    #endif
+        {
+        case KLinkLayerClosed:
+        case KConnectionUninitialised:
+            #ifdef _DEBUG
+                CMsgConnManager::WriteToLog( _L8( "   KLinkLayerClosed, notify clients of EMsgBearerLost" ) );
+            #endif
+            Cancel();
+            iConnManStatus = EMsgConnManBearerLost;
+            BroadcastBearerEventL( EMsgBearerLost );
+            iConnection.Close();
+            iConnectionClosed = ETrue;
+            iEventSubscribers.Reset();
+            iConnManStatus = EMsgConnManIdle;
+            break;
+        case KLinkLayerOpen:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "   KLinkLayerOpen -> GPRS Context Active." ) );
+            #endif
+            if( iConnManStatus == EMsgConnManBearerSuspended )
+                {
+                #ifdef _DEBUG
+                    WriteToLog( _L8( "   Moving to active state." ) );
+                #endif
+                iConnManStatus = EMsgConnManObservingAccessPoint;
+                BroadcastBearerEventL( EMsgBearerActive );
+                StartNetworkObserver();
+                }
+            break;
+        case KDataTransferTemporarilyBlocked:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "   KDataTransferTemporarilyBlocked -> GPRS Context Suspended." ) );
+            #endif
+            if( iConnManStatus != EMsgConnManBearerSuspended )
+                {
+                #ifdef _DEBUG
+                    WriteToLog( _L8( "   Moving to suspended state." ) );
+                #endif
+                iConnManStatus = EMsgConnManBearerSuspended;
+                BroadcastBearerEventL( EMsgBearerSuspended );
+                }
+            StartNetworkObserver();
+            break;
+        default:
+            #ifdef _DEBUG
+                #ifdef __WINS__
+                    if( iStatus.Int() == KErrCancel )
+                        WriteToLog( _L8( "   Bearer event generation cancelled" ) );
+                    else
+                        WriteToLog( _L8( "   Some weird status: %d" ), iStatus.Int() );
+                #else
+                    WriteToLog( _L8( "   Default case! WTF?!?" ) );
+                #endif
+            #endif
+            StartNetworkObserver();
+            break;
+        }     
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::CancelStartL
+// 
+// ---------------------------------------------------------
+//
+void CMsgConnManager::CancelStartL()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::CancelStartL()" ) );
+    #endif
+    if( iClientStatus != NULL && iClientStatus->Int() == KRequestPending )
+        {
+        if( iConnManStatus == EMsgConnManWaitingForStartComplete ||
+            iConnManStatus == EMsgConnManWaitingForNotifications )
+            {
+            Cancel();
+            iEventSubscribers.Reset();
+            User::RequestComplete( iClientStatus, KErrCancel );
+            iConnManStatus = EMsgConnManIdle;
+            iConnectionClosed = ETrue;
+            }
+        else User::Leave( KErrAbort );
+        }
+    else User::Leave( KErrAbort );
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::StopConnection
+// 
+// ---------------------------------------------------------
+//
+void CMsgConnManager::StopConnection()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::StopConnection()" ) );
+    #endif
+    if( iConnManStatus == EMsgConnManWaitingForStartComplete ||
+        iConnManStatus == EMsgConnManWaitingForNotifications ||
+        iConnManStatus == EMsgConnManIdle )
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( "  Status is %d, wrong state for this operation. Abort." ), iConnManStatus );
+        #endif
+        }
+    else
+        {
+        //If bearer has been lost, we're already closed
+        if( iConnManStatus != EMsgConnManBearerLost )
+            {
+            Cancel();
+            iConnection.Close();
+            iConnectionClosed = ETrue;
+            iEventSubscribers.Reset();
+            iConnManStatus = EMsgConnManIdle;
+            }
+        }
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  StopConnection() ends." ) );
+    #endif
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::StopConnection
+// 
+// ---------------------------------------------------------
+//
+void CMsgConnManager::StopConnection( TRequestStatus& aStatus )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CImpsConnectionManager::StopConnectionL()" ) );
+    #endif  
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    iTimedCompleteStatus = &aStatus;
+    if( iConnManStatus == EMsgConnManWaitingForStartComplete ||
+        iConnManStatus == EMsgConnManWaitingForNotifications ||
+        iConnManStatus == EMsgConnManDisconnectingPrevious ||
+        iConnManStatus == EMsgConnManIdle )
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( "  Status is %d, wrong state for this operation. Abort." ),
+                                iConnManStatus );
+        #endif
+        User::RequestComplete( iClientStatus, KErrAbort );
+        }
+    else
+        {
+        //If bearer has been lost, we're already closed
+        if( iConnManStatus != EMsgConnManBearerLost )
+            {
+            Cancel();
+            iConnection.Close();
+            iConnectionClosed = ETrue;
+            iEventSubscribers.Reset();
+            iConnectionTimer->ActivateTimer( iStatus, 4000000 );
+            iConnManStatus = EMsgConnManDisconnectingPrevious;
+            SetActive();
+            }
+        else
+            {
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Bearer lost, nothing to do. Complete with KErrNone" ) );
+            #endif
+            User::RequestComplete( iClientStatus, KErrNone );
+            }
+        }
+    #ifdef _DEBUG
+        WriteToLog( _L8( " StopConnectionL() ends" ) );
+    #endif
+    }
+    
+// ----------------------------------------------------
+// CMsgConnManager::BroadcastBearerEvent
+// 
+// ----------------------------------------------------
+//
+void CMsgConnManager::BroadcastBearerEventL( const TMsgBearerEvent aBearerEvent )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::BroadcastBearerEvent" ) );
+    #endif
+    TInt subs = iEventSubscribers.Count();
+    #ifdef _DEBUG
+        WriteToLog( _L8( " %d clients subscribed." ), subs );
+    #endif
+    if( subs > 0 )
+        {
+        TBool empty = EFalse;
+        MMsgBearerObsCallback* client = NULL;
+        for( TInt i = 0;i < subs && !empty;i++ )
+            {
+            //Just in case:
+            //If a client has managed to remove a listener from the queue
+            //in the previous callback, "i" will index a bad handle.
+            subs = iEventSubscribers.Count();
+            if( subs > 0 && i < subs )
+                {
+                client = iEventSubscribers[i];
+                __ASSERT_ALWAYS( client != NULL, User::Panic( _L( "ObserverNULL!" ), 1 ) );
+                TInt error = iProgressBuffer().iError;
+                if( aBearerEvent == EMsgBearerLost )
+                    {
+                    #ifdef _DEBUG
+                        TInt stage = iProgressBuffer().iStage;
+                        WriteToLog( _L8( " Event is EMsgBearerLost" ) );
+                        WriteToLog( _L8( "   Stage: %d" ), stage );
+                        WriteToLog( _L8( "   Error: %d" ), error );
+                    #endif
+                    }
+                TBool authClose = error == KErrConnectionTerminated;
+                client->HandleBearerEventL( authClose, aBearerEvent );
+                #ifdef _DEBUG
+                    WriteToLog( _L8("  Client no. %d serviced" ), i );
+                #endif
+                }
+            else
+                {
+                #ifdef _DEBUG
+                    WriteToLog( _L8(
+                    "  An event listener was removed inside the callback!" ) );
+                #endif
+                //Leave the for loop
+                empty = ETrue;
+                }
+            }
+        }
+    #ifdef _DEBUG
+        WriteToLog( _L8( " BroadcastBearerEvent() ends" ) );
+    #endif
+    }
+
+// ----------------------------------------------------
+// CMsgConnManager::IssueRequest
+// 
+// ----------------------------------------------------
+//
+void CMsgConnManager::IssueRequest()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::IssueRequest(), status: %d" ), IsActive() );
+    #endif
+    iStatus = KRequestPending;
+    iConnection.ProgressNotification( iProgressBuffer, iStatus );
+    SetActive();
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::StartConnection
+//
+// ---------------------------------------------------------
+//
+void CMsgConnManager::StartConnection( TRequestStatus& aStatus )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::StartConnection()  iConnManStatus: %d" ), iConnManStatus );
+    #endif
+    TInt error = 0;
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    if( iConnectionClosed )
+        {
+        error = iConnection.Open( iSocketSession );
+        iConnectionClosed = EFalse;
+        }
+    TBool exists = EFalse;
+    TNifProgress progress;
+    error = iConnection.Progress( progress );
+    #ifdef _DEBUG
+        WriteToLog( _L8( " Connection stage: %d  error: %d" ), progress.iStage, error );
+    #endif
+    TRAPD( err, exists = IsValidApL( iAccessPointID ) );
+    if( ( error == KErrNone && err == KErrNone ) && exists )
+        {
+        if( progress.iStage == KConnectionUninitialised ) 
+            HandleNewConnection();
+        else
+            HandleExistingConnection();
+        }
+    else
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( " Something's wrong, complete with KErrUnknown. IAP exists: %d  Error: %d Err: %d" ), exists, error, err );
+        #endif
+        User::RequestComplete( iClientStatus, KErrUnknown );
+        iConnectionClosed = ETrue;
+        }
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::HandleNewConnection
+// 
+// ---------------------------------------------------------
+//
+void CMsgConnManager::HandleNewConnection()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  CMsgConnManager::HandleNewConnection()" ) );
+    #endif
+    switch( iConnManStatus )
+        {
+        case EMsgConnManIdle:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "   Current status is EMsgConnManIdle," ) );
+                WriteToLog( _L8( "   starting to connect  IAP: %d" ), iAccessPointSettings.IapId() );
+            #endif
+            iLastConnectionStage = KConnectionUninitialised;
+            iConnection.Start( iAccessPointSettings, iStatus );
+            iConnManStatus = EMsgConnManWaitingForStartComplete;
+            iConnectionTimer->ActivateTimer( this, 20000000 );
+            SetActive();
+            break;
+        case EMsgConnManDisconnectingPrevious:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "   Current status is EMsgConnManDisconnectingPrevious," ) );
+                WriteToLog( _L8( "   new connection cannot be started, ignore." ) );
+            #endif
+            User::RequestComplete( iClientStatus, KErrNotReady );
+            break;
+        default:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "   We're in some weird state, complete with KErrUnknown" ) );
+            #endif
+            User::RequestComplete( iClientStatus, KErrUnknown );
+            iConnManStatus = EMsgConnManIdle;
+            break;
+        }   
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::HandleExistingConnection
+// 
+// ---------------------------------------------------------
+//
+void CMsgConnManager::HandleExistingConnection()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  CMsgConnManager::HandleOldConnection()" ) );
+    #endif
+    switch( iConnManStatus )
+        {
+        case EMsgConnManDisconnectingPrevious:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "   Current status is EMsgConnManDisconnectingPrevious," ) );
+                WriteToLog( _L8( "   attempting to open a connection while previous one is still disconnecting. Complete with KErrNotReady." ) );
+            #endif
+            User::RequestComplete( iClientStatus, KErrNotReady );
+            break;
+        case EMsgConnManObservingAccessPoint:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "   Current status is EMsgConnManObservingAccessPoint," ) );
+                WriteToLog( _L8( "   already connected" ) );
+            #endif
+            User::RequestComplete( iClientStatus, KErrNone );
+            break;
+        case EMsgConnManWaitingForStartComplete:
+        case EMsgConnManWaitingForNotifications:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "   Already connecting, ignore" ) );
+            #endif
+            User::RequestComplete( iClientStatus, KErrAlreadyExists );
+            break;
+        default:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "   Unknown state, complete with KErrUnknown." ) );
+            #endif
+            User::RequestComplete( iClientStatus, KErrUnknown );
+        }
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::HandleTimerEventL
+// 
+// ---------------------------------------------------------
+//
+void CMsgConnManager::HandleTimerEvent( TInt /*aStatus*/ )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::HandleTimerEventL()" ) );
+    #endif
+    switch( iConnManStatus )
+        {
+        case EMsgConnManWaitingForNotifications:
+        case EMsgConnManWaitingForStartComplete:
+            Cancel();
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Connection initiation timed out, complete with error KErrTimedOut" ) );
+            #endif
+            User::RequestComplete( iClientStatus, KErrTimedOut );
+            iConnection.Close();
+            iConnectionClosed = ETrue;
+            iConnManStatus = EMsgConnManIdle;
+            break;
+        default:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Default case, problems..." ) );
+            #endif
+            break;
+        }
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::AddEventSubscriberL
+// 
+// ---------------------------------------------------------
+//
+void CMsgConnManager::AddEventSubscriberL( MMsgBearerObsCallback* aClient )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::AddEventSubscriberL()" ) );
+    #endif
+    if( iEventSubscribers.Count() < KMaxNumberOfSubscribers )
+        User::LeaveIfError( iEventSubscribers.Append( aClient ) );
+    else
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( "  Not allowed to have more than %d clients" ), KMaxNumberOfSubscribers );
+        #endif
+        User::Leave( KErrAlreadyExists );
+        }
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::RemoveEventSubscriber
+// 
+// ---------------------------------------------------------
+//
+void CMsgConnManager::RemoveEventSubscriber( MMsgBearerObsCallback* aClient )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::RemoveEventSubscriber()" ) );
+    #endif
+    TInt index = iEventSubscribers.Find( aClient );
+    if( index >= 0 )
+        {      
+        iEventSubscribers.Remove( index );
+        }
+    }
+
+#ifdef _DEBUG
+// ----------------------------------------------------
+// CMsgConnManager::WriteToLog
+// 
+// ----------------------------------------------------
+//
+void CMsgConnManager::WriteToLog( TRefByValue<const TDesC8> aFmt,... )                                 
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf8<KConnManLogBufferMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    RDebug::RawPrint( buf );
+    RFileLogger::Write( KConnManLogDir, KConnManLogFile, EFileLoggingModeAppend, buf );
+    }
+#endif
+
+// ----------------------------------------------------
+// CMsgConnManager::SetAccessPointIDL
+// 
+// ----------------------------------------------------
+//
+void CMsgConnManager::SetAccessPointIDL( const TInt aAccessPointID )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::SetAccessPointIDL: %d" ), aAccessPointID );
+    #endif
+    if( IsValidApL( aAccessPointID ) )
+        {
+        iAccessPointID = aAccessPointID;
+        iAccessPointSettings.SetIapId( iAccessPointID );
+        iAccessPointSettings.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
+        }
+    else
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( "  The specified AP does not exist, leaves with KErrNotFound" ) );
+        #endif
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// ----------------------------------------------------
+// CMsgConnManager::NumberOfActiveConns
+// 
+// ----------------------------------------------------
+//
+TInt CMsgConnManager::NumberOfActiveConns()
+    {
+    TUint count = 0;
+    TInt error = KErrNone;
+    if( !iConnectionClosed )
+    	{
+    	error = iConnection.EnumerateConnections( count );
+    	}
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::NumberOfActiveConns()  Conns: %d  Error: %d" ), count, error );
+    #endif
+    return KErrNone == error ? count : error;
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::ReadFromCommsDbLC
+// 
+// ---------------------------------------------------------
+//
+HBufC* CMsgConnManager::ReadFromCommsDbLC( const TSupportedCommDbRecords aParameter )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::ReadFromCommsDbLC()" ) );
+    #endif
+    TPtrC dbRecord;
+    HBufC* value = NULL;
+    CCommsDbTableView* view = NULL;
+    TInt error = InitCommDbViewLC( dbRecord, view, aParameter );
+    if( error == KErrNone )
+        {
+        TDbColType colType;
+        TUint32 attribute = 0;
+        view->ReadTypeAttribL( dbRecord, colType, attribute );
+        switch( colType )
+            {
+            case EDbColBit:
+                break;
+            case EDbColUint32:
+                {
+                TUint32 intValue = 0;
+                _LIT( KProxyPort,"%d" );
+                view->ReadUintL( dbRecord, intValue );
+                value = HBufC::NewLC( sizeof( KProxyPort ) );
+                TPtr portPtr( value->Des() );
+                portPtr.Format( KProxyPort, intValue ); 
+                value->Des().Copy( portPtr );    
+                }
+                break;
+            case EDbColText8:
+                break;
+            case EDbColText16:
+                break;
+            case EDbColLongText16:
+                value = view->ReadLongTextLC( dbRecord );
+                break;
+            default:
+                break;
+            }
+            if( value != NULL )
+                {
+                #ifdef _DEBUG
+                    HBufC8* temp = HBufC8::NewL( value->Des().Length() );
+                    TPtr8 ptr( temp->Des() );
+                    ptr.Copy( *value );
+                    WriteToLog( _L8( "  Value was found: %S" ), &ptr );
+                    delete temp;
+                    temp = NULL;
+                #endif
+                CleanupStack::Pop();                //value
+                CleanupStack::PopAndDestroy();      //view
+                CleanupStack::PushL( value );       //Put it back in
+                }
+            else
+                {
+                #ifdef _DEBUG
+                    WriteToLog( _L8( "  No proxy address defined in CommDb" ) );
+                #endif
+                CleanupStack::PopAndDestroy();      //view
+                }
+        }
+    else
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( "  Error: %d" ), error );
+        #endif
+        }
+    return value;
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::InitCommDbViewLC
+// 
+// ---------------------------------------------------------
+//
+TInt CMsgConnManager::InitCommDbViewLC( TPtrC& aDbRecord,
+                                        CCommsDbTableView*& aView,
+                                        const TSupportedCommDbRecords aParameter )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  CMsgConnManager::InitCommDbViewLC" ) );
+    #endif
+    aView = iCommsDatabase->OpenViewMatchingUintLC
+                            ( TPtrC( IAP ), TPtrC( COMMDB_ID ), iAccessPointID );
+    TInt error = aView->GotoFirstRecord();
+    if( error == KErrNone )
+        {
+        error = DetermineRecordTypeLC( aDbRecord, aView, aParameter );
+        #ifdef _DEBUG
+            if( error != KErrNone )
+                WriteToLog( _L8( "    DetermineRecordType() failed - Error: %d" ), error );
+        #endif
+        }
+    else
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( "    No matching view found - Error: %d" ), error );
+        #endif
+        CleanupStack::PopAndDestroy();  //aView
+        aView = NULL;
+        }
+    return error;
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::DetermineRecordType
+// 
+// ---------------------------------------------------------
+//
+TInt CMsgConnManager::DetermineRecordTypeLC( TPtrC& aDbColumn,
+                                             CCommsDbTableView*& aView,
+                                             const TSupportedCommDbRecords aParameter )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "      CMsgConnManager::DetermineRecordType()" ) );
+    #endif 
+    TInt error = KErrNotFound;
+    switch( aParameter )
+        {
+        case EMsgProxyAddress:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "      Type is EImpsProxyAddress" ) );
+            #endif
+            if( CheckProxyUsageLC( aView ) )
+                {
+                error = KErrNone;
+                aDbColumn.Set( TPtrC( PROXY_SERVER_NAME ) );
+                }
+            break;
+        case EMsgProxyPort:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "      Type is EImpsProxyPort" ) );
+            #endif
+            if( CheckProxyUsageLC( aView ) )
+                {
+                error = KErrNone;
+                aDbColumn.Set( TPtrC( PROXY_PORT_NUMBER ) );
+                }
+            break;
+        default:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "      Default case, problems..." ) );
+            #endif
+            error = KErrNotSupported;
+            break;
+        }
+    return error;
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::CheckProxyUsageLC
+// 
+// ---------------------------------------------------------
+//
+TBool CMsgConnManager::CheckProxyUsageLC( CCommsDbTableView*& aView )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::CheckProxyUsageL()" ) );
+    #endif
+    TBool useProxy = EFalse;
+    TUint32 serviceIdNumber = 0;
+    TBuf<KCommsDbSvrMaxFieldLength> serviceIdText;
+    aView->ReadTextL( TPtrC( IAP_SERVICE_TYPE ), serviceIdText );
+    aView->ReadUintL( TPtrC( IAP_SERVICE ), serviceIdNumber );
+    CleanupStack::PopAndDestroy();  //aView
+    aView = NULL;
+    aView = iCommsDatabase->OpenViewOnProxyRecordLC( serviceIdNumber, serviceIdText );
+    TInt error = aView->GotoFirstRecord();
+    if( error == KErrNone )
+        {
+        aView->ReadBoolL( TPtrC( PROXY_USE_PROXY_SERVER ), useProxy );
+        if( !useProxy )
+            {
+            CleanupStack::PopAndDestroy();  //aView
+            aView = NULL;
+            }
+        }
+    else
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( "  The AP does not use a proxy server." ) );
+        #endif
+        CleanupStack::PopAndDestroy();  //aView
+        aView = NULL;
+        }
+    return useProxy;
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::IsValidApL
+// 
+// ---------------------------------------------------------
+//
+TBool CMsgConnManager::IsValidApL( TUint32 aUid )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::IsValidApL()" ) );
+    #endif
+    CCommsDbTableView* table = iCommsDatabase->OpenViewMatchingUintLC( TPtrC( IAP ),
+                                                                       TPtrC( COMMDB_ID ),
+                                                                       aUid );
+    TInt res = table->GotoFirstRecord();
+    CleanupStack::PopAndDestroy(); // table
+    return res == KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CMsgConnManager::DoCancel
+// 
+// ---------------------------------------------------------
+//
+void CMsgConnManager::DoCancel()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CMsgConnManager::DoCancel()" ) );
+    #endif
+    switch( iConnManStatus )
+        {
+        case EMsgConnManWaitingForStartComplete:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Status is EMsgConnManWaitingForStartComplete" ) );
+            #endif
+            iConnection.Close();
+            iConnectionTimer->Cancel();
+            break;
+        case EMsgConnManWaitingForNotifications:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Status is EMsgConnManWaitingForNotifications" ) );
+            #endif
+            iConnection.CancelProgressNotification();
+            iConnectionTimer->Cancel();
+            iConnection.Close();
+            break;
+        case EMsgConnManDisconnectingPrevious:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Status is EMsgConnManDisconnectingPrevious" ) );
+            #endif
+            iConnectionTimer->Cancel();
+            User::RequestComplete( iClientStatus, KErrCancel );
+             #ifdef _DEBUG
+                WriteToLog( _L8( "    StopConnection() terminated, client's request completed." ) );
+            #endif
+            break;
+        case EMsgConnManObservingAccessPoint:
+        case EMsgConnManBearerSuspended:
+            {
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Status is %d" ), iConnManStatus );
+            #endif
+            iConnection.CancelProgressNotification();
+            #ifdef __WINS__
+                TRequestStatus* status = &iStatus;
+                User::RequestComplete( status, KErrCancel );
+            #endif
+            }
+            break;
+        case EMsgConnManIdle:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Status is EMsgConnManIdle" ) );
+            #endif
+            break;
+        default:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Default case" ) );
+            #endif
+            break;
+        }
+    }
+
+// ----------------------------------------------------
+// NewImpsConnManL
+// Returns a ConnManager instance
+// ----------------------------------------------------
+//
+EXPORT_C MMsgConnManager* NewMsgConnManagerL( const TInt aDefaultAccessPoint ) 
+    { 
+    return CMsgConnManager::NewL( aDefaultAccessPoint ); 
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/msgconnmanager/src/msgconntimer.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,193 @@
+/*
+* 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:   Connection manager timer
+*
+*/
+
+
+
+
+// INCLUDES
+#include "msgconntimer.h"
+#include "msgconnmanager.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CMsgConnTimer::CMsgConnTimer() : CActive( EPriorityStandard ),
+                                 iCompleteIfCancel( EFalse )
+                                          
+    {
+    }
+
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CMsgConnTimer::CMsgConnTimer( MMsgConnTimerCallback* aClient ) :
+                              CActive( EPriorityStandard ),
+                              iClient( aClient )
+                                               
+                                          
+    {
+    }
+
+// ---------------------------------------------------------
+// Symbian OS default constructor may leave.
+//
+// ---------------------------------------------------------
+//
+void CMsgConnTimer::ConstructL()
+    {
+    User::LeaveIfError( iTimer.CreateLocal() );
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------
+// Two-phased constructor.
+//
+// ---------------------------------------------------------
+//
+CMsgConnTimer* CMsgConnTimer::NewL()
+    {
+    CMsgConnTimer* self = new ( ELeave ) CMsgConnTimer();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// Two-phased constructor.
+//
+// ---------------------------------------------------------
+//
+CMsgConnTimer* CMsgConnTimer::NewL( MMsgConnTimerCallback* aClient )
+    {
+    CMsgConnTimer* self = new ( ELeave ) CMsgConnTimer( aClient );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// Destructor
+//
+// ---------------------------------------------------------
+//
+CMsgConnTimer::~CMsgConnTimer()
+    {
+    #ifdef _DEBUG
+        CMsgConnManager::WriteToLog( _L8( "CMsgConnTimer::~CMsgConnTimer(), destructor called." ) );  
+    #endif
+    Cancel();
+    iTimer.Close();
+    }
+
+// ---------------------------------------------------------
+// CMsgConnTimer::ActivateTimer
+//
+// ---------------------------------------------------------
+//
+void CMsgConnTimer::ActivateTimer( TRequestStatus& aStatus,
+                                   TTimeIntervalMicroSeconds32 aDelay )
+    {
+    #ifdef _DEBUG
+        CMsgConnManager::WriteToLog( _L8( "CMsgConnTimer::ActivateTimer()." ) );
+    #endif
+    __ASSERT_ALWAYS( !IsActive(), User::Panic( _L("ConnectionTimer"), 1 ) );
+    iClient = NULL;
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    iTimer.After( iStatus, aDelay );
+    #ifdef _DEBUG
+        CMsgConnManager::WriteToLog( _L8( "  Timer activated." ) );
+    #endif
+    SetActive();
+    }
+
+// ---------------------------------------------------------
+// CMsgConnTimer::ActivateTimer
+//
+// ---------------------------------------------------------
+//
+void CMsgConnTimer::ActivateTimer( MMsgConnTimerCallback* aClient,
+                                   TTimeIntervalMicroSeconds32 aDelay )
+    {
+    #ifdef _DEBUG
+        CMsgConnManager::WriteToLog( _L8( "CMsgConnTimer::ActivateTimer()" ) );
+    #endif
+    __ASSERT_ALWAYS( !IsActive(), User::Panic( _L("ConnectionTimer"), 1 ) );
+    iClient = aClient;
+    iClientStatus = NULL;
+    iTimer.After( iStatus, aDelay );
+    #ifdef _DEBUG
+        CMsgConnManager::WriteToLog( _L8( "  Timer activated (with client)" ) );
+    #endif
+    SetActive();
+    }
+
+// ---------------------------------------------------------
+// CMsgConnTimer::RunL
+//
+// ---------------------------------------------------------
+//
+void CMsgConnTimer::RunL()
+    {
+    #ifdef _DEBUG
+        CMsgConnManager::WriteToLog( _L8( "CMsgConnTimer::RunL()." ) );
+    #endif
+    if( iClient != NULL )
+        {
+        #ifdef _DEBUG
+            CMsgConnManager::WriteToLog( _L8( "  iClient != NULL, Callback interface in use." ) );
+        #endif
+        iClient->HandleTimerEvent( iStatus.Int() );
+        iClient = NULL;
+        }
+    else
+        {
+        #ifdef _DEBUG
+            CMsgConnManager::WriteToLog( _L8( "  iClient == NULL, completing request." ) );
+        #endif
+        User::RequestComplete( iClientStatus, iStatus.Int() );
+        }
+    }
+
+// ---------------------------------------------------------
+// CMsgConnTimer::DoCancel
+//
+// ---------------------------------------------------------
+//
+void CMsgConnTimer::DoCancel()
+    {
+    #ifdef _DEBUG
+        CMsgConnManager::WriteToLog( _L8( "CMsgConnTimer::DoCancel()" ) );
+    #endif
+    iTimer.Cancel();
+    if( iClientStatus != NULL )
+        User::RequestComplete( iClientStatus, KErrCancel );
+    #ifdef _DEBUG
+        CMsgConnManager::WriteToLog( _L8( "  DoCancel() ends" ) );
+    #endif
+    }
+
+//  End of File  
+
--- a/package_definition.xml	Tue Aug 31 15:35:50 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<SystemDefinition schema="3.0.0">
- <package id="legacypresence" name="Legacy Presence Services" levels="engine fw ui">
-  <collection id="pressrv_plat" name="Legacy Presence Services Platform Interfaces" level="ui">
-   <component id="presence_list_api" name="Presence List API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/presence_list_api/presence_list_api.metaxml"/>
-    <unit bldFile="pressrv_plat/presence_list_api/group"/>
-   </component>
-   <component id="watcher_info_api" name="Watcher Info API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/watcher_info_api/watcher_info_api.metaxml"/>
-    <unit bldFile="pressrv_plat/watcher_info_api/group"/>
-   </component>
-   <component id="simple_documents_api" name="SIMPLE Documents API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/simple_documents_api/simple_documents_api.metaxml"/>
-    <unit bldFile="pressrv_plat/simple_documents_api/group"/>
-   </component>
-   <component id="authorization_api" name="Authorization API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/authorization_api/authorization_api.metaxml"/>
-    <unit bldFile="pressrv_plat/authorization_api/group"/>
-   </component>
-   <component id="xdm_protocol_plugin_api" name="XDM Protocol Plug-in API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/xdm_protocol_plugin_api/xdm_protocol_plugin_api.metaxml"/>
-    <unit bldFile="pressrv_plat/xdm_protocol_plugin_api/group"/>
-   </component>
-   <component id="watcher_api" name="Watcher API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/watcher_api/watcher_api.metaxml"/>
-    <unit bldFile="pressrv_plat/watcher_api/group"/>
-   </component>
-   <component id="xdm_api" name="XDM API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/xdm_api/xdm_api.metaxml"/>
-    <unit bldFile="pressrv_plat/xdm_api/group"/>
-   </component>
-   <component id="registration_api" name="Registration API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/registration_api/registration_api.metaxml"/>
-    <unit bldFile="pressrv_plat/registration_api/group"/>
-   </component>
-   <component id="publisher_api" name="Publisher API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/publisher_api/publisher_api.metaxml"/>
-    <unit bldFile="pressrv_plat/publisher_api/group"/>
-   </component>
-   <component id="messaging_connection_manager_api" name="Messaging Connection Manager API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/messaging_connection_manager_api/messaging_connection_manager_api.metaxml"/>
-    <unit bldFile="pressrv_plat/messaging_connection_manager_api/group"/>
-   </component>
-   <component id="xdm_settings_api" name="XDM Settings API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/xdm_settings_api/xdm_settings_api.metaxml"/>
-    <unit bldFile="pressrv_plat/xdm_settings_api/group"/>
-   </component>
-   <component id="simple_settings_api" name="SIMPLE Settings API" class="api" filter="s60">
-    <meta rel="Api" href="pressrv_plat/simple_settings_api/simple_settings_api.metaxml"/>
-    <unit bldFile="pressrv_plat/simple_settings_api/group"/>
-   </component>
-   <component id="simple_instant_msg_api" name="Simple Instant Msg API" class="api" filter="s60">
-    <unit bldFile="pressrv_plat/simple_instant_msg_api/group"/>
-   </component>
-  </collection>
- </package>
-</SystemDefinition>
--- a/package_map.xml	Tue Aug 31 15:35:50 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-<PackageMap root="sf" layer="mw"/>
Binary file presencefwsimpleadpt/Conf/presencefwsimpleadpt.confml has changed
Binary file presencefwsimpleadpt/Conf/presencefwsimpleadpt_10282C84.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/cenrep/backup_registration.xml	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration version="1.0">
+    <proxy_data_manager sid = "0x10282C84" />
+    <restore requires_reboot = "no"/>
+</backup_registration>
Binary file presencefwsimpleadpt/cenrep/keys_presencefwsimpleadpt.xls has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Build information file for SIP/Simple Protocol Plugin
+*
+*/
+
+
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+// CenRep config files
+../Conf/presencefwsimpleadpt.confml         			MW_LAYER_CONFML(presencefwsimpleadpt.confml)
+../Conf/presencefwsimpleadpt_10282C84.crml	         	MW_LAYER_CRML(presencefwsimpleadpt_10282c84.crml)
+
+
+// backup registry file
+../cenrep/backup_registration.xml   z:/private/10282c84/backup_registration.xml
+
+//ROM SIS stub
+presencefwsimpleadptstub.SIS    /epoc32/data/z/system/install/presencefwsimpleadptstub.sis
+
+// IBYs
+../rom/presencefwsimpleadpt.iby CORE_MW_LAYER_IBY_EXPORT_PATH(presencefwsimpleadpt.iby)
+
+PRJ_MMPFILES
+simpleplugin.mmp
+
+PRJ_TESTMMPFILES
+
+PRJ_TESTEXPORTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/group/make_StubSis.bat	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,18 @@
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:  SIMPLE Protocol implementation for Presence Framework
+rem
+
+if exist presencefwsimpleadptstub.sis (del presencefwsimpleadptstub.sis)
+makesis -s presencefwsimpleadptstub.pkg presencefwsimpleadptstub.sis
Binary file presencefwsimpleadpt/group/presencefwsimpleadptstub.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/group/presencefwsimpleadptstub.pkg	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,38 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:  SIMPLE Protocol implementation for Presence Framework
+;
+&EN
+
+;Header
+#{"PresenceFwSimpleAdpt"}, (0x10282C84), 1, 0, 0, TYPE=SA
+
+;Localised VendorID
+%{"Nokia"}
+
+;VendorID
+:"Nokia"
+
+;Supports Series 60 v 3.0
+;This line indicates that this installation is for the Series 60 platform v3.0
+;This line must appear _exactly_ as shown below in the sis file
+;If this line is missing or incorrect, the sis file will not be able
+;to be installed on Series 60 v3.0 platforms
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+;Files
+""-"z:\sys\bin\simpleplugin.dll"
+
+;resources
+""-"z:\resource\plugins\simpleplugin.rsc"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/group/prfwsimpleplugin.hrh	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,39 @@
+/*
+* 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:    resource definitions
+*
+*/
+
+
+
+#ifndef SIMPLEPLUGIN_RESOURCE_HRH
+#define SIMPLEPLUGIN_RESOURCE_HRH
+ 
+/**
+ * System wide UID 2:s for ECom plugin dlls.
+ */
+#define SIMPLEPLUGIN_DLL_UID_ECOM_PLUGIN        0x10009D8D
+ 
+/**
+ * SIMPLE protocol dll.
+ */
+#define SIMPLEPLUGIN_DLL_UID_SIMPLE_PROTOCOL    0x10282C84 
+ 
+/**
+ * Resource file compatible defintions for PrFw test protocols.
+ */
+#define SIMPLEPLUGIN_1_IMPLEMENTATION_UID       0x10282C86 
+ 
+#endif // SIMPLEPLUGIN_RESOURCE_HRH
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/group/simpleplugin.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Project definition file for SIP/Simple Protocol Plugin
+*
+*/
+
+
+
+// To get the MW_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+
+#include "prfwsimpleplugin.hrh"
+
+TARGET                  simpleplugin.dll
+TARGETTYPE              plugin
+UID                     SIMPLEPLUGIN_DLL_UID_ECOM_PLUGIN  SIMPLEPLUGIN_DLL_UID_SIMPLE_PROTOCOL
+CAPABILITY              CAP_ECOM_PLUGIN
+VENDORID                VID_DEFAULT
+
+// ECOM RESOURCE
+START RESOURCE  simpleplugin.rss
+TARGET          simpleplugin.rsc
+END
+
+
+SOURCEPATH      ../src
+SOURCE          simpleplugin.cpp
+SOURCE          simplepluginauthorization.cpp
+SOURCE          simplepluginconnection.cpp
+SOURCE          simpleplugindata.cpp
+SOURCE          simplepluginentitywatcher.cpp
+SOURCE          simpleplugingroups.cpp
+SOURCE          simplepluginpublisher.cpp
+SOURCE          simplepluginsession.cpp
+SOURCE          simplepluginvariation.cpp
+SOURCE          simplepluginwatcher.cpp
+SOURCE          simplepluginwinfo.cpp
+SOURCE          simplepluginxdmutils.cpp
+SOURCE          simpleplugindebugutils.cpp
+
+USERINCLUDE     .
+USERINCLUDE     ../inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+LIBRARY         euser.lib   // Base
+LIBRARY         ecom.lib
+LIBRARY         bafl.lib
+LIBRARY         xmlparser.lib
+LIBRARY         xmldom.lib
+LIBRARY         charconv.lib
+
+LIBRARY         simpleengine.lib
+LIBRARY         rlspresxdm.lib
+LIBRARY         xdmengine.lib
+LIBRARY         xdmsettingsapi.lib
+LIBRARY         presencesettingsapi.lib
+LIBRARY         centralrepository.lib
+
+DEBUGLIBRARY    flogger.lib // Sending trace data to log file
+DEBUGLIBRARY    efsrv.lib   // file server
+DEBUGLIBRARY    apparc.lib
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/group/simpleplugin.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    ECOM registery info for SIP/Simple Protocol Plugin
+*
+*/
+
+
+
+
+#include <ecom/registryinfov2.rh>
+#include <ximpprotocolpluginifids.hrh>
+#include "prfwsimpleplugin.hrh"
+
+// ---------------------------------------------------------------------------
+// ECOM registery info for Presence Framework ECOM hook
+// ---------------------------------------------------------------------------
+//
+RESOURCE REGISTRY_INFO theInfo 
+    {
+    resource_format_version = RESOURCE_FORMAT_VERSION_2;
+    dll_uid = SIMPLEPLUGIN_DLL_UID_SIMPLE_PROTOCOL;
+
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            // implemented interface
+            interface_uid = XIMP_ECOM_IF_UID_PROTOCOL_PLUGIN_BASE_INTERFACE;
+
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = SIMPLEPLUGIN_1_IMPLEMENTATION_UID;
+                    version_no         = 1;
+                    display_name       = "SIMPLE Protocol";
+                    default_data       = "SIMPLE";
+
+                    // Protocol capabilities: "<tag1>value<tag2>value..."
+                    //
+                    // <p>Provider
+                    // <f>Feature id
+                    // <s>Supported schema
+                    //
+                    // Example:
+                    // "<p>Nokia<f>feat/pres/foo<f>feat/pres/bar<s>sip"
+                    //
+                    opaque_data        = "<p>Nokia<f>feat/pres/pub<f>feat/pres/fetch<f>feat/pres/subs<s>sip";
+                    }
+                };
+            }
+        };
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/msimplepluginconnectionobs.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,135 @@
+/*
+* 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:    Presence FW SIMPLE plugin engine connection observer
+*
+*/
+
+
+
+
+#ifndef MSIMPLEPLUGINCONNECTIONOBSERVER_H
+#define MSIMPLEPLUGINCONNECTIONOBSERVER_H
+
+#include <e32std.h>
+
+class TXIMPRequestId;
+class MXIMPObjectFactory;
+class MPresenceObjectFactory;
+class MXIMPProtocolConnectionHost;
+
+class CSimplePluginWinfo;
+class MSimpleWinfo;
+class CSimplePluginXdmUtils;
+
+
+/**
+ *  MSimplePluginConnectionObs
+ *
+ *  SIMPLE engine connection
+ *
+ *  @lib simpleengine
+ *  @since s60 v5.0
+ */
+
+class MSimplePluginConnectionObs
+    {
+
+public:
+
+enum TReqType
+    {
+    /** undefined */
+    ENoReq = 0,
+    /** Connection initializing */
+    EOpenSess
+    };
+
+    /**
+     * Coplete the request
+     *
+     * @since S60 3.2
+     * @param aType request type
+     * @param aStatus status
+     */
+    virtual void CompleteReq( TReqType aType, TInt aStatus ) = 0;
+
+    /**
+     * Coplete the request
+     *
+     * @since S60 3.2
+     * @param aReqId PrFw request id
+     * @param aStatus status
+     */
+    virtual void CompleteReq( TXIMPRequestId aReqId, TInt aStatus ) = 0;
+    
+    /**
+     * Coplete the SIP watcher info request
+     *
+     * @since S60 3.2
+     * @param aReqId PrFw request id
+     * @param aStatus status
+     */
+    virtual void CompleteWinfoReq( TXIMPRequestId aReqId, TInt aStatus ) = 0;    
+
+    /**
+     * PrFw Object Factory accessor
+     * @since S60 3.2
+     * @return PrFw Object Factory
+     */
+    virtual MXIMPObjectFactory& ObjectFactory()=0;
+    
+    /**
+     * PrFw Object Factory accessor
+     * @since S60 3.2
+     * @return PrFw Object Factory
+     */
+    virtual MPresenceObjectFactory& PresenceObjectFactory()=0;
+
+    /**
+     * CSimplePluginWinfo accessor
+     * @since S60 3.2
+     * @return CSimplePluginWinfo, ownership is not transferred.
+     */
+    virtual CSimplePluginWinfo* WinfoHandlerL()=0;
+
+    /**
+     * CSimplePluginWinfoObserver is terminated
+     * @since S60 3.2
+     * @param aReason reason code
+     */
+    virtual void WinfoTerminatedL( TInt aReason )=0;
+
+    /**
+     * Watcher info subscription notification is received
+     * @aWinfo notification content
+     */
+    virtual void WinfoNotification( MSimpleWinfo& aWinfo ) = 0;
+
+    /**
+     * Access CSimplePluginXdmUtils
+     * @return CSimplePluginXdmUtils entity
+     */
+    virtual CSimplePluginXdmUtils* XdmUtilsL() = 0;
+
+    /**
+     * Access connection host
+     * @return MXIMPProtocolConnectionHost
+     */
+    virtual MXIMPProtocolConnectionHost* Host() = 0;    
+
+    };
+
+#endif
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/msimplepluginsettings.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Presence FW SIMPLE plugin engine settings
+*
+*/
+
+
+
+
+#ifndef MSIMPLEPLUGINCONNECTIONSETTINGS_H
+#define MSIMPLEPLUGINCONNECTIONSETTINGS_H
+
+#include <e32std.h>
+
+class CSimplePluginVariation;
+
+/**
+ *  MSimplePluginConnectionObs
+ *
+ *  SIMPLE engine connection
+ *
+ *  @lib simpleengine
+ *  @since s60 v5.0
+ */
+
+class MSimplePluginSettings
+    {
+
+public:
+
+    /**
+     * Current registered SIP entity
+     */
+    virtual TPtrC16 CurrentSipPresentity() = 0;
+
+    /**
+     * Current registered SIP entity
+     */
+    virtual TPtrC8 CurrentSipPresentity8() = 0;
+
+    /**
+     * Current domain syntax accessor
+     */
+    virtual TPtrC16 CurrentDomain() = 0;
+    
+    /**
+     * Variation
+     */
+    virtual CSimplePluginVariation& Variation() = 0; 
+
+    };
+
+#endif
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/msimpleplugintestobs.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* 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:    Presence FW SIMPLE plugin test suite
+*
+*/
+
+
+
+
+#ifndef MSIMPLEPLUGINTESTOBS_H
+#define MSIMPLEPLUGINTESTOBS_H
+
+#include <e32std.h>
+
+
+/**
+ * MSimplePluginTestObs
+ *
+ *  SIMPLE plugin tester observer for active object testing
+ *
+ *  @lib simpleplugin
+ *  @since s60 v5.0
+ */
+
+class MSimplePluginTestObs
+    {
+
+public:
+
+    /**
+     * Test callback in the begin of RunL or callback
+     */
+    virtual void TestCallbackInRunL( 
+        TInt aStatus, TInt aState, TInt aAuxInt, const TDesC& aAuxStr) = 0;        
+        
+    /**
+     * Test callback before new asynch request
+     */ 
+    virtual void TestCallbackAsynchL( 
+        TInt aStatus, TInt aState, TInt aAuxInt, const TDesC& aAuxStr) = 0;
+                   
+
+    };
+
+#endif
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/msimpleplugtestobs.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,51 @@
+/*
+* 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:    Presence FW SIMPLE plugin test suite
+*
+*/
+
+
+
+
+#ifndef MSIMPLEPLUGINTESTOBS_H
+#define MSIMPLEPLUGINTESTOBS_H
+
+#include <e32std.h>
+
+
+/**
+ * MSimplePluginTestObs
+ *
+ *  SIMPLE plugin tester observer for active object testing
+ *
+ *  @lib simpleplugin
+ *  @since S60 v3.2
+ */
+
+class MSimplePluginTestObs
+    {
+
+public:
+
+    /**
+     * Current registered SIP entity
+     */
+    virtual void TestCallback( 
+        TInt aStatus, TInt aState, TInt aAuxInt, const TDesC& aAuxStr) = 0;
+
+    };
+
+#endif
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/presencefwsimpleadptprivatecrkeys.h	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+#ifndef PRESENCEFWSIMPLEADPTPRIVATECRKEYS_H
+#define PRESENCEFWSIMPLEADPTPRIVATECRKEYS_H
+
+#include <e32std.h>
+
+const TUid KCRUIDPresencefwSimpleadptVariation = {0x10282C84};
+
+// Id for rule to grant all elements
+const TUint32 KPrFwSimpleGrantAllRuleName  = 0x00000001;
+// Id for rule to grant own data
+const TUint32 KPrFwSimpleGrantOwnRuleName  = 0x00000002;
+// Id for default rule
+const TUint32 KPrFwSimpleDefaultRuleName  = 0x00000003;
+// Id for block rule
+const TUint32 KPrFwSimpleBlockRuleName  = 0x00000004;
+// Default rule action, allow/confirm/block
+const TUint32 KPrFwSimpleDefaultRuleAction = 0x00000005;
+// Block rule action, block/polit
+const TUint32 KPrFwSimpleBlockRuleAction = 0x00000006;
+// Template for RLS service URI for a user group
+const TUint32 KPrFwSimpleRlsGroupUriTemplate = 0x00000007;
+// Top level for lists in shared XDM index document
+const TUint32 KPrFwSimpleSharedXdmTop = 0x00000008;
+// Name of the Shared XDM list for granted users
+const TUint32 KPrFwSimpleGrantListName = 0x00000009;
+
+#endif      // PRESENCEFWSIMPLEADPTPRIVATECRKEYS_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simpleplugin.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Simple Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#ifndef CSIMPLEPLUGIN_H
+#define CSIMPLEPLUGIN_H
+
+#include <e32std.h>
+
+#include <ximpbase.h>
+#include <ximpprotocolpluginbase.h>
+
+class MXIMPProtocolConnection;
+class MXIMPServiceInfo;
+class MXIMPClientContextInfo;
+class CSimplePluginConnection;
+
+
+/**
+ * CSimplePlugin
+ *
+ * Implementation of CPrFwProtocolPluginBase
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+class CSimplePlugin: public CXIMPProtocolPluginBase
+    {
+public:
+
+    static CSimplePlugin* NewL();
+    static CSimplePlugin* NewLC();
+
+    virtual ~CSimplePlugin();
+
+private:
+
+    CSimplePlugin();
+    void ConstructL();
+
+
+public:
+
+// from base class MXIMPProtocolPlugin
+
+    /**
+     * Defined in a base class
+     */
+    void PrimeHost( MXIMPProtocolPluginHost& aHost );
+
+    /**
+     * Defined in a base class
+     */
+    MXIMPProtocolConnection& AcquireConnectionL(
+        const MXIMPServiceInfo& aService,
+        const MXIMPContextClientInfo& aContextClient );
+
+    /**
+     * Defined in a base class
+     */
+    void ReleaseConnection(
+        MXIMPProtocolConnection& aConnection );
+
+// from base class MXIMPBase
+
+    /**
+     * Defined in a base class
+     */
+    TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps );
+
+    /**
+     * Defined in a base class
+     */
+    const TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps ) const;
+
+    /**
+     * Defined in a base class
+     */
+    TInt32 GetInterfaceId() const;
+
+
+private: // Data
+
+    /*
+     * Prime host
+     * Not own.
+     */
+    MXIMPProtocolPluginHost* iHost;
+
+    /**
+     * Simple plugin connections
+     */
+    RPointerArray< CSimplePluginConnection > iConnections;
+
+    };
+
+#endif // CSIMPLEPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simplepluginauthorization.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,450 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Simple Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#ifndef CSIMPLEPLUGINAUTHORIZATION_H
+#define CSIMPLEPLUGINAUTHORIZATION_H
+
+#include <e32std.h>
+
+#include <ximpbase.h>
+#include <protocolpresenceauthorization.h>
+
+#include "simpleplugincommon.h"
+#include "msimplepluginconnectionobs.h"
+
+class TXIMPRequestId;
+class MXIMPIdentity;
+class MPresenceInfoFilter;
+class MProtocolPresenceAuthorizationDataHost;
+
+class MSimpleWinfo;
+class CPresenceXDM;
+class CRLSXDM;
+class CXdmEngine;
+class CXdmDocument;
+
+
+/**
+ * CSimplePluginAuthorization
+ *
+ * Simple Engine Connection
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+NONSHARABLE_CLASS( CSimplePluginAuthorization ) : public CActive,
+    public MProtocolPresenceAuthorization
+    {
+public:
+
+
+    /**
+     * Current operation
+     */
+    enum TPluginAuthOperation
+        {
+        ENoOperation,
+        // XDM operations
+        EGrantPresenceForPresentity,
+        EGrantPresenceForPresentityGroupMembers,
+        EWithdrawFromPresentity,
+        EWithdrawFromGroupMembers,
+        EGrantForEveryone,
+        EWithdrawFromEveryone,
+        ESubscribeBlockList,
+        EUnsubscribeBlockList,
+        EBlockPresentity,
+        EUnblockPresentity,
+        // SIP and XDM  operations
+        ESubscribePresenceGrantRequestList,
+        EUnsubscribePresenceGrantRequestList        
+        };
+        
+    /**
+     * Current default rule
+     */
+    enum TPluginAuthDefRule
+        {
+        ERuleDef,
+        ERuleConfirm,
+        ERuleAllow
+        };     
+
+    /**
+     * Constructor.
+     * @param aObs callback for complete requests
+     */
+    static CSimplePluginAuthorization* NewL(
+        MSimplePluginConnectionObs& aObs );
+
+    virtual ~CSimplePluginAuthorization();
+
+    /**
+     * SetDataHost
+     *
+     * Set Data Host
+     *
+     * @lib ?library
+     * @since s60 v5.0
+     */
+    void SetDataHost( MProtocolPresenceAuthorizationDataHost& aDataHost );
+
+    /**
+     * WinfoTerminatedL
+     *
+     * SIMPLE Winfo watcher subscription is terminated
+     * @param aReason reason code
+     */
+    void WinfoTerminatedL( TInt aReason );
+
+    /**
+     * WINFO received from SIMPLE
+     * @param aWinfo WINFO
+     */
+    void WinfoNotificationL( MSimpleWinfo& aWinfo );
+    
+    /**
+     * This is to ensure that WINFO watchers responses are detected.
+     * @param aPrFwId framework request id to be completed
+     * @param sStatus error code
+     */
+    TBool HandleIfMine( TXIMPRequestId aPrFwId, TInt aStatus );
+
+
+private:
+
+    CSimplePluginAuthorization(
+        MSimplePluginConnectionObs& aObs );
+
+    void ConstructL( );
+
+
+// from base class MXIMPBase
+public:
+
+    /**
+     * Defined in a base class
+     */
+    TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps );
+
+    /**
+     * Defined in a base class
+     */
+    const TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps ) const;
+
+    /**
+     * Defined in a base class
+     */
+    TInt32 GetInterfaceId() const;
+
+
+// from base class MProtocolPresenceAuthorization
+
+    /**
+     * Defined in a base class
+     */
+    void DoSubscribePresenceGrantRequestListL(
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUnsubscribePresenceGrantRequestListL(
+                    TXIMPRequestId aReqId );
+
+// Granting presence information access to single presentities
+
+    /**
+     * Defined in a base class
+     */
+    void DoGrantPresenceForPresentityL(
+                    const MXIMPIdentity& aPresentityId,
+                    const MPresenceInfoFilter& aPif,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUpdatePresenceGrantPifForPresentityL(
+                    const MXIMPIdentity& aPresentityId,
+                    const MPresenceInfoFilter& aPif,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoWithdrawPresenceGrantFromPresentityL(
+                    const MXIMPIdentity& aPresentityId,
+                    TXIMPRequestId aReqId );
+
+// Granting presence information access to presentity group members
+
+    /**
+     * Defined in a base class
+     */
+    void DoGrantPresenceForPresentityGroupMembersL(
+                    const MXIMPIdentity& aGroupId,
+                    const MPresenceInfoFilter& aPif,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUpdatePresenceGrantPifForPresentityGroupMembersL(
+                    const MXIMPIdentity& aGroupId,
+                    const MPresenceInfoFilter& aPif,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoWithdrawPresenceGrantFromPresentityGroupMembersL(
+                    const MXIMPIdentity& aGroupId,
+                    TXIMPRequestId aReqId );
+
+// Granting presence information access to everyone
+
+    /**
+     * Defined in a base class
+     */
+    void DoGrantPresenceForEveryoneL(
+                    const MPresenceInfoFilter& aPif,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUpdatePresenceGrantPifForEveryoneL(
+                    const MPresenceInfoFilter& aPif,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoWithdrawPresenceGrantFromEveryoneL(
+                    TXIMPRequestId aReqId );
+
+// Subscribe presence block list
+
+    /**
+     * Defined in a base class
+     */
+    void DoSubscribePresenceBlockListL(
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUnsubscribePresenceBlockListL(
+                    TXIMPRequestId aReqId );
+
+// Blocking presence information access from single presentities
+
+    /**
+     * Defined in a base class
+     */
+    void DoBlockPresenceForPresentityL(
+                    const MXIMPIdentity& aPresentityId,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoCancelPresenceBlockFromPresentityL(
+                    const MXIMPIdentity& aPresentityId,
+                    TXIMPRequestId aReqId );
+
+
+
+protected:
+
+// from base class CActive
+
+    /**
+     * Defined in a base class
+     */
+    void RunL();
+
+    /**
+     * Defined in a base class
+     */
+    TInt RunError( TInt aError );
+
+    /**
+     * Defined in a base class
+     */
+    void DoCancel();
+
+private:
+
+    /**
+     * Save presentity id
+     * @param aPresentityId presentity id
+     */
+    void SetPresIdentityL(
+        const MXIMPIdentity& aPresentityId );
+
+    /**
+     * Calls MXIMPProtocolConnectionHost callback
+     * @param aStatus error status
+     */
+    void CompletePrFwReq( TInt aStatus );
+
+
+    /**
+     * Start XDM operation
+     */
+    void StartXdmOperationL(
+        const MXIMPIdentity& aId,
+        TXIMPRequestId aReqId,
+        TPluginAuthOperation aOperation );
+        
+    /**
+     * Start XDM operation. StartXdmOperationL calls this.
+     */
+    void DoStartXdmOperationL(
+        const MXIMPIdentity& aId,
+        TXIMPRequestId aReqId,
+        TPluginAuthOperation aOperation ); 
+        
+    /**
+     * Start XDM operation. HandleIfMine calls this.
+     */
+    void DoStartXdmOperationL(
+        TXIMPRequestId aReqId,
+        TPluginAuthOperation aOperation );                
+
+    /**
+     * Call CSimpleXdmUtils operation
+     */
+    void CallActualXdmOperationL();
+    
+    /**
+     * Copy data from aBlockers to aBlockedSouls
+     * @param aBlockers user ids
+     * @param aBlockedSouls user PrFwIdentities
+     *
+     */
+    void CopyBlockersToArrayL( 
+        CPtrCArray& aBlockers, RPointerArray<MXIMPIdentity>& aBlockedSouls ); 
+        
+    /**
+     * Handle full Winfo notification
+     * @param aWinfo WINFO
+     */    
+    void HandleFullWinfoNotificationL( MSimpleWinfo& aWinfo ); 
+    
+    /**
+     * Handle partial Winfo notification
+     * @param aWinfo WINFO     
+     */    
+    void HandlePartialWinfoNotificationL( MSimpleWinfo& aWinfo );
+    
+    /**
+     * Call HandlePresenceGrantRequestReceivedL
+     * @param aUserId user id
+     */
+    void CallHandlePresenceGrantRequestReceivedL( const TDesC& aUserId );
+
+    /**
+     * Call HandlePresenceGrantRequestObsoletedL(
+     * @param aUserId user id
+     */
+    void CallHandlePresenceGrantRequestObsoletedL( const TDesC& aUserId ); 
+    
+    /**
+     * Handle block list subscription routines
+     */
+    void HandleSubscribeBlockListL();        
+    
+
+private: // Data
+
+    /**
+     * PrFw Plugin connection observer
+     */
+    MSimplePluginConnectionObs& iConnObs;
+
+    /**
+     * PrFw Plugin Authorization Data Host
+     * Not own.
+     */
+    MProtocolPresenceAuthorizationDataHost* iDataHost;
+
+    /**
+     * XDM Settings id
+     */
+    TInt iSettingsId;
+
+    /**
+     * PrFW request id
+     */
+    TXIMPRequestId iPrFwId;
+
+    /**
+     * PrFW request id for own requests
+     */
+    TXIMPRequestId iPrFwIdOwn;
+
+    /**
+     * Simple Engine request id
+     */
+    TInt iSimpleId;
+
+    /**
+     * Current operation
+     */
+    TPluginAuthOperation iOperation;
+
+    /**
+     * Current presentity in progress
+     * Own.
+     */
+    HBufC16* iPresIdentity;
+
+    /**
+     * Whether XDM utility is initialized
+     */
+    TBool iXdmOk;
+
+    /**
+     * XDM Utils
+     * Not own.
+     */
+    CSimplePluginXdmUtils* iXdmUtils;
+    
+    /**
+     * Current default rule
+     */
+    TPluginAuthDefRule iDefRule; 
+    
+    /**
+     * Active WINFO subscription
+     */
+    TBool iWinfoSubs;   
+
+
+    };
+
+#endif // CSimplePluginAuthorization_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simpleplugincommon.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,168 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    C++ compatible definitions for PrFw SIMPLE protocol
+*
+*/
+
+
+
+#ifndef SIMPLEPLUGINCOMMON_H
+#define SIMPLEPLUGINCOMMON_H
+
+#include <e32std.h>
+#include <e32err.h>
+
+
+/**
+ * common definitions for SIMPLE Plugin
+ */
+
+// Simple Plugin specifications
+
+/** Nothing subscribed */
+const TUint KSimplePluginSubsNone = 0x00000000;
+/** Grant list subscribed */
+const TUint KSimplePluginSubsGrant = 0x00000001;
+
+/** max length of auth rule id in auth rules document */
+const TUint KSimplePluginMaxRuleLength = 100;
+
+/** the last general error code in e32err.h */
+const TInt KSimplePluginGeneralErrorLow = KErrCommsBreak;
+
+// OMA specifications
+
+/** OMA buddy list id */
+_LIT( KSimpleOMABuddyList, "oma_buddylist");
+/** OMA blocked list id */
+_LIT( KSimpleOMABlockedList, "oma_blockedcontacts");
+
+
+namespace NSimplePlugin
+    {
+    namespace NSimpleRls
+        {
+        _LIT( KOne,   "http://");   // 7
+        _LIT( KThree, "/resource-lists/users/"); // 22
+        _LIT( KFive,  "/index/~~/resource-lists/list%5b@name=%22");  // 41
+        _LIT( KSeven, "%22%5d");  // 6
+        const TInt totalSize = 76;
+        }
+    namespace NSimpleRlsBuddy
+        {
+        _LIT( KOne,   "http://"); // 7
+        _LIT( KThree, "/resource-lists/users/"); // 22
+        _LIT( KFive,  "/index/~~/resource-lists/list%5b@name=%22oma_buddylist%22%5d/list%5b@name=%22");  // 77
+        _LIT( KSeven, "%22%5d");  // 6
+        const TInt totalSize = 112;
+        }
+    namespace NSimpleOma
+        {
+        _LIT( KSimpleIndex,   "index");
+        _LIT( KSimpleResourceLists, "resource-lists");
+        _LIT( KSimpleList, "list");
+        _LIT( KSimpleName, "name");
+        _LIT( KSimpleDisplayName, "display-name");
+        _LIT( KSimpleEntry, "entry");
+        _LIT( KSimpleExternal, "external");  
+        _LIT( KSimpleAnchor, "anchor");               
+        _LIT( KSimplePerson, "person");      
+        _LIT( KSimpleBlock, "block");
+        _LIT( KSimplePoliteBlock, "polite-block");
+        _LIT( KSimpleConfirm, "confirm");
+        _LIT( KSimpleAllow, "allow");         
+        _LIT( KSimpleOpen, "open");
+        _LIT( KSimpleClosed, "closed");
+        _LIT( KSimpleUri, "uri"); 
+        _LIT8( KSimplePerson8, "person");                      
+        _LIT8( KSimpleWatcher8, "watcher");
+        _LIT8( KSimpleWatherInfo8, "watcherinfo");
+        _LIT8( KSimpleWatcherList8, "watcher-list");
+        _LIT8( KSimpleStatus8, "status");
+        _LIT8( KSimpleActive8, "active");
+        _LIT8( KSimpleEvent8, "event");
+        _LIT8( KSimplePending8, "pending");
+        _LIT8( KSimpleOverridingwillingness8, "overriding-willingness");
+        _LIT8( KSimpleBasic8, "basic");       
+        _LIT8( KSimpleStatusicon8, "status-icon");
+        _LIT8( KSimpleNote8, "note");
+        _LIT8( KSimpleSubscribe8, "subscribe");
+        _LIT8( KSimpleList8, "list");
+        _LIT8( KSimpleResource8, "resource");
+        _LIT8( KSimpleInstance8, "instance");
+        _LIT8( KSimpleState8, "state");
+        _LIT8( KSimpleTerminated8, "terminated");
+        _LIT8( KSimpleUri8, "uri");
+        _LIT8( KSimpleFull8, "full");
+        _LIT8( KSimpleFullState8, "fullState");
+        _LIT8( KSimpleTrue8, "true");
+        _LIT8( KSimpleId8, "id"); 
+        _LIT8( KSimpleTimestamp8, "timestamp");       
+        }
+    }
+
+
+// S60 specifications
+
+/** Presence XDM block rule id */
+_LIT( KSimpleXdmBlockRule, "blockall");
+/** Presence XDM grant rule id */
+_LIT( KSimpleXdmGrantRule, "allowall");
+/** Presence XDM grant rule id for own sbscribe*/
+_LIT( KSimpleXdmOwnGrantRule, "grantown");
+/** Presence XDM default rule id */
+_LIT( KSimpleXdmDefaultRule, "default");
+
+/** S60 Shared XDM list for granted entities */
+_LIT( KSimpleS60GrantedList, "oma_grantlist");
+
+/** S60 default RLS URI template */ 
+_LIT( KSimpleRlsGroupUriTemplate, "<GROUP_ID>_<USER_ID>@<DOMAIN>");
+_LIT16( KSimpleGroupTag, "<GROUP_ID>");
+_LIT16( KSimpleUserTag, "<USER_ID>"); 
+_LIT16( KSimpleDomainTag, "<DOMAIN>"); 
+
+/**
+ example:
+
+ <rls-services ...
+   <service uri="sip:my_friends_MY-IDENTITY@EXAMPLE.COM">
+      <resource-list>http://EXAMPLE.COM/resource-lists/users/
+        sip:USER@EXAMPLE.COM/index/~~/resource-lists/list%5b@name=%22oma_buddylist%22%5d/list%5b@name=%22my_friends%22%5d
+      </resource-list>
+      <packages>
+        <package>presence</package>
+      </packages>
+   </service>
+   <service uri="sip:my_colleques_MY-IDENTITY@EXAMPLE@EXAMPLE.COM">
+      <resource-list>http://EXAMPLE.COM/resource-lists/users/
+        sip:USER@EXAMPLE.COM/index/~~/resource-lists/list%5b@name=%22oma_buddylist%22%5d/list%5b@name=%22my_colleques%22%5d
+      </resource-list>
+      <packages>
+        <package>presence</package>
+      </packages>
+   </service>
+ </rls-services
+
+ */
+
+namespace NSimpleDocument
+    {
+    _LIT8( KSimpleAvatarContent8, "simpleavatar.s60.com" ); // notice: static now, supports only one
+    _LIT8( KSimpleAvatarCIDURI8, "cid:simpleavatar.s60.com" ); // notice: static now, supports only one
+    }
+
+
+#endif // SIMPLEPLUGINDEF_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simplepluginconnection.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,314 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    CSimplePluginConnection implementation.
+*
+*/
+
+
+
+
+#ifndef CSIMPLEPLUGINCONNECTION_H
+#define CSIMPLEPLUGINCONNECTION_H
+
+
+#include <ximpprotocolconnection.h>
+#include <protocolpresencefeatures.h>
+#include "msimplepluginconnectionobs.h"
+#include "msimplepluginsettings.h"
+
+class MXIMPObjectFactory;
+class MXIMPServiceInfo;
+class CSimplePluginAuthorization;
+class CSimplePluginSession;
+class CSimplePluginPublisher;
+class CSimplePluginWatcher;
+class CSimplePluginGroups;
+class CSimplePluginVariation;
+
+/**
+ * CSimplePluginConnection
+ *
+ * Implementation of MXIMPProtocolConnection
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+NONSHARABLE_CLASS(CSimplePluginConnection) : public CBase,
+    public MXIMPProtocolConnection,
+    public MProtocolPresenceFeatures,
+    public MSimplePluginConnectionObs,
+    public MSimplePluginSettings  
+    {
+
+public:
+
+    static CSimplePluginConnection* NewL(
+        const MXIMPServiceInfo& aServiceInfo,
+        const MXIMPContextClientInfo& aClientCtxInfo );
+
+    ~CSimplePluginConnection();
+
+private:
+
+    CSimplePluginConnection();
+
+
+    void ConstructL( const MXIMPServiceInfo& aServiceInfo,
+                     const MXIMPContextClientInfo& aClientCtxInfo );
+                     
+public:
+
+    /**
+     * Convert error code into PrFW errors
+     * @param aStatus error code [IN]
+     * @return harmonized error code
+     */
+    static TInt HarmonizeErrorCode( TInt aStatus );
+
+// from base class MXIMPBase
+public:
+
+    /**
+     * Defined in a base class
+     */
+    TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps );
+
+    /**
+     * Defined in a base class
+     */
+    const TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps ) const;
+
+    /**
+     * Defined in a base class
+     */
+    TInt32 GetInterfaceId() const;
+
+
+// from base class MXIMPProtocolConnection
+public:
+
+    /**
+     * Defined in a base class
+     */
+    void PrimeHost( MXIMPProtocolConnectionHost& aHost );
+
+    /**
+     * Defined in a base class
+     */
+    void OpenSessionL(
+        const MXIMPContextClientInfo& aContextClient,
+        TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void OpenSessionL(
+        const TInt& aSettingsId,
+        TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void CloseSession( 
+        const MXIMPContextClientInfo& aContextClient,
+        TXIMPRequestId aOpId );
+
+    /**
+     * Defined in a base class
+     */
+    void GetSupportedFeaturesL( CDesC8Array& aFeatures ) const;
+    
+    /**
+     * Defined in a base class
+     */    
+    MProtocolPresenceFeatures& ProtocolPresenceFeatures();
+    
+/*<branchInfo originator="gronoff" since="08-06-06" category="new_feature" error=”none”>
+<pf_5250_OFF_CYCLE_SW_INT>
+</branchInfo>*/
+// BRANCH 08-06-06 : gronoff
+    TAny* GetProtocolInterface( TInt aInterfaceId );
+// BRANCH_END 08-06-06 : gronoff        
+    
+    
+// from base class MProtocolPresenceFeatures
+
+    MProtocolPresenceWatching& PresenceWatching();
+
+
+    MProtocolPresencePublishing& PresencePublishing();
+
+
+    MProtocolPresentityGroups& PresentityGroups();
+
+
+    MProtocolPresenceAuthorization& PresenceAuthorization();  
+    
+    
+
+// from base class MSimplePluginConnectionObs
+
+    /**
+     * Defined in a base class
+     */
+    void CompleteReq( TReqType aType, TInt aStatus );
+
+    /**
+     * Defined in a base class
+     */
+    void CompleteReq( TXIMPRequestId aReqId, TInt aStatus );
+    
+    /**
+     * Defined in a base class
+     */
+    void CompleteWinfoReq( TXIMPRequestId aReqId, TInt aStatus );      
+
+    /**
+     * Defined in a base class
+     */
+    MXIMPObjectFactory& ObjectFactory();
+    
+    /**
+     * Defined in a base class
+     */    
+    MPresenceObjectFactory& PresenceObjectFactory();    
+
+    /**
+     * Defined in a base class
+     */
+    CSimplePluginWinfo* WinfoHandlerL();
+
+    /**
+     * Defined in a base class
+     */
+    void WinfoTerminatedL( TInt aReason );
+
+    /**
+     * Defined in a base class
+     */
+    void WinfoNotification( MSimpleWinfo& aWinfo );
+
+    /**
+     * Defined in a base class
+     */
+    CSimplePluginXdmUtils* XdmUtilsL();
+
+    /**
+     * Defined in a base class
+     */
+    MXIMPProtocolConnectionHost* Host();
+
+    
+// from base class MSimplePluginSettings 
+
+    /**
+     * Defined in a base class
+     */
+    TPtrC16 CurrentSipPresentity();
+
+    /**
+     * Defined in a base class
+     */
+    TPtrC8 CurrentSipPresentity8();
+
+    /**
+     * Defined in a base class
+     */
+    TPtrC16 CurrentDomain();
+    
+    /**
+     * Variation
+     */
+    CSimplePluginVariation& Variation();  
+    
+private:
+
+    
+
+private:    // data members
+
+    /**
+     * Host for connection.
+     * Not own.
+     */
+    MXIMPProtocolConnectionHost* iConnectionHost;
+
+    /**
+     * Simple Engine session
+     * Own.
+     */
+    CSimplePluginSession* iSession;
+
+    /**
+     * current request id
+     */
+    TXIMPRequestId iPrFwId;
+
+    /**
+     * MProtocolPresenceAuthorization implementation.
+     * Own.
+     */
+    CSimplePluginAuthorization* iAuth;
+
+    /**
+     * CSimplePluginWinfo
+     * Own.
+     */
+    CSimplePluginWinfo* iPluginWinfo;
+
+    /**
+     * CSimplePluginPublisher
+     * Own.
+     */
+    CSimplePluginPublisher* iPublisher;
+
+    /**
+     * CSimplePluginWatcher
+     * Own.
+     */
+    CSimplePluginWatcher* iWatcher;
+
+    /**
+     * CSimplePluginGroups
+     * Own.
+     */
+    CSimplePluginGroups* iGroups;
+
+    /**
+     * Current user SIP identity
+     * Own.
+     */
+    HBufC16* iSipPresentity;
+
+    /**
+     * XDM utils
+     * Own.
+     */
+    CSimplePluginXdmUtils* iXdmUtils;
+    
+    
+    /**
+     * Run time variation
+     * Own
+     */
+    CSimplePluginVariation* iVariation;    
+
+    };
+
+
+#endif // CSIMPLEPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simpleplugindata.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,178 @@
+/*
+* 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:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#ifndef C_SIMPLEPLUGINDATA_H
+#define C_SIMPLEPLUGINDATA_H
+
+
+// Includes
+#include <e32std.h>
+
+class MXIMPObjectFactory;
+class MXIMPIdentity;
+
+class MPresenceObjectFactory;
+class MSimpleDocument;
+class MPresenceInfo;
+class MSimplePresenceList;
+class MPresenceInfoFieldCollection;
+class MPersonPresenceInfo;
+class MPresenceInfoFieldValueEnum;
+class MSimpleElement;
+class MPresenceInfoFieldValueText;
+
+
+/**
+ *  CSimplePluginData
+ *
+ *  This provides data conversion between SIMPLE Engine and PrFw data strcutres.
+ *
+ *  @lib simplexmlutils
+ *  @since s60 v5.0
+ */
+NONSHARABLE_CLASS(CSimplePluginData) : public CBase
+    {
+public:
+
+    static CSimplePluginData* NewL(  );
+
+    static CSimplePluginData* NewLC();
+
+    virtual ~CSimplePluginData();
+
+    /**
+     * Convert to engine notification to MPresenceInfo
+     * @param aPresenceFactory PrFw Presence Factory
+     * @param aDocument notification
+     * @param aPrInfo PrFW info structure [out]
+     */
+    static void NotifyToPrInfoL(
+        MPresenceObjectFactory& aPresenceFactory,        
+        MSimpleDocument& aDocument,
+        MPresenceInfo& aPrInfo );
+
+    /**
+     * Convert to engine list notification to MPresenceInfo elements
+     * @param aFactory PrFw Factory
+     * @param aPresenceFactory PrFw Presence Factory
+     * @param aList notification
+     * @param aEntities array of PrFW info structure [out]
+     * @param aTerminated array of PrFW info structure for terminated  entities [out]
+     * @param aFullList ETrue if full state list [out]
+     */
+    static void NotifyListToPrInfoL(
+        MXIMPObjectFactory& aFactory,
+        MPresenceObjectFactory& aPresenceFactory,        
+        MSimplePresenceList& aList,
+        RPointerArray<MPresenceInfo>& aEntities,
+        RPointerArray<MXIMPIdentity>& aActives,
+        RPointerArray<MXIMPIdentity>& aTerminated,
+        TBool& aFullList );
+
+    /**
+     * Converts MPersonPresenceInfo to MSimpleDocument elements
+     * @param aInfo Person's presence info [in]
+     * @param aDocument PIDF document containing Person's presence info [out] 
+     * @param aSipId Person's SIP indetity
+     */
+    static void AddPrPersToSimpleDocumentL(
+        const MPersonPresenceInfo* aInfo,
+        MSimpleDocument& aDocument,
+        const TDesC8& aSipId );
+
+
+private:
+
+    CSimplePluginData();
+
+    void ConstructL( );
+
+    static void UserOverridingWillingnessToPrFwL(
+        MPresenceObjectFactory& aPresenceFactory,        
+        MSimpleElement* aElement,
+        MPresenceInfoFieldCollection& aCollection );
+
+    static void UserStatusIconToPrFwL(
+        MPresenceObjectFactory& aPresenceFactory,        
+        MSimpleElement* aElement,
+        MPresenceInfoFieldCollection& aCollection,
+        MSimpleDocument& aDocument );
+
+    static void UserNoteToPrFwL(
+        MPresenceObjectFactory& aPresenceFactory,        
+        MSimpleElement* aElement,
+        MPresenceInfoFieldCollection& aCollection );
+        
+    static void CollectAllPresentitiesL( 
+        RPointerArray<MPresenceInfo>& aEntities,
+        RPointerArray<MXIMPIdentity>& aActives,        
+        RPointerArray<MSimpleDocument>& aDocs,         
+        MXIMPObjectFactory& aFactory,
+        MPresenceObjectFactory& aPresenceFactory );
+        
+    /**
+     * Add terminated instances into array
+     * @param aTerminated list of PrFw indetities [OUT]
+     * @param aElems RLS meta data list entry elements
+     * @param aFactory PrFw Factory
+     */     
+    static void CollectTerminatedPresentitiesL( 
+        RPointerArray<MXIMPIdentity>& aTerminated,
+        RPointerArray<MSimpleElement>& aElems,    
+        MXIMPObjectFactory& aFactory );
+        
+    /** 
+     * Search the latest timestamp in the elements
+     * @param aElems element array     
+     * @retun position of the latest element in the element array. KErrNotFound if not found.    
+     */
+    static TInt SearchLatestTimestampL( 
+        RPointerArray<MSimpleElement>& aElems  );
+        
+    /**
+     * Add availability info into SIMPLE document
+     * @param aText new value [IN]
+     * @param aPersElem personal data to be modified [OUT]     
+     */    
+    static void AddPrPersAvailabilityToDocL( 
+        const MPresenceInfoFieldValueText* aText, 
+        MSimpleElement* aPersElem );
+    
+    /**
+     * Check if the current element is terminated instance.
+     * If yes then add the aUri into aTerminated
+     * @param aTerminated list of PrFw indetities [OUT]
+     * @param aElem current element
+     * @param aUri8 corresponding sip entity URI
+     * @param aFactory PrFw Factory
+     */
+    static void SearchTerminatedInstanceL( 
+            RPointerArray<MXIMPIdentity>& aTerminated,
+            MSimpleElement* aElem,    
+            const TDesC8* aUri8,
+            MXIMPObjectFactory& aFactory );
+        
+      
+
+};
+
+
+
+#endif // C_SIMPLEPLUGINDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simpleplugindebugutils.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    DEBUG utilities, for DEBUG version only
+*
+*/
+
+
+
+
+#ifndef SIMPLEPLUGINDEBUGUTILS_H
+#define SIMPLEPLUGINDEBUGUTILS_H
+
+#ifdef _DEBUG
+
+#include <e32std.h>
+#include <s32file.h>
+
+// FORWARD DECLARATION
+class RFs;
+class RFileReadStream;
+
+
+//**********************************
+// PluginLogger
+//**********************************
+NONSHARABLE_CLASS( PluginLogger )
+    {
+public:
+    static void Log(TRefByValue<const TDesC> aFmt,...);
+    };
+
+#endif // _DEBUG
+
+#endif      // simpledebugutils_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simpleplugindef.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    C++ compatible definitions for PrFw SIMPLE protocol
+*
+*/
+
+
+
+#ifndef SIMPLEPLUGINDEF_H
+#define SIMPLEPLUGINDEF_H
+
+#include <e32std.h>
+#include "prfwsimpleplugin.hrh" 
+
+
+/**
+ * C++ compatible definitions for PrFw SIMPLE protocol.
+ *
+ * This must be kept in-sync with definitions in
+ * "simpleplugin_resource.hrh"
+ */
+
+//PrFw primary test protocol
+const TInt K_SIMPLEPLUGIN_1_IMPLEMENTATION_UID  = SIMPLEPLUGIN_1_IMPLEMENTATION_UID;
+const TInt K_SIMPLEPLUGIN_1_VERSION_NO          = 1;
+_LIT( K_SIMPLEPLUGIN_1_DISPLAY_NAME,            "PrFw SIMPLE protocol" );
+_LIT( K_SIMPLEPLUGIN_1_DEFAULT_DATA,            "SIMPLE" );
+_LIT( K_SIMPLEPLUGIN_1_OPAQUE_DATA ,            " " );
+
+#endif // SIMPLEPLUGINDEF_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simplepluginentitywatcher.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,225 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Simple Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#ifndef CSIMPLEPLUGINENTITYWATCHER_H
+#define CSIMPLEPLUGINENTITYWATCHER_H
+
+#include <e32std.h>
+
+#include <protocolpresencewatching.h>
+
+#include <msimplewatcherobserver.h>
+
+#include "simpleplugincommon.h"
+#include "msimplepluginconnectionobs.h"
+
+
+class TXIMPRequestId;
+class MXIMPIdentity;
+class MXIMPProtocolConnectionHost;
+class MPersonPresenceInfo;
+
+class MSimpleDocument;
+class MSimpleWatcher;
+
+class CSimplePluginWatcher;
+
+/**
+ * CSimplePluginEntityWatcher
+ *
+ * Simple Engine Connection
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+NONSHARABLE_CLASS( CSimplePluginEntityWatcher ): public CBase,
+    public MSimpleWatcherObserver
+    {
+
+private:
+    /**
+     * Current operation
+     */
+    enum TPluginEntityWatcherOperation
+        {
+        EPluginIdle,
+        EPluginStop,
+        EPluginStart
+        };
+
+public:
+
+    /**
+     * Constructor.
+     * @param aObs callback for complete requests
+     * @param aConn Simple Engine connection
+     * @param aHost PrFw connection host
+     */
+    static CSimplePluginEntityWatcher* NewL(
+        MSimplePluginConnectionObs& aObs,
+        MSimpleConnection& aConn,
+        CSimplePluginWatcher& aWatcher );
+
+    virtual ~CSimplePluginEntityWatcher();
+
+
+    /**
+     * Access Request id
+     * @return PrFw request id
+     */
+    TXIMPRequestId PrFwRequestId();
+
+    /**
+     * Access Presentity id
+     * @return Presentity id
+     */
+    TPtrC8 PresentityId();
+
+    /**
+     * Start subscribe
+     * @param aPresentityId presentity id
+     */
+    void StartSubscribeL(
+        const TDesC8& aPresentityId );
+
+    /**
+     * Start subscribe
+     * @param aPresentityId presentity id
+     */
+    void StartSubscribeListL(
+        const TDesC8& aPresentityId );
+
+    /**
+     * Set simple name
+     * @param aPresentityId presentity id
+     */
+    void SetSimpleNameL(
+        const TDesC8& aPresentityId );
+
+    void StopSubscribeL( );
+
+private:
+
+    CSimplePluginEntityWatcher(
+        MSimplePluginConnectionObs& aObs,
+        MSimpleConnection& aConn,
+        CSimplePluginWatcher& aWatcher );
+
+    void ConstructL( );
+
+public:
+
+// from base class MSimpleWatcherObserver
+
+    /**
+     * Defined in a base class
+     */
+    void WatcherReqCompleteL( TInt aOpId, TInt aStatus );
+
+    /**
+     * Defined in a base class
+     */
+    void WatcherNotificationL( MSimpleDocument& aDocument );
+
+    /**
+     * Defined in a base class
+     */
+    void WatcherListNotificationL( MSimplePresenceList& aList );
+
+    /**
+     * Defined in a base class
+     */
+    void WatcherTerminatedL(
+        TInt aOpId, TInt aReason );
+
+private:
+
+    /**
+     * Calls caller active object
+     * @param aStatus error status
+     */
+    void CompleteClientReq( TInt aStatus );
+
+
+
+private: // Data
+
+    /**
+     * host class
+     */
+    CSimplePluginWatcher& iPluginWatcher;
+
+    /**
+     * PrFw Plugin connection observer
+     */
+    MSimplePluginConnectionObs& iConnObs;
+
+    /**
+     * SIMPLE engine connection
+     */
+    MSimpleConnection& iConnection;
+
+    /**
+     * SIMPLE engine watcher
+     * Own.
+     */
+    MSimpleWatcher* iWatcher;
+
+    /**
+     * PrFW request id
+     */
+    TXIMPRequestId iPrFwId;
+
+    /**
+     * Simple Engine request id
+     */
+    TInt iSimpleId;
+
+    /**
+     * client statutus.
+     * Not own.
+     */
+    TRequestStatus* iClientStatus;
+
+    /**
+     * Subscribed entity id
+     * Own.
+     */
+    HBufC8* iEntityId;
+
+    /**
+     * Subscribed entity id, pure group name
+     * Own.
+     */
+    HBufC8* iSimpleEntityId;
+
+    /**
+     * current pending operation
+     */
+    TPluginEntityWatcherOperation iOperation;
+
+    /**
+     * Whether subscription of list is pending
+     */
+    TBool iListSubsActive;
+
+    };
+
+#endif // CSimplePluginEntityWatcher_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simpleplugingroups.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,441 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Simple Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#ifndef CSIMPLEPLUGINGROUPS_H
+#define CSIMPLEPLUGINGROUPS_H
+
+#include <e32std.h>
+
+#include <ximpbase.h>
+#include <protocolpresentitygroups.h>
+
+#include <mrlspresxdmasynchandler.h>
+
+#include "simpleplugincommon.h"
+#include "msimplepluginconnectionobs.h"
+
+
+class TXIMPRequestId;
+class MXIMPIdentity;
+class MPresenceInfoFilter;
+class MProtocolPresentityGroupsDataHost;
+class MXIMPObjectCollection;
+
+class MSimpleWinfo;
+class CPresenceXDM;
+class CRLSXDM;
+class CXdmEngine;
+class CXdmDocument;
+
+
+/**
+ * CSimplePluginGroups
+ *
+ * Simple Engine Connection
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+NONSHARABLE_CLASS( CSimplePluginGroups ) : public CActive,
+    public MProtocolPresentityGroups
+    {
+private:
+
+
+    /**
+     * Current operation
+     */
+    enum TPluginGroupsOperation
+        {
+        ENoOperation,
+        ECreatePresentityGroup,
+        EDeletePresentityGroup,
+        EAddPresentityGroupMember,
+        ERemovePresentityGroupMember,
+        EGetListOfLists,
+        EGetListContent
+        };
+
+    /**
+     * Current actibe object state
+     */
+    enum TPluginGroupsState
+        {
+        EPluginIdle,
+        EPluginInitXdm,
+        EPluginFetchRls,
+        EPluginAddGroupMember,
+        EPluginRemoveGroupMember,
+        EPluginCommitRls,
+        EPluginCommitXdm,
+        ERemoveGroupFromGranted        
+        };
+
+public:
+    /**
+     * Constructor.
+     * @param aObs callback for complete requests
+     */
+    static CSimplePluginGroups* NewL(
+        MSimplePluginConnectionObs& aObs );
+
+    virtual ~CSimplePluginGroups();
+
+
+
+private:
+
+    CSimplePluginGroups(
+        MSimplePluginConnectionObs& aObs );
+
+    void ConstructL( );
+
+
+// from base class MXIMPBase
+public:
+
+    /**
+     * Defined in a base class
+     */
+    TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps );
+
+    /**
+     * Defined in a base class
+     */
+    const TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps ) const;
+
+    /**
+     * Defined in a base class
+     */
+    TInt32 GetInterfaceId() const;
+
+
+// from base class MProtocolPresentityGroups
+
+    /**
+     * Defined in a base class
+     */
+    void DoSubscribePresentityGroupListL(
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUnsubscribePresentityGroupListL(
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoCreatePresentityGroupL(
+                    const MXIMPIdentity& aGroupId,
+                    const TDesC16& aDisplayName,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoDeletePresentityGroupL(
+                    const MXIMPIdentity& aGroupId,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUpdatePresentityGroupDisplayNameL(
+                    const MXIMPIdentity& aGroupId,
+                    const TDesC16& aDisplayName,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoSubscribePresentityGroupContentL(
+                    const MXIMPIdentity& aGroupId,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUnsubscribePresentityGroupContentL(
+                    const MXIMPIdentity& aGroupId,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoAddPresentityGroupMemberL(
+                    const MXIMPIdentity& aGroupId,
+                    const MXIMPIdentity& aMemberId,
+                    const TDesC16& aMemberDisplayName,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoRemovePresentityGroupMemberL(
+                    const MXIMPIdentity& aGroupId,
+                    const MXIMPIdentity& aMemberId,
+                    TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUpdatePresentityGroupMemberDisplayNameL(
+                    const MXIMPIdentity& aGroupId,
+                    const MXIMPIdentity& aMemberId,
+                    const TDesC16& aMemberDisplayName,
+                    TXIMPRequestId aReqId );
+
+protected:
+
+// from base class CActive
+
+    /**
+     * Defined in a base class
+     */
+    void RunL();
+
+    /**
+     * Defined in a base class
+     */
+    TInt RunError( TInt aError );
+
+    /**
+     * Defined in a base class
+     */
+    void DoCancel();
+
+private:
+
+    /**
+     * Save presentity id
+     * @param aPresentityId presentity id
+     */
+    void SetPresIdentityL(
+        const MXIMPIdentity& aPresentityId );
+
+    /**
+     * Save presentity id
+     * @param aPresentityId presentity id
+     */
+    void SetPresIdentity2L(
+        const MXIMPIdentity& aPresentityId );
+
+    /**
+     * Calls MXIMPProtocolConnectionHost callback
+     * @param aStatus error status
+     */
+    void CompletePrFwReq( TInt aStatus );
+
+    /**
+     * Start XDM operation
+     */
+    void StartXdmOperationL(
+        TXIMPRequestId aReqId,
+        TPluginGroupsOperation aOperation );
+
+    /**
+     * Start XDM operation
+     */
+    void StartXdmOperationL(
+        const MXIMPIdentity& aId,
+        TXIMPRequestId aReqId,
+        TPluginGroupsOperation aOperation );
+
+    /**
+     * Start XDM operation
+     */
+    void StartXdmOperationL(
+        const MXIMPIdentity& aId,
+        const TDesC16& aDisplayName,
+        TXIMPRequestId aReqId,
+        TPluginGroupsOperation aOperation );
+
+    /**
+     * Start XDM operation
+     */
+    void StartXdmOperationL(
+        const MXIMPIdentity& aId,
+        const MXIMPIdentity& aMemberId,
+        TXIMPRequestId aReqId,
+        TPluginGroupsOperation aOperation );
+
+    /**
+     * Start XDM operation
+     */
+    void StartXdmOperationL(
+        const MXIMPIdentity& aId,
+        const MXIMPIdentity& aMemberId,
+        const TDesC16& aDisplayName,
+        TXIMPRequestId aReqId,
+        TPluginGroupsOperation aOperation );              
+
+    /**
+     * Start XDM operation
+     */
+    void StartXdmOperationL();
+    
+    /**
+     * Start XDM operation, StartXdmOperationL calls this.
+     */
+    void DoStartXdmOperationL( );      
+
+    /**
+     * Call CSimpleXdmUtils operation
+     */
+    void CallActualXdmOperationL();
+
+    /**
+     * Get list of the entity lists
+     */
+    void GetListOfListsL();
+
+    /**
+     * Get content of the entity list
+     */
+    void GetListContentL();
+
+    /**
+     * Yields to active scheduler and runs next RunL loop
+     * @param aStatus error status
+     */
+    void CompleteMe( TInt aStatus );
+    
+    /**
+     * Copy data from aLists and from aNames into aCollection
+     * @param aNames group names [IN]
+     * @param aNames group display names [IN]
+     * @param aCollection collection of MPresentityGroupInfo [OUT]
+     */         
+    void CopyGroupArraysToCollectionL( 
+        CDesCArrayFlat& aLists, CDesCArrayFlat& aNames, MXIMPObjectCollection& aCollection );  
+        
+    /**
+     * Copy data from aIds and from aNames into aCollection
+     * @param aNames group member names [IN]
+     * @param aNames group member display names [IN]
+     * @param aCollection collection of MPresentityGroupMemberInfo [OUT]
+     */        
+    void CopyGroupMembersToCollectionL( 
+        CPtrCArray& aIds, CPtrCArray& aNames, MXIMPObjectCollection& aCollection);
+        
+        
+    /**
+     * Add presentity group
+     * @param aGroupId group id
+     * @param adispName display name
+     */        
+    void HandleCreatePresentityGroupL( 
+        const TDesC& aGroupId, const TDesC& aDispName );
+            
+    /**
+     * Delete presentity group
+     * @param aGroupId group id
+     */    
+    void HandleDeletePresentityGroupL( const TDesC& aGroupId );
+    
+    /**
+     * Add presentity group member
+     */    
+    void HandleAddPresentityGroupMemberL();
+    
+    /**
+     * Remove group member
+     */
+    void HandleRemovePresentityGroupMemberL();
+
+
+
+private: // Data
+
+    /**
+     * PrFw Plugin connection observer
+     */
+    MSimplePluginConnectionObs& iConnObs;
+
+    /**
+     * XDM Settings id
+     */
+    TInt iSettingsId;
+
+    /**
+     * PrFW request id
+     */
+    TXIMPRequestId iPrFwId;
+
+    /**
+     * PrFW request id for own requests
+     */
+    TXIMPRequestId iPrFwIdOwn;
+
+    /**
+     * Simple Engine request id
+     */
+    TInt iSimpleId;
+
+    /**
+     * Subscribed items. Bitmask.
+     */
+    TUint iSubscribed;
+
+    /**
+     * Current operation
+     */
+    TPluginGroupsOperation iOperation;
+
+    /**
+     * Current presentity in progress
+     * Own.
+     */
+    HBufC16* iPresIdentity;
+
+    /**
+     * Current presentity in progress
+     * Own.
+     */
+    HBufC16* iPresIdentity2;
+
+    /**
+     * XDM Utils
+     * Not own.
+     */
+    CSimplePluginXdmUtils* iXdmUtils;
+
+    /**
+     * Display name
+     * Own
+     */
+    HBufC* iDisplayName;
+
+    /**
+     * Active object state
+     */
+    TPluginGroupsState iState;
+
+    TBool iCompleted;
+
+    };
+
+#endif // CSimplePluginGroups_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simplepluginpublisher.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,450 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Simple Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#ifndef CSIMPLEPLUGINPUBLISHER_H
+#define CSIMPLEPLUGINPUBLISHER_H
+
+#include <e32std.h>
+
+#include <ximpbase.h>
+#include <protocolpresencepublishing.h>
+
+#include <msimplepublishobserver.h>
+#include <msimplewatcherobserver.h>
+
+#include "simpleplugincommon.h"
+#include "msimplepluginconnectionobs.h"
+#include "msimplepluginsettings.h"
+
+class TXIMPRequestId;
+class MXIMPIdentity;
+class MXIMPProtocolConnectionHost;
+
+class MPersonPresenceInfo;
+class MServicePresenceInfo;
+class MDevicePresenceInfo;
+
+class MSimplePublisher;
+class MSimpleDocument;
+class MSimpleWinfo;
+class MSimpleWatcher;
+class MSimpleElement;
+
+
+/**
+ * CSimplePluginWatcherInfo
+ *
+ * watcher info.
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+NONSHARABLE_CLASS( CSimplePluginWatcherInfo ): public CBase
+    {
+public:
+
+    /**
+     * Constructor.
+     * @param aId watcher id
+     * @param aSipId watcher SIP identity
+     */
+    static CSimplePluginWatcherInfo* NewL(
+        const TDesC8& aId,
+        const TDesC& aSipId );
+
+    virtual ~CSimplePluginWatcherInfo();
+            
+    /**
+     * Destructor
+     */
+    void Destroy();
+    
+    /** 
+     * Match to given info
+     * @param aId watcher id
+     * @param aSipId watcher SIP identity     
+     * @return ETrue if current entity matches to the parameters
+     */
+    TBool Match( const TDesC8& aId,
+        const TDesC& aSipId ); 
+        
+    TPtrC SipId();    
+    
+    inline static TInt LinkOffset(); 
+    
+private:
+
+    CSimplePluginWatcherInfo( );
+
+    /** 
+     * Constructor
+     * @param aId watcher id
+     * @param aSipId watcher SIP identity     
+     */
+    void ConstructL( 
+        const TDesC8& aId,
+        const TDesC& aSipId ); 
+   
+public: // data        
+
+    TDblQueLink iLink;
+    
+private: // data
+    
+    HBufC8* iId;
+    HBufC* iSipId;
+
+    };
+
+/**
+ * CSimplePluginPublisher
+ *
+ * publisher.
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+NONSHARABLE_CLASS( CSimplePluginPublisher ): public CActive,
+    public MSimplePublishObserver,
+    public MSimpleWatcherObserver,
+    public MProtocolPresencePublishing
+    {
+public:
+
+    /**
+     * Current operation
+     */
+    enum TPluginPublishOperation
+        {
+        ENoOperation,
+        EPublishOwn,
+        ESubscribeOwn,
+        EUnsubscribeOwn,
+        ESubscribeWinfo,
+        EUnsubscribeWinfo
+        };
+
+    /**
+     * Constructor.
+     * @param aConnSetts current settings
+     * @param aObs callback for complete requests
+     * @param aConn Simple Engine connection
+     */
+    static CSimplePluginPublisher* NewL(
+        MSimplePluginSettings& aConnSetts,
+        MSimplePluginConnectionObs& aObs,
+        MSimpleConnection& aConn );
+
+    virtual ~CSimplePluginPublisher();
+
+    /**
+     * WinfoTerminatedL
+     *
+     * SIMPLE Winfo watcher sunscription is terminated
+     * @param aReason reason code
+     */
+     void WinfoTerminatedL( TInt aReason );
+
+     /**
+      * WINFO received from SIMPLE
+      * @param aWinfo WINFO
+      */
+     void WinfoNotificationL( MSimpleWinfo& aWinfo );
+
+private:
+
+    CSimplePluginPublisher(
+        MSimplePluginSettings& aConnSetts,    
+        MSimplePluginConnectionObs& aObs,
+        MSimpleConnection& aConn );
+
+    void ConstructL( );
+
+
+public:
+
+// from base class MSimplePublishObserver
+
+    /**
+     * Defined in a base class
+     */
+    void PublishReqCompleteL( TInt aOpid, TInt aStatus);
+
+    /**
+     * Defined in a base class
+     */
+    void PublishTerminatedL( TInt aOpid );
+
+// from base class MSimpleWatcherObserver
+
+    /**
+     * Defined in a base class
+     */
+    void WatcherReqCompleteL( TInt aOpId, TInt aStatus );
+
+    /**
+     * Defined in a base class
+     */
+    void WatcherNotificationL( MSimpleDocument& aDocument );
+
+    /**
+     * Defined in a base class
+     */
+    void WatcherListNotificationL( MSimplePresenceList& aList );
+
+    /**
+     * Defined in a base class
+     */
+    void WatcherTerminatedL(
+        TInt aOpId, TInt aReason );
+
+
+// from base class MXIMPBase
+public:
+
+    /**
+     * Defined in a base class
+     */
+    TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps );
+
+    /**
+     * Defined in a base class
+     */
+    const TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps ) const;
+
+    /**
+     * Defined in a base class
+     */
+    TInt32 GetInterfaceId() const;
+
+
+// from base class MProtocolPresencePublishing
+public:
+
+    /**
+     * Defined in a base class
+     */
+    void DoPublishOwnPresenceL(
+        const MPresenceInfo& aOwnPresence,
+        TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoSubscribeOwnPresenceL(
+        const MPresenceInfoFilter& aPif,
+        TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUpdateOwnPresenceSubscriptionPifL(
+        const MPresenceInfoFilter& aPif,
+        TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUnsubscribeOwnPresenceL(
+        TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoSubscribePresenceWatcherListL(
+        TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUnsubscribePresenceWatcherListL(
+        TXIMPRequestId aReqId );
+
+
+protected:
+
+// from base class CActive
+
+    /**
+     * Defined in a base class
+     */
+    void RunL();
+
+    /**
+     * Defined in a base class
+     */
+    TInt RunError( TInt aError );
+
+    /**
+     * Defined in a base class
+     */
+    void DoCancel();
+
+private:
+
+
+    /**
+     * Calls MXIMPProtocolConnectionHost callback
+     * @param aStatus error status
+     */
+    void CompletePrFwReq( TInt aStatus );
+
+    /**
+     * Initialize a document
+     */
+    void InitializeSimpleDocumentL( );
+
+    /**
+     * Add person information to the document.
+     * @param aPersInfo personal information
+     */
+    void AddSimpleDocumentPersL(
+        const MPersonPresenceInfo* aInfo );
+
+    void AddSimpleDocumentServiceL(
+        const MServicePresenceInfo& aInfo );
+
+    void AddSimpleDocumentDeviceL(
+        const MDevicePresenceInfo& aInfo );
+
+    /**
+     * Make a publish request
+     */
+    void MakePublishReqL();
+
+    /**
+     * Start XDM initialization
+     */
+    void StartXdmOperationL( TXIMPRequestId aReqId );
+    
+    /**
+     * Start XDM initialization. StartXdmOperationL calls this.
+     */
+    void DoStartXdmOperationL( TXIMPRequestId aReqId );    
+    
+    /**
+     * Delete watcher information
+     */
+    void DeleteWatchers();  
+    
+    void AddWatcherIfNotExistsL( const TDesC8& aId, const TDesC& aSipId );
+        
+    void RemoveWatcherIfExistsL( const TDesC8& aId, const TDesC& aSipId ); 
+    
+    CDesCArrayFlat* MakeCurrentWatcherListLC();  
+    
+    
+    /**
+     * Update private data member of active watchers list
+     * @param aElems SIMPLE elements [IN]
+     */
+    void UpdateActiveWatchersListL( 
+        RPointerArray<MSimpleElement>& aElems );     
+
+
+private: // Data
+
+    /**
+     * PrFw Plugin connection observer
+     */
+    MSimplePluginConnectionObs& iConnObs;
+    
+    /**
+     * Current settings
+     */
+    MSimplePluginSettings& iConnSets;
+
+    /**
+     * SIMPLE engine connection
+     */
+    MSimpleConnection& iConnection;
+
+    /**
+     * SIMPLE engine publisher
+     * Own.
+     */
+    MSimplePublisher* iPublisher;
+
+    /**
+     * SIMPLE engine watcher
+     * Own.
+     */
+    MSimpleWatcher* iWatcher;
+
+    /**
+     * PrFW request id
+     */
+    TXIMPRequestId iPrFwId;
+
+    /**
+     * Simple Engine request id
+     */
+    TInt iSimpleId;
+
+    /**
+     * Subscribed winfo
+     */
+    TBool iSubscribed;
+
+    /**
+     * Subscribed own data
+     */
+    TBool iSubscribedOwn;
+
+    /**
+     * Published own data
+     */
+    TBool iPublished;
+
+    /**
+     * Current operation
+     */
+    TPluginPublishOperation iOperation;
+
+    /**
+     * Simple publish document
+     * Own.
+     */
+    MSimpleDocument* iDocument;
+
+    /**
+     * XDM Utils
+     * Not own.
+     */
+    CSimplePluginXdmUtils* iXdmUtils;
+    
+    /**
+     * WINFO watchers
+     * Own.
+     */
+    TDblQue<CSimplePluginWatcherInfo> iWatcherList;
+
+    };
+    
+    TInt CSimplePluginWatcherInfo::LinkOffset()
+        {
+        return _FOFF(CSimplePluginWatcherInfo, iLink);
+        }     
+
+#endif // CSimplePluginPublisher_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simplepluginsession.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,173 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Simple Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#ifndef CSIMPLEPLUGINSESSION_H
+#define CSIMPLEPLUGINSESSION_H
+
+
+#include <e32std.h>
+#include <msimpleconnectionobserver.h>
+#include "msimplepluginconnectionobs.h"
+
+class MXIMPContextClientInfo;
+class MXIMPProtocolConnection;
+class MXIMPServiceInfo;
+
+
+class MSimpleConnection;
+
+/**
+ * CSimplePluginSession
+ *
+ * Simple Engine Connection
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+NONSHARABLE_CLASS( CSimplePluginSession ) : public CBase,
+                             public MSimpleConnectionObserver
+    {
+public:
+
+    static CSimplePluginSession* NewL(
+        const MXIMPServiceInfo& aService,
+        MSimplePluginConnectionObs& aObs );
+
+    virtual ~CSimplePluginSession();
+
+    /**
+     * OpenSessionL
+     *
+     * Opens the SIP connection (registers when needed)
+     * 
+     */
+    void OpenSessionL();
+    
+    /**
+     * OpenSessionL
+     *
+     * Opens the SIP connection (registers when needed)
+     * @param aSettingsId settings id
+     *
+     */
+    void OpenSessionL( TInt aSettingsId );    
+
+    /**
+     * MSimpleConnection accessor
+     * @return MSImpleConnection instance
+     */
+    MSimpleConnection* SimpleConnection();
+
+    /**
+     * XDMSettings accessor
+     * @return XDM Settings ID
+     */
+    TInt XdmSettingsId();
+
+    /**
+     * Current registered SIP entity
+     */
+    TPtrC8 CurrentSipPresentity();
+
+    /**
+     * Domain syntax for current settings
+     */
+    TPtrC16 CurrentDomain();
+
+private:
+
+    CSimplePluginSession( MSimplePluginConnectionObs& aObs );
+
+    void ConstructL(
+        const MXIMPServiceInfo& aService );
+
+
+public:
+
+// from base class MSimpleConnectionObserver
+
+    /**
+     * Defined in a base class
+     */
+    void ConnectionStatusL( MSimpleConnection::TSimpleState aState );
+
+    /**
+     * Defined in a base class
+     */
+    void RequestCompleteL( TInt aOpId, TInt aStatus );
+
+// from base class CActive
+
+protected:
+
+
+private: // Data
+
+    /**
+     * PrFw Plugin connection observer
+     */
+    MSimplePluginConnectionObs& iObs;
+
+    /**
+     * Simple Engine connection.
+     * Own.
+     */
+    MSimpleConnection* iConnection;
+
+    /**
+     * Current Simple Engine operation id
+     */
+    TInt iOpId;
+
+    /**
+     * IAP Id
+     */
+    TInt32 iIap;
+
+    /**
+     * XDM Settings id
+     */
+    TInt iXdmSetting;
+
+    /**
+     * Request type
+     */
+    MSimplePluginConnectionObs::TReqType iType;
+
+    /**
+     * Current User ID, User's SIP identity
+     * Own.
+     */
+    HBufC8* iUserId8;
+
+    /**
+     * Domain syntax for current settings
+     * Own,
+     */
+    HBufC16* iDomain;
+    
+    /**
+     * Whether conncted to network
+     */
+    TBool iConnected;
+
+    };
+
+#endif // CSIMPLEPLUGINSESSION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simplepluginvariation.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,201 @@
+/*
+* 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:    CSimplePluginVariation implementation.
+*
+*/
+
+
+
+
+#ifndef CSIMPLEPLUGINVARIATION_H
+#define CSIMPLEPLUGINVARIATION_H
+
+#include <e32std.h>
+
+class CRepository;
+
+/**
+ * CSimplePluginVariation
+ *
+ * Implementation of MXIMPProtocolConnection
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+NONSHARABLE_CLASS(CSimplePluginVariation) : public CBase
+    {
+
+public:
+
+    enum TSimplePluginAuthRule
+        {
+        ERuleNone,
+        ERulePoliteBlock,
+        ERuleBlock,
+        ERuleConfirm,
+        ERuleAllow
+        };
+
+    static CSimplePluginVariation* NewL( );
+
+    ~CSimplePluginVariation();
+
+private:
+
+    CSimplePluginVariation();
+
+
+    void ConstructL( );
+
+
+public:
+
+    /**
+     * Get data from CenRep
+     */
+    void InitL();
+
+    /**
+     * Grant rule name
+     * @return rule name
+     */
+    TPtrC GrantRuleName(); 
+    
+    /**
+     * Grant own rule name
+     * @return rule name
+     */
+    TPtrC GrantOwnRuleName();
+    
+    /**
+     * Default rule name
+     * @return rule name
+     */
+    TPtrC DefaultRuleName();
+    
+    /**
+     * Block rule name
+     * @return rule name
+     */
+    TPtrC BlockRuleName();  
+    
+    /**
+     * Default rule action
+     * @return action
+     */
+    TSimplePluginAuthRule DefaultRuleAction();
+    
+    /**
+     * Block rule action
+     * @return action
+     */
+    TSimplePluginAuthRule BlockRuleAction();
+    
+    /**
+     * RlsGroupUriTemplate
+     * @return RlsGroupUriTemplate
+     */
+    TPtrC RlsGroupUriTemplate();
+    
+    /**
+     * SharedXdmTop
+     * @return SharedXdmTop
+     */
+    TPtrC SharedXdmTop();
+    
+    /**
+     * GrantListName
+     * @return GrantListName
+     */
+    TPtrC GrantListName();  
+    
+private:
+
+    void InitGrantRuleNameL( CRepository* aRepository );
+    
+    void InitGrantOwnRuleNameL( CRepository* aRepository );
+    
+    void InitDefaultRuleNameL( CRepository* aRepository );
+    
+    void InitBlockRuleNameL( CRepository* aRepository );    
+    
+    void InitDefaultRuleActionL( CRepository* aRepository );
+    
+    void InitBlockRuleActionL( CRepository* aRepository );
+    
+    void InitRlsGroupUriTemplateL( CRepository* aRepository );
+    
+    void InitSharedXdmTopL( CRepository* aRepository );  
+    
+    void InitGrantListNameL( CRepository* aRepository );
+
+
+private:    // data members
+
+    /**
+     * Id for rule to grant all elements
+     * Own
+     */
+    HBufC* iGrantAllRuleName;
+
+    /**
+     * Id for rule to grant own data
+     * Own
+     */
+    HBufC* iGrantOwnRuleName;
+
+    /**
+     * Id for default rule
+     * Own
+     */
+    HBufC* iDefaultRuleName;
+
+    /**
+     * Id for block rule
+     * Own
+     */
+    HBufC* iBlockRuleName;
+
+    /**
+     * Default rule action, allow/confirm/block/polite-block
+     */
+    TSimplePluginAuthRule iDefaultRuleAction;
+
+    /**
+     * Block rule action, block/polite-block
+     */
+    TSimplePluginAuthRule iBlockRuleAction;
+
+    /**
+     * Template for RLS service URI for a user group
+     * Own
+     */
+     HBufC* iRlsGroupUriTemplate;
+
+    /**
+     * Top level for lists in shared XDM index document
+     * Own
+     */
+    HBufC* iSharedXdmTop;
+    
+    /**
+     * Name of list for granted users in XDM list
+     * Own
+     */    
+    HBufC* iGrantListName;
+
+    };
+
+
+#endif // CSIMPLEPLUGINVARIATION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simplepluginwatcher.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,366 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Simple Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#ifndef CSIMPLEPLUGINWATCHER_H
+#define CSIMPLEPLUGINWATCHER_H
+
+#include <e32std.h>
+
+#include <protocolpresencewatching.h>
+
+#include <msimplewatcherobserver.h>
+
+#include "simpleplugincommon.h"
+#include "msimplepluginconnectionobs.h"
+#include "msimplepluginsettings.h"
+
+
+class TXIMPRequestId;
+class MXIMPIdentity;
+class MXIMPProtocolConnectionHost;
+class MPersonPresenceInfo;
+class MXIMPObjectCollection;
+
+class MSimpleDocument;
+class MSimpleWatcher;
+
+class CSimplePluginEntityWatcher;
+class CSimplePluginXdmUtils;
+
+/**
+ * CSimplePluginWatcher
+ *
+ * Simple Engine Connection
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+NONSHARABLE_CLASS( CSimplePluginWatcher ): public CActive,
+    public MProtocolPresenceWatching
+    {
+    
+private:
+
+    /**
+     * Current operation
+     */
+    enum TPluginWatcherOperation
+        {
+        EPluginUndef,
+        EPluginSubscribeGroup,
+        EPluginUnsubscribeGroup
+        };
+        
+    /**
+     * Current actibe object state
+     */
+    enum TPluginXdmState
+        {
+        EPluginIdle,
+        EPluginInitXdm,
+        EPluginFetchRls,
+        EPluginAddGroupMember,
+        EPluginRemoveGroupMember
+        // EPluginCommitRls,
+        // EPluginCommitXdm
+        };        
+            
+public:
+
+    /**
+     * Constructor.
+     * @param aconnSets current settings
+     * @param aObs callback for complete requests
+     * @param aConn Simple Engine connection
+     */
+    static CSimplePluginWatcher* NewL(
+        MSimplePluginSettings& aConnSets,
+        MSimplePluginConnectionObs& aObs,
+        MSimpleConnection& aConn );
+
+    virtual ~CSimplePluginWatcher();
+
+    /**
+     * SetHost
+     *
+     * Set PrFw Host
+     *
+     * @lib ?library
+     * @since s60 v5.0
+     * @patam aHost PrFW Host
+     */
+    void SetHost( MXIMPProtocolConnectionHost* aHost );
+
+    /**
+     * SIP Watcher is complets it's task.
+     * @param aStatus error status
+     */
+    void CompleteWatcher( TInt aStatus );
+
+    /**
+     * Delete a single entity watcher
+     * @param aPresentityid presentity id
+     */
+    void DeleteWatcher(
+        const TDesC8& aPresentityid );
+
+    /**
+     * Get Block list
+     * @param aList list name
+     * @param aMembers blocked users [OUT]
+     */
+    void GetEntitiesInListL(
+        const TDesC& aList,
+        MXIMPObjectCollection& aMembers );
+
+
+private:
+
+    CSimplePluginWatcher(
+        MSimplePluginSettings& aConnSets,
+        MSimplePluginConnectionObs& aObs,
+        MSimpleConnection& aConn );
+
+    void ConstructL( );
+    
+    /**
+     * Calls MXIMPProtocolConnectionHost callback
+     * @param aStatus error status
+     */
+    void CompletePrFwReq( TInt aStatus ); 
+    
+    /**
+     * Handles RunL routines for subscription
+     */
+    void DoRunForSubscriptionL();
+    
+    /**
+     * Handles RunL routines for unsubscription
+     */
+    void DoRunForUnsubscriptionL();    
+
+
+public:
+
+
+// from base class MXIMPBase
+public:
+
+    /**
+     * Defined in a base class
+     */
+    TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps );
+
+    /**
+     * Defined in a base class
+     */
+    const TAny* GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOps ) const;
+
+    /**
+     * Defined in a base class
+     */
+    TInt32 GetInterfaceId() const;
+
+
+// from base class MProtocolPresenceWatching
+public:
+
+    /**
+     * Defined in a base class
+     */
+    void DoSubscribePresentityPresenceL(
+            const MXIMPIdentity& aPresentityId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUpdatePresentityPresenceSubscriptionPifL(
+            const MXIMPIdentity& aPresentityId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUnsubscribePresentityPresenceL(
+            const MXIMPIdentity& aPresentityId,
+            TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoSubscribePresentityGroupMembersPresenceL(
+            const MXIMPIdentity& aGroupId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUpdatePresentityGroupMembersPresenceSubscriptionPifL(
+            const MXIMPIdentity& aGroupId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+    /**
+     * Defined in a base class
+     */
+    void DoUnsubscribePresentityGroupMembersPresenceL(
+            const MXIMPIdentity& aGroupId,
+            TXIMPRequestId aReqId );
+
+protected:
+
+// from base class CActive
+
+    /**
+     * Defined in a base class
+     */
+    void RunL();
+
+    /**
+     * Defined in a base class
+     */
+    TInt RunError( TInt aError );
+
+    /**
+     * Defined in a base class
+     */
+    void DoCancel();
+
+private:
+
+    /**
+     * Match existing watcher
+     * @param aPresentityId presentity id
+     * @return watcher or NULL when not found
+     */
+    CSimplePluginEntityWatcher* MatchWatcher2L(
+        const TDesC8& aPresentityId, TBool aCreate );
+
+    /**
+     * Save presentity id
+     * @param aPresentityId presentity id
+     */
+    void SetPresIdentityL(
+        const MXIMPIdentity& aPresentityId );
+
+    /**
+     *  Start watching service in RLS
+     */
+    void StartWatchingRlsL();
+
+    void StartXdmOperationL();
+    
+    /**
+     * StartXdmoperationL calls this
+     */
+    void DoStartXdmOperationL();    
+    
+    void GetListContentL();  
+    
+    /**
+     * Copy data from aIds and from aNames into aCollection
+     * @param aNames group member names [IN]
+     * @param aNames group member display names [IN]
+     * @param aCollection collection of MPresentityGroupMemberInfo [OUT]
+     */        
+    void CopyGroupMembersToCollectionL( 
+        CPtrCArray& aIds, CPtrCArray& aNames, MXIMPObjectCollection& aCollection);
+        
+    /**
+     * DoSubscribePresentityPresenceL calls this. 
+     */
+    void DoDoSubscribePresentityPresenceL(
+            const MXIMPIdentity& aPresentityId,
+            TXIMPRequestId aReqId );  
+            
+    /**
+     * DoUnsubscribePresentityPresenceL calls this.
+     */
+    void DoDoUnsubscribePresentityPresenceL(
+            const MXIMPIdentity& aPresentityId,
+            TXIMPRequestId aReqId );  
+          
+    /**
+     * DoDoUnsubscribePresentityGroupMembersPresenceL calls this
+     */        
+    void DoDoUnsubscribePresentityGroupMembersPresenceL(
+            const MXIMPIdentity& aGroupId,
+            TXIMPRequestId aReqId );                                  
+
+
+private: // Data
+
+    /**
+     * Current settings
+     */
+    MSimplePluginSettings& iConnSets;
+
+    /**
+     * PrFw Plugin connection observer
+     */
+    MSimplePluginConnectionObs& iConnObs;
+
+    /**
+     * SIMPLE engine connection
+     */
+    MSimpleConnection& iConnection;
+
+    /**
+     * SIMPLE engine watchers
+     */
+    RPointerArray<CSimplePluginEntityWatcher> iWatchers;
+
+    /**
+     * Current PrFW request id
+     */
+    TXIMPRequestId iPrFwId;
+
+    /**
+     * Current presentity in progress
+     * Own.
+     */
+    HBufC16* iPresIdentity;
+
+    /**
+     * XDM Utils
+     * Not own.
+     */
+    CSimplePluginXdmUtils* iXdmUtils;
+
+    /**
+     * Whether the request is completed
+     */
+    TBool iCompleted;
+    
+    TPluginWatcherOperation iOperation;
+    
+    TPluginXdmState iXdmState;
+
+    };
+
+#endif // CSimplePluginWatcher_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simplepluginwinfo.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,177 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Simple Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#ifndef CSIMPLEPLUGINWINFO_H
+#define CSIMPLEPLUGINWINFO_H
+
+#include <e32std.h>
+
+#include <msimplewinfoobserver.h>
+
+#include "simpleplugincommon.h"
+#include "msimplepluginconnectionobs.h"
+
+#include <ximpbase.h>
+
+class MSimpleWinfo;
+class MXIMPIdentity;
+class MPresenceInfoFilter;
+class MSimpleWinfoWatcher;
+class MXIMPProtocolConnectionHost;
+class MSimpleConnection;
+
+
+
+
+/**
+ * CSimplePluginWinfo
+ *
+ * Simple Engine Connection
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+NONSHARABLE_CLASS( CSimplePluginWinfo ) : public CBase,
+    public MSimpleWinfoObserver
+    {
+public:
+
+    /**
+     * Constructor.
+     * @param aObs callback for complete requests
+     * @param aConn Simple Engine connection
+     */
+    static CSimplePluginWinfo* NewL(
+        MSimplePluginConnectionObs& aObs,
+        MSimpleConnection& aConn );
+
+    virtual ~CSimplePluginWinfo();
+
+    /**
+     * SetHost
+     *
+     * Set PrFw Host
+     *
+     * @lib ?library
+     * @since s60 v5.0
+     * @patam aHost PrFW Host
+     */
+    void SetHost( MXIMPProtocolConnectionHost* aHost );
+
+    /**
+     * SubscribeWinfoListL
+     *
+     *
+     * @lib ?library
+     * @since s60 v5.0
+     * @param aReqId PrFw req id
+     */
+    void SubscribeWinfoListL( TXIMPRequestId aReqId );
+
+    /**
+     * UnsubscribeWinfoListL
+     *
+     *
+     * @lib ?library
+     * @since s60 v5.0
+     * @param aReqId PrFw req id
+     */
+    void UnsubscribeWinfoListL( TXIMPRequestId aReqId );
+
+private:
+
+    CSimplePluginWinfo(
+        MSimplePluginConnectionObs& aObs,
+        MSimpleConnection& aConn );
+
+    void ConstructL( );
+
+
+public:
+
+// from base class MSimpleWinfoObserver
+
+// Subscribe presence grant request list
+
+    /**
+     * Defined in a base class
+     */
+    void WinfoReqCompleteL( TInt aOpid, TInt aStatus );
+
+    /**
+     * Defined in a base class
+     */
+    void WinfoTerminatedL(
+        TInt aOpid, TInt aReason );
+
+    /**
+     * Defined in a base class
+     */
+    void WinfoNotificationL( MSimpleWinfo& aWinfo );
+
+
+private: // Data
+
+    /**
+     * PrFw Plugin connection observer
+     */
+    MSimplePluginConnectionObs& iConnObs;
+
+    /**
+     * PrFw Host.
+     * Not Own.
+     */
+    MXIMPProtocolConnectionHost* iHost;
+
+    /**
+     * SIMPLE engine connection
+     */
+    MSimpleConnection& iConnection;
+
+    /**
+     * SIMPLE engine winfo watcher.
+     * Own.
+     */
+    MSimpleWinfoWatcher* iWinfoWatcher;
+
+    /**
+     * PrFW request id
+     */
+    TXIMPRequestId iPrFwId;
+
+    /**
+     * Simple Engine request id
+     */
+    TInt iSimpleId;
+
+    /**
+     * Subscribed
+     */
+    TInt iSubscribed;
+
+    /**
+     * Winfo subscribe completed
+     */
+    TBool iWinfoCompleted;
+
+
+    };
+
+#endif // CSimplePluginWinfo_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/inc/simplepluginxdmutils.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,747 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Simple Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#ifndef CSIMPLEPLUGINXDMUTILS_H
+#define CSIMPLEPLUGINXDMUTILS_H
+
+#include <e32std.h>
+
+#include <badesca.h>
+
+#include <mrlspresxdmasynchandler.h>
+
+#include "simpleplugincommon.h"
+
+// Test suite
+class MSimplePluginTestObs;
+
+class MSimplePluginSettings;
+
+class CPresenceXDM;
+class CRLSXDM;
+class CXdmEngine;
+class CXdmDocument;
+class CXdmDocumentNode;
+
+class TPresenceActionXDM;
+class TPresenceTransformXDM;
+class TPresCondMisc;
+
+
+// notice: class CPtrCArray;  after PrFw headers fixed.
+
+class TRequestStatus;
+
+
+/**
+ * CSimplePluginXdmUtils
+ *
+ * Simple Engine Connection
+ *
+ * @lib ?library
+ * @since s60 v5.0
+ */
+NONSHARABLE_CLASS( CSimplePluginXdmUtils ) : public CActive,
+    public MRLSPresXDMAsyncHandler
+    {
+public:
+
+
+    /**
+     * Active object asynch states
+     */
+    enum TPluginXdmState
+        {
+        EStateIdle,
+        /** Get OMA XDM lists */
+        EGetXdmOMALists,
+        /** Create OMA XDM lists */
+        ECreateXdmOMALists,
+        /** Get OMA XDM lists only, no rules later */
+        EGetXdmOMAListsOnly,
+        /** Create OMA XDM lists only, no rules later */
+        ECreateXdmOMAListsOnly,
+        /** Get RLS service */
+        EGetRlsServices,
+        /** Update RLS service */
+        EUpdateRlsServices,
+        /** Get rules from server for GrantPresenceForPresentity */
+        EGetXdmRules,
+        /** Update rules to server for GrantPresenceForPresentity */
+        EUpdateXdmRules,
+        /** Update XDM OMA List */
+        EUpdateXdmOMAList,
+        /** Cancel XDM document operation */
+        ECancelDocument,
+        /** Re-Update RLS service - 409 HTTP error handling*/
+        EReUpdateRlsServices        
+        };
+
+    /**
+     * Current operation
+     */
+    enum TPluginXdmOperation
+        {
+        ENoOperation,
+        EXdmInit,
+        EXdmInitXdmsOnly,
+        EXdmDeleteAll,
+        EXdmCancel,
+        EXdmAddUserToGroup,
+        EXdmAddGroupToGroup,
+        EXdmRemoveUserFromGroup,
+        EXdmRemoveGroupFromGroup,
+        EXdmGrantForAll,
+        EXdmWithdrawFromAll,
+        EXdmGetBlockedList,
+        EXdmCreateGroup,
+        EXdmDeleteGroup,
+        EXdmRlsFetch,
+        EXdmRlsAdd,
+        EXdmRlsRemove,
+        EXdmGrantGroup,
+        EXdmWithdrawGroup,
+        EXdmSetReactiveAuth,
+        EXdmSetProactiveAuth
+        };
+               
+
+    /**
+     * Constructor.
+     * @param aConnSets connection settings
+     * @param aXdmId XDm settings id
+     */
+    static CSimplePluginXdmUtils* NewL(
+        MSimplePluginSettings& aConnSets,
+        TInt aXdmId);
+
+    virtual ~CSimplePluginXdmUtils();
+    
+    /**
+     * Cancel non active wrappers
+     */
+    void CancelWrappers();
+     
+    /**
+     * Initialize XDMS and Presence XDM structures in network.
+     * @param aStatus Request status of the caller
+     */
+    void InitializeXdmL( TRequestStatus& aStatus );
+
+    /**
+     * Initialize XDMS in network
+     * @param aStatus Request status of the caller
+     */
+    void InitializeXdmsOnlyL( TRequestStatus& aStatus );
+
+    /**
+     * Add resource-list into RLS document, overwrite old document
+     * @param aStatus Request status of the caller
+     */
+    void FetchRlsL( TRequestStatus& aStatus );
+
+    /**
+     * Add resource-list into RLS document.
+     * FetchRlsL must be called before this method.
+     * @param aName list name
+     */
+    void AddRlsGroupL(
+        const TDesC& aName );
+
+    /**
+     * Remove resource-list in RLS document
+     * FetchRlsL must be called before this method.
+     * Use RemoveRlsServiceByResourceListL instead when possible.      
+     * @param aName list name
+     */
+    void RemoveRlsGroupL( const TDesC& aName );
+    
+    /**
+     * Remove service URI in RLS document by corresponding shared XDM document entry.
+     * The document in the server is updated when needed.
+     * FetchRlsL must be called before this method.
+     * This completes without error if the service was not found. 
+     * @param aGroup user's group name, that's converted to resource-list value and used
+     * to match the service resource-list in the rls-services document.
+     * @param aStatus Request status of the caller.     
+     */
+    void RemoveRlsServiceByResourceListL( const TDesC& aGroup, TRequestStatus& aStatus  );    
+    
+    
+    /**
+     * Access service URI in RLS document by corresponding shared XDM document entry.
+     * FetchRlsL must be called before this method.
+     * Leaves with KErrNotFound if RLS service is not found.
+     * @param aGroup user's group name, that's converted to resource-list value and used
+     * to match the service resource-list in the rls-services document.
+     * @return Access service URI in RLS document, ownership is transferred. May be NULL.
+     */
+    HBufC* RlsServiceByResourceListLC( const TDesC& aGroup );     
+
+    /**
+     * Add entity to granted list.
+     * InitializeXdmL must be called before this method.
+     * @param aUri entity URI to be granted
+     * @param aStatus Request status of the caller
+     */
+    void AddEntityToGrantedL( const TDesC& aUri, TRequestStatus& aStatus );
+
+    /**
+     * Remove entity from granted list.
+     * InitializeXdmL must be called before this method.
+     * @param aUri entity URI to be removed
+     * @param aStatus Request status of the caller
+     */
+    void RemoveEntityFromGrantedL(
+        const TDesC&  aUri, TRequestStatus& aStatus );
+
+    /**
+     * Add entity to blocked list.
+     * InitializeXdmL must be called before this method.
+     * @param aUri entity URI to be blocked
+     * @param aStatus Request status of the caller
+     */
+    void AddEntityToBlockedL( const TDesC& aUri, TRequestStatus& aStatus );
+
+    /**
+     * Remove entity from blocked list.
+     * InitializeXdmL must be called before this method.
+     * @param aUri entity URI to be removed
+     * @param aStatus Request status of the caller
+     */
+    void RemoveEntityFromBlockedL(
+        const TDesC&  aUri, TRequestStatus& aStatus );
+
+    /**
+     * Add group to granted.
+     * InitializeXdmL must be called before this method.
+     * @param aName a group to be granted
+     * @param aStatus Request status of the caller
+     */
+    void AddGroupToGrantedL( const TDesC& aName, TRequestStatus& aStatus );
+
+    /**
+     * Remove group from granted list.
+     * InitializeXdmL must be called before this method.
+     * @param aName a group to be removed from granted list
+     * @param aStatus Request status of the caller
+     */
+    void RemoveGroupFromGrantedL(
+        const TDesC&  aName, TRequestStatus& aStatus );
+
+    /**
+     * Grant right for everyone, proactive authorization is set on.
+     * InitializeXdmL must be called before this method.
+     * @param aStatus Request status of the caller
+     */
+    void GrantForEveryoneL( TRequestStatus& aStatus );
+
+    /**
+     * Withdraw right from eveyone, reactive authorization is set on.
+     * InitializeXdmL must be called before this method.
+     * @param aStatus Request status of the caller
+     */
+    void WithdrawFromEveryoneL( TRequestStatus& aStatus );
+    
+    /**
+     * Set reactive authorization policy.
+     * Default rule is set to CONFIRM.
+     */
+    void SetReactiveAuthL( TRequestStatus& aStatus ); 
+    
+    /**
+     * Set proactive authorization policy.
+     * Default rule is set to ALLOW if it was CONFIRM.
+     */
+    void SetProactiveAuthL( TRequestStatus& aStatus );      
+
+    /**
+     * Get (subscribe) Block List.
+     * InitializeXdmL must be called before this method.
+     * @param aMembers blocked users [OUT].
+     */
+    void SubscribeBlockListL( CPtrCArray& aMembers );
+
+    /**
+     * Unsubscribe Block List.
+     * @param aStatus Request status of the caller
+     */
+    void UnsubscribeBlockListL( TRequestStatus& aStatus );
+
+    /**
+     * Create entity's own group
+     * InitializeXdmL or InitilaizeXdmsOnlyL must be called before this method.
+     * @param aName group name
+     * @param aDisplayName group's display name
+     */
+    void CreateEntityGroupL(
+        const TDesC&  aName,
+        const TDesC&  aDisplayName );
+
+    /**
+     * Delete entity's own group
+     * InitializeXdmL or InitilaizeXdmsOnlyL must be called before this method.
+     */
+    void DeleteEntityGroupL( const TDesC&  aName );
+
+    /**
+     * Add group member
+     * InitializeXdmL or InitilaizeXdmsOnlyL must be called before this method.
+     * @param aGroup group name
+     * @param aUser member
+     * @param aDispName display name
+     * @param aStatus Request status of the caller
+     */
+    void AddPresentityGroupMemberL(
+        const TDesC&  aGroup,
+        const TDesC&  aUser,
+        const TDesC&  aDispName,
+        TRequestStatus& aStatus );
+
+    /**
+     * Remove group member
+     * InitializeXdmL or InitilaizeXdmsOnlyL must be called before this method.
+     * @param aGroup group name
+     * @param aUser member
+     * @param aStatus Request status of the caller
+     */
+    void RemovePresentityGroupMemberL(
+        const TDesC&  aGroup,
+        const TDesC&  aUser,
+        TRequestStatus& aStatus );
+
+    /**
+     * GetUserListsL
+     * InitializeXdmL or InitilaizeXdmsOnlyL must be called before this method.
+     * The size of the parameter arrays are same.
+     * @param aIds sip id array [OUT]
+     * @param aDispNames display name array [OUT]
+     */
+    void GetUserListsL( CDesCArrayFlat& aIds, CDesCArrayFlat& aDispNames );
+
+    /**
+     * GetEntitiesInListL
+     * InitializeXdmL or InitilaizeXdmsOnlyL must be called before this method.
+     * The size of the parameter arrays are same.
+     * @param aList naem of the user's list [IN]
+     * @param aIds sip id array [OUT]
+     * @param aDispNames display name array [OUT]
+     */
+    void GetEntitiesInListL(
+        const TDesC&  aList, CPtrCArray& aIds, CPtrCArray& aDispNames);
+
+    /**
+     * Updates XDM reource lists into server
+     * @param aStatus Request status of the caller
+     */
+    void CommitXdmL( TRequestStatus& aStatus );
+
+    /**
+     * Updates RLS reource lists into server
+     * @param aStatus Request status of the caller
+     */
+    void CommitRlsL( TRequestStatus& aStatus );
+
+    /**
+     * Test Suite setter
+     * @param aObs test observer, may be NULL
+     */
+    void SetTestObserver( MSimplePluginTestObs* aObs );
+
+    /**
+     * Generate RLS document URI based on URI template located in CentRep variation definition.
+     * @param aGroup grouup name
+     * @param aPresentityUri presntity's URI, may be SIP or TEL URI. Domain part is stripped from SIP URI.
+     * @param aDomain domain part of the URI,  
+                      Leading '@' is stripped off and it must be hard coded in a template when needed.
+     * @return RLS document URI     
+     */
+    HBufC16* CreateRlsDocumentUri16LC(
+        const TDesC16& aGroup,
+        const TDesC16& aPresentityUri,
+        const TDesC16& aDomain );                
+
+private:
+
+    CSimplePluginXdmUtils(
+        MSimplePluginSettings& aObs, TInt aXdmId );
+
+    void ConstructL( );
+
+  TBool DoesUserListExistsL( const TDesC& aName );
+
+
+public:
+
+// from base class MRLSPresXDMAsyncHandler
+
+    /**
+     * Defined in a base class
+     */
+    void HandleRLSUpdateDocumentL(TInt aErrorCode);
+
+    /**
+     * Defined in a base class
+     */
+    void HandleRLSUpdateCancelL(TInt aErrorCode);
+
+    /**
+     * Defined in a base class
+     */
+    void HandleRLSDeleteAllEmptyListsL(TInt aErrorCode);
+
+    /**
+     * Defined in a base class
+     */
+    void HandlePresUpdateDocumentL(TInt aErrorCode);
+
+    /**
+     * Defined in a base class
+     */
+    void HandlePresUpdateCancelL(TInt aErrorCode);
+
+
+
+protected:
+
+// from base class CActive
+
+    /**
+     * Defined in a base class
+     */
+    void RunL();
+
+    /**
+     * Defined in a base class
+     */
+    TInt RunError( TInt aError );
+
+    /**
+     * Defined in a base class
+     */
+    void DoCancel();
+
+private:
+
+    /**
+     * Complete client request
+     * @param aStatus return code
+     */
+    void CompleteClientReq( TInt aStatus );
+
+    /**
+     * Get XDm OMA lists from a server
+     */
+    void GetXdmOMAListsL();
+
+    /**
+     * Create OMA Shared Xdm Lists when needed.
+     * @return true if a list is created.
+     */
+    TBool CreateXdmOMAListsIfNeededL( );
+
+    /**
+     * Create a specified OMA Shared Xdm List when needed.
+     *
+     * @param aRoot parent for the new list
+     * @param aName name for the new list
+     * Leave with KErrAlreadyExists if all the lists already exist.
+     * @return true is list was added into root node.
+     */
+    TBool CreateXdmOMAListIfNeededL( CXdmDocumentNode* aRoot, const TDesC& aName );
+
+    /**
+     * Create Resource List in shared xdm document
+     * @param aParent parent for the new list
+     * @param aName name for the new list
+     */
+    void CreateResourceListL(
+        CXdmDocumentNode* aParent, const TDesC& aName );
+
+    /**
+     * Search List under a parent list, one level only
+     * @param aParent parent list node
+     * @param aName list to be searched for
+     * @return child node found or NULL if not found.
+     */
+    CXdmDocumentNode* SearchListUnderParentL(
+        CXdmDocumentNode* aParent, const TDesC& aName );
+
+    void GetXdmRulesL();
+
+    /**
+     * Make Rls list URI
+     * @param aXCapUri XCAP URI
+     * @param aListName a list to be referred
+     * @return URI, ownerhisp is transferred
+     */
+    HBufC* MakeRlsUriL(
+        const TDesC& aXcapUri, const TDesC& aListName );
+
+    /**
+     * Make Rls list URI
+     * @param aXCapUri XCAP URI
+     * @param aListName a list to be referred
+     * @return URI, ownerhisp is transferred
+     */
+    HBufC* MakeRlsBuddyUriL(
+        const TDesC& aXcapUri, const TDesC& aListName );
+
+    void MakeInitialXdmsDocumentL();
+
+    /**
+     * Updates XDM rules into server
+     */
+    void UpdateXdmRulesL();
+
+    /**
+     * Updates XDMS reource lists into server
+     */
+    void UpdateXdmsL();
+
+    /**
+     * Updates RLS document into server
+     */
+    void UpdateRlsL();
+
+    /**
+     * Handles pres auth rules document callback method
+     * @param aErrorCode returned error code
+     */
+    void DoHandlePresUpdateDocumentL( TInt aErrorCode );
+    
+    /**
+     * Handles RLS document callback method
+     * @param aErrorCode returned error code
+     */
+    void DoHandleRLSUpdateDocumentL(TInt aErrorCode);    
+
+    void DoAddUserToListL(
+        const TDesC& aList, const TDesC&  aName );
+
+    void DoAddUserToUserListL(
+        const TDesC& aList, const TDesC&  aUser, const TDesC&  aDispName );
+
+    void DoAddListIntoGrantRuleL( const TDesC& aListUri );
+
+    void DoRemoveListFromGrantRuleL( const TDesC& aListUri );
+
+    void DoRemoveUserFromListL(
+        const TDesC& aList, const TDesC&  aName );
+
+    void DoRemoveUserFromUserListL( const TDesC& aList, const TDesC&  aUser );
+
+    void DoGrantForAllL();
+
+    void DoWithdrawFromAllL();
+    
+    void DoSetReactiveAuthL(); 
+    
+    /**
+     * Set Proactive authorization
+     */
+    void DoSetProactiveAuthL();        
+
+    void DoGetListMembersL(
+        const TDesC& aList, CPtrCArray& aMembers  );
+
+    void DoCreateEntityGroupL( const TDesC& aList, const TDesC& aDisName  );
+
+    void DoDeleteEntityGroupL( const TDesC& aList );
+
+    /**
+     * Search OMA Buddy List
+     * Leaves with KErrNotFound if not found
+     * @return list node
+     */
+    CXdmDocumentNode* DoGetBuddyListL();
+
+    /**
+     * Search a specific user XDM list
+     * Leaves with KErrNotFound if not found
+     * @param aList list name
+     * @param aBuddyList parent buddy list
+     * @return list node
+     */
+    CXdmDocumentNode* DoGetUserListL(
+        const TDesC& aList, CXdmDocumentNode* aBuddyList );
+        
+    /**
+     * Remove service URI in RLS document by corresponding shared XDM document entry.
+     * FetchRlsL must be called before this method.
+     * @param aResourceList resource-list entry value, a reference to Shared XDM document.
+     * @return ETrue if service is found and removed.
+     */
+    TBool DoRemoveRlsServiceByResourceListL( const TDesC& aResourceList ); 
+    
+    /**
+     * Access service URI in RLS document by corresponding shared XDM document entry.
+     * FetchRlsL must be called before this method.
+     * @param aResourceList resource-list entry value, a reference to Shared XDM document.
+     * @return service URI, ownership is transferred.
+     */
+    HBufC* DoGetRlsServiceByResourceListL( const TDesC& aResourceList );  
+    
+    /**
+     * Accesor for iAuxBuffer that contains last negotiated RLS service URI
+     * @return buffer content
+     */    
+    TPtrC AuxBuffer(); 
+    
+    /**
+     * Run next XDM routines
+     * @param aOrigState original XDM state
+     * @param aStatus error status
+     */
+    void DoXdmRunL( TPluginXdmState aOrigState, TInt aStatus ); 
+    
+    /**
+     * Handle RLS service URI negatioation
+     */
+    void RlsServiceUriNegotiationL();
+    
+    /**
+     * Make default auth rule
+     * @param aRuleId Rule id
+     * @param aAction action class initialized
+     * @param aTransform transform class initialized
+     */
+    void MakeDefaultRuleL( 
+        TDes& aRuleId, 
+        TPresenceActionXDM& aAction, 
+        TPresenceTransformXDM& aTransform,
+        TPresCondMisc& aMisc );
+      
+    /**
+     * Replace Group tag in URI
+     * @param aBuf URI buffer [IN,OUT]
+     * @param aGroup Group name
+     */         
+    static void ReplaceGroupTag( HBufC16* aBuf, const TDesC16& aGroup );
+        
+    /**
+     * Replace Domain tag in URI
+     * @param aBuf URI buffer [IN,OUT]
+     * @param aDomain Domain value
+     */          
+    static void ReplaceDomainTag( HBufC16* aBuf, const TDesC16& aDomain );
+        
+    /**
+     * Replace User tag in URI
+     * @param aBuf URI buffer [IN,OUT]
+     * @param aPresentityUri User URI value
+     */    
+    static void ReplaceUserTag( 
+        HBufC16* aBuf, const TDesC16& aPresentityUri );
+
+
+private: // Data
+
+    /**
+     * PrFw Plugin connection observer
+     */
+    MSimplePluginSettings& iConnSets;
+
+    /**
+     * XDM Settings id
+     */
+    TInt iSettingsId;
+
+    /**
+     * Simple Engine request id
+     */
+    TInt iSimpleId;
+
+    /**
+     * Subscribed items. Bitmask.
+     */
+    TUint iSubscribed;
+
+    /**
+     * Presence XDM Client
+     * Own.
+     */
+    CPresenceXDM* iPresenceXdm;
+
+    /**
+     * RlsXDM Client
+     * Own.
+     */
+    CRLSXDM* iRlsXdm;
+
+    /**
+     * XDM Engine
+     * Own.
+     */
+    CXdmEngine* iXdmEngine;
+
+    /**
+     * XDM document for resource-lists
+     * Own.
+     */
+    CXdmDocument* iXdmDoc;
+
+    /**
+     * Current state
+     */
+    TPluginXdmState iXdmState;
+
+    /**
+     * Current operation
+     */
+    TPluginXdmOperation iOperation;
+
+    /**
+     * Whether Presence XDM is up-to-date
+     */
+    TBool iPresXdmOk;
+
+    /**
+     * Whether XDM is up-to-date
+     */
+    TBool iXdmOk;
+
+    /**
+     * client statutus.
+     * Not own.
+     */
+    TRequestStatus* iClientStatus;
+
+    /**
+     * Test suite observer
+     * Not own.
+     */
+    MSimplePluginTestObs* iTestObs;
+    
+    /**
+     * Auxiliary buffer for for Negotiated RLS service URI
+     */
+    HBufC* iAuxBuffer;
+    
+    /**
+     * Auxiliary buffer for for Negotiated RLS service URI
+     */
+    HBufC* iAuxBuffer2;    
+         
+    };
+
+
+
+#endif // CSimplePluginXdmUtils_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/rom/presencefwsimpleadpt.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* 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 SIMPLE Adaptation
+*
+*/
+
+
+
+
+#ifndef PRESENCEFW_SIMPLE_IBY
+#define PRESENCEFW_SIMPLE_IBY
+
+#ifdef __PRESENCE_FRAMEWORK
+#ifdef __SIP_SIMPLE_PRESENCE_PROTOCOL
+
+#include <data_caging_paths_for_iby.hrh>
+
+// Presence ECOM plugin
+ECOM_PLUGIN( simpleplugin.dll, simpleplugin.rss )
+
+// stub SIS, provides support for SIS upgrading
+data=DATAZ_/system/install/presencefwsimpleadptstub.sis     system/install/presencefwsimpleadptstub.sis
+
+#endif      // __SIP_SIMPLE_PRESENCE_PROTOCOL
+#endif      // __PRESENCE_FRAMEWORK
+
+#endif      // PRESENCEFW_SIMPLE_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simpleplugin.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,214 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#include <ecom/implementationproxy.h>
+
+#include <ximpserviceinfo.h>
+#include <ximpbase.h>
+#include <ximpidentity.h>
+#include <presenceinfo.h>
+#include <ximpprotocolconnectionhost.h>
+
+#include "simpleplugin.h"
+#include "simpleplugindef.h"
+#include "simplepluginconnection.h"
+
+
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// ---------------------------------------------------------------------------
+// Key value pair table to identify correct constructor
+// function for the requested interface.
+// ---------------------------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( K_SIMPLEPLUGIN_1_IMPLEMENTATION_UID, CSimplePlugin::NewL )
+    };
+
+// ---------------------------------------------------------------------------
+// Exported function to return the implementation proxy table
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+    return ImplementationTable;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePlugin::CSimplePlugin()
+// ---------------------------------------------------------------------------
+//
+CSimplePlugin::CSimplePlugin()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePlugin::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePlugin::ConstructL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePlugin::NewLC()
+// ---------------------------------------------------------------------------
+//
+CSimplePlugin* CSimplePlugin::NewLC()
+    {
+    CSimplePlugin* self = new( ELeave ) CSimplePlugin();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePlugin::NewL()
+// ---------------------------------------------------------------------------
+//
+CSimplePlugin* CSimplePlugin::NewL()
+    {
+    CSimplePlugin* self = CSimplePlugin::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePlugin::~CSimplePlugin()
+// ---------------------------------------------------------------------------
+//
+CSimplePlugin::~CSimplePlugin()
+    {
+    iConnections.ResetAndDestroy();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePlugin::PrimeHost()
+// ---------------------------------------------------------------------------
+//
+void CSimplePlugin::PrimeHost( MXIMPProtocolPluginHost& aHost )
+    {
+    iHost = &aHost;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePlugin::AcquireConnectionL()
+// ---------------------------------------------------------------------------
+//
+MXIMPProtocolConnection& CSimplePlugin::AcquireConnectionL(
+    const MXIMPServiceInfo& aServiceInfo,
+    const MXIMPContextClientInfo& aContextClient )
+    {
+    
+    // TODO: singleton takes place here. Change name to CSimplePluginImp???
+    // CSimplePluginConnection reflects to Singleton. This should compare PresenceID
+    // and share a single entity with identical ids.HOW DOES PrFW work in this case???
+
+    // support multiple connections
+    // always create a new connection - no connection sharing, it takes place in SIP Stack.
+    CSimplePluginConnection* connection =
+        CSimplePluginConnection::NewL( aServiceInfo, aContextClient );
+    CleanupStack::PushL( connection );
+    iConnections.AppendL( connection );
+    CleanupStack::Pop( connection );
+    return *connection;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePlugin::ReleaseConnection()
+// ---------------------------------------------------------------------------
+//
+void CSimplePlugin::ReleaseConnection( MXIMPProtocolConnection& aConnection )
+    {
+    TInt connectionsCount = iConnections.Count();
+
+    for( TInt i( connectionsCount - 1 ); i >= 0; i-- )
+        {
+        MXIMPProtocolConnection* tmp = iConnections[i];
+        if( tmp == &aConnection )
+            {
+            delete iConnections[i];
+            iConnections.Remove( i );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePlugin::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CSimplePlugin::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions )
+    {
+
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        MXIMPProtocolPlugin* myIf = this;
+        return myIf;
+        }
+    if( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePlugin::GetInterface()
+// ---------------------------------------------------------------------------
+//
+const TAny* CSimplePlugin::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        const MXIMPProtocolPlugin* myIf = this;
+        return myIf;
+        }
+    if( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePlugin::GetInterfaceId()
+// ---------------------------------------------------------------------------
+//
+TInt32 CSimplePlugin::GetInterfaceId() const
+    {
+    return MXIMPProtocolPlugin::KInterfaceId;
+    }
+    
+    
+
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simplepluginauthorization.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,1071 @@
+/*
+* 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:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+
+#include <e32std.h>
+
+#include <ximpdatasubscriptionstate.h>
+#include <protocolpresenceauthorizationdatahost.h>
+#include <ximpobjectfactory.h>
+#include <presenceobjectfactory.h>
+#include <ximpstatus.h>
+#include <ximpidentity.h>
+#include <presencegrantrequestinfo.h>
+#include <ximpobjectcollection.h>
+#include <presenceblockinfo.h>
+#include <presenceerrors.hrh>
+
+#include <simplefactory.h>
+#include <msimpleconnection.h>
+#include <msimplewinfo.h>
+#include <msimpleelement.h>
+
+#include "simplepluginauthorization.h"
+#include "simpleplugindebugutils.h"
+#include "simplepluginwinfo.h"
+#include "simplepluginxdmutils.h"
+#include "simpleplugincommon.h"
+#include "simplepluginconnection.h"
+
+/**
+    The design is the following one
+
+    1. DoGrantPresenceForEveryOneL
+      modify default rule to ALLOW.
+
+    2. DoWithdrawPresenceFromEveryOneL
+      if current rule is ALLOW then
+        {  BLOCK  }
+        otherwise no action.
+
+    3. DoSubscribePresenceGrantRequestListL
+      modify default rule to CONFIRM.
+
+    4. DoUnsubscribePresenceGrantRequestListL
+      if current rule is CONFIRM then
+        { go to ALLOW  }
+        otherwise no action.
+*/
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::CSimplePluginAuthorization
+// ---------------------------------------------------------------------------
+//
+CSimplePluginAuthorization::CSimplePluginAuthorization(
+    MSimplePluginConnectionObs& aObs )
+: CActive( CActive::EPriorityStandard ),
+  iConnObs(aObs),
+  iOperation(ENoOperation),
+  iXdmOk(EFalse), iDefRule(ERuleDef), iWinfoSubs( EFalse )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::ConstructL( )
+    {
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::NewL
+// ---------------------------------------------------------------------------
+//
+CSimplePluginAuthorization* CSimplePluginAuthorization::NewL(
+    MSimplePluginConnectionObs& aObs )
+    {
+    CSimplePluginAuthorization* self =
+        new( ELeave ) CSimplePluginAuthorization( aObs );
+    CleanupStack::PushL( self );
+    self->ConstructL(  );
+    CleanupStack::Pop( self );
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: NewL this=%d"), (TInt)self );
+#endif
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::~CSimplePluginAuthorization
+// ---------------------------------------------------------------------------
+//
+CSimplePluginAuthorization::~CSimplePluginAuthorization()
+    {
+    delete iPresIdentity;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::SetDataHost
+// We assume that this method is given by PrFw right after
+// constrcution.
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::SetDataHost(
+    MProtocolPresenceAuthorizationDataHost& aDataHost )
+    {
+    iDataHost = &aDataHost;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::WinfoTerminatedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::WinfoTerminatedL( TInt /*aReason*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: WinfoTerminatedL") );
+#endif
+
+    if ( iWinfoSubs )
+        {
+        MXIMPDataSubscriptionState* myState = iConnObs.ObjectFactory().NewDataSubscriptionStateLC();
+        MXIMPStatus* myStatus = iConnObs.ObjectFactory().NewStatusLC();
+        // Notice: consider error codes
+        myStatus->SetResultCode( KErrCompletion );
+        myState->SetSubscriptionStateL(
+            MXIMPDataSubscriptionState::ESubscriptionInactive );
+
+        // parameters' OWNERSHIP is taken
+        iDataHost->SetPresenceGrantRequestDataSubscriptionStateL(
+            myState,
+            myStatus );
+
+        iWinfoSubs = EFalse;
+
+        CleanupStack::Pop( /*myStatus*/ );
+        CleanupStack::Pop( /*myState*/ );
+        }
+ }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoSubscribePresenceGrantRequestListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoSubscribePresenceGrantRequestListL(
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoSubscribePresenceGrantRequestListL"));
+#endif
+
+    /*
+    This means Reactive authorization, i.e. modify default rule as CONFIRM.
+    Also this starts the WINFO subscription.
+
+    Once the authorization request is received the
+    MProtocolPresenceAuthorizationDataHost::HandlePresenceGrantRequestReceivedL shall
+    be called in the host API.
+
+    First make the watcher list SIP subscription and after that is completed
+    in HandleIfMine then continue and modify XDMS authentication rule.
+    HandleIfMine can be called also immediately if there already exists an WINFO subscrption.
+    */
+
+    iOperation = ESubscribePresenceGrantRequestList;
+    iPrFwId = aReqId;
+    TRAPD( err, iConnObs.WinfoHandlerL()->SubscribeWinfoListL( aReqId ));
+    if ( err )
+        {
+        iOperation = ENoOperation;
+        User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+        }
+    else
+        {
+        iWinfoSubs = ETrue;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoUnsubscribePresenceGrantRequestListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoUnsubscribePresenceGrantRequestListL(
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoUnsubscribePresenceGrantRequestListL TEST COVERS 4"));
+#endif
+
+    // First modify XDMS authentication rule and then unsubscribe
+    // SIP watcher list subscription.
+    TRAPD( err, DoStartXdmOperationL( aReqId, EUnsubscribePresenceGrantRequestList ));
+    if ( err )
+        {
+        User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+        }
+    iPrFwId = aReqId;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoGrantPresenceForPresentityL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoGrantPresenceForPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    const MPresenceInfoFilter& /*aPif*/,  // notice: pif not supported
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoGrantPresenceForPresentityL"));
+#endif
+    StartXdmOperationL( aPresentityId, aReqId, EGrantPresenceForPresentity );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoUpdatePresenceGrantPifForPresentityL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoUpdatePresenceGrantPifForPresentityL(
+    const MXIMPIdentity& /*aPresentityId*/,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoUpdatePresenceGrantPifForPresentityL"));
+#endif
+    // Notice: aPif filter not supported.
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoWithdrawPresenceGrantFromPresentityL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoWithdrawPresenceGrantFromPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoWithdrawPresenceGrantFromPresentityL"));
+#endif
+    StartXdmOperationL( aPresentityId, aReqId, EWithdrawFromPresentity );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoGrantPresenceForPresentityGroupMembersL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoGrantPresenceForPresentityGroupMembersL(
+    const MXIMPIdentity& aGroupId,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoGrantPresenceForPresentityGroupMembersL"));
+#endif
+    StartXdmOperationL( aGroupId, aReqId, EGrantPresenceForPresentityGroupMembers );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoUpdatePresenceGrantPifForPresentityGroupMembersL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoUpdatePresenceGrantPifForPresentityGroupMembersL(
+    const MXIMPIdentity& /*aGroupId*/,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoUpdatePresenceGrantPifForPresentityGroupMembersL"));
+#endif
+    // Notice: aPif filter not supported
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoWithdrawPresenceGrantFromPresentityGroupMembersL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoWithdrawPresenceGrantFromPresentityGroupMembersL(
+    const MXIMPIdentity& aGroupId,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoWithdrawPresenceGrantFromPresentityGroupMembersL"));
+#endif
+    StartXdmOperationL( aGroupId, aReqId, EWithdrawFromGroupMembers );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoGrantPresenceForEveryoneL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoGrantPresenceForEveryoneL(
+    const MPresenceInfoFilter& /*aPif*/,   // // Notice: aPif filter not supported
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoGrantPresenceForEveryoneL"));
+#endif
+    MXIMPIdentity* nobody = iConnObs.ObjectFactory().NewIdentityLC();  // << nobody
+    StartXdmOperationL( *nobody, aReqId, EGrantForEveryone );
+    CleanupStack::PopAndDestroy( );                     // >> nobody
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoUpdatePresenceGrantPifForEveryoneL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoUpdatePresenceGrantPifForEveryoneL(
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoUpdatePresenceGrantPifForEveryoneL"));
+#endif
+    // Notice: aPif filter not supported
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoWithdrawPresenceGrantFromEveryoneL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoWithdrawPresenceGrantFromEveryoneL(
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoWithdrawPresenceGrantFromEveryoneL"));
+#endif
+    MXIMPIdentity* nobody = iConnObs.ObjectFactory().NewIdentityLC();  // << nobody
+    StartXdmOperationL( *nobody, aReqId, EWithdrawFromEveryone );
+    CleanupStack::PopAndDestroy( );                     // >> nobody
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoSubscribePresenceBlockListL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoSubscribePresenceBlockListL(
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoSubscribePresenceBlockListL"));
+#endif
+    MXIMPIdentity* nobody = iConnObs.ObjectFactory().NewIdentityLC();  // << nobody
+    StartXdmOperationL( *nobody, aReqId, ESubscribeBlockList );
+    CleanupStack::PopAndDestroy( );                     // >> nobody
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoUnsubscribePresenceBlockListL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoUnsubscribePresenceBlockListL(
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoUnsubscribePresenceBlockListL"));
+#endif
+    MXIMPIdentity* nobody = iConnObs.ObjectFactory().NewIdentityLC();  // << nobody
+    StartXdmOperationL( *nobody, aReqId, EUnsubscribeBlockList );
+    CleanupStack::PopAndDestroy( );                     // >> nobody
+    }
+
+// Blocking presence information access from single presentities
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoBlockPresenceForPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoBlockPresenceForPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoBlockPresenceForPresentityL"));
+#endif
+    StartXdmOperationL( aPresentityId, aReqId, EBlockPresentity );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoCancelPresenceBlockFromPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoCancelPresenceBlockFromPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: DoCancelPresenceBlockFromPresentityL"));
+#endif
+    StartXdmOperationL( aPresentityId, aReqId, EUnblockPresentity );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoCancel(  )
+    {
+    iXdmUtils->Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::RunL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::RunL(  )
+    {
+    TInt myStatus = iStatus.Int();
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: RunL %d"), myStatus );
+#endif
+
+    if ( iOperation == EUnsubscribePresenceGrantRequestList && !myStatus )
+        {
+        // unsubscribe watcher list after successful default rule modification.
+        TRAPD( err, iConnObs.WinfoHandlerL()->UnsubscribeWinfoListL( iPrFwId ));
+        if ( err )
+            {
+            User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+            }
+        else
+            {
+            // This will end to HandleIfMine.
+            }
+        }
+    else if ( !iXdmOk && !myStatus )
+        {
+        iXdmOk = ETrue;
+        CallActualXdmOperationL();
+        }
+    else // iXdmOK or myStatus
+        {
+        CompletePrFwReq( myStatus );
+        }
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::CallActualXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::CallActualXdmOperationL()
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: CallActualXdmOperationL") );
+#endif
+    switch ( iOperation )
+        {
+        case EGrantPresenceForPresentity:
+            // iPresIdentity can't be null in this case
+            iXdmUtils->AddEntityToGrantedL( iPresIdentity->Des(), iStatus );
+            SetActive();
+            break;
+        case EWithdrawFromPresentity:
+            // iPresIdentity can't be null in this case
+            iXdmUtils->RemoveEntityFromGrantedL( iPresIdentity->Des(),iStatus );
+            SetActive();
+            break;
+        case EGrantPresenceForPresentityGroupMembers:
+            // iPresIdentity can't be null in this case
+            iXdmUtils->AddGroupToGrantedL( iPresIdentity->Des(), iStatus );
+            SetActive();
+            break;
+        case EWithdrawFromGroupMembers:
+            // iPresIdentity can't be null in this case
+            iXdmUtils->RemoveGroupFromGrantedL( iPresIdentity->Des(), iStatus );
+            SetActive();
+            break;
+        case EGrantForEveryone:
+            iXdmUtils->GrantForEveryoneL( iStatus );
+            SetActive();
+            break;
+        case EWithdrawFromEveryone:
+            iXdmUtils->WithdrawFromEveryoneL( iStatus );
+            SetActive();
+            break;
+        case ESubscribeBlockList:
+            HandleSubscribeBlockListL();
+            break;
+        case EUnsubscribeBlockList:
+            iXdmUtils->UnsubscribeBlockListL( iStatus );
+            SetActive();
+            break;
+        case EBlockPresentity:
+            // iPresIdentity can't be null in this case
+            iXdmUtils->AddEntityToBlockedL( iPresIdentity->Des(), iStatus );
+            SetActive();
+            break;
+        case EUnblockPresentity:
+            // iPresIdentity can't be null in this case
+            iXdmUtils->RemoveEntityFromBlockedL( iPresIdentity->Des(), iStatus );
+            SetActive();
+            break;
+        case ESubscribePresenceGrantRequestList:
+            iXdmUtils->SetReactiveAuthL( iStatus );
+            SetActive();
+            break;
+        case EUnsubscribePresenceGrantRequestList:
+        default:
+            iXdmUtils->SetProactiveAuthL( iStatus );
+            SetActive();
+            break;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::CopyBlockersToArrayL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::CopyBlockersToArrayL(
+        CPtrCArray& aBlockers, RPointerArray<MXIMPIdentity>& aBlockedSouls )
+    {
+    MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();
+
+    aBlockedSouls.Reset();
+
+    TInt nodeCount = aBlockers.Count();
+    for ( TInt i = 0; i < nodeCount; i++ )
+        {
+        MXIMPIdentity* entity = myFactory.NewIdentityLC(); // << entity
+        entity->SetIdentityL( aBlockers[i] );
+        aBlockedSouls.AppendL( entity );
+        CleanupStack::Pop(); // >> entity
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CSimplePluginAuthorization::RunError( TInt aError )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: RunError %d"), aError );
+#endif
+    // complete the open request
+    CompletePrFwReq( aError );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CSimplePluginAuthorization::GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOptions )
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        MProtocolPresenceAuthorization* myIf = this;
+        return myIf;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::GetInterface()
+// ---------------------------------------------------------------------------
+//
+const TAny* CSimplePluginAuthorization::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        const MProtocolPresenceAuthorization* myIf = this;
+        return myIf;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::GetInterfaceId()
+// ---------------------------------------------------------------------------
+//
+TInt32 CSimplePluginAuthorization::GetInterfaceId() const
+    {
+    return MProtocolPresenceAuthorization::KInterfaceId;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::SetPresIdentityL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::SetPresIdentityL(
+     const MXIMPIdentity& aPresentityId )
+     {
+     delete iPresIdentity;
+     iPresIdentity = NULL;
+     iPresIdentity = aPresentityId.Identity().AllocL();
+     }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::WinfoNotificationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::WinfoNotificationL(
+    MSimpleWinfo& aWinfo )
+    {
+    if ( !iWinfoSubs )
+        {
+        return;
+        }
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: WinfoNotificationL starts"));
+#endif
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    RPointerArray<MSimpleElement> elems;
+    CleanupClosePushL( elems );
+    TInt err = aWinfo.SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    TInt count = elems.Count();
+
+    if ( !count )
+        {
+        // stop parsing empty notification
+        User::Leave( KErrArgument );
+        }
+
+    __ASSERT_DEBUG( count == 1, User::Leave( KErrCorrupt ) );
+
+    const TDesC8* stateVal = aWinfo.AttrValue( KSimpleState8 );
+    if ( stateVal && !stateVal->CompareF( KSimpleFull8 ))
+        {
+        // Call full list method
+        HandleFullWinfoNotificationL( aWinfo );
+        }
+    else
+        {
+        // Indicate changes in WINFO list one by one.
+        HandlePartialWinfoNotificationL( aWinfo );
+        }
+    CleanupStack::PopAndDestroy( &elems );
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: WinfoNotificationL ends"));
+#endif
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::StartXdmOperationL(
+    const MXIMPIdentity& aId,
+    TXIMPRequestId aReqId,
+    TPluginAuthOperation aOperation )
+    {
+    TRAPD( err, DoStartXdmOperationL(aId, aReqId, aOperation ));
+    if ( err )
+        {
+        User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoStartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoStartXdmOperationL(
+    const MXIMPIdentity& aId,
+    TXIMPRequestId aReqId,
+    TPluginAuthOperation aOperation )
+    {
+    SetPresIdentityL( aId );
+    DoStartXdmOperationL( aReqId, aOperation );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::DoStartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::DoStartXdmOperationL(
+    TXIMPRequestId aReqId,
+    TPluginAuthOperation aOperation )
+    {
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) );
+    iPrFwId = aReqId;
+    iOperation = aOperation;
+    if ( !iXdmUtils )
+        {
+        iXdmUtils = iConnObs.XdmUtilsL();
+        }
+    if ( iXdmOk )
+        {
+        CallActualXdmOperationL();
+        }
+    else
+        {
+        iXdmUtils->InitializeXdmL( iStatus );
+        SetActive();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::HandleFullWinfoNotificationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::HandleFullWinfoNotificationL(
+    MSimpleWinfo& aWinfo )
+    {
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: HandleFullWinfoNotificationL starts"));
+#endif
+
+    // Search for pending watchers and call HandlePresenceGrantRequestListL
+    using namespace NSimplePlugin::NSimpleOma;
+
+    RPointerArray<MSimpleElement> elems;
+    CleanupClosePushL( elems );
+    TInt err = aWinfo.SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    TInt count = elems.Count();
+
+    MSimpleElement* elem = elems[0];
+    TPtrC8 p8 = elem->LocalName();
+    err = p8.CompareF( KSimpleWatcherList8 );
+    User::LeaveIfError( err );
+
+    err = elem->SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    count = elems.Count();
+
+    // Search watchers who are pending (status = pending)
+    HBufC* nodeContent = NULL;
+    MXIMPObjectCollection *pendings = iConnObs.ObjectFactory().NewObjectCollectionLC();
+
+    TBool pendingFound(EFalse);
+
+    for ( TInt i = 0; i < count; i++ )
+        {
+        elem = elems[i];
+        p8.Set( elem->LocalName());
+        if (!( p8.CompareF( KSimpleWatcher8 )))
+            {
+            const TDesC8* pp8 = elem->AttrValue( KSimpleStatus8 );
+            if ( pp8 && !pp8->CompareF( KSimplePending8 ))
+                {
+                // Build collection of grant requests
+                // Find the child node containing the SIP entity
+                nodeContent = elem->ContentUnicodeL();
+                CleanupStack::PushL( nodeContent );
+                // create the collection entry here
+                MPresenceGrantRequestInfo* grInfo =
+                   iConnObs.PresenceObjectFactory().NewPresenceGrantRequestInfoLC();
+                MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC();
+                identity->SetIdentityL( nodeContent->Des());
+                grInfo->SetRequestorIdL( identity ); // ownership is taken
+                CleanupStack::Pop( ); // identity
+#ifdef _DEBUG
+                TBuf<200> debug_buffer;
+                debug_buffer = nodeContent->Des();
+                PluginLogger::Log(
+                    _L("PluginAuth: add pending into collection: %S"), &debug_buffer );
+#endif
+                pendings->AddObjectL( grInfo );  // ownership is taken
+                CleanupStack::Pop( );            // grInfo
+                pendingFound = ETrue;
+                CleanupStack::PopAndDestroy( nodeContent );
+                }
+            }
+        }
+
+    if ( pendingFound )
+        {
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginAuthorization: callback HandlePresenceGrantRequestListL"));
+#endif
+        iPrFwIdOwn = iDataHost->HandlePresenceGrantRequestListL( pendings );
+        CleanupStack::Pop();    // >> pendings
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy( ); // >> pendings
+        }
+
+    CleanupStack::PopAndDestroy( &elems );
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: HandleFullWinfoNotificationL ends"));
+#endif
+
+    /* example:
+
+   <?xml version="1.0"?>
+     <watcherinfo xmlns="urn:ietf:params:xml:ns:watcherinfo"
+   version="0" state="full">
+     <watcher-list resource="sip:presentity@example.com"
+                   package="presence">
+         <watcher status="active"
+            id="sr8fdsj"
+            duration-subscribed="509"
+            expiration="20"
+            event="approved">sip:watcherA@example.com"
+          </watcher>
+     */
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::HandlePartialWinfoNotificationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::HandlePartialWinfoNotificationL(
+    MSimpleWinfo& aWinfo )
+    {
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: HandlePartialWinfoNotificationL starts"));
+#endif
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    RPointerArray<MSimpleElement> elems;
+    CleanupClosePushL( elems );
+    TInt err = aWinfo.SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    TInt count = elems.Count();
+
+    MSimpleElement* elem = elems[0];
+    TPtrC8 p8 = elem->LocalName();
+    err = p8.CompareF( KSimpleWatcherList8 );
+    User::LeaveIfError( err );
+
+    err = elem->SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    count = elems.Count();
+
+    HBufC* nodeContent = NULL;
+
+    for ( TInt i = 0; i < count; i++ )
+        {
+        elem = elems[i];
+        p8.Set( elem->LocalName());
+        if (!( p8.CompareF( KSimpleWatcher8 )))
+            {
+            const TDesC8* pp8 = elem->AttrValue( KSimpleStatus8 );
+            if ( pp8 && !pp8->CompareF( KSimplePending8 ))
+                {
+                nodeContent = elem->ContentUnicodeL();
+                CleanupStack::PushL( nodeContent );
+                CallHandlePresenceGrantRequestReceivedL( nodeContent->Des() );
+                CleanupStack::PopAndDestroy( nodeContent );
+                }
+            else if ( pp8 && !pp8->CompareF( KSimpleTerminated8 ))
+                {
+                nodeContent = elem->ContentUnicodeL();
+                CleanupStack::PushL( nodeContent );
+                CallHandlePresenceGrantRequestObsoletedL( nodeContent->Des() );
+                CleanupStack::PopAndDestroy( nodeContent );
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy( &elems );
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: HandlePartialWinfoNotificationL ends"));
+#endif
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::CallHandlePresenceGrantRequestReceivedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::CallHandlePresenceGrantRequestReceivedL(
+    const TDesC& aUserId )
+    {
+    // create the collection entry here
+    MPresenceGrantRequestInfo* grInfo =
+       iConnObs.PresenceObjectFactory().NewPresenceGrantRequestInfoLC();  // +grInfo
+    MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC();   // +identity
+    identity->SetIdentityL( aUserId );
+    grInfo->SetRequestorIdL( identity ); // ownership is taken
+    CleanupStack::Pop( );    // -identity
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: callback HandlePresenceGrantRequestReceivedL"));
+#endif
+    iPrFwIdOwn = iDataHost->HandlePresenceGrantRequestReceivedL( grInfo ); // ownership is taken
+    CleanupStack::Pop( );           // -grInfo
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::CallHandlePresenceGrantRequestObsoletedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::CallHandlePresenceGrantRequestObsoletedL(
+    const TDesC& aUserId)
+    {
+    MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC();
+    identity->SetIdentityL( aUserId );
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: callback HandlePresenceGrantRequestObsoletedL"));
+#endif
+    iPrFwIdOwn = iDataHost->HandlePresenceGrantRequestObsoletedL( identity); // ownership is taken
+    CleanupStack::Pop( );           // >> identity
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::HandleSubscribeBlockListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::HandleSubscribeBlockListL()
+    {
+    RPointerArray<MXIMPIdentity> blockedSouls;
+    CleanupClosePushL( blockedSouls );
+
+    const TInt KMyGran = 10;
+    CPtrCArray* blockers = new (ELeave) CPtrCArray( KMyGran );
+    CleanupStack::PushL( blockers );      // << blockers
+
+    iXdmUtils->SubscribeBlockListL( *blockers );
+
+    CopyBlockersToArrayL( *blockers, blockedSouls );
+
+    CleanupStack::PopAndDestroy( blockers );
+
+    MXIMPObjectCollection* coll =
+        iConnObs.ObjectFactory().NewObjectCollectionLC();    // << coll
+    TInt count = blockedSouls.Count();
+    for ( TInt i = count-1; i >= 0; i-- )
+        {
+        MXIMPIdentity* currId = blockedSouls[i];
+        MPresenceBlockInfo* bInfo = iConnObs.PresenceObjectFactory().NewPresenceBlockInfoLC();
+        bInfo->SetBlockedEntityIdL( currId ); // ownership is taken
+        bInfo->SetBlockedEntityDisplayNameL( currId->Identity() );
+        blockedSouls.Remove( i );
+        coll->AddObjectL( bInfo );      // ownership is taken
+        CleanupStack::Pop();                                // >> bInfo
+        }
+    CompletePrFwReq( KErrNone );
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuth: callback HandlePresenceBlockListL"));
+#endif
+    // Callback for subscription result
+    iDataHost->HandlePresenceBlockListL( coll );
+
+    CleanupStack::Pop();                                // >> coll
+    CleanupStack::PopAndDestroy( &blockedSouls );
+
+    // Callback for subscription state (terminated).
+    MXIMPDataSubscriptionState* myState = iConnObs.ObjectFactory().NewDataSubscriptionStateLC();
+    MXIMPStatus* myStatus = iConnObs.ObjectFactory().NewStatusLC();
+    // Notice: consider error codes
+    myStatus->SetResultCode( KErrNone );
+    myState->SetSubscriptionStateL(
+        MXIMPDataSubscriptionState::ESubscriptionInactive );
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: callback SetPresenceBlockDataSubscriptionStateL"));
+#endif
+    iDataHost->SetPresenceBlockDataSubscriptionStateL(
+        myState, myStatus );
+    CleanupStack::Pop( 2 ); // >> myState, myStatus
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::CompletePrFwReq
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginAuthorization::CompletePrFwReq( TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: CompletePrFwReq status=%d"), aStatus );
+#endif
+    iOperation = ENoOperation;
+    iConnObs.CompleteReq( iPrFwId, aStatus  );
+    iPrFwId = TXIMPRequestId();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginAuthorization::HandleIfMine
+// ---------------------------------------------------------------------------
+//
+TBool CSimplePluginAuthorization::HandleIfMine( TXIMPRequestId aReqId, TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: HandleIfMine aStatus=%d iOper=%d"), aStatus, iOperation);
+#endif
+    TInt err = KErrNone;
+    TBool ret = EFalse;
+
+    // We check wheter the request is made by this entity.
+    if ( iPrFwId != aReqId )
+        {
+        // Nothing to do, request was not orginated by this entity.
+        }
+    else
+        {
+        if ( !aStatus )
+            {
+            switch ( iOperation )
+                {
+                case ESubscribePresenceGrantRequestList:
+                    // Modify rule to CONFIRM
+#ifdef _DEBUG
+                    PluginLogger::Log(_L("PluginAuthorization: HandleIfMine TEST COVERS 7"));
+#endif
+                    TRAP( err, DoStartXdmOperationL( aReqId, iOperation ));
+                    err = CSimplePluginConnection::HarmonizeErrorCode( err );
+                    ret = ETrue;
+                    break;
+                // In UnsubscribePresenceGrantRequestList case the rule modifcation
+                // has been made first before SIP unsubscribe operation.
+                case EUnsubscribePresenceGrantRequestList:
+                default:
+                    iWinfoSubs = EFalse;
+                    break;
+                }
+            }
+        else
+            {
+            CompletePrFwReq( err );
+            ret = ETrue;
+            }
+        if ( err )
+            {
+            CompletePrFwReq( err );
+            ret = ETrue;
+            }
+        else
+            {
+            }
+        }
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginAuthorization: HandleIfMine returns %d"), ret );
+#endif
+    return ret;
+    }
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simplepluginconnection.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,573 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#include <e32std.h>
+
+#include <ximpstatus.h>
+#include <ximpserviceinfo.h>
+#include <ximpcontextclientinfo.h>
+#include <ximpprotocolconnectionhost.h>
+#include <ximpfeatureinfo.h>
+#include <ximpidentity.h>
+#include <ximperrors.hrh>
+#include <presenceerrors.hrh>
+
+#include <protocolpresencedatahost.h>
+
+#include "simplepluginconnection.h"
+#include "simplepluginsession.h"
+#include "simpleplugindebugutils.h"
+#include "simplepluginauthorization.h"
+#include "simplepluginwinfo.h"
+#include "simplepluginpublisher.h"
+#include "simplepluginwatcher.h"
+#include "simpleplugingroups.h"
+#include "simplepluginxdmutils.h"
+#include "simplepluginvariation.h"
+#include "msimplepluginconnectionobs.h"
+#include "msimplepluginsettings.h"
+#include "simpleerrors.h"
+
+class MXIMPObjectFactory;
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::CSimplePluginConnection
+// ---------------------------------------------------------------------------
+//
+CSimplePluginConnection::CSimplePluginConnection()
+: iSipPresentity(NULL)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::NewL
+// ---------------------------------------------------------------------------
+//
+CSimplePluginConnection* CSimplePluginConnection::NewL( 
+    const MXIMPServiceInfo& aServiceInfo,
+    const MXIMPContextClientInfo& aClientCtxInfo )
+    {
+    CSimplePluginConnection* self = new( ELeave ) CSimplePluginConnection(  );
+    CleanupStack::PushL( self );
+    self->ConstructL( aServiceInfo, aClientCtxInfo );
+    CleanupStack::Pop( self );    
+    return self;
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginConnection::ConstructL( 
+    const MXIMPServiceInfo& aServiceInfo,
+    const MXIMPContextClientInfo& /* aClientCtxInfo */ )
+    {                  
+    iSession = CSimplePluginSession::NewL( aServiceInfo, *this ); 
+   
+    iAuth = CSimplePluginAuthorization::NewL( *this );   
+        
+    iPublisher = CSimplePluginPublisher::NewL(
+        *this, *this,        
+        *iSession->SimpleConnection() ); 
+        
+    iWatcher = CSimplePluginWatcher::NewL(
+        *this, *this,
+        *iSession->SimpleConnection() ); 
+        
+    iGroups = CSimplePluginGroups::NewL( 
+        *this );
+    
+    iPluginWinfo = CSimplePluginWinfo::NewL( 
+        *this, *(iSession->SimpleConnection()));  
+        
+    iVariation = CSimplePluginVariation::NewL();    
+    iVariation->InitL();      
+    }    
+
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::~CSimplePluginConnection
+// ---------------------------------------------------------------------------
+//
+CSimplePluginConnection::~CSimplePluginConnection()
+    {     
+    
+    delete iSipPresentity;
+    
+    delete iVariation;                   
+    delete iPluginWinfo;    
+    delete iWatcher;
+    delete iPublisher;
+    delete iAuth;   
+    delete iGroups; 
+    delete iSession;       
+    
+    delete iXdmUtils;    
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::PrimeHost
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginConnection::PrimeHost( MXIMPProtocolConnectionHost& aHost )
+    {
+    iConnectionHost = &aHost;
+    iAuth->SetDataHost( iConnectionHost->ProtocolPresenceDataHost().AuthorizationDataHost() );
+    }
+    
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::ProtocolPresenceFeatures
+// ---------------------------------------------------------------------------
+//  
+MProtocolPresenceFeatures& CSimplePluginConnection::ProtocolPresenceFeatures()
+    {
+    return *this;
+    }
+    
+/*<branchInfo originator="gronoff" since="08-06-06" category="new_feature" error=”none”>
+<pf_5250_OFF_CYCLE_SW_INT>
+</branchInfo>*/
+// BRANCH 08-06-17 : gronoff
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GetProtocolInterface()
+// ---------------------------------------------------------------------------
+// 
+TAny* CSimplePluginConnection::GetProtocolInterface( TInt /*aInterfaceId*/ )
+	{
+	return NULL;
+	}
+// BRANCH_END 08-06-17 : gronoff   
+
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::PresenceWatching
+// ---------------------------------------------------------------------------
+//
+MProtocolPresenceWatching& CSimplePluginConnection::PresenceWatching()
+    {   
+    return *iWatcher;
+    }
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::PresencePublishing
+// ---------------------------------------------------------------------------
+//
+MProtocolPresencePublishing& CSimplePluginConnection::PresencePublishing()
+    {
+    return *iPublisher;
+    }
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::PresentityGroups
+// ---------------------------------------------------------------------------
+//
+MProtocolPresentityGroups& CSimplePluginConnection::PresentityGroups()
+    {
+    return *iGroups;
+    }
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::PresenceAuthorization
+// ---------------------------------------------------------------------------
+//
+MProtocolPresenceAuthorization& CSimplePluginConnection::PresenceAuthorization()
+    {      
+    return *iAuth;
+    }
+    
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::OpenSessionL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginConnection::OpenSessionL(
+    const TInt& aSettingsId,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginConnection: OpenSessionL"));
+#endif             
+    iPrFwId = aReqId;
+    TRAPD( err, iSession->OpenSessionL( aSettingsId )); 
+    if ( err )
+        {
+        User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+        }     
+    }  
+
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::OpenSessionL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginConnection::OpenSessionL( 
+    const MXIMPContextClientInfo& /*aClientCtxInfo*/,
+    TXIMPRequestId /*aReqId*/ )
+    {   
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginConnection: OpenSessionL - error: not supported"));
+#endif    
+    User::Leave( KErrNotSupported );           
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::CloseSession
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginConnection::CloseSession( 
+    const MXIMPContextClientInfo& /*aClientCtxInfo*/,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginConnection: CloseSession"));
+#endif          
+    iPrFwId = aReqId;
+    
+    delete iPluginWinfo;
+    iPluginWinfo = NULL;    
+    delete iWatcher;
+    iWatcher = NULL;
+    delete iPublisher;
+    iPublisher = NULL;
+    delete iAuth;    
+    iAuth = NULL;
+    delete iSession;    
+    iSession = NULL;
+    delete iGroups;
+    iGroups = NULL; 
+    delete iXdmUtils;
+    iXdmUtils = NULL; 
+    
+    CompleteReq( iPrFwId, KErrNone );          
+    }
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::GetSupportedFeaturesL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginConnection::GetSupportedFeaturesL( CDesC8Array& aFeatures ) const
+    {
+    // first empty the whole array
+    aFeatures.Reset();   
+    using namespace NXIMPFeature::Presence;    
+    aFeatures.AppendL( KPublish );
+    aFeatures.AppendL( KFetch );    
+    aFeatures.AppendL( KSubscribe );    
+    aFeatures.AppendL( KUnsubscribe  );    
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::CompleteReq
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginConnection::CompleteReq( TReqType aType, TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginConnection: CompleteReq stat=%d"), aStatus);
+#endif         
+
+    TInt retVal = HarmonizeErrorCode( aStatus );
+    
+    // Return immediately if PrimeHost() is not called. This is for testing purposes. 
+    if ( !iConnectionHost )
+        {
+        iPrFwId = TXIMPRequestId(); 
+        return;
+        }
+                      
+    switch ( aType )
+        {
+        case EOpenSess:
+#ifdef _DEBUG
+    PluginLogger::Log(
+        _L("PluginConnection: callback HandleRequestCompleted stat=%d"), retVal);
+    PluginLogger::Log(
+        _L("PluginConnection: ------------------------------------------------1"));        
+#endif          
+            iConnectionHost->HandleRequestCompleted( iPrFwId, retVal );
+            iPrFwId = TXIMPRequestId();             
+            break;
+        default: 
+            break;   
+        };
+    }
+        
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::CompleteReq
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginConnection::CompleteReq( TXIMPRequestId aReqId, TInt aStatus )
+    {    
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginConnection: CompleteReq stat=%d"), aStatus);
+#endif
+
+    TInt retVal = HarmonizeErrorCode( aStatus );
+                   
+    // Return immediately if PrimeHost() is not called. This is for testing purposes.
+    if ( !iConnectionHost )
+        {
+        return;
+        }  
+#ifdef _DEBUG
+    PluginLogger::Log(
+        _L("PluginConnection: callback HandleRequestCompleted stat=%d"), retVal);
+    PluginLogger::Log(
+        _L("PluginConnection: ------------------------------------------------2"));        
+#endif              
+    iConnectionHost->HandleRequestCompleted( aReqId, retVal );
+    } 
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::CompleteWinfoReq
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginConnection::CompleteWinfoReq( TXIMPRequestId aReqId, TInt aStatus )
+    {    
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginConnection: CompleteWinfoReq stat=%d"), aStatus);
+#endif
+
+    if ( iAuth && iAuth->HandleIfMine( aReqId, aStatus ))
+        {
+        // Nothing to do, the request in not complete yet
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginConnection: CompleteWinfoReq waits ***"), aStatus);
+#endif         
+        }
+    else
+        {
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginConnection: CompleteWinfoReq completes ***"), aStatus);
+#endif        
+        CompleteReq( aReqId, aStatus );
+        }
+    }                  
+     
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::ObjectFactory
+// ---------------------------------------------------------------------------
+// 
+MXIMPObjectFactory& CSimplePluginConnection::ObjectFactory()
+    {
+    return iConnectionHost->ObjectFactory();
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::PresenceObjectFactory
+// ---------------------------------------------------------------------------
+// 
+MPresenceObjectFactory& CSimplePluginConnection::PresenceObjectFactory()
+    {
+    return iConnectionHost->ProtocolPresenceDataHost().PresenceObjectFactory();    
+    }     
+  
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::Host
+// ---------------------------------------------------------------------------
+//     
+MXIMPProtocolConnectionHost* CSimplePluginConnection::Host()
+    {
+    return iConnectionHost;
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::CurrentDomain
+// ---------------------------------------------------------------------------
+//     
+TPtrC16 CSimplePluginConnection::CurrentDomain()
+    {
+    return iSession->CurrentDomain();    
+    } 
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::Variation
+// ---------------------------------------------------------------------------
+//     
+CSimplePluginVariation& CSimplePluginConnection::Variation()
+    {
+    return *iVariation; 
+    }        
+           
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::CurrentSipPresentity
+// ---------------------------------------------------------------------------
+// 
+TPtrC16 CSimplePluginConnection::CurrentSipPresentity()
+    {       
+    delete iSipPresentity;
+    iSipPresentity = NULL;    
+    TRAPD( err, iSipPresentity = HBufC16::NewL( iSession->CurrentSipPresentity().Length() ));
+        
+    if ( !err )
+        {                
+        iSipPresentity->Des().Copy( iSession->CurrentSipPresentity() );
+        return iSipPresentity->Des();
+        }
+    else
+        {
+        return TPtrC16();
+        }        
+    }     
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::CurrentSipPresentit8
+// ---------------------------------------------------------------------------
+// 
+TPtrC8 CSimplePluginConnection::CurrentSipPresentity8()
+    {
+    return iSession->CurrentSipPresentity();
+    } 
+            
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::XdmUtilsL
+// ---------------------------------------------------------------------------
+//
+CSimplePluginXdmUtils* CSimplePluginConnection::XdmUtilsL()
+    {
+    if ( !iXdmUtils )
+        {                
+        iXdmUtils = CSimplePluginXdmUtils::NewL( 
+            *this, iSession->XdmSettingsId() );
+        }
+    return iXdmUtils;
+    }
+            
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::WinfoHandlerL
+// ---------------------------------------------------------------------------
+//
+CSimplePluginWinfo* CSimplePluginConnection::WinfoHandlerL()
+    {
+    if ( !iPluginWinfo )
+        {
+        iPluginWinfo = CSimplePluginWinfo::NewL( 
+            *this, *(iSession->SimpleConnection() ));
+        }
+    iPluginWinfo->SetHost( iConnectionHost );
+    return iPluginWinfo;
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::WinfoTerminatedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginConnection::WinfoTerminatedL( TInt aReason )
+    {
+    // Pass the information to iAuth and iPublisher,
+    // so that they can call PrFw Plugin Data Host callbacks.
+    iAuth->WinfoTerminatedL( aReason );
+    iPublisher->WinfoTerminatedL( aReason );
+    }  
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::WinfoNotification
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginConnection::WinfoNotification( MSimpleWinfo& aWinfo )
+    {
+    TRAP_IGNORE( iPublisher->WinfoNotificationL( aWinfo ));    
+    TRAP_IGNORE( iAuth->WinfoNotificationL( aWinfo ));
+    }      
+            
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::GetInterface
+// ---------------------------------------------------------------------------
+//
+TAny* CSimplePluginConnection::GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOptions )
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        MXIMPProtocolConnection* myIf = this;
+        return myIf;
+        }
+    if( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }  
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::GetInterface
+// ---------------------------------------------------------------------------
+//
+const TAny* CSimplePluginConnection::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        const MXIMPProtocolConnection* myIf = this;
+        return myIf;
+        }
+    if( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }  
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::GetInterfaceId
+// ---------------------------------------------------------------------------
+//
+TInt32 CSimplePluginConnection::GetInterfaceId() const
+    {
+    return MXIMPProtocolConnection::KInterfaceId;
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginConnection::HarmonizeErrorCode
+// ---------------------------------------------------------------------------
+//
+TInt CSimplePluginConnection::HarmonizeErrorCode( TInt aStatus )
+    {    
+
+    TInt retVal = aStatus;
+
+    // Convert error codes outsise e32err.h error range into PrFw errors.
+
+    switch ( aStatus )
+        {
+        case KSimpleErrAuthorization:
+            retVal = KPresenceErrNotEnoughCredits;
+            break;
+        case KSimpleErrTimeout:
+        case KErrTimedOut:
+            retVal = KXIMPErrServicRequestTimeouted;
+            break;            
+        default:
+            {
+            if ( aStatus < KSimplePluginGeneralErrorLow )
+                {
+                retVal = KXIMPErrServiceGeneralError;
+                }
+            }
+            break;                                
+        };
+        
+    return retVal;    
+    }
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simpleplugindata.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,776 @@
+/*
+* 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:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+
+// *** system include files go here:
+#include <e32std.h>
+#include <s32strm.h>
+#include <utf.h>
+
+#include <presenceobjectfactory.h>
+#include <presenceinfo.h>
+#include <personpresenceinfo.h>
+#include <presenceinfofieldcollection.h>
+#include <presenceinfofield.h>
+#include <presenceinfofieldvaluetext.h>
+#include <presenceinfofieldvalueenum.h>
+#include <presenceinfofieldvaluebinary.h>
+#include <presenceinfofieldvalueenum.h>
+#include <presenceerrors.hrh>
+
+#include <ximpobjectfactory.h>
+#include <ximpidentity.h>
+#include <ximpdatasubscriptionstate.h>
+#include <ximpprotocolconnectionhost.h>
+#include <ximpstatus.h>
+
+#include <msimpledocument.h>
+#include <msimpleelement.h>
+#include <msimplepresencelist.h>
+#include <msimplemeta.h>
+#include <msimplecontent.h>
+#include <simpleutils.h>
+#include <simplefactory.h>
+
+#include "simpleplugindata.h"
+#include "simpleplugincommon.h"
+#include "simpleplugindebugutils.h"
+
+
+// ----------------------------------------------------------
+// CSimplePluginData::CSimplePluginData
+// ----------------------------------------------------------
+//
+CSimplePluginData::CSimplePluginData( )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::~CSimplePluginData
+// ---------------------------------------------------------------------------
+//
+CSimplePluginData::~CSimplePluginData()
+    {
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::NewL
+// ---------------------------------------------------------------------------
+//
+CSimplePluginData* CSimplePluginData::NewL( )
+    {
+    CSimplePluginData* self = CSimplePluginData::NewLC( );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::NewLC
+// ---------------------------------------------------------------------------
+//
+CSimplePluginData* CSimplePluginData::NewLC( )
+    {
+    CSimplePluginData* self = new( ELeave ) CSimplePluginData;
+    CleanupStack::PushL( self );
+    self->ConstructL(  );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginData::ConstructL( )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::NotifyToPrInfoL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginData::NotifyToPrInfoL(
+        MPresenceObjectFactory& aPresenceFactory,
+        MSimpleDocument& aDocument,
+        MPresenceInfo& aPrInfo )
+    {
+    MPersonPresenceInfo* persInfo = aPresenceFactory.NewPersonPresenceInfoLC();
+    MPresenceInfoFieldCollection& coll = persInfo->Fields();
+
+    // Search own person info. Notice: Extend supported attributes later
+
+    RPointerArray<MSimpleElement> elems;
+    CleanupClosePushL( elems );
+    TInt err = aDocument.SimpleElementsL( elems );
+
+    if ( !err )
+        {
+        TInt myLatestPosition = SearchLatestTimestampL( elems );
+
+        if ( myLatestPosition != KErrNotFound )
+            {
+            MSimpleElement* elem = elems[myLatestPosition];
+
+            using namespace NSimplePlugin::NSimpleOma;
+
+            // person element found
+            RPointerArray<MSimpleElement> elems2;
+            CleanupClosePushL( elems2 );
+            elem->SimpleElementsL( elems2 );
+            TInt count2 = elems2.Count();
+
+            for ( TInt j = 0; j < count2; j++ )
+                {
+                MSimpleElement* elem2 = elems2[j];
+                if ( !elem2->LocalName().CompareF( KSimpleOverridingwillingness8 ))
+                    {
+                    UserOverridingWillingnessToPrFwL( aPresenceFactory, elem2, coll );
+                    }
+                else if ( !elem2->LocalName().CompareF( KSimpleStatusicon8 ))
+                    {
+                    UserStatusIconToPrFwL( aPresenceFactory, elem2, coll, aDocument );
+                    }
+                else if ( !elem2->LocalName().CompareF( KSimpleNote8 ))
+                    {
+                    UserNoteToPrFwL( aPresenceFactory, elem2, coll );
+                    }
+                }
+
+            CleanupStack::PopAndDestroy( &elems2 );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &elems );
+
+    aPrInfo.SetPersonPresenceL( persInfo );
+    CleanupStack::Pop();   // >> persInfo
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::UserOverridingWillingnessToPrFwL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginData::UserOverridingWillingnessToPrFwL(
+        MPresenceObjectFactory& aPresenceFactory,
+        MSimpleElement* aElement,
+        MPresenceInfoFieldCollection& aCollection )
+    {
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginData: UserOverridingWillingnessToPrFwL") );
+#endif
+    using namespace NSimplePlugin::NSimpleOma;
+
+    RPointerArray<MSimpleElement> elems;
+    CleanupClosePushL( elems );
+    User::LeaveIfError( aElement->SimpleElementsL( elems ));
+    MSimpleElement* elem3 = elems[0]; // notice: we assume that there is no other sub-elements
+    if ( !elem3->LocalName().CompareF( KSimpleBasic8 ))
+        {
+        // write the data into text field.
+        HBufC* nodeContent = elem3->ContentUnicodeL();
+        CleanupStack::PushL( nodeContent );
+        if ( nodeContent )
+            {
+            // Save availability
+            using namespace NPresenceInfo::NFieldType;
+            MPresenceInfoField* field = aPresenceFactory.NewInfoFieldLC();
+            field->SetFieldTypeL( KAvailability );
+            MPresenceInfoFieldValueText* text = aPresenceFactory.NewTextInfoFieldLC();
+            text->SetTextValueL( nodeContent->Des() );
+            field->SetFieldValue( text );
+            CleanupStack::Pop();            // >> text
+            aCollection.AddOrReplaceFieldL( field );
+            CleanupStack::Pop();            // >> field
+            }
+        CleanupStack::PopAndDestroy( nodeContent );
+        }
+    CleanupStack::PopAndDestroy( &elems );  // close the array, do not delete the content
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::UserStatusIconToPrFwL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginData::UserStatusIconToPrFwL(
+        MPresenceObjectFactory& aPresenceFactory,
+        MSimpleElement* aElement,
+        MPresenceInfoFieldCollection& aCollection,
+        MSimpleDocument& aDocument )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginData: UserStatusIconToPrFwL") );
+#endif
+    using namespace NSimpleDocument;
+
+    using namespace NPresenceInfo::NFieldType;
+
+    HBufC* nodeContent = aElement->ContentUnicodeL();
+    CleanupStack::PushL( nodeContent );
+    if ( nodeContent )
+        {
+        RPointerArray<MSimpleContent> contents;
+        CleanupClosePushL( contents );
+
+        // Search the corresponding direct content
+        aDocument.GetDirectContentsL( contents );
+
+        TInt contCount = contents.Count();
+        for ( TInt i = 0; i<contCount; i++ )
+            {
+            TPtrC8 id = (contents[i])->ContentID();
+            // nodecontent = "cid:simple.avatar.com"
+            // content-id: simple.avatar.com
+            HBufC8* cid8 = NULL;
+            cid8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( nodeContent->Des() );
+            CleanupStack::PushL( cid8 ); // << cid8
+
+            TInt contentLen = cid8->Des().Length() - 4;  // "cid:"
+            TInt headLen = id.Length();
+            TPtrC8 pUnquoted( KNullDesC8 );
+            if ( id.Locate('"') == 0 )
+                {
+                // remove "..." characters
+                pUnquoted.Set( id.Mid( 1, headLen-2 ));
+                }
+            else
+                {
+                pUnquoted.Set( id );
+                }
+            TInt foundPos = cid8->Des().Find( pUnquoted );
+            if ( contentLen == headLen && foundPos >= 0 )
+                {
+                MPresenceInfoField* field = aPresenceFactory.NewInfoFieldLC();
+                field->SetFieldTypeL( KAvatar );
+                MPresenceInfoFieldValueBinary* val = aPresenceFactory.NewBinaryInfoFieldLC();
+                val->SetMimeTypeL( (contents[i])->ContentType() );
+                // Body is not BASE64 encoded internally
+                val->SetBinaryValueL( (contents[i])->Body() );
+                field->SetFieldValue( val );
+                CleanupStack::Pop();                // >> val
+                aCollection.AddOrReplaceFieldL( field );
+                CleanupStack::Pop();                // >> field
+                }
+            CleanupStack::PopAndDestroy( cid8 ); // >> cid8
+            }
+        CleanupStack::PopAndDestroy( &contents );
+        }
+    CleanupStack::PopAndDestroy( nodeContent );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::UserNoteToPrFwL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginData::UserNoteToPrFwL(
+        MPresenceObjectFactory& aPresenceFactory,
+        MSimpleElement* aElement,
+        MPresenceInfoFieldCollection& aCollection )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginData: UserNoteToPrFwL") );
+#endif
+    // using namespace NSimplePlugin::NSimpleOma;
+    HBufC* nodeContent = aElement->ContentUnicodeL();
+    CleanupStack::PushL( nodeContent );
+    if ( nodeContent )
+        {
+        // Save note, convert from unicode
+        // notice: consider xml::lang-attribute
+        // note <-> KStatusMessage
+        using namespace NPresenceInfo::NFieldType;
+        MPresenceInfoField* field = aPresenceFactory.NewInfoFieldLC();
+        field->SetFieldTypeL( KStatusMessage );
+        MPresenceInfoFieldValueText* text = aPresenceFactory.NewTextInfoFieldLC();
+        text->SetTextValueL( nodeContent->Des() );
+        field->SetFieldValue( text );
+        CleanupStack::Pop();            // >> text
+        aCollection.AddOrReplaceFieldL( field );
+        CleanupStack::Pop();            // >> field
+        }
+    CleanupStack::PopAndDestroy( nodeContent );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::NotifyListToPrInfoL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginData::NotifyListToPrInfoL(
+    MXIMPObjectFactory& aFactory,
+    MPresenceObjectFactory& aPresenceFactory,
+    MSimplePresenceList& aList,
+    RPointerArray<MPresenceInfo>& aEntities,
+    RPointerArray<MXIMPIdentity>& aActives,
+    RPointerArray<MXIMPIdentity>& aTerminated,
+    TBool& aFullList )
+    {
+    // Split array into individual prInfos
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginData: NotifyListToPrInfoL") );
+#endif
+
+    RPointerArray<MSimpleDocument> docs;
+    CleanupClosePushL( docs );
+    // get documents, ownership is not transferred.
+    aList.GetDocuments( docs );
+
+    CollectAllPresentitiesL( aEntities, aActives, docs, aFactory, aPresenceFactory );
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    MSimpleMeta* meta = aList.MetaData();
+
+#ifdef _DEBUG
+    // TODO: remove
+    if ( meta == NULL )
+    PluginLogger::Log(_L("PluginData: META Is NULL !!! *****"));
+#endif
+
+
+
+    // ownership in not transferred
+    if ( meta && !meta->LocalName().CompareF( KSimpleList8 ))
+        {
+        // list element found, find out if fullstate
+        const TDesC8* fullStateVal = meta->AttrValue( KSimpleFullState8 );
+        if ( fullStateVal && !fullStateVal->CompareF( KSimpleTrue8 ))
+            {
+            aFullList = ETrue;
+            }
+        else
+            {
+            aFullList = EFalse;
+            }
+
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginData: fullState === %d"), aFullList );
+#endif
+
+        // Search "terminated" presentities
+        RPointerArray<MSimpleElement> elems2;
+        CleanupClosePushL( elems2 );
+        meta->SimpleElementsL( elems2);
+        CollectTerminatedPresentitiesL( aTerminated, elems2, aFactory );
+        CleanupStack::PopAndDestroy( &elems2 );
+        }
+
+    CleanupStack::PopAndDestroy( &docs );
+    }
+
+        /*
+        example:
+   Content-Transfer-Encoding: binary
+   Content-ID: <nXYxAE@pres.vancouver.example.com>
+   Content-Type: application/rlmi+xml;charset="UTF-8"
+
+   <?xml version="1.0" encoding="UTF-8"?>
+   <list xmlns="urn:ietf:params:xml:ns:rlmi"
+         uri="sip:adam-friends@pres.vancouver.example.com"
+         version="1" fullState="true">
+     <name xml:lang="en">Buddy List at COM</name>
+     <name xml:lang="de">Liste der Freunde an COM</name>
+     <resource uri="sip:bob@vancouver.example.com"">        <------- note
+       <name>Bob Smith</name>
+       <instance id="juwigmtboe" state="active"
+                 cid="bUZBsM@pres.vancouver.example.com"/>
+     </resource>
+     <resource uri="sip:dave@vancouver.example.com">
+       <name>Dave Jones</name>
+       <instance id="hqzsuxtfyq" state="active"
+                 cid="ZvSvkz@pres.vancouver.example.com"/>
+     </resource>
+     <resource uri="sip:ed@dallas.example.net">
+       <name>Ed at NET</name>
+     </resource>
+     <resource uri="sip:adam-friends@stockholm.example.org">
+       <name xml:lang="en">My Friends at ORG</name>
+       <name xml:lang="de">Meine Freunde an ORG</name>
+     </resource>
+   </list>
+        */
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::AddPrPersToSimpleDocumentL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginData::AddPrPersToSimpleDocumentL(
+    const MPersonPresenceInfo* aInfo,
+    MSimpleDocument& aDocument,
+    const TDesC8& aSipId )
+    {
+    using namespace NSimpleDocument;
+
+    TPtrC8 p8( KSimpleAvatarCIDURI8 );
+    TInt bufSize = p8.Length();
+
+    HBufC16* CIDcontent = HBufC16::NewLC( bufSize );   // << CID
+    CIDcontent->Des().Copy( KSimpleAvatarCIDURI8 );
+
+    // notice: we do not generate random id but a static one.
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    aDocument.SetEntityURIL( aSipId );
+
+    MSimpleElement* persElem = aDocument.AddSimpleElementL(
+        KSimpleNsPDM, KSimplePerson8 );
+    CleanupClosePushL( *persElem );             // << persElem
+
+    using namespace NPresenceInfo::NFieldType;
+
+    const MPresenceInfoFieldCollection& coll = aInfo->Fields();
+
+    TInt myCount = coll.FieldCount();
+    for ( TInt i = 0; i < myCount; i++ )
+        {
+        const MPresenceInfoField& field =  coll.FieldAt( i );
+        const TDesC8& fieldType = field.FieldType();
+        const MXIMPBase& storage = field.FieldValue();
+
+        // Notice: tuple id saving for partial data in future.
+
+        /*
+        Mapping:
+        Avatar -> Person/status-icon
+        status-msg -> Person/note
+        Availability -> Person/overriding-willingness
+        */
+
+        if ( !fieldType.CompareF( KAvatar ) )
+            {
+            const MPresenceInfoFieldValueBinary* bin =
+                  TXIMPGetInterface< const MPresenceInfoFieldValueBinary >::From( storage,
+                  MXIMPBase::EReturnNullIfUnknown );
+            if ( bin )
+                {
+                MSimpleElement* elem = persElem->AddSimpleElementL(
+                        KSimpleNsRPID,
+                        KSimpleStatusicon8 );
+                CleanupClosePushL( *elem );             // << elem
+                elem->SetContentUnicodeL( CIDcontent->Des());
+                // Create the MIME multipart content
+                MSimpleContent* content = TSimpleFactory::NewContentL(
+                    KSimpleAvatarContent8, bin->MimeType() );
+                CleanupClosePushL( *content );          // << content
+                content->CopyBodyL( bin->BinaryValue( ) );
+                aDocument.AddDirectContentL( *content, EFalse );
+                CleanupStack::PopAndDestroy( content );         // >> content
+                CleanupStack::PopAndDestroy( elem );  // >> elem
+                }
+            }
+        else if ( !fieldType.CompareF( KStatusMessage ) )
+            {
+            const MPresenceInfoFieldValueText* text =
+                  TXIMPGetInterface< const MPresenceInfoFieldValueText >::From( storage,
+                  MXIMPBase::EReturnNullIfUnknown );
+            if ( text )
+                {
+                MSimpleElement* elem = persElem->AddSimpleElementL(
+                    KSimpleNsPDM,
+                    KSimpleNote8 );
+                CleanupClosePushL( *elem );             // << elem
+                elem->SetContentUnicodeL( text->TextValue() );
+                CleanupStack::PopAndDestroy( elem );  // >> elem
+                }
+            }
+        else if ( !fieldType.CompareF( KAvailability ))
+            {
+            const MPresenceInfoFieldValueText* text =
+                  TXIMPGetInterface< const MPresenceInfoFieldValueText >::From( storage,
+                  MXIMPBase::EReturnNullIfUnknown );
+            if ( text )
+                {
+                AddPrPersAvailabilityToDocL( text, persElem );
+                }         
+            }
+        else
+            {
+            // Notice: currently all the fields in the namespace are supported,
+            // but this ensures that if namespace is extended later, it is
+            // handled right way in the adaptation
+            User::Leave( KPresenceErrPresenceInfoFieldTypeNotSupported );
+            }
+        }
+    CleanupStack::PopAndDestroy( persElem );
+    CleanupStack::PopAndDestroy( CIDcontent );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::CollectAllPresentitiesL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginData::CollectAllPresentitiesL(
+    RPointerArray<MPresenceInfo>& aEntities,
+    RPointerArray<MXIMPIdentity>& aActives,
+    RPointerArray<MSimpleDocument>& aDocs,
+    MXIMPObjectFactory& aFactory,
+    MPresenceObjectFactory& aPresenceFactory )
+    {
+    TInt count = aDocs.Count();
+
+    // active presentities
+    for ( TInt i = 0; i < count; i++ )
+        {
+        MPresenceInfo* info = aPresenceFactory.NewPresenceInfoLC();   // << info
+        aEntities.AppendL( info );
+        // aEntities may contain entries even this method leaves
+        CleanupStack::Pop();                                      // >> info
+
+        NotifyToPrInfoL( aPresenceFactory, *aDocs[i], *info );
+
+        // Add SIP identity to active users list
+        MXIMPIdentity* active = aFactory.NewIdentityLC();  // << active
+        aActives.AppendL( active );
+        CleanupStack::Pop();                            // >> active
+
+        // Convert SIP entity URI from UTF to Unicode.
+        const TDesC8* pUri8 = (aDocs[i])->EntityURI();
+        HBufC16* uri16 = NULL;
+        uri16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *pUri8 );
+        CleanupStack::PushL( uri16 );  // << uri16
+        active->SetIdentityL( uri16->Des() );
+
+#ifdef _DEBUG
+    // ---------------------------------------------------------
+    TBuf<200> buffer2;
+    buffer2.Copy(uri16->Des());
+    const MPersonPresenceInfo* pers_debug = info->PersonPresence();
+    const MPresenceInfoFieldCollection& coll_debug = pers_debug->Fields();
+    TInt count_debug = coll_debug.FieldCount();
+    PluginLogger::Log(_L("PluginData: nbr of fields received =%d"), count_debug );
+    PluginLogger::Log(_L("PluginData: User added to actives: %S"), &buffer2 );
+    // ---------------------------------------------------------
+#endif
+        CleanupStack::PopAndDestroy( uri16 );  // >> uri16
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::CollectTerminatedPresentitiesL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginData::CollectTerminatedPresentitiesL(
+    RPointerArray<MXIMPIdentity>& aTerminated,
+    RPointerArray<MSimpleElement>& aElems,
+    MXIMPObjectFactory& aFactory )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginData: CollectTerminatedPresentitiesL"));
+#endif
+    using namespace NSimplePlugin::NSimpleOma;
+
+    TInt count2 = aElems.Count();
+    for ( TInt i = 0; i < count2; i++ )
+        {
+        MSimpleElement* elem2 = aElems[i];
+        if ( !elem2->LocalName().CompareF( KSimpleResource8 ))
+            {
+            // resource element
+            RPointerArray<MSimpleElement> elems3;
+            CleanupClosePushL( elems3 );
+            elem2->SimpleElementsL( elems3 );
+            TInt count3 = elems3.Count();
+            const TDesC8* uri8 = elem2->AttrValue( KSimpleUri8 );
+            if ( !uri8 )
+                {
+                continue;
+                }
+            for ( TInt j=0; j < count3; j++ )
+                {
+                MSimpleElement* elem3 = elems3[j];
+                SearchTerminatedInstanceL( aTerminated, elem3, uri8, aFactory  );
+                }
+            CleanupStack::PopAndDestroy( &elems3 );
+            } // resource element
+        }// for (i); list element subelement
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginData: CollectTerminatedPresentitiesL ends"));
+#endif
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::SearchLatestTimestampL
+// ---------------------------------------------------------------------------
+//
+TInt CSimplePluginData::SearchLatestTimestampL(
+    RPointerArray<MSimpleElement>& aElems  )
+    {
+    TInt ret = KErrNotFound;
+
+    const TInt KMaxTimestamp = 40;
+    TBuf<KMaxTimestamp> myTimestamp;
+
+    // Timestamp to save the latest one person data
+    myTimestamp = KNullDesC;
+
+    // They want to get empty notifications too.
+    TInt count = aElems.Count();
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    MSimpleElement* elem = NULL;
+    TPtrC8 p8;
+
+    for ( TInt i = 0; i < count; i++ )
+        {
+        elem = aElems[i];
+        p8.Set( elem->LocalName());
+        if (!( p8.CompareF( KSimplePerson8 )))
+            {
+
+            if ( ret == KErrNotFound )
+                {
+                // Save since the time stamp is optional, this is first <person> .
+                // the whole <person> may also be missing.
+                ret = i;
+                }
+
+            // person element found
+            RPointerArray<MSimpleElement> elems2;
+            CleanupClosePushL( elems2 );
+            elem->SimpleElementsL( elems2 );
+            TInt count2 = elems2.Count();
+
+            // Search optional timestamp element first, the latest one
+            for ( TInt j = 0; j < count2; j++ )
+                {
+                //
+                MSimpleElement* elem2 = elems2[j];
+                // Search optional timestamp element
+                if ( !elem2->LocalName().CompareF( KSimpleTimestamp8 ))
+                    {
+                    HBufC* nodeContent = elem2->ContentUnicodeL();
+                    // Notice: Timestamp comparision assumes now
+                    // that all the timestamps have a similar format.
+                    if ( myTimestamp.Compare( nodeContent->Des() ) < 0 )
+                        {
+                        // Save latest timestamp
+                        myTimestamp.Copy( nodeContent->Des() );
+                        ret = i;
+                        }
+                    delete nodeContent;
+                    }
+                }
+            CleanupStack::PopAndDestroy( &elems2 );
+            }
+        }  // for
+
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::AddPrPersAvailabilityToDocL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginData::AddPrPersAvailabilityToDocL(
+    const MPresenceInfoFieldValueText* aText, MSimpleElement* aPersElem )
+    {
+    using namespace NSimplePlugin::NSimpleOma;
+
+    MSimpleElement* elem = aPersElem->AddSimpleElementL(
+            KSimpleNsOP,
+            KSimpleOverridingwillingness8 );
+    CleanupClosePushL( *elem );             // << elem
+    MSimpleElement* elem2 = elem->AddSimpleElementL(
+            KSimpleNsOP,
+            KSimpleBasic8 );
+    CleanupClosePushL( *elem2 );             // << elem2
+    if ( !aText->TextValue().CompareF( KSimpleOpen ) )
+        {
+        elem2->SetContentUnicodeL( KSimpleOpen );
+        }
+    else 
+        {
+        elem2->SetContentUnicodeL( KSimpleClosed );
+        }
+    CleanupStack::PopAndDestroy( elem2 ); // >> elem2
+    CleanupStack::PopAndDestroy( elem );  // >> elem
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginData::SearchTerminatedInstanceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginData::SearchTerminatedInstanceL(
+    RPointerArray<MXIMPIdentity>& aTerminated,
+    MSimpleElement* aElem,
+    const TDesC8* uri8,
+    MXIMPObjectFactory& aFactory )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginData: SearchTerminatedInstanceL"));
+#endif
+
+    using namespace NSimplePlugin::NSimpleOma;
+    if ( !aElem->LocalName().CompareF( KSimpleInstance8 ))
+        {
+        // instance element
+        const TDesC8* stateVal = aElem->AttrValue( KSimpleState8 );
+        if ( stateVal && !stateVal->CompareF( KSimpleTerminated8 ))
+            {
+            // Add presentity into terminated list
+            MXIMPIdentity* terminated = aFactory.NewIdentityLC();  // +terminated
+            aTerminated.AppendL( terminated );
+            CleanupStack::Pop();                   // -terminated
+
+            // Convert SIP entity URI from UTF to Unicode.
+            HBufC16* uri16 = NULL;
+            uri16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *uri8 );
+            CleanupStack::PushL( uri16 );  // +uri16
+            terminated->SetIdentityL( uri16->Des() );
+
+#ifdef _DEBUG
+            // Debug buffer size
+            const TInt KMyBufSize = 200;
+            // ---------------------------------------------------------
+            TBuf<KMyBufSize> buffer3;
+            buffer3.Copy(uri16->Des());
+            PluginLogger::Log(_L("PluginData:   SearchTerminatedInstanceL TERMINATED INSTANCE FOUND ***"));
+            PluginLogger::Log(_L("PluginData:   User added to terminated: %S"), &buffer3 );
+            // ---------------------------------------------------------
+#endif
+            CleanupStack::PopAndDestroy( uri16 );   // -uri16
+            }
+        else
+            {
+            // -------------------------------------------------------------
+#ifdef _DEBUG
+            if ( stateVal != NULL )
+                {
+                // Debug buffer size
+                const TInt KMyBufSize = 100;
+                HBufC16* uri16 = NULL;
+                uri16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *stateVal );
+                CleanupStack::PushL( uri16 );  // +uri16
+                TBuf<KMyBufSize> buffer4;
+                buffer4.Copy(uri16->Des());
+                PluginLogger::Log(_L("    STATEVAL: %S"), &buffer4 );
+                CleanupStack::PopAndDestroy( uri16 );   // -uri16
+                }
+#endif
+            // -------------------------------------------------------------
+            }
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simpleplugindebugutils.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    DEBUG utilities, for DEBUG version only
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+
+#ifdef _DEBUG
+#include <flogger.h>
+#include <e32debug.h>
+#include <apparc.h>
+#include <bautils.h>
+
+#include "simpleplugindebugutils.h"
+
+//**********************************
+// PluginLogger
+//**********************************
+const TInt KLogBufferLength = 256;
+
+// ---------------------------------------------------------
+// PluginLogger::Log
+// ---------------------------------------------------------
+//
+void PluginLogger::Log(TRefByValue<const TDesC> aFmt,...)
+    {
+    VA_LIST list;
+    VA_START(list, aFmt);
+
+    // Print to log file
+    TBuf<KLogBufferLength> buf;
+    buf.FormatList(aFmt, list);
+
+    _LIT(KLogDir, "simple");
+    _LIT(KLogFile, "simple.txt");
+    // Write to log file
+    RFileLogger::Write(KLogDir, KLogFile, EFileLoggingModeAppend, buf);
+    }
+
+#endif  // _DEBUG
+
+
+
+//  End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simplepluginentitywatcher.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,459 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#include <e32std.h>
+#include <utf.h>
+
+#include <ximpdatasubscriptionstate.h>
+#include <personpresenceinfo.h>
+#include <protocolpresencewatchingdatahost.h>
+#include <presenceinfo.h>
+#include <presenceinfofieldcollection.h>
+#include <presenceinfofield.h>
+#include <presenceinfofieldvaluetext.h>
+#include <presenceinfofieldvalueenum.h>
+#include <presenceobjectfactory.h>
+#include <presentitygroupmemberinfo.h>
+#include <protocolpresencedatahost.h>
+#include <protocolpresentitygroupsdatahost.h>
+#include <ximpobjectcollection.h>
+#include <ximpobjectfactory.h>
+#include <ximpprotocolconnectionhost.h>
+#include <ximpstatus.h>
+#include <ximpidentity.h>
+
+#include <simplefactory.h>
+
+#include <msimplewinfo.h>
+#include <msimplewatcher.h>
+#include <msimpledocument.h>
+#include <msimpleelement.h>
+
+#include "simpleplugincommon.h"
+#include "simplepluginentitywatcher.h"
+#include "simpleplugindebugutils.h"
+#include "simpleplugindata.h"
+#include "simpleutils.h"
+#include "simplepluginwatcher.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::CSimplePluginEntityWatcher
+// ---------------------------------------------------------------------------
+//
+CSimplePluginEntityWatcher::CSimplePluginEntityWatcher(
+    MSimplePluginConnectionObs& aObs,
+    MSimpleConnection& aConn,
+    CSimplePluginWatcher& aWatcher
+     )
+  : iPluginWatcher(aWatcher), iConnObs(aObs), iConnection(aConn),
+  iOperation(EPluginIdle)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginEntityWatcher::ConstructL( )
+    {
+    iWatcher = TSimpleFactory::NewWatcherL( iConnection, *this );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::NewL
+// ---------------------------------------------------------------------------
+//
+CSimplePluginEntityWatcher* CSimplePluginEntityWatcher::NewL(
+    MSimplePluginConnectionObs& aObs,
+    MSimpleConnection& aConn,
+    CSimplePluginWatcher& aWatcher )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginEntityWatcher: NewL"));
+#endif
+    CSimplePluginEntityWatcher* self =
+        new( ELeave ) CSimplePluginEntityWatcher( aObs, aConn, aWatcher );
+    CleanupStack::PushL( self );
+    self->ConstructL(  );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::~CSimplePluginEntityWatcher
+// ---------------------------------------------------------------------------
+//
+CSimplePluginEntityWatcher::~CSimplePluginEntityWatcher()
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginEntityWatcher: DESTRUCTOR"));
+#endif
+    if ( iWatcher )
+        {
+        iWatcher->Close();
+        }
+    delete iEntityId;
+    delete iSimpleEntityId;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::StartSubscribeL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginEntityWatcher::StartSubscribeL(
+    const TDesC8& aPresentityId )
+    {
+    delete iEntityId;
+    iEntityId = NULL;
+
+    iListSubsActive = EFalse;
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginEntityWatcher: -> SubscribeL"));
+#endif
+    iSimpleId = iWatcher->SubscribeL( aPresentityId, NULL, ETrue, EFalse );
+
+    // Save entity id after successful call
+    iEntityId = aPresentityId.AllocL();
+
+    iOperation = EPluginStart;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::StartSubscribeListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginEntityWatcher::StartSubscribeListL(
+    const TDesC8& aPresentityId )
+    {
+    delete iEntityId;
+    iEntityId = NULL;
+
+    iListSubsActive = ETrue;
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginEntityWatcher: -> SubscribeListL"));
+#endif
+    iSimpleId = iWatcher->SubscribeListL( aPresentityId, NULL, ETrue, EFalse );
+
+    // Save entity id after successful call
+    iEntityId = aPresentityId.AllocL();
+
+    iOperation = EPluginStart;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::SetSimpleNameL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginEntityWatcher::SetSimpleNameL(
+    const TDesC8& aPresentityId )
+    {
+    delete iSimpleEntityId;
+    iSimpleEntityId = NULL;
+
+
+    // Save entity id after successful call
+    iSimpleEntityId = aPresentityId.AllocL();
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::StopSubscribeL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginEntityWatcher::StopSubscribeL(
+     )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginEntityWatcher: -> UnsubscribeL"));
+#endif
+    iSimpleId = iWatcher->UnsubscribeL( );
+    iOperation = EPluginStop;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::WatcherReqCompleteL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginEntityWatcher::WatcherReqCompleteL(
+    TInt /*aOpId*/, TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginEntityWatcher: WatcherReqCompleteL"));
+#endif
+    TPluginEntityWatcherOperation orig = iOperation;
+    iOperation = EPluginIdle;
+
+    CompleteClientReq( aStatus );
+
+    if ( aStatus && ( orig == EPluginStop || orig == EPluginStart) )
+        {
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginEntityWatcher: calls DeleteWatcher **"));
+#endif
+        // Delete this entity as useless
+        iPluginWatcher.DeleteWatcher( iEntityId->Des() );
+        // Do not call anything, since the method call above deletes this instance.
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::WatcherNotificationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginEntityWatcher::WatcherNotificationL(
+    MSimpleDocument& aDocument )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginEntityWatcher: WatcherNotificationL" ));
+#endif
+
+    // No need to check the expiration here since WatcherTerminatedL
+    // is called then too.
+    MProtocolPresenceWatchingDataHost& watcherHost =
+        iConnObs.Host()->ProtocolPresenceDataHost().WatchingDataHost();
+    MPresenceInfo* prInfo =  iConnObs.PresenceObjectFactory().NewPresenceInfoLC();
+
+    CSimplePluginData::NotifyToPrInfoL( iConnObs.PresenceObjectFactory(), aDocument, *prInfo );
+
+#ifdef _DEBUG
+    // ---------------------------------------------------------
+    const MPersonPresenceInfo* pers_debug = prInfo->PersonPresence();
+    const MPresenceInfoFieldCollection& coll_debug = pers_debug->Fields();
+    TInt count_debug = coll_debug.FieldCount();
+    PluginLogger::Log(_L("PluginEntityWatcher: nbr of fields received =%d"), count_debug );
+    // ---------------------------------------------------------
+#endif
+
+    MXIMPIdentity* identity2 = iConnObs.ObjectFactory().NewIdentityLC();
+    HBufC* uniBuffer =
+        CnvUtfConverter::ConvertToUnicodeFromUtf8L( *aDocument.EntityURI() );
+    CleanupStack::PushL( uniBuffer );               // << uniBuffer
+    identity2->SetIdentityL( uniBuffer->Des() );
+    CleanupStack::PopAndDestroy( uniBuffer );  // >> uniBuffer
+
+    if ( iListSubsActive )
+        {
+        // Set Group Id
+        HBufC* uniBuffer2 =
+            CnvUtfConverter::ConvertToUnicodeFromUtf8L( iEntityId->Des() );
+        CleanupStack::PushL( uniBuffer2 );
+        MXIMPIdentity* gId = iConnObs.ObjectFactory().NewIdentityLC(); // << gId
+        gId->SetIdentityL( uniBuffer2->Des() );
+
+        MXIMPObjectCollection* coll =
+            iConnObs.ObjectFactory().NewObjectCollectionLC();    // << coll
+
+       iPluginWatcher.GetEntitiesInListL( uniBuffer2->Des(), *coll );
+
+        MProtocolPresentityGroupsDataHost& groupHost =
+            iConnObs.Host()->ProtocolPresenceDataHost().GroupsDataHost();
+#ifdef _DEBUG
+        PluginLogger::Log(
+        _L("PluginEntityWatcher: callback HandlePresentityGroupContentL"));
+#endif
+        groupHost.HandlePresentityGroupContentL( gId, coll );
+
+        CleanupStack::Pop( 2 ); // >> gId, coll
+        CleanupStack::PopAndDestroy( uniBuffer2 );
+
+        // This is done only for first notification for group subscription
+        iListSubsActive = EFalse;
+        }
+
+    // PrFw Host API callback
+#ifdef _DEBUG
+    PluginLogger::Log(
+        _L("PluginEntityWatcher: callback HandleSubscribedPresentityPresenceL"));
+#endif
+    watcherHost.HandleSubscribedPresentityPresenceL( identity2, prInfo );
+    CleanupStack::Pop();        // >> identity2
+    CleanupStack::Pop();        // >> prInfo
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::WatcherListNotificationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginEntityWatcher::WatcherListNotificationL(
+    MSimplePresenceList& aList )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginEntityWatcher: WatcherListNotificationL" ));
+#endif
+
+    // call all the necessary callbacks, for new data + teminated ones.
+
+    // check out whether fullstate list or not
+    TBool fullState( EFalse );
+
+    MProtocolPresenceWatchingDataHost& watcherHost =
+        iConnObs.Host()->ProtocolPresenceDataHost().WatchingDataHost();
+
+    RPointerArray<MPresenceInfo> entities;
+    RPointerArray<MXIMPIdentity> terminated;
+    RPointerArray<MXIMPIdentity> allEntities;
+
+    TRAPD( err, CSimplePluginData::NotifyListToPrInfoL(
+        iConnObs.ObjectFactory(), iConnObs.PresenceObjectFactory(),
+        aList, entities, allEntities, terminated, fullState ));
+    if ( err )
+        {
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginEntityWatcher: WatcherListNotificationL error *" ));
+#endif
+        entities.ResetAndDestroy();
+        terminated.ResetAndDestroy();
+        allEntities.ResetAndDestroy();
+        entities.Close();
+        terminated.Close();
+        allEntities.Close();
+        return;
+        }
+
+    CompleteClientReq( KErrNone );
+
+    // Call HandleSubscribedPresentityPresenceL for all users
+    TInt counter = entities.Count();
+    for ( TInt i = counter-1 ; i>=0; i-- )
+        {
+        // ---------------------------------------------------------
+#ifdef _DEBUG
+        const MPersonPresenceInfo* info = entities[i]->PersonPresence();
+        const MPresenceInfoFieldCollection& coll_debug = info->Fields();
+        TInt count_debug = coll_debug.FieldCount();
+
+        PluginLogger::Log(
+            _L("PluginWatcher: callback HandleSubscribedPresentityPresenceL nbrFields=%d"), count_debug );
+#endif
+    // ---------------------------------------------------------
+
+        watcherHost.HandleSubscribedPresentityPresenceL(
+            allEntities[i], entities[i] );
+        // Owenership is transferred
+        allEntities.Remove(i);
+        entities.Remove(i);
+        }
+
+    // call SetPresentityPresenceDataSubscriptionStateL for terminated users
+    counter = terminated.Count();
+    for ( TInt i = counter-1 ; i>=0; i-- )
+        {
+        MXIMPDataSubscriptionState *state = iConnObs.ObjectFactory().NewDataSubscriptionStateLC();
+        state->SetSubscriptionStateL(
+            MXIMPDataSubscriptionState::ESubscriptionInactive );
+#ifdef _DEBUG
+        PluginLogger::Log(
+                _L("PluginWatcher: TEST COVERS 1"));
+        PluginLogger::Log(
+        _L("PluginWatcher: callback SetPresentityPresenceDataSubscriptionStateL"));
+#endif
+        watcherHost.SetPresentityPresenceDataSubscriptionStateL(
+            terminated[i], state, NULL );
+        CleanupStack::Pop( 1 ); // state
+        // Owenership is transferred
+        terminated.Remove(i);
+        }
+
+    entities.ResetAndDestroy();
+    terminated.ResetAndDestroy();
+    allEntities.ResetAndDestroy();
+
+    entities.Close();
+    terminated.Close();
+    allEntities.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::WatcherTerminatedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginEntityWatcher::WatcherTerminatedL(
+    TInt /*aOpId*/, TInt /*aReason*/ )
+    {
+    // Call PrFw Host and  tell to CSimplePluginWatcher that
+    // this entity can be deleted.
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginEntityWatcher: WatcherTerminatedL" ));
+#endif
+
+    MProtocolPresenceWatchingDataHost& watcherHost =
+        iConnObs.Host()->ProtocolPresenceDataHost().WatchingDataHost();
+    MXIMPDataSubscriptionState *state = iConnObs.ObjectFactory().NewDataSubscriptionStateLC();
+    MXIMPStatus* status = iConnObs.ObjectFactory().NewStatusLC();
+    state->SetSubscriptionStateL(
+        MXIMPDataSubscriptionState::ESubscriptionInactive );
+    status->SetResultCode( KErrCompletion );
+    MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC();
+
+    HBufC16* buf16 = HBufC16::NewLC( PresentityId().Length());
+    buf16->Des().Copy( PresentityId() );
+    identity->SetIdentityL( buf16->Des() );
+    CleanupStack::PopAndDestroy( buf16 );
+
+#ifdef _DEBUG
+    PluginLogger::Log(
+    _L("PluginWatcher: callback SetPresentityPresenceDataSubscriptionStateL"));
+#endif
+    watcherHost.SetPresentityPresenceDataSubscriptionStateL(
+        identity, state, status );
+    CleanupStack::Pop( 3 ); // identity, status, state
+
+    // Delete this entity as useless
+    iPluginWatcher.DeleteWatcher( iEntityId->Des() );
+    // Do not call anything, since the method call above deletes this instance.
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::CompleteClientReq
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginEntityWatcher::CompleteClientReq( TInt aStatus )
+    {
+    // complete the open PrFw request immediately here!
+    iPluginWatcher.CompleteWatcher( aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::PresentityId
+// ---------------------------------------------------------------------------
+//
+TPtrC8 CSimplePluginEntityWatcher::PresentityId( )
+    {
+    return iEntityId ? iEntityId->Des() : TPtrC8();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginEntityWatcher::PrFwRequestId
+// ---------------------------------------------------------------------------
+//
+TXIMPRequestId CSimplePluginEntityWatcher::PrFwRequestId( )
+    {
+    return iPrFwId;
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simpleplugingroups.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,893 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#include <e32std.h>
+
+#include <presentitygroupinfo.h>
+#include <presenceobjectfactory.h>
+#include <presentitygroupmemberinfo.h>
+#include <protocolpresencedatahost.h>
+#include <protocolpresentitygroupsdatahost.h>
+#include <ximpdatasubscriptionstate.h>
+#include <ximpidentity.h>
+#include <ximpobjectfactory.h>
+#include <ximpobjectcollection.h>
+#include <ximpprotocolconnectionhost.h>
+#include <ximpstatus.h>
+
+#include <simplefactory.h>
+#include <msimpleconnection.h>
+
+#include <pressettingsapi.h>
+#include <cpresencexdm.h>
+#include <rlspresxdmconsts.h>
+#include <XdmErrors.h>
+#include <presenceerrors.hrh>
+
+#include "simpleplugingroups.h"
+#include "simpleplugindebugutils.h"
+#include "simplepluginxdmutils.h"
+#include "simpleplugincommon.h"
+#include "simplepluginconnection.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::CSimplePluginGroups
+// ---------------------------------------------------------------------------
+//
+CSimplePluginGroups::CSimplePluginGroups(
+    MSimplePluginConnectionObs& aObs  )
+: CActive( CActive::EPriorityStandard ),
+  iConnObs(aObs), iSubscribed(KSimplePluginSubsNone),
+  iOperation( ENoOperation),
+  iState( EPluginIdle ), iCompleted( ETrue )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::ConstructL( )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::NewL
+// ---------------------------------------------------------------------------
+//
+CSimplePluginGroups* CSimplePluginGroups::NewL(
+    MSimplePluginConnectionObs& aObs )
+    {
+    CSimplePluginGroups* self =
+        new( ELeave ) CSimplePluginGroups( aObs );
+    CleanupStack::PushL( self );
+    self->ConstructL(  );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::~CSimplePluginGroups
+// ---------------------------------------------------------------------------
+//
+CSimplePluginGroups::~CSimplePluginGroups()
+    {
+    delete iPresIdentity;
+    delete iPresIdentity2;
+    delete iDisplayName;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoSubscribePresentityGroupListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoSubscribePresentityGroupListL(
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: DoSubscribePresentityGroupListL"));
+#endif
+
+    iCompleted = EFalse;
+
+    // List of lists under OMa buddylist
+    StartXdmOperationL( aReqId, EGetListOfLists );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoUnsubscribePresentityGroupListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoUnsubscribePresentityGroupListL(
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: DoUnsubscribePresentityGroupListL"));
+#endif
+    iPrFwId = aReqId;
+    iCompleted = EFalse;
+    CompletePrFwReq( KErrNone );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoCreatePresentityGroupL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoCreatePresentityGroupL(
+    const MXIMPIdentity& aGroupId,
+    const TDesC16& aDisplayName,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: DoCreatePresentityGroupL"));
+#endif
+    iCompleted = EFalse;
+    StartXdmOperationL(
+        aGroupId, aDisplayName, aReqId, ECreatePresentityGroup );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoDeletePresentityGroupL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoDeletePresentityGroupL(
+    const MXIMPIdentity& aGroupId,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: DoDeletePresentityGroupL"));
+#endif
+    iCompleted = EFalse;
+    StartXdmOperationL( aGroupId, aReqId, EDeletePresentityGroup );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoUpdatePresentityGroupDisplayNameL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoUpdatePresentityGroupDisplayNameL(
+    const MXIMPIdentity& /*aGroupId*/,
+    const TDesC16& /*aDisplayName*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: DoUpdatePresentityGroupDisplayNameL"));
+#endif
+    // Notice: not supported.
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoSubscribePresentityGroupContentL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoSubscribePresentityGroupContentL(
+    const MXIMPIdentity& aGroupId,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: DoSubscribePresentityGroupContentL"));
+#endif
+    iCompleted = EFalse;
+
+    // List of lists under OMa buddylist
+    StartXdmOperationL( aGroupId, aReqId, EGetListContent );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoUnsubscribePresentityGroupContentL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoUnsubscribePresentityGroupContentL(
+    const MXIMPIdentity& /*aGroupId*/,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: DoUnsubscribePresentityGroupContentL"));
+#endif
+    iCompleted = EFalse;
+    iPrFwId = aReqId;
+    CompletePrFwReq( KErrNone );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoAddPresentityGroupMemberL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoAddPresentityGroupMemberL(
+    const MXIMPIdentity& aGroupId,
+    const MXIMPIdentity& aMemberId,
+    const TDesC16& aMemberDisplayName,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: DoAddPresentityGroupMemberL"));
+#endif
+    iCompleted = EFalse;
+    StartXdmOperationL(
+        aGroupId, aMemberId, aMemberDisplayName,
+        aReqId, EAddPresentityGroupMember );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoRemovePresentityGroupMemberL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoRemovePresentityGroupMemberL(
+    const MXIMPIdentity& aGroupId,
+    const MXIMPIdentity& aMemberId,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: DoRemovePresentityGroupMemberL"));
+#endif
+    iCompleted = EFalse;
+    StartXdmOperationL(
+        aGroupId, aMemberId,
+        aReqId, ERemovePresentityGroupMember );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoUpdatePresentityGroupMemberDisplayNameL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoUpdatePresentityGroupMemberDisplayNameL(
+    const MXIMPIdentity& /*aGroupId*/,
+    const MXIMPIdentity& /*aMemberId*/,
+    const TDesC16& /*aMemberDisplayName*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(
+        _L("PluginGroups: DoUpdatePresentityGroupMemberDisplayNameL"));
+#endif
+    // Notice: Not supported.
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoCancel(  )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: DoCancel"));
+#endif
+    if ( iOperation != ENoOperation )
+        {
+        iXdmUtils->Cancel();
+        }
+    else
+        {
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::RunL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::RunL(  )
+    {
+    TInt myStatus = iStatus.Int();
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: RunL status=%d active=%d"), myStatus, IsActive() );
+#endif
+
+    if ( !myStatus )
+        {
+        // OK resposne
+        CallActualXdmOperationL();
+        }
+    else
+        {
+        if ( iOperation == EDeletePresentityGroup && iState == EPluginCommitRls )
+            {
+            // Igonere RLS deletion failure and contine Shared XDM deletion
+            CallActualXdmOperationL();
+            }
+        else
+            {
+            // Other errors terminated the show
+            CompletePrFwReq( myStatus );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::CallActualXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::CallActualXdmOperationL()
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: CallActualXdmOperationL operation=%d"), iOperation );
+#endif
+
+    switch ( iOperation )
+        {
+        case ECreatePresentityGroup:
+            HandleCreatePresentityGroupL( iPresIdentity->Des(), iDisplayName->Des() );
+            break;
+        case EDeletePresentityGroup:
+            HandleDeletePresentityGroupL( iPresIdentity->Des() );
+            break;
+        case EAddPresentityGroupMember:
+            HandleAddPresentityGroupMemberL();
+            break;
+        case ERemovePresentityGroupMember:
+            HandleRemovePresentityGroupMemberL();
+            break;
+        case EGetListOfLists:
+            GetListOfListsL();
+            break;
+        case EGetListContent:
+            GetListContentL();
+            break;
+        default:
+            User::Leave( KErrNotSupported );
+            break;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CSimplePluginGroups::RunError( TInt aError )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: RunError %d active=%d"), aError, IsActive());
+#endif
+    // complete the open request
+    CompletePrFwReq( aError );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CSimplePluginGroups::GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOptions )
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        MProtocolPresentityGroups* myIf = this;
+        return myIf;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::GetInterface()
+// ---------------------------------------------------------------------------
+//
+const TAny* CSimplePluginGroups::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        const MProtocolPresentityGroups* myIf = this;
+        return myIf;
+        }
+    else if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::GetInterfaceId()
+// ---------------------------------------------------------------------------
+//
+TInt32 CSimplePluginGroups::GetInterfaceId() const
+    {
+    return MProtocolPresentityGroups::KInterfaceId;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::SetPresIdentityL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::SetPresIdentityL(
+    const MXIMPIdentity& aPresentityId )
+    {
+    delete iPresIdentity;
+    iPresIdentity = NULL;
+    iPresIdentity = aPresentityId.Identity().AllocL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::SetPresIdentity2L()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::SetPresIdentity2L(
+    const MXIMPIdentity& aPresentityId )
+    {
+    delete iPresIdentity2;
+    iPresIdentity2 = NULL;
+    iPresIdentity2 = aPresentityId.Identity().AllocL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::StartXdmOperationL(
+    TXIMPRequestId aReqId,
+    TPluginGroupsOperation aOperation )
+    {
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) );
+    iPrFwId = aReqId;
+    iOperation = aOperation;
+    StartXdmOperationL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::StartXdmOperationL(
+    const MXIMPIdentity& aId,
+    TXIMPRequestId aReqId,
+    TPluginGroupsOperation aOperation )
+    {
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) );
+    SetPresIdentityL( aId );
+    iPrFwId = aReqId;
+    iOperation = aOperation;
+    StartXdmOperationL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::StartXdmOperationL(
+        const MXIMPIdentity& aId,
+        const TDesC16& aDisplayName,
+        TXIMPRequestId aReqId,
+        TPluginGroupsOperation aOperation )
+    {
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) );
+    SetPresIdentityL( aId );
+
+    delete iDisplayName;
+    iDisplayName = NULL;
+    iDisplayName = aDisplayName.AllocL();
+
+    iPrFwId = aReqId;
+    iOperation = aOperation;
+    StartXdmOperationL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::StartXdmOperationL(
+        const MXIMPIdentity& aId,
+        const MXIMPIdentity& aMemberId,
+        TXIMPRequestId aReqId,
+        TPluginGroupsOperation aOperation )
+    {
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) );
+    SetPresIdentityL( aId );
+    SetPresIdentity2L( aMemberId );
+    iPrFwId = aReqId;
+    iOperation = aOperation;
+    StartXdmOperationL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::StartXdmOperationL(
+        const MXIMPIdentity& aId,
+        const MXIMPIdentity& aMemberId,
+        const TDesC16& aDisplayName,
+        TXIMPRequestId aReqId,
+        TPluginGroupsOperation aOperation )
+    {
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) );
+    SetPresIdentityL( aId );
+    SetPresIdentity2L( aMemberId );
+
+    delete iDisplayName;
+    iDisplayName = NULL;
+    iDisplayName = aDisplayName.AllocL();
+
+    iPrFwId = aReqId;
+    iOperation = aOperation;
+    StartXdmOperationL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::StartXdmOperationL()
+    {
+    TRAPD( err, DoStartXdmOperationL() );
+    if ( err )
+        {
+        User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+        }
+    else
+        {
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::DoStartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::DoStartXdmOperationL()
+    {
+    if ( !iXdmUtils )
+        {
+        iXdmUtils = iConnObs.XdmUtilsL();
+        }
+    else
+        {
+        }
+
+    // Delete Group is the only method that access XDM rules,
+    // others access shared lists only.
+    if ( iOperation != EDeletePresentityGroup )
+        {
+        iXdmUtils->InitializeXdmsOnlyL( iStatus );
+        }
+    else
+        {
+        iXdmUtils->InitializeXdmL( iStatus );
+        }
+
+    iState = EPluginInitXdm;
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::GetListOfListsL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::GetListOfListsL()
+    {
+    MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();
+    MProtocolPresentityGroupsDataHost& dataHost =
+        iConnObs.Host()->ProtocolPresenceDataHost().GroupsDataHost();
+
+    // This searches data from the local cache only.
+    MXIMPObjectCollection* userLists =
+        myFactory.NewObjectCollectionLC();          // << userLists
+
+    const TInt KMyGran = 10;
+    CDesCArrayFlat* lists = new (ELeave) CDesCArrayFlat( KMyGran );
+    CleanupStack::PushL( lists );      // << lists
+
+    CDesCArrayFlat* dNames = new (ELeave) CDesCArrayFlat( KMyGran );
+    CleanupStack::PushL( dNames );      // << dNames
+
+    iXdmUtils->GetUserListsL( *lists, *dNames );
+
+    CopyGroupArraysToCollectionL( *lists, *dNames, *userLists );
+
+    CleanupStack::PopAndDestroy( dNames );  // >> dNames
+    CleanupStack::PopAndDestroy( lists );   // >> lists
+
+    CompletePrFwReq( KErrNone );
+
+    // Callback for subscription state (terminated).
+    MXIMPDataSubscriptionState* myState =
+        myFactory.NewDataSubscriptionStateLC();
+    MXIMPStatus* myStatus = myFactory.NewStatusLC();
+    // Notice: consider error codes
+    myStatus->SetResultCode( KErrNone );
+    myState->SetSubscriptionStateL(
+        MXIMPDataSubscriptionState::ESubscriptionInactive );
+    myState->SetDataStateL( MXIMPDataSubscriptionState::EDataUnavailable );
+#ifdef _DEBUG
+    PluginLogger::Log(
+    _L("PluginGroups: callback SetPresentityGroupListDataSubscriptionStateL"));
+#endif
+    dataHost.SetPresentityGroupListDataSubscriptionStateL(
+        myState, myStatus );
+
+
+    CleanupStack::Pop( 2 ); // >> myState, myStatus
+
+    // callback for data
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: callback HandlePresentityGroupListL"));
+#endif
+    dataHost.HandlePresentityGroupListL( userLists );
+    CleanupStack::Pop();     // >> userLists
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::GetListContentL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::GetListContentL()
+    {
+    MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();
+    MProtocolPresentityGroupsDataHost& dataHost =
+        iConnObs.Host()->ProtocolPresenceDataHost().GroupsDataHost();
+
+    MXIMPObjectCollection* entities =
+        myFactory.NewObjectCollectionLC();          // << entities
+
+    const TInt KMyGran = 10;
+    CPtrCArray* ids = new (ELeave) CPtrCArray( KMyGran );
+    CleanupStack::PushL( ids );      // << ids
+
+    CPtrCArray* dispNames = new (ELeave) CPtrCArray( KMyGran );
+    CleanupStack::PushL( dispNames  );      // << dispNames
+
+
+    iXdmUtils->GetEntitiesInListL( iPresIdentity->Des(), *ids, *dispNames );
+
+    CopyGroupMembersToCollectionL( *ids, *dispNames, *entities );
+
+    CleanupStack::PopAndDestroy( dispNames );
+    CleanupStack::PopAndDestroy( ids );
+
+    // Complete the PrFw request
+    CompletePrFwReq( KErrNone );
+
+    // callback for data
+    MXIMPIdentity* id = myFactory.NewIdentityLC();  // << id
+    id->SetIdentityL( iPresIdentity->Des() );
+#ifdef _DEBUG
+    PluginLogger::Log(
+        _L("PluginGroups: callback HandlePresentityGroupContentL ."));
+#endif
+    dataHost.HandlePresentityGroupContentL( id, entities );
+    CleanupStack::Pop();                  // >> id
+    CleanupStack::Pop();                  // >> entities
+
+    // Callback for subscription state (terminated).
+    id = myFactory.NewIdentityLC();                     // << id
+    id->SetIdentityL( iPresIdentity->Des() );
+    MXIMPDataSubscriptionState* myState =
+        myFactory.NewDataSubscriptionStateLC();         // << myState
+    MXIMPStatus* myStatus = myFactory.NewStatusLC();    // << myStatus
+    // Notice: consider error codes
+    myStatus->SetResultCode( KErrNone );
+    myState->SetSubscriptionStateL(
+        MXIMPDataSubscriptionState::ESubscriptionInactive );
+#ifdef _DEBUG
+    PluginLogger::Log(
+        _L("PluginGroups: callback SetPresentityGroupContentDataSubscriptionStateL"));
+#endif
+    dataHost.SetPresentityGroupContentDataSubscriptionStateL(
+        id, myState, myStatus );
+    CleanupStack::Pop( 3 ); // >> myStatus, myState, id
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::CompletePrFwReq
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::CompletePrFwReq( TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: CompletePrFwReq status=%d"), aStatus );
+#endif
+
+    if ( iCompleted  )
+        {
+        return;
+        }
+
+    iCompleted = ETrue;
+    iOperation = ENoOperation;
+    iConnObs.CompleteReq( iPrFwId, aStatus );
+    iPrFwId = TXIMPRequestId();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::CompleteMe
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::CompleteMe( TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginGroups: CompleteMe status=%d"), aStatus );
+#endif
+
+    iStatus = KRequestPending;
+    TRequestStatus* s= &iStatus;
+    User::RequestComplete( s, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::CopyGroupArraysToCollectionL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::CopyGroupArraysToCollectionL(
+    CDesCArrayFlat& aLists, CDesCArrayFlat& aNames, MXIMPObjectCollection& aCollection )
+    {
+    TInt count = aLists.Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        // create here the PrFW group info
+        MPresentityGroupInfo* info =
+            iConnObs.PresenceObjectFactory().NewPresentityGroupInfoLC(); // << info
+        MXIMPIdentity* id = iConnObs.ObjectFactory().NewIdentityLC();  // << id
+        id->SetIdentityL( aLists[i] );
+        info->SetGroupIdL( id );
+        CleanupStack::Pop(); // >> id
+
+        info->SetGroupDisplayNameL( aNames[i] );
+        aCollection.AddObjectL( info );
+        CleanupStack::Pop(); // >> info
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::CopyGroupMembersToCollectionL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::CopyGroupMembersToCollectionL(
+    CPtrCArray& aIds, CPtrCArray& aNames, MXIMPObjectCollection& aCollection)
+    {
+    TInt count = aIds.Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        // create here MPresentityGroupMemberInfo
+        MPresentityGroupMemberInfo* info =
+            iConnObs.PresenceObjectFactory().NewPresentityGroupMemberInfoLC(); // << info
+        MXIMPIdentity* id = iConnObs.ObjectFactory().NewIdentityLC();  // << id
+        id->SetIdentityL( aIds[i] );
+        info->SetGroupMemberIdL( id );
+        CleanupStack::Pop(); // >> id
+
+        info->SetGroupMemberDisplayNameL( aNames[i] );
+        aCollection.AddObjectL( info );
+        CleanupStack::Pop(); // >> info
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::HandleCreatePresentityGroupL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::HandleCreatePresentityGroupL(
+    const TDesC& aGroupId, const TDesC& aDispName )
+    {
+    if ( iState == EPluginInitXdm )
+        {
+        iState = EPluginCommitXdm;
+        iXdmUtils->CreateEntityGroupL( aGroupId, aDispName );
+        iXdmUtils->CommitXdmL( iStatus );
+        SetActive();
+        }
+    else
+        {
+        // We are ready
+        CompletePrFwReq( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::HandleDeletePresentityGroupL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::HandleDeletePresentityGroupL( const TDesC& aGroupId )
+    {
+    if ( iState == EPluginInitXdm )
+        {
+        iState = EPluginFetchRls;
+        iXdmUtils->FetchRlsL( iStatus );
+        SetActive();
+        }
+    else if ( iState == EPluginFetchRls )
+        {
+        iState = EPluginCommitRls;
+        // Remove RLS service
+        iXdmUtils->RemoveRlsServiceByResourceListL( aGroupId, iStatus );
+        SetActive();
+        }
+    else if ( iState == EPluginCommitRls )
+        {
+        iState = EPluginCommitXdm;
+        iXdmUtils->DeleteEntityGroupL( aGroupId );
+        iXdmUtils->CommitXdmL( iStatus );
+        SetActive();
+        }
+    else if ( iState == EPluginCommitXdm )
+        {
+        // Delete the group from a granted rule. The following won't leave if
+        // it does not locate under the rule.
+#ifdef _DEBUG
+        PluginLogger::Log(
+                _L("PluginWatcher: TEST COVERS 2 **"));
+#endif
+        iState = ERemoveGroupFromGranted;
+        iXdmUtils->RemoveGroupFromGrantedL( aGroupId, iStatus );
+        SetActive();
+        }
+    else
+        {
+        // We are ready
+        CompletePrFwReq( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::HandleAddPresentityGroupMemberL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::HandleAddPresentityGroupMemberL( )
+    {
+    if ( iState == EPluginInitXdm )
+        {
+        iXdmUtils->AddPresentityGroupMemberL(
+            iPresIdentity->Des(), iPresIdentity2->Des(),
+            iDisplayName->Des(), iStatus );
+        iState = EPluginAddGroupMember;
+        SetActive();
+        }
+    else
+        {
+        // We are ready
+        CompletePrFwReq( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginGroups::HandleRemovePresentityGroupMemberL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginGroups::HandleRemovePresentityGroupMemberL()
+    {
+    if ( iState == EPluginInitXdm )
+        {
+        iXdmUtils->RemovePresentityGroupMemberL(
+            iPresIdentity->Des(), iPresIdentity2->Des(), iStatus );
+        iState = EPluginRemoveGroupMember;
+        SetActive();
+        }
+    else
+        {
+        // We are ready
+        CompletePrFwReq( KErrNone );
+        }
+    }
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simplepluginpublisher.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,1071 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#include <e32std.h>
+#include <utf.h>
+
+#include <personpresenceinfo.h>
+#include <presenceinfo.h>
+#include <presenceinfofield.h>
+#include <presenceinfofieldcollection.h>
+#include <presenceinfofieldvaluetext.h>
+#include <presenceinfofieldvalueenum.h>
+#include <presenceinfofieldvaluebinary.h>
+#include <presenceobjectfactory.h>
+#include <presencewatcherinfo.h>
+#include <presenceerrors.hrh>
+
+#include <servicepresenceinfo.h>
+#include <devicepresenceinfo.h>
+
+#include <protocolpresencedatahost.h>
+#include <protocolpresencepublishingdatahost.h>
+
+#include <ximpdatasubscriptionstate.h>
+#include <ximperrors.hrh>
+#include <ximpidentity.h>
+#include <ximpobjectcollection.h>
+#include <ximpobjectfactory.h>
+#include <ximpprotocolconnectionhost.h>
+#include <ximpstatus.h>
+
+#include <simplefactory.h>
+
+#include <msimplewinfo.h>
+#include <msimplepublisher.h>
+#include <msimplewatcher.h>
+#include <msimpledocument.h>
+#include <msimpleelement.h>
+#include <msimplecontent.h>
+
+#include "simpleplugincommon.h"
+#include "simplepluginpublisher.h"
+#include "simpleplugindebugutils.h"
+#include "simpleutils.h"
+#include "simplepluginwinfo.h"
+#include "simpleplugindata.h"
+#include "simplepluginxdmutils.h"
+#include "simplepluginconnection.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// -----------------------------------------------------------------------------
+// CSimplePluginWatcherInfo::CSimplePluginWatcherInfo
+// -----------------------------------------------------------------------------
+CSimplePluginWatcherInfo::CSimplePluginWatcherInfo( )
+        {}
+
+// -----------------------------------------------------------------------------
+// CSimplePluginWatcherInfo::~CSimplePluginWatcherInfo
+// -----------------------------------------------------------------------------
+CSimplePluginWatcherInfo::~CSimplePluginWatcherInfo()
+    {
+    delete iId;
+    delete iSipId;
+    }
+
+// ----------------------------------------------------------
+// CSimplePluginWatcherInfo::NewL
+// ----------------------------------------------------------
+//
+CSimplePluginWatcherInfo* CSimplePluginWatcherInfo::NewL(
+   const TDesC8& aId, const TDesC& aSipId )
+    {
+    CSimplePluginWatcherInfo* self = new (ELeave) CSimplePluginWatcherInfo( );
+    CleanupStack::PushL( self );
+    self->ConstructL( aId, aSipId );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CSimplePluginWatcherInfo::ConstructL
+// ----------------------------------------------------------
+//
+void CSimplePluginWatcherInfo::ConstructL(
+    const TDesC8& aId, const TDesC& aSipId  )
+    {
+    iId = aId.AllocL();
+    iSipId = aSipId.AllocL();
+    }
+
+// -----------------------------------------------------------------------------
+// CSimplePluginWatcherInfo::Destroy
+// -----------------------------------------------------------------------------
+void CSimplePluginWatcherInfo::Destroy()
+    {
+    iLink.Deque();
+    delete this;
+    }
+
+// -----------------------------------------------------------------------------
+// CSimplePluginWatcherInfo::Match
+// -----------------------------------------------------------------------------
+TBool CSimplePluginWatcherInfo::Match( const TDesC8& aId, const TDesC& aSipId )
+    {
+    if ( (!iId->Des().CompareF( aId )) && (!iSipId->Des().CompareF( aSipId)) )
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSimplePluginWatcherInfo::SipId
+// -----------------------------------------------------------------------------
+TPtrC CSimplePluginWatcherInfo::SipId( )
+    {
+    return iSipId ? iSipId->Des() : TPtrC();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::CSimplePluginPublisher
+// ---------------------------------------------------------------------------
+//
+CSimplePluginPublisher::CSimplePluginPublisher(
+    MSimplePluginSettings& aConnSets,
+    MSimplePluginConnectionObs& aObs,
+    MSimpleConnection& aConn )
+: CActive( CActive::EPriorityStandard ),
+  iConnObs(aObs), iConnSets( aConnSets), iConnection(aConn),
+  iSubscribed(EFalse), iSubscribedOwn(EFalse), iPublished(EFalse),
+  iWatcherList( CSimplePluginWatcherInfo::LinkOffset())
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::ConstructL( )
+    {
+    iPublisher = TSimpleFactory::NewPublisherL( iConnection, *this );
+    iWatcher = TSimpleFactory::NewWatcherL( iConnection, *this );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::NewL
+// ---------------------------------------------------------------------------
+//
+CSimplePluginPublisher* CSimplePluginPublisher::NewL(
+    MSimplePluginSettings& aConnSets,
+    MSimplePluginConnectionObs& aObs,
+    MSimpleConnection& aConn )
+    {
+    CSimplePluginPublisher* self =
+        new( ELeave ) CSimplePluginPublisher( aConnSets, aObs, aConn );
+    CleanupStack::PushL( self );
+    self->ConstructL(  );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::~CSimplePluginPublisher
+// ---------------------------------------------------------------------------
+//
+CSimplePluginPublisher::~CSimplePluginPublisher()
+    {
+    if ( iDocument )
+        {
+        iDocument->Close();
+        }
+
+    if ( iPublisher )
+        {
+        iPublisher->Close();
+        }
+
+    if ( iWatcher )
+        {
+        iWatcher->Close();
+        }
+
+    // delete iWatchers;
+    DeleteWatchers();
+
+    }
+
+// -----------------------------------------------------------------------------
+// CSimplePluginPublisher::DeleteWatchers
+// -----------------------------------------------------------------------------
+void CSimplePluginPublisher::DeleteWatchers()
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: DeleteWatchers" ) );
+#endif
+    // Delete all buffered transaction requests
+    TDblQueIter<CSimplePluginWatcherInfo> rIter( iWatcherList );
+    rIter.SetToFirst();
+
+    while ( rIter )
+        {
+        CSimplePluginWatcherInfo* w = rIter;
+        rIter++;
+        // delete wathcer info
+        w->Destroy();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSimplePluginPublisher::AddWatcherIfNotExistsL
+// -----------------------------------------------------------------------------
+void CSimplePluginPublisher::AddWatcherIfNotExistsL( const TDesC8& aId, const TDesC& aSipId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: AddWatcherIfNotExistsL" ) );
+#endif
+    TDblQueIter<CSimplePluginWatcherInfo> rIter( iWatcherList );
+    rIter.SetToFirst();
+
+    TBool found(EFalse);
+
+    while ( rIter )
+        {
+        CSimplePluginWatcherInfo* w = rIter;
+        rIter++;
+        found = w->Match( aId, aSipId );
+        if ( found )
+            {
+            break;
+            }
+        else
+            {
+            // continue searching
+            }
+        }
+    if ( !found )
+        {
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginPublisher: AddWatcherIfNotExistsL adds a watcher" ) );
+#endif
+        CSimplePluginWatcherInfo* w = CSimplePluginWatcherInfo::NewL( aId, aSipId );
+        iWatcherList.AddLast( *w );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSimplePluginPublisher::RemoveWatcherIfExistsL
+// -----------------------------------------------------------------------------
+void CSimplePluginPublisher::RemoveWatcherIfExistsL( const TDesC8& aId, const TDesC& aSipId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: RemoveWatcherIfExistsL" ) );
+#endif
+    TDblQueIter<CSimplePluginWatcherInfo> rIter( iWatcherList );
+    rIter.SetToFirst();
+
+    TBool found(EFalse);
+
+    while ( rIter )
+        {
+        CSimplePluginWatcherInfo* w = rIter;
+        rIter++;
+        // delete wathcer info
+        found = w->Match( aId, aSipId );
+        if ( found )
+            {
+#ifdef _DEBUG
+            PluginLogger::Log(_L("PluginPublisher: RemoveWatcherIfExistsL removes a watcher" ) );
+#endif
+            w->Destroy();
+            break;
+            }
+        else
+            {
+            // continue searching
+            }
+        }
+    }
+// -----------------------------------------------------------------------------
+// CSimplePluginPublisher::MakeCurrentWatcherListLC
+// -----------------------------------------------------------------------------
+CDesCArrayFlat* CSimplePluginPublisher::MakeCurrentWatcherListLC()
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: MakeCurrentWatcherListL" ) );
+#endif
+    // No one should be added more than once
+    const TInt KMyGran = 10;
+    CDesCArrayFlat* watchers = new (ELeave) CDesCArrayFlat( KMyGran );
+    CleanupStack::PushL( watchers );      // << watchers
+
+    // add user only once here.
+    TDblQueIter<CSimplePluginWatcherInfo> rIter( iWatcherList );
+    rIter.SetToFirst();
+
+    while ( rIter )
+        {
+        CSimplePluginWatcherInfo* w = rIter;
+        rIter++;
+
+        TInt dummy = 0;
+        if ( watchers->Find( w->SipId(), dummy ))
+            {
+            watchers->AppendL( w->SipId() );
+            }
+        else
+            {
+            // continue searching
+            }
+        }
+
+    return watchers;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::DoPublishOwnPresenceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::DoPublishOwnPresenceL(
+    const MPresenceInfo& aOwnPresence,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: DoPublishOwnPresenceL"));
+#endif
+
+    const MPersonPresenceInfo* persInfo = aOwnPresence.PersonPresence();
+
+    // convert data format from PrFW to internal
+    if ( !persInfo )
+        {
+        // Notice: error codes
+        CompletePrFwReq( KErrArgument );
+        return;
+        }
+    InitializeSimpleDocumentL( );
+    AddSimpleDocumentPersL( persInfo );
+
+    TInt myCount = aOwnPresence.ServicePresenceCount();
+    for ( TInt i=0; i < myCount; i++ )
+        {
+        const MServicePresenceInfo& servInfo = aOwnPresence.ServicePresenceAt(i);
+        AddSimpleDocumentServiceL( servInfo );
+        }
+    myCount = aOwnPresence.DevicePresenceCount();
+    for ( TInt i=0; i < myCount; i++ )
+        {
+        const MDevicePresenceInfo& devInfo = aOwnPresence.DevicePresenceAt(i);
+        AddSimpleDocumentDeviceL( devInfo );
+        }
+
+    // Ensure that XDM rules exists, the show continues in RunL
+    StartXdmOperationL(aReqId );
+    iOperation = EPublishOwn;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::DoSubscribeOwnPresenceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::DoSubscribeOwnPresenceL(
+    const MPresenceInfoFilter& /*aPif*/,   // notice: aPif filter not supported
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: DoSubscribeOwnPresenceL"));
+#endif
+
+    StartXdmOperationL( aReqId );
+
+    iOperation = ESubscribeOwn;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::DoUpdateOwnPresenceSubscriptionPifL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::DoUpdateOwnPresenceSubscriptionPifL(
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: DoUpdateOwnPresenceSubscriptionPifL"));
+#endif
+    // Notice: aPif filter not supported
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::DoUnsubscribeOwnPresenceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::DoUnsubscribeOwnPresenceL(
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: DoUnsubscribeOwnPresenceL"));
+#endif
+    iSubscribedOwn = EFalse;
+    TRAPD( err, iSimpleId = iWatcher->UnsubscribeL());
+    if ( err )
+        {
+        User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+        }
+    iPrFwId = aReqId;
+    iOperation = EUnsubscribeOwn;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::DoSubscribePresenceWatcherListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::DoSubscribePresenceWatcherListL(
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: DoSubscribePresenceWatcherListL"));
+#endif
+
+    if ( !iSubscribed )
+        {
+        TRAPD( err, iConnObs.WinfoHandlerL()->SubscribeWinfoListL( aReqId ));
+        if ( err )
+            {
+            User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+            }
+        iSubscribed = ETrue;
+        iPrFwId = aReqId;
+        iOperation = ESubscribeWinfo;
+        }
+    else
+        {
+        iPrFwId = aReqId;
+        CompletePrFwReq( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::DoUnsubscribePresenceWatcherListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::DoUnsubscribePresenceWatcherListL(
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: DoUnsubscribePresenceWatcherListL"));
+#endif
+    if ( iSubscribed )
+        {
+        TRAPD( err, iConnObs.WinfoHandlerL()->UnsubscribeWinfoListL( aReqId ));
+        if ( err )
+            {
+            User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+            }
+        iSubscribed = EFalse;
+        iPrFwId = aReqId;
+        iOperation = EUnsubscribeWinfo;
+        }
+    else
+        {
+        iPrFwId = aReqId;
+        CompletePrFwReq( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::PublishReqCompleteL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::PublishReqCompleteL( TInt /*aOpid*/, TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: PublishReqCompleteL("));
+#endif
+    if ( !aStatus )
+        {
+        iPublished = ETrue;
+        }
+    else
+        {
+        }
+
+    CompletePrFwReq( aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::PublishTerminatedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::PublishTerminatedL( TInt /*aOpid*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: PublishTerminatedL"));
+#endif
+    // Notice: nothing to do now in Host APi.
+    iPublished = EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::WatcherReqCompleteL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::WatcherReqCompleteL( TInt /*aOpid*/, TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: WatcherReqCompleteL"));
+#endif
+    if ( !aStatus )
+        {
+        iSubscribedOwn = ETrue;
+        }
+    else
+        {
+        }
+    CompletePrFwReq( aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::WatcherNotificationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::WatcherNotificationL( MSimpleDocument& aDocument )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: WatcherNotificationL"));
+#endif
+
+    // Notice: Do not need to check the expiration here since WatcherTerminatedL
+    // is called then too.
+
+    MProtocolPresencePublishingDataHost& publishHost =
+        iConnObs.Host()->ProtocolPresenceDataHost().PublishingDataHost();
+    MPresenceInfo* prInfo = iConnObs.PresenceObjectFactory().NewPresenceInfoLC();  // << prInfo
+    CSimplePluginData::NotifyToPrInfoL( iConnObs.PresenceObjectFactory(), aDocument, *prInfo );
+
+#ifdef _DEBUG
+    // ---------------------------------------------------------
+    const MPersonPresenceInfo* pers_debug = prInfo->PersonPresence();
+    const MPresenceInfoFieldCollection& coll_debug = pers_debug->Fields();
+    TInt count_debug = coll_debug.FieldCount();
+    PluginLogger::Log(_L("PluginPublisher: nbr of fields received =%d"), count_debug );
+    // ---------------------------------------------------------
+#endif
+
+    // PrFw Host API callbacks
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: callback HandleSubscribedOwnPresenceL"));
+#endif
+    publishHost.HandleSubscribedOwnPresenceL( prInfo );
+    CleanupStack::Pop();  // >> prInfo
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::WatcherListNotificationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::WatcherListNotificationL( MSimplePresenceList& /*aList*/ )
+    {
+    // Notice: not needed.
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::WatcherTerminatedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::WatcherTerminatedL(
+    TInt /*aOpId*/, TInt /*aReason*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: WatcherTerminatedL"));
+#endif
+    iSubscribedOwn = EFalse;
+
+    MProtocolPresencePublishingDataHost& publishHost =
+        iConnObs.Host()->ProtocolPresenceDataHost().PublishingDataHost();
+    MXIMPDataSubscriptionState *state = iConnObs.ObjectFactory().NewDataSubscriptionStateLC();
+    MXIMPStatus* status = iConnObs.ObjectFactory().NewStatusLC();
+    state->SetSubscriptionStateL( MXIMPDataSubscriptionState::ESubscriptionInactive );
+    status->SetResultCode( KErrCompletion );
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: callback SetOwnPresenceDataSubscriptionStateL"));
+#endif
+    publishHost.SetOwnPresenceDataSubscriptionStateL( state, status );
+    CleanupStack::Pop( 2 ); // status, state
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::CompletePrFwReq
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::CompletePrFwReq( TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: CompletePrFwReq status=%d"), aStatus );
+#endif
+    if ( iOperation != ENoOperation )
+        {
+        iOperation = ENoOperation;
+        iConnObs.CompleteReq( iPrFwId, aStatus );
+        iPrFwId = TXIMPRequestId();
+        }
+    else
+        {
+        }
+    return;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::DoCancel(  )
+    {
+    iXdmUtils->Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::RunL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::RunL(  )
+    {
+
+    TInt status = iStatus.Int();
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: RunL %d"), status );
+#endif
+
+    if ( !status )
+        {
+        if ( iOperation == ESubscribeOwn )
+            {
+            iSimpleId = iWatcher->SubscribeL(
+                iConnSets.CurrentSipPresentity8(),
+                NULL,  // aFilter <-> aPif
+                ETrue, EFalse );
+            }
+        else
+            {
+            MakePublishReqL();
+            }
+        }
+    else
+        {
+        CompletePrFwReq( status );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CSimplePluginPublisher::RunError( TInt aError )
+    {
+    CompletePrFwReq( aError );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::GetInterface
+// ---------------------------------------------------------------------------
+//
+TAny* CSimplePluginPublisher::GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOptions )
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        MProtocolPresencePublishing* myIf = this;
+        return myIf;
+        }
+    else if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::GetInterface
+// ---------------------------------------------------------------------------
+//
+const TAny* CSimplePluginPublisher::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        const MProtocolPresencePublishing* myIf = this;
+        return myIf;
+        }
+    else if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::GetInterfaceId
+// ---------------------------------------------------------------------------
+//
+TInt32 CSimplePluginPublisher::GetInterfaceId() const
+    {
+    return MProtocolPresencePublishing::KInterfaceId;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::InitializeSimpleDocumentL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::InitializeSimpleDocumentL( )
+    {
+    if ( iDocument )
+        {
+        iDocument->Close();
+        iDocument = NULL;
+        }
+    iDocument = TSimpleFactory::NewDocumentL();
+    iDocument->AddNamespaceL( KSimplePDM, KSimpleNsPDM );
+    iDocument->AddNamespaceL( KSimpleRPID, KSimpleNsRPID );
+    iDocument->AddNamespaceL( KSimpleOP, KSimpleNsOP );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::AddSimpleDocumentPersL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::AddSimpleDocumentPersL(
+    const MPersonPresenceInfo* aInfo )
+    {
+    CSimplePluginData::AddPrPersToSimpleDocumentL(
+        aInfo, *iDocument, iConnSets.CurrentSipPresentity8() );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::AddSimpleDocumentServiceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::AddSimpleDocumentServiceL(
+    const MServicePresenceInfo& aInfo )
+    {
+    if ( aInfo.Fields().FieldCount() > 0 || aInfo.ServiceType().Length() )
+        {
+        // Notice: currently all the fields in the namespace are supported,
+        // but this ensures that if namespace is extended later, it is
+        // handled right way in the adaptation
+        User::Leave( KPresenceErrPresenceInfoFieldTypeNotSupported );
+        }
+    else
+        {
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::AddSimpleDocumentDeviceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::AddSimpleDocumentDeviceL(
+    const MDevicePresenceInfo& aInfo )
+    {
+    if ( aInfo.Fields().FieldCount() > 0 || aInfo.DeviceName().Length() )
+        {
+        // Notice: currently all the fields in the namespace are supported,
+        // but this ensures that if namespace is extended later, it is
+        // handled right way in the adaptation
+        User::Leave( KPresenceErrPresenceInfoFieldTypeNotSupported );
+        }
+    else
+        {
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::MakePublishReqL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::MakePublishReqL( )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: -> MakePublishReqL"));
+#endif
+    // Send the iDocument
+    if ( !iPublished )
+        {
+        iSimpleId = iPublisher->StartPublishL( *iDocument, ETrue );
+        }
+    else
+        {
+        iSimpleId = iPublisher->ModifyPublishL( *iDocument);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::StartXdmOperationL(
+    TXIMPRequestId aReqId )
+    {
+    TRAPD( err, DoStartXdmOperationL( aReqId ));
+    if ( err )
+        {
+        User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::DoStartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::DoStartXdmOperationL(
+    TXIMPRequestId aReqId )
+    {
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) );
+    iPrFwId = aReqId;
+    if ( !iXdmUtils )
+        {
+        iXdmUtils = iConnObs.XdmUtilsL();
+        }
+    iXdmUtils->InitializeXdmL( iStatus );
+    SetActive();
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::WinfoNotificationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::WinfoNotificationL(
+    MSimpleWinfo& aWinfo )
+    {
+    // ignore if not subscribed
+    if ( !iSubscribed )
+        {
+        return;
+        }
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: WinfoNotificationL"));
+#endif
+
+    // Handle full-state and partial state notifications
+    // - If terminated -> remove from iWatcherList
+    // - If active -> add into iWatcherList if does not already exist
+    // WinfoTerminatedL handles termination of subscription.
+
+    // Notice: CSimplePluginWinfo has completed the open request if needed before this.
+
+
+    /* example:
+
+    // active/pending/terminated
+
+   <?xml version="1.0"?>
+     <watcherinfo xmlns="urn:ietf:params:xml:ns:watcherinfo"
+   version="0" state="full">
+     <watcher-list resource="sip:presentity@example.com"
+                   package="presence">
+         <watcher status="active"
+            id="sr8fdsj"
+            duration-subscribed="509"
+            expiration="20"
+            event="approved">sip:watcherA@example.com"
+          </watcher>
+     */
+
+    RPointerArray<MSimpleElement> elems;
+    CleanupClosePushL( elems );         // << elems
+    TInt err = aWinfo.SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    TInt count = elems.Count();
+
+    __ASSERT_DEBUG( count == 1, User::Leave( KErrCorrupt ) );
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    const TDesC8* stateVal = aWinfo.AttrValue( KSimpleState8 );
+    if ( stateVal && !stateVal->CompareF( KSimpleFull8 ))
+        {
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginPublisher: fullstate = TRUE") );
+#endif
+        // full winfo-list is received
+        DeleteWatchers();
+        }
+  else
+        {
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginPublisher: fullstate = FALSE") );
+#endif
+    }
+
+    MSimpleElement* elem = elems[0];
+    TPtrC8 p8 = elem->LocalName();
+    err = p8.CompareF( KSimpleWatcherList8 );
+    User::LeaveIfError( err );
+
+    err = elem->SimpleElementsL( elems );
+    User::LeaveIfError( err );
+
+    // Collect the active watchers only.
+    UpdateActiveWatchersListL( elems );
+
+    CDesCArrayFlat* watchers = MakeCurrentWatcherListLC();  // << watchers
+    MXIMPObjectCollection *actives =
+        iConnObs.ObjectFactory().NewObjectCollectionLC();                  // << actives
+
+    // Create MPresenceWatcherInfo entities for
+    // all active watchers and add to actives.
+    TInt wCount = watchers->MdcaCount();
+    for ( TInt j = 0; j < wCount; j++ )
+        {
+        // create MPresenceWatcherInfo object
+        MPresenceWatcherInfo* wInfo =
+            iConnObs.PresenceObjectFactory().NewPresenceWatcherInfoLC();           // << wInfo
+
+        MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC();  // << identity
+#ifdef _DEBUG
+        TBuf<200> debug_buffer;
+        debug_buffer = watchers->MdcaPoint( j );
+        PluginLogger::Log(_L("PluginPublisher: add watcher into collection: %S"), &debug_buffer);
+#endif
+        identity->SetIdentityL( watchers->MdcaPoint( j ) );
+        wInfo->SetWatcherIdL( identity );
+        CleanupStack::Pop( );                               // >> identity
+
+        wInfo->SetWatcherDisplayNameL( watchers->MdcaPoint( j ) );
+        wInfo->SetWatcherTypeL( MPresenceWatcherInfo::EPresenceSubscriber );
+
+        actives->AddObjectL( wInfo );
+        CleanupStack::Pop( );                           // >> wInfo
+        }
+
+    MProtocolPresencePublishingDataHost& publishHost =
+        iConnObs.Host()->ProtocolPresenceDataHost().PublishingDataHost();
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: callback HandlePresenceWatcherListL"));
+#endif
+    publishHost.HandlePresenceWatcherListL( actives );
+    CleanupStack::Pop();                            // >> actives
+    CleanupStack::PopAndDestroy( watchers );        // >> watchers
+    CleanupStack::PopAndDestroy( &elems );          // >> elems
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::WinfoTerminatedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::WinfoTerminatedL( TInt /*aReason*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: WinfoTerminatedL") );
+#endif
+
+    if ( !iSubscribed )
+        {
+        return;
+        }
+
+    // call SetPresenceWatcherListDataSubscriptionStateL
+    iSubscribed = EFalse;
+
+    MProtocolPresencePublishingDataHost& publishHost =
+        iConnObs.Host()->ProtocolPresenceDataHost().PublishingDataHost();
+    MXIMPDataSubscriptionState *state = iConnObs.ObjectFactory().NewDataSubscriptionStateLC();
+    MXIMPStatus* status = iConnObs.ObjectFactory().NewStatusLC();
+    state->SetSubscriptionStateL( MXIMPDataSubscriptionState::ESubscriptionInactive );
+    state->SetDataStateL( MXIMPDataSubscriptionState::EDataUnavailable );
+    status->SetResultCode( KErrCompletion );
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginPublisher: callback SetPresenceWatcherListDataSubscriptionStateL"));
+#endif
+    publishHost.SetPresenceWatcherListDataSubscriptionStateL( state, status );
+    CleanupStack::Pop( 2 ); // status, state
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimplePluginPublisher::UpdateActiveWatchersListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginPublisher::UpdateActiveWatchersListL(
+    RPointerArray<MSimpleElement>& aElems )
+    {
+    // Collect active users.
+    using namespace NSimplePlugin::NSimpleOma;
+
+    HBufC* nodeContent = NULL;
+
+    TInt count = aElems.Count();
+
+    for ( TInt i = 0; i < count; i++ )
+        {
+        MSimpleElement* elem = aElems[i];
+        TPtrC8 p8( elem->LocalName());
+        if (!( p8.CompareF( KSimpleWatcher8 )))
+            {
+            const TDesC8* pp8 = elem->AttrValue( KSimpleStatus8 );
+            // Active wathers here
+            if ( pp8 && !pp8->CompareF( KSimpleActive8 ))
+                {
+
+                // save id since there may be multiple subscriptions
+                // from a single watcher SIP identity.
+                const TDesC8* pId8 = elem->AttrValue( KSimpleId8 );
+
+                // Build collection of grant requests
+                // Find the child node containing the SIP entity
+                nodeContent = elem->ContentUnicodeL();
+                CleanupStack::PushL( nodeContent );         // << nodeContent
+
+                AddWatcherIfNotExistsL( pId8 ? *pId8 : KNullDesC8, nodeContent->Des() );
+
+                CleanupStack::PopAndDestroy( nodeContent ); // >> nodeContent
+                }
+            // Terminated wathers here, remove them from active list
+            else if ( pp8 && !pp8->CompareF( KSimpleTerminated8 ))
+                {
+
+                const TDesC8* pId8 = elem->AttrValue( KSimpleId8 );
+
+                // Remove terminated from iWatcherList
+                nodeContent = elem->ContentUnicodeL();
+                CleanupStack::PushL( nodeContent );             // << nodeContent
+
+                RemoveWatcherIfExistsL( pId8 ? *pId8 : KNullDesC8, nodeContent->Des() );
+
+                CleanupStack::PopAndDestroy( nodeContent );     // >> nodeContent
+                }
+            }
+        }
+
+    }
+
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simplepluginsession.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,223 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#include <e32std.h>
+
+#include <presenceinfo.h>
+
+#include <ximpserviceinfo.h>
+#include <ximpbase.h>
+#include <ximpidentity.h>
+#include <ximpprotocolconnectionhost.h>
+
+#include <simplefactory.h>
+#include <msimpleconnection.h>
+#include <msimpleconnectionobserver.h>
+#include <pressettingsapi.h>
+
+#include "simplepluginsession.h"
+#include "simpleplugindebugutils.h"
+#include "msimplepluginconnectionobs.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::CSimplePluginSession()
+// ---------------------------------------------------------------------------
+//
+CSimplePluginSession::CSimplePluginSession( MSimplePluginConnectionObs& aObs)
+: // CActive( CActive::EPriorityStandard ) ,
+  iObs(aObs), iType( MSimplePluginConnectionObs::ENoReq ), iConnected( EFalse )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginSession::ConstructL(
+    const MXIMPServiceInfo& aService )
+    {
+    // iIap is needed only
+    iIap = aService.IapId();
+
+    iConnection = TSimpleFactory::NewConnectionL( *this );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::NewL()
+// ---------------------------------------------------------------------------
+//
+CSimplePluginSession* CSimplePluginSession::NewL(
+    const MXIMPServiceInfo& aServiceInfo,
+    MSimplePluginConnectionObs& aObs )
+    {
+    CSimplePluginSession* self =  new( ELeave ) CSimplePluginSession( aObs );
+    CleanupStack::PushL( self );
+    self->ConstructL( aServiceInfo );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::~CSimplePluginSession()
+// ---------------------------------------------------------------------------
+//
+CSimplePluginSession::~CSimplePluginSession()
+    {
+    delete iUserId8;
+    delete iDomain;
+    if ( iConnection )
+        {
+        iConnection->Close();        
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::SimpleConnection()
+// ---------------------------------------------------------------------------
+//
+MSimpleConnection* CSimplePluginSession::SimpleConnection( )
+    {
+    return iConnection;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::XdmSettingsId()
+// ---------------------------------------------------------------------------
+//
+TInt CSimplePluginSession::XdmSettingsId( )
+    {
+    return iXdmSetting;
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::CurrentDomain()
+// ---------------------------------------------------------------------------
+//
+TPtrC16 CSimplePluginSession::CurrentDomain( )
+    {
+    return iDomain ? iDomain->Des() : TPtrC16();
+    }    
+
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::OpenSessionL()
+// Notice: MXIMPServiceInfo::IapId supported only
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginSession::OpenSessionL()
+    {
+    TPresSettingsSet mySet;
+
+#ifdef _DEBUG
+
+    PluginLogger::Log(_L("PluginSession: OpenSessionL") );
+        
+    RArray<TInt> setIds;
+    CDesCArray* carr = PresSettingsApi::GetAllSetsNamesLC( setIds );
+    TInt myCount = setIds.Count();
+    for (TInt i=0; i<myCount; i++)
+        {
+
+        TBuf<500> buffer2; buffer2.Copy(carr->MdcaPoint(i));
+        PluginLogger::Log(_L("PluginSession: ID:%d = %S"), setIds[i], &buffer2);
+        }
+    setIds.Reset();
+    CleanupStack::PopAndDestroy( carr );
+#endif
+
+    iConnected = EFalse;
+
+    User::LeaveIfError( PresSettingsApi::SettingsSetL( iIap, mySet ));
+    iXdmSetting = mySet.iXDMSetting;
+    
+    iDomain = mySet.iDomainSyntax.AllocL();   
+
+    // SIP register
+    iOpId = iConnection->LoginL( iIap );
+    iType = MSimplePluginConnectionObs::EOpenSess;       
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::OpenSessionL()
+// Notice: Multiple connections support to be done.
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginSession::OpenSessionL( TInt aSettingsId )
+    {
+    iIap = aSettingsId;
+    OpenSessionL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::ConnectionStatusL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginSession::ConnectionStatusL( MSimpleConnection::TSimpleState aState )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginSession: ConnectionStatusL %d"), aState );
+#endif
+        
+    if ( (aState == MSimpleConnection::EInactive || aState == MSimpleConnection::EUnavailable ) &&
+         iConnected )
+        {
+#ifdef _DEBUG
+        PluginLogger::Log(
+            _L("PluginSession: ConnectionStatusL callback HandleConnectionTerminated") );
+#endif  
+        iConnected = EFalse;                    
+        iObs.Host()->HandleConnectionTerminated( NULL );         
+        }        
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::RequestCompleteL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginSession::RequestCompleteL( TInt /*aOpId*/, TInt aStatus )
+    {
+    MSimplePluginConnectionObs::TReqType current = iType;
+    iType = MSimplePluginConnectionObs::ENoReq;
+    if ( !aStatus )
+        {
+        iConnected = ETrue;
+        }
+    iObs.CompleteReq( current, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginSession::CurrentSipPresentity()
+// ---------------------------------------------------------------------------
+//
+TPtrC8 CSimplePluginSession::CurrentSipPresentity()
+    {        
+    // Get from Simple engine
+    delete iUserId8;
+    iUserId8 = NULL;
+    TRAP_IGNORE( iUserId8 = iConnection->CurrentSIPIdentityL().AllocL() );
+    return iUserId8 ? iUserId8->Des() : TPtrC8();
+    }
+
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simplepluginvariation.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,373 @@
+/*
+* 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:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#include <e32std.h>
+#include <centralrepository.h>
+
+#include "simpleplugincommon.h"
+#include "simplepluginvariation.h"
+#include "presencefwsimpleadptprivatecrkeys.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::CSimplePluginVariation
+// ---------------------------------------------------------------------------
+//
+CSimplePluginVariation::CSimplePluginVariation( )
+: iDefaultRuleAction(ERuleConfirm), iBlockRuleAction(ERulePoliteBlock)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginVariation::ConstructL( )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::NewL
+// ---------------------------------------------------------------------------
+//
+CSimplePluginVariation* CSimplePluginVariation::NewL( )
+    {
+    CSimplePluginVariation* self =
+        new( ELeave ) CSimplePluginVariation();
+    CleanupStack::PushL( self );
+    self->ConstructL(  );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::~CSimplePluginVariation
+// ---------------------------------------------------------------------------
+//
+CSimplePluginVariation::~CSimplePluginVariation()
+    {
+    delete iGrantAllRuleName;
+    delete iGrantOwnRuleName;
+    delete iDefaultRuleName;
+    delete iBlockRuleName;
+    delete iRlsGroupUriTemplate;
+    delete iSharedXdmTop;
+    delete iGrantListName;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::InitL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginVariation::InitL()
+    {
+    // Read Central Repository settings
+    CRepository* repository = NULL;
+
+    TBuf<KSimplePluginMaxRuleLength> myBuffer;
+
+    TRAP_IGNORE( repository =
+        CRepository::NewL( KCRUIDPresencefwSimpleadptVariation ));
+
+    CleanupStack::PushL( repository );
+
+    // initialize strings
+    delete iGrantAllRuleName;
+    iGrantAllRuleName = NULL;
+    delete iGrantOwnRuleName;
+    iGrantOwnRuleName = NULL;
+    delete iDefaultRuleName;
+    iDefaultRuleName = NULL;
+    delete iBlockRuleName;
+    iBlockRuleName = NULL;
+    delete iRlsGroupUriTemplate;
+    iRlsGroupUriTemplate = NULL;
+    delete iSharedXdmTop;
+    iSharedXdmTop = NULL;
+    delete iGrantListName;
+    iGrantListName = NULL;
+    
+    // Read values from CenRep
+    InitGrantRuleNameL( repository );
+    InitGrantOwnRuleNameL( repository );
+    InitDefaultRuleNameL( repository );
+    InitBlockRuleNameL( repository );
+    InitDefaultRuleActionL( repository );
+    InitBlockRuleActionL( repository );           
+    InitRlsGroupUriTemplateL( repository );
+    InitSharedXdmTopL( repository );
+    InitGrantListNameL( repository );
+
+    CleanupStack::PopAndDestroy( repository );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::GrantRuleName
+// ---------------------------------------------------------------------------
+//
+TPtrC CSimplePluginVariation::GrantRuleName()
+    {
+    return iGrantAllRuleName ? iGrantAllRuleName->Des() : TPtrC();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::GrantOwnRuleName
+// ---------------------------------------------------------------------------
+//
+TPtrC CSimplePluginVariation::GrantOwnRuleName()
+    {
+    return iGrantOwnRuleName ? iGrantOwnRuleName->Des() : TPtrC();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::DefaultRuleName
+// ---------------------------------------------------------------------------
+//
+TPtrC CSimplePluginVariation::DefaultRuleName()
+    {
+    return iDefaultRuleName ? iDefaultRuleName->Des() : TPtrC();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::BlockRuleName
+// ---------------------------------------------------------------------------
+//
+TPtrC CSimplePluginVariation::BlockRuleName()
+    {
+    return iBlockRuleName ? iBlockRuleName->Des() : TPtrC();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::DefaultRuleAction
+// ---------------------------------------------------------------------------
+//
+CSimplePluginVariation::TSimplePluginAuthRule CSimplePluginVariation::DefaultRuleAction()
+    {
+    return iDefaultRuleAction;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::BlockRuleAction
+// ---------------------------------------------------------------------------
+//
+CSimplePluginVariation::TSimplePluginAuthRule CSimplePluginVariation::BlockRuleAction()
+    {
+    return iBlockRuleAction;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::RlsGroupUriTemplate
+// ---------------------------------------------------------------------------
+//
+TPtrC CSimplePluginVariation::RlsGroupUriTemplate()
+    {
+    return iRlsGroupUriTemplate ? iRlsGroupUriTemplate->Des() : TPtrC();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::SharedXdmTop
+// ---------------------------------------------------------------------------
+//
+TPtrC CSimplePluginVariation::SharedXdmTop()
+    {
+    return iSharedXdmTop ? iSharedXdmTop->Des() : TPtrC();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::GrantListName
+// ---------------------------------------------------------------------------
+//
+TPtrC CSimplePluginVariation::GrantListName()
+    {
+    return iGrantListName ? iGrantListName->Des() : TPtrC();
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::InitGrantRuleNameL
+// ---------------------------------------------------------------------------
+//    
+void CSimplePluginVariation::InitGrantRuleNameL( CRepository* aRepository )
+    {    
+    TBuf<KSimplePluginMaxRuleLength> myBuffer;    
+    
+    if ( !aRepository || aRepository->Get( KPrFwSimpleGrantAllRuleName, myBuffer ))
+        {
+        // Use deault value when not found in Central Repository
+        myBuffer = KSimpleXdmGrantRule;
+        }
+    iGrantAllRuleName = myBuffer.AllocL( );
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::InitGrantOwnRuleNameL
+// ---------------------------------------------------------------------------
+//    
+void CSimplePluginVariation::InitGrantOwnRuleNameL( CRepository* aRepository )
+    {    
+    TBuf<KSimplePluginMaxRuleLength> myBuffer;    
+    
+    if ( !aRepository || aRepository->Get( KPrFwSimpleGrantOwnRuleName, myBuffer ))
+        {
+        // Use deault value when not found in Central Repository
+        myBuffer = KSimpleXdmOwnGrantRule;
+        }
+    iGrantOwnRuleName = myBuffer.AllocL( );
+    } 
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::InitDefaultRuleNameL
+// ---------------------------------------------------------------------------
+//    
+void CSimplePluginVariation::InitDefaultRuleNameL( CRepository* aRepository )
+    {    
+    TBuf<KSimplePluginMaxRuleLength> myBuffer;    
+    
+    if ( !aRepository || aRepository->Get( KPrFwSimpleDefaultRuleName, myBuffer ))
+        {
+        // Use deault value when not found in Central Repository
+        myBuffer = KSimpleXdmDefaultRule;
+        }
+    iDefaultRuleName = myBuffer.AllocL( );
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::InitBlockRuleNameL
+// ---------------------------------------------------------------------------
+//    
+void CSimplePluginVariation::InitBlockRuleNameL( CRepository* aRepository )
+    {    
+    TBuf<KSimplePluginMaxRuleLength> myBuffer;    
+    
+    if ( !aRepository || aRepository->Get( KPrFwSimpleBlockRuleName, myBuffer ))
+        {
+        // Use deault value when not found in Central Repository
+        myBuffer = KSimpleXdmBlockRule;
+        }
+    iBlockRuleName = myBuffer.AllocL( );
+    }    
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::InitDefaultRuleActionL
+// ---------------------------------------------------------------------------
+//    
+void CSimplePluginVariation::InitDefaultRuleActionL( CRepository* aRepository )
+    {    
+    TBuf<KSimplePluginMaxRuleLength> myBuffer;  
+    
+    using namespace NSimplePlugin::NSimpleOma;      
+    
+    iDefaultRuleAction = ERuleAllow;
+    if ( aRepository && !aRepository->Get( KPrFwSimpleDefaultRuleAction, myBuffer ))
+        {
+        if ( !myBuffer.CompareF( KSimpleBlock ))
+            {
+            iDefaultRuleAction = ERuleBlock;
+            }
+        else if ( !myBuffer.CompareF( KSimplePoliteBlock ))
+            {
+            iDefaultRuleAction = ERulePoliteBlock;
+            }
+        else if ( !myBuffer.CompareF( KSimpleConfirm ))
+            {
+            iDefaultRuleAction = ERuleConfirm;
+            }
+        else if ( !myBuffer.CompareF( KSimpleAllow ))
+            {
+            iDefaultRuleAction = ERuleAllow;
+            }
+        }
+    }
+        
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::InitBlockRuleActionL
+// ---------------------------------------------------------------------------
+//    
+void CSimplePluginVariation::InitBlockRuleActionL( CRepository* aRepository )
+    {    
+    TBuf<KSimplePluginMaxRuleLength> myBuffer;  
+    
+    using namespace NSimplePlugin::NSimpleOma;      
+    
+    iBlockRuleAction = ERuleBlock;
+    if ( aRepository && !aRepository->Get( KPrFwSimpleBlockRuleAction, myBuffer ))
+        {
+        if ( myBuffer.CompareF( KSimpleBlock ))
+            {
+            iBlockRuleAction = ERulePoliteBlock;
+            }
+        else 
+            {
+            // default value is used            
+            }
+        }
+    else
+        {
+        // default value is used
+        }    
+    } 
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::InitRlsGroupUriTemplateL
+// ---------------------------------------------------------------------------
+//    
+void CSimplePluginVariation::InitRlsGroupUriTemplateL( CRepository* aRepository )
+    {    
+    TBuf<KSimplePluginMaxRuleLength> myBuffer;  
+            
+    if ( !aRepository || aRepository->Get( KPrFwSimpleRlsGroupUriTemplate, myBuffer ))
+        {
+        myBuffer = KSimpleRlsGroupUriTemplate;
+        }
+    iRlsGroupUriTemplate = myBuffer.AllocL();    
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::InitSharedXdmTopL
+// ---------------------------------------------------------------------------
+//    
+void CSimplePluginVariation::InitSharedXdmTopL( CRepository* aRepository )
+    {
+    TBuf<KSimplePluginMaxRuleLength> myBuffer;
+
+    if ( !aRepository || aRepository->Get( KPrFwSimpleSharedXdmTop, myBuffer ))
+        {
+        myBuffer = KSimpleOMABuddyList;
+        }
+    iSharedXdmTop = myBuffer.AllocL();
+    }
+    
+// ---------------------------------------------------------------------------
+// CSimplePluginVariation::InitGrantListNameL
+// ---------------------------------------------------------------------------
+//    
+void CSimplePluginVariation::InitGrantListNameL( CRepository* aRepository )
+    {    
+    TBuf<KSimplePluginMaxRuleLength> myBuffer;  
+            
+    if ( !aRepository || aRepository->Get( KPrFwSimpleGrantListName, myBuffer ))
+        {
+        myBuffer = KSimpleS60GrantedList;
+        }
+    iGrantListName = myBuffer.AllocL();   
+    }               
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simplepluginwatcher.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,784 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#include <e32std.h>
+#include <utf.h>
+
+#include <personpresenceinfo.h>
+
+#include <presenceinfo.h>
+#include <presenceinfofieldcollection.h>
+#include <presenceinfofield.h>
+#include <presenceinfofieldvaluetext.h>
+#include <presenceinfofieldvalueenum.h>
+#include <presenceobjectfactory.h>
+#include <presenceerrors.hrh>
+
+#include <presentitygroupmemberinfo.h>
+
+#include <protocolpresencedatahost.h>
+#include <protocolpresentitygroupsdatahost.h>
+#include <protocolpresencewatchingdatahost.h>
+
+#include <ximpdatasubscriptionstate.h>
+#include <ximperrors.hrh>
+#include <ximpidentity.h>
+#include <ximpobjectcollection.h>
+#include <ximpobjectfactory.h>
+#include <ximpprotocolconnectionhost.h>
+#include <ximpstatus.h>
+
+#include <simplefactory.h>
+#include <simpleerrors.h>
+#include <msimplewinfo.h>
+#include <msimplewatcher.h>
+#include <msimpledocument.h>
+#include <msimpleelement.h>
+
+#include "simpleplugincommon.h"
+#include "simplepluginwatcher.h"
+#include "simplepluginentitywatcher.h"
+#include "simpleplugindebugutils.h"
+#include "simpleutils.h"
+#include "simplepluginxdmutils.h"
+#include "simpleplugindata.h"
+#include "simplepluginconnection.h"
+
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::CSimplePluginWatcher
+// ---------------------------------------------------------------------------
+//
+CSimplePluginWatcher::CSimplePluginWatcher(
+    MSimplePluginSettings& aConnSets,
+    MSimplePluginConnectionObs& aObs,
+    MSimpleConnection& aConn )
+: CActive( CActive::EPriorityStandard ),
+  iConnSets( aConnSets), iConnObs(aObs), iConnection(aConn), iCompleted( ETrue ),
+  iOperation( EPluginUndef ), iXdmState( EPluginIdle )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::ConstructL( )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::NewL
+// ---------------------------------------------------------------------------
+//
+CSimplePluginWatcher* CSimplePluginWatcher::NewL(
+    MSimplePluginSettings& aConnSets,
+    MSimplePluginConnectionObs& aObs,
+    MSimpleConnection& aConn )
+    {
+    CSimplePluginWatcher* self =
+        new( ELeave ) CSimplePluginWatcher( aConnSets, aObs, aConn );
+    CleanupStack::PushL( self );
+    self->ConstructL(  );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::~CSimplePluginWatcher
+// ---------------------------------------------------------------------------
+//
+CSimplePluginWatcher::~CSimplePluginWatcher()
+    {
+    iWatchers.ResetAndDestroy();
+    iWatchers.Close();
+    delete iPresIdentity;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoSubscribePresentityPresenceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoSubscribePresentityPresenceL(
+    const MXIMPIdentity& aPresentityId,
+    const MPresenceInfoFilter& /*aPif*/,   // notice: aPif filter not supported
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWatcher: DoSubscribePresentityPresenceL"));
+#endif
+
+    TRAPD( err, DoDoSubscribePresentityPresenceL(aPresentityId, aReqId ));
+    if ( err )
+        {
+        User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoDoSubscribePresentityPresenceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoDoSubscribePresentityPresenceL(
+    const MXIMPIdentity& aPresentityId,
+    TXIMPRequestId aReqId )
+    {
+    iOperation = EPluginUndef;
+    iXdmState = EPluginIdle;
+
+    SetPresIdentityL( aPresentityId );
+    iPrFwId = aReqId;
+    iCompleted = EFalse;
+
+  HBufC8* pres8 = NULL;
+    pres8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iPresIdentity->Des() );
+    CleanupStack::PushL( pres8 ); // << pres8
+
+    CSimplePluginEntityWatcher* watcher = MatchWatcher2L( pres8->Des(), ETrue );
+    watcher->StartSubscribeL( pres8->Des() );
+    CleanupStack::PopAndDestroy( pres8 );  // >> pres8
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoUpdatePresentityPresenceSubscriptionPifL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoUpdatePresentityPresenceSubscriptionPifL(
+    const MXIMPIdentity& /*aPresentityId*/,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(
+        _L("PluginWatcher: DoUpdatePresentityPresenceSubscriptionPifL"));
+#endif
+
+    iOperation = EPluginUndef;
+
+    // notice: aPif filter not supported
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoUnsubscribePresentityPresenceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoUnsubscribePresentityPresenceL(
+    const MXIMPIdentity& aPresentityId,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWatcher: DoUnsubscribePresentityPresenceL"));
+#endif
+
+    TRAPD( err, DoDoUnsubscribePresentityPresenceL( aPresentityId, aReqId ) );
+    if ( err )
+        {
+        User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoDoUnsubscribePresentityPresenceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoDoUnsubscribePresentityPresenceL(
+    const MXIMPIdentity& aPresentityId,
+    TXIMPRequestId aReqId )
+    {
+
+    iOperation = EPluginUndef;
+    iXdmState = EPluginIdle;
+
+    SetPresIdentityL( aPresentityId );
+    iPrFwId = aReqId;
+    iCompleted = EFalse;
+
+  HBufC8* pres8 = NULL;
+    pres8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( iPresIdentity->Des() );
+    CleanupStack::PushL( pres8 ); // << pres8
+
+    CSimplePluginEntityWatcher* watcher = MatchWatcher2L( pres8->Des(), EFalse );
+    if ( !watcher )
+        {
+        User::Leave( KErrNotFound ); // Notice: error code
+        }
+    else
+        {
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginWatcher: -> StopSubscribeL"));
+#endif
+        watcher->StopSubscribeL();
+        }
+    CleanupStack::PopAndDestroy( pres8 );  // >> pres8
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoSubscribePresentityGroupMembersPresenceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoSubscribePresentityGroupMembersPresenceL(
+    const MXIMPIdentity& aGroupId,
+    const MPresenceInfoFilter& /*aPif*/,   // notice: aPif filter not supported
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(
+        _L("PluginWatcher: DoSubscribePresentityGroupMembersPresenceL"));
+#endif
+
+    iOperation = EPluginSubscribeGroup;
+    iXdmState = EPluginIdle;
+
+    SetPresIdentityL( aGroupId );
+    iPrFwId = aReqId;
+    iCompleted = EFalse;
+
+    // Get Shared XDM lists first and create RLS service first
+    StartXdmOperationL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoUpdatePresentityGroupMembersPresenceSubscriptionPifL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoUpdatePresentityGroupMembersPresenceSubscriptionPifL(
+    const MXIMPIdentity& /*aGroupId*/,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(
+  _L("PluginWatcher: DoUpdatePresentityGroupMembersPresenceSubscriptionPifL"));
+#endif
+    // notice: aPif filter not supported
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoUnsubscribePresentityGroupMembersPresenceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoUnsubscribePresentityGroupMembersPresenceL(
+    const MXIMPIdentity& aGroupId,
+    TXIMPRequestId aReqId )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(
+        _L("PluginWatcher: DoUnsubscribePresentityGroupMembersPresenceL"));
+#endif
+    TRAPD( err, DoDoUnsubscribePresentityGroupMembersPresenceL( aGroupId, aReqId ));
+    if ( err )
+        {
+        User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoDoUnsubscribePresentityGroupMembersPresenceL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoDoUnsubscribePresentityGroupMembersPresenceL(
+    const MXIMPIdentity& aGroupId,
+    TXIMPRequestId aReqId )
+    {
+    iOperation = EPluginUnsubscribeGroup;
+    iXdmState = EPluginIdle;
+
+    SetPresIdentityL( aGroupId );
+    iPrFwId = aReqId;
+    iCompleted = EFalse;
+
+    HBufC* buf16 = iXdmUtils->RlsServiceByResourceListLC( iPresIdentity->Des() ); // << buf16
+
+    HBufC8* buf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( buf16->Des() );
+    CleanupStack::PushL( buf );  // << buf
+
+    CSimplePluginEntityWatcher* watcher = MatchWatcher2L( buf->Des(), EFalse );
+
+    CleanupStack::PopAndDestroy( buf );  // >> buf
+    CleanupStack::PopAndDestroy( buf16 );  // >> buf16
+
+    if ( !watcher )
+        {
+        User::Leave( KErrNotFound ); // Notice: error code
+        }
+    else
+        {
+        watcher->StopSubscribeL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::GetInterface
+// ---------------------------------------------------------------------------
+//
+TAny* CSimplePluginWatcher::GetInterface(
+        TInt32 aInterfaceId,
+        TIfGetOps aOptions )
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        MProtocolPresenceWatching* myIf = this;
+        return myIf;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::GetInterface
+// ---------------------------------------------------------------------------
+//
+const TAny* CSimplePluginWatcher::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        const MProtocolPresenceWatching* myIf = this;
+        return myIf;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( _L("CSimplePlugin"), KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::GetInterfaceId
+// ---------------------------------------------------------------------------
+//
+TInt32 CSimplePluginWatcher::GetInterfaceId() const
+    {
+    return MProtocolPresenceWatching::KInterfaceId;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::MatchWatcher2L
+// ---------------------------------------------------------------------------
+//
+CSimplePluginEntityWatcher* CSimplePluginWatcher::MatchWatcher2L(
+    const TDesC8& aPresentityid, TBool aCreate )
+    {
+    TInt count = iWatchers.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        CSimplePluginEntityWatcher* temp = (iWatchers[i]);
+        if ( !temp->PresentityId().CompareF( aPresentityid ))
+            {
+            return temp;
+            }
+        }
+
+    // If watcher was not found, crete it when wanted so.
+    if ( !aCreate )
+        {
+        return NULL;
+        }
+    else
+        {
+        CSimplePluginEntityWatcher* watcher = CSimplePluginEntityWatcher::NewL(
+            iConnObs, iConnection, *this );
+        iWatchers.AppendL( watcher );
+        return watcher;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DeleteWatcher
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DeleteWatcher(
+    const TDesC8& aPresentityid )
+    {
+
+#ifdef _DEBUG
+    PluginLogger::Log( _L("PluginWatcher: DeleteWatcher **"));
+#endif
+
+    TInt count = iWatchers.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        CSimplePluginEntityWatcher* temp = (iWatchers[i]);
+        if ( !temp->PresentityId().CompareF( aPresentityid ) )
+            {
+            iWatchers.Remove( i );
+            iWatchers.GranularCompress();
+            delete temp;
+            break;
+            }
+        else
+            {
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::GetEntitiesInListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::GetEntitiesInListL(
+    const TDesC& aList, MXIMPObjectCollection& aMembers )
+    {
+    __ASSERT_DEBUG( iXdmUtils, User::Leave( KErrCorrupt ) );
+
+    const TInt KMyGran = 10;
+    CPtrCArray* ids = new (ELeave) CPtrCArray( KMyGran );
+    CleanupStack::PushL( ids );      // << ids
+
+    CPtrCArray* dispNames = new (ELeave) CPtrCArray( KMyGran );
+    CleanupStack::PushL( dispNames  );      // << dispNames
+
+    iXdmUtils->GetEntitiesInListL( aList, *ids, *dispNames );
+
+    CopyGroupMembersToCollectionL( *ids, *dispNames, aMembers );
+
+    CleanupStack::PopAndDestroy( dispNames );
+    CleanupStack::PopAndDestroy( ids );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::StartWatchingRlsL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::StartWatchingRlsL()
+    {
+    HBufC* buf = iXdmUtils->RlsServiceByResourceListLC( iPresIdentity->Des() );  // << buf
+
+    HBufC8* buf2 = NULL;
+    buf2 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( buf->Des() );
+    CleanupStack::PushL( buf2 ); // << buf2
+
+    CSimplePluginEntityWatcher* watcher = MatchWatcher2L( buf2->Des(), ETrue );
+
+    watcher->StartSubscribeListL( buf2->Des() );
+
+    watcher->SetSimpleNameL( buf2->Des() );
+
+    CleanupStack::PopAndDestroy( buf2 );  // >> buf2
+    CleanupStack::PopAndDestroy( buf );  // >> buf
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::SetPresIdentityL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::SetPresIdentityL(
+     const MXIMPIdentity& aPresentityId )
+     {
+     delete iPresIdentity;
+     iPresIdentity = NULL;
+     iPresIdentity = aPresentityId.Identity().AllocL();
+     }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::CompletePrFwReq
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::CompletePrFwReq( TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWatcher: CompletePrFwReq status=%d"), aStatus );
+#endif
+    iXdmState = EPluginIdle;
+
+    if ( !iCompleted )
+        {
+        iCompleted = ETrue;
+        // Convert error code when needed
+        if ( aStatus == KSimpleErrNotFound &&
+             ( iOperation == EPluginSubscribeGroup ||
+               iOperation == EPluginUnsubscribeGroup ))
+            {
+            aStatus = KPresenceErrUnknownPresentityGroup;
+            }
+        else if ( aStatus == KSimpleErrNotFound )
+            {
+            aStatus = KPresenceErrUnknownPresentity;
+            }
+        else
+            {
+            }
+        iConnObs.CompleteReq( iPrFwId, aStatus );
+        iPrFwId = TXIMPRequestId();
+        iOperation = EPluginUndef;
+        }
+    else
+        {
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::CompleteWatcher
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::CompleteWatcher( TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWatcher: CompleteWatcher status=%d"), aStatus );
+#endif
+    // start to remove RLS service when needed.
+    if ( iOperation == EPluginUnsubscribeGroup && iXdmState == EPluginIdle )
+        {
+        TRAPD( err, iXdmUtils->FetchRlsL( iStatus ));
+        if ( err )
+            {
+            CompletePrFwReq( err );
+            }
+        else
+            {
+            iXdmState = EPluginFetchRls;
+            SetActive();
+            }
+        }
+    else
+        {
+        CompletePrFwReq( aStatus );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::StartXdmOperationL()
+    {
+    TRAPD( err, DoStartXdmOperationL() );
+    if ( err )
+        {
+        User::Leave( CSimplePluginConnection::HarmonizeErrorCode( err ));
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoStartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoStartXdmOperationL()
+    {
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) );
+    if ( !iXdmUtils )
+        {
+        iXdmUtils = iConnObs.XdmUtilsL();
+        }
+    iXdmUtils->InitializeXdmsOnlyL( iStatus );
+
+    iXdmState = EPluginInitXdm;
+
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoCancel(  )
+    {
+    iXdmUtils->Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::RunL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::RunL(  )
+    {
+
+    TInt status = iStatus.Int();
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWatcher: RunL %d"), status );
+#endif
+    if ( !status )
+        {
+        // create RLS service first here
+        if ( iOperation == EPluginSubscribeGroup )
+            {
+            DoRunForSubscriptionL();
+            }
+        // remove RLS service when needed.
+        else if ( iOperation == EPluginUnsubscribeGroup )
+            {
+            DoRunForUnsubscriptionL();
+            }
+        else
+            {
+            // Idle state should not be completed. We should not come here
+            // because of PrFw core makes one request at a time.
+            }
+        }
+    else
+        {
+        CompletePrFwReq( status );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CSimplePluginWatcher::RunError( TInt aError )
+    {
+    CompletePrFwReq( aError );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::GetListContentL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::GetListContentL()
+    {
+    MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();
+    MProtocolPresentityGroupsDataHost& dataHost =
+        iConnObs.Host()->ProtocolPresenceDataHost().GroupsDataHost();
+
+    MXIMPObjectCollection* entities =
+        myFactory.NewObjectCollectionLC();          // << entities
+    GetEntitiesInListL( iPresIdentity->Des(), *entities );
+
+    // callback for data
+    MXIMPIdentity* id = myFactory.NewIdentityLC();  // << id
+    id->SetIdentityL( iPresIdentity->Des() );
+#ifdef _DEBUG
+    PluginLogger::Log(
+        _L("PluginWatcher: callback HandlePresentityGroupContentL"));
+#endif
+    dataHost.HandlePresentityGroupContentL( id, entities );
+    CleanupStack::Pop();                            // >> id
+    CleanupStack::Pop();                            // >> entities
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::CopyGroupMembersToCollectionL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::CopyGroupMembersToCollectionL(
+    CPtrCArray& aIds, CPtrCArray& aNames, MXIMPObjectCollection& aCollection)
+    {
+    MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();
+    MPresenceObjectFactory& myPresenceFactory = iConnObs.PresenceObjectFactory();
+    TInt count = aIds.Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        // create here MPresentityGroupMemberInfo
+        MPresentityGroupMemberInfo* info = myPresenceFactory.NewPresentityGroupMemberInfoLC(); // << info
+        MXIMPIdentity* id = myFactory.NewIdentityLC();  // << id
+        id->SetIdentityL( aIds[i] );
+        info->SetGroupMemberIdL( id );
+        CleanupStack::Pop(); // >> id
+
+        info->SetGroupMemberDisplayNameL( aNames[i] );
+        aCollection.AddObjectL( info );
+        CleanupStack::Pop(); // >> info
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoRunForSubscriptionL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoRunForSubscriptionL( )
+    {
+    if ( iXdmState == EPluginInitXdm )
+        {
+        // get members of the list first
+        GetListContentL();
+
+        // Fetch RLS document first before modifying the data.
+        TRAPD( err, iXdmUtils->FetchRlsL( iStatus ));
+        if ( err )
+            {
+            CompletePrFwReq( err );
+            }
+        else
+            {
+            iXdmState = EPluginFetchRls;
+            SetActive();
+            }
+        }
+    else if ( iXdmState == EPluginFetchRls )
+        {
+        // Create RLS document service
+        iXdmUtils->AddRlsGroupL( iPresIdentity->Des() );
+        iXdmState = EPluginAddGroupMember;
+        iXdmUtils->CommitRlsL( iStatus );
+        SetActive();
+        }
+    else
+        {
+        StartWatchingRlsL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWatcher::DoRunForUnsubscriptionL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWatcher::DoRunForUnsubscriptionL( )
+    {
+    TInt status = iStatus.Int();
+    if ( iXdmState == EPluginIdle )
+        {
+        TRAPD( err, iXdmUtils->FetchRlsL( iStatus ));
+        if ( err )
+            {
+            CompletePrFwReq( err );
+            }
+        else
+            {
+            iXdmState = EPluginFetchRls;
+            SetActive();
+            }
+        }
+    else if ( iXdmState == EPluginFetchRls )
+        {
+        TRAPD( err, iXdmUtils->RemoveRlsServiceByResourceListL( iPresIdentity->Des(), iStatus ));
+        if ( err )
+            {
+            CompletePrFwReq( err );
+            }
+        else
+            {
+            iXdmState = EPluginRemoveGroupMember;
+            SetActive();
+            }
+        }
+    else
+        {
+        CompletePrFwReq( status );
+        }
+    }
+
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simplepluginwinfo.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,211 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#include <e32std.h>
+
+#include <ximpdatasubscriptionstate.h>
+#include <ximpobjectfactory.h>
+
+#include <simplefactory.h>
+#include <msimplewinfowatcher.h>
+
+#include "simpleplugincommon.h"
+#include "simplepluginwinfo.h"
+#include "simpleplugindebugutils.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWinfo::CSimplePluginWinfo()
+// ---------------------------------------------------------------------------
+//
+CSimplePluginWinfo::CSimplePluginWinfo(
+    MSimplePluginConnectionObs& aObs,
+    MSimpleConnection& aConn )
+  : iConnObs(aObs), iConnection(aConn), iSubscribed(0), iWinfoCompleted(EFalse)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWinfo::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWinfo::ConstructL( )
+    {
+    iWinfoWatcher = TSimpleFactory::NewWinfoWatcherL( iConnection, *this );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWinfo::NewL()
+// ---------------------------------------------------------------------------
+//
+CSimplePluginWinfo* CSimplePluginWinfo::NewL(
+    MSimplePluginConnectionObs& aObs,
+    MSimpleConnection& aConn )
+    {
+    CSimplePluginWinfo* self =
+        new( ELeave ) CSimplePluginWinfo( aObs, aConn );
+    CleanupStack::PushL( self );
+    self->ConstructL(  );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWinfo::~CSimplePluginWinfo()
+// ---------------------------------------------------------------------------
+//
+CSimplePluginWinfo::~CSimplePluginWinfo()
+    {
+    if ( iWinfoWatcher )
+        {
+        iWinfoWatcher->Close();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWinfo::SetHost()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWinfo::SetHost(
+    MXIMPProtocolConnectionHost* aHost )
+    {
+    iHost = aHost;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWinfo::SubscribeWinfoListL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWinfo::SubscribeWinfoListL( TXIMPRequestId aReqId )
+    {
+    iWinfoCompleted = EFalse;
+    iSubscribed++;
+    if ( iSubscribed == 1 )
+        {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWinfo: -> SubscribeWatcherListL") );
+#endif
+        iSimpleId = iWinfoWatcher->SubscribeWatcherListL( NULL );
+        iSubscribed = ETrue;
+        iPrFwId = aReqId;
+        }
+    else
+        {
+        iSimpleId = 0;
+        iPrFwId = aReqId;
+        WinfoReqCompleteL( iSimpleId, KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWinfo::UnsubscribeWinfoListL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWinfo::UnsubscribeWinfoListL( TXIMPRequestId aReqId )
+    {
+    iWinfoCompleted = EFalse;
+    TInt orig = iSubscribed;
+    iSubscribed--;
+    if ( iSubscribed < 0 )
+        {
+        iSubscribed = 0;
+        }
+
+    if ( !iSubscribed && orig )
+        {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWinfo: -> UnsubscribeL") );
+#endif
+        iSubscribed++;
+        iSimpleId = iWinfoWatcher->UnsubscribeL();
+        iSubscribed--;
+        iPrFwId = aReqId;
+        }
+    else
+        {
+        iSimpleId = 0;
+        iPrFwId = aReqId;
+        WinfoReqCompleteL( iSimpleId, KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWinfo::WinfoReqCompleteL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWinfo::WinfoReqCompleteL( TInt /*aOpId*/, TInt aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWinfo: WinfoReqCompleteL status=%d"), aStatus );
+#endif
+
+    if ( !iWinfoCompleted  )
+        {
+        iWinfoCompleted = ETrue;
+        iSimpleId = 0;
+        iConnObs.CompleteWinfoReq( iPrFwId, aStatus );
+        // Do not wait MXIMPProtocolConnectionHostObserver callback, this
+        // class is ready to serve the next request now.
+        iPrFwId = TXIMPRequestId();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWinfo::WinfoTerminatedL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWinfo::WinfoTerminatedL(
+    TInt aOpId, TInt aReason )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWinfo: WinfoTerminatedL opid=%d"), aOpId );
+#endif
+
+    if ( iSimpleId == aOpId )
+        {
+        iSimpleId = 0;
+        iConnObs.WinfoTerminatedL( aReason );
+        }
+ }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginWinfo::WinfoNotificationL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginWinfo::WinfoNotificationL(
+    MSimpleWinfo& aWinfo )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWinfo: WinfoNotificationL starts"));
+#endif
+
+    WinfoReqCompleteL( iSimpleId, KErrNone );
+    iConnObs.WinfoNotification( aWinfo );
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWinfo: WinfoNotificationL ends"));
+#endif
+    }
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencefwsimpleadpt/src/simplepluginxdmutils.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,2522 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    SIMPLE Protocol implementation for Presence Framework
+*
+*/
+
+
+
+
+#include <e32std.h>
+#include <utf.h>
+
+#include <simplefactory.h>
+#include <msimpleconnection.h>
+
+#include <pressettingsapi.h>
+#include <cpresencexdm.h>
+#include <rlspresxdmconsts.h>
+#include <XdmErrors.h>
+#include <prescondmisc.h>
+#include <prescondidentityone.h>
+#include <presenceactionxdm.h>
+#include <presencetransformxdm.h>
+#include <crlsxdm.h>
+
+#include <XdmEngine.h>
+#include <XdmDocument.h>
+#include <XdmProtocolInfo.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include <XdmSettingsApi.h>
+#include <XdmErrors.h>
+
+#include "simpleplugindebugutils.h"
+#include "simpleplugincommon.h"
+#include "simplepluginxdmutils.h"
+#include "simpleplugindata.h"
+#include "simplepluginvariation.h"
+#include "msimplepluginsettings.h"
+
+// Test suite
+#include "msimpleplugintestobs.h"
+
+// This is for debugging and local test mode oly
+#include <in_sock.h>
+
+// URI prefixies
+const TInt KMyLenPrefix = 4;
+_LIT16( KMySip, "sip:" );
+_LIT16( KMyTel, "tel:" );
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::CSimplePluginXdmUtils
+// ---------------------------------------------------------------------------
+//
+CSimplePluginXdmUtils::CSimplePluginXdmUtils(
+    MSimplePluginSettings& aConnSets, TInt aXmdId )
+: CActive( EPriorityStandard ),
+  iConnSets(aConnSets), iSettingsId(aXmdId),
+  iXdmState(EStateIdle), iOperation( ENoOperation), iTestObs( NULL )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::ConstructL(  )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::NewL
+// ---------------------------------------------------------------------------
+//
+CSimplePluginXdmUtils* CSimplePluginXdmUtils::NewL(
+    MSimplePluginSettings& aConnSets,
+    TInt aXmdId )
+    {
+    CSimplePluginXdmUtils* self =
+        new( ELeave ) CSimplePluginXdmUtils( aConnSets, aXmdId );
+    CleanupStack::PushL( self );
+    self->ConstructL(   );
+    CleanupStack::Pop( self );
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: NewL this=%d"), (TInt)self);
+#endif
+
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::~CSimplePluginXdmUtils()
+// ---------------------------------------------------------------------------
+//
+CSimplePluginXdmUtils::~CSimplePluginXdmUtils()
+    {
+
+    Cancel();
+
+    CancelWrappers();
+
+    if ( iXdmDoc && iXdmEngine )
+        {
+        TRAP_IGNORE( iXdmEngine->DeleteDocumentModelL( iXdmDoc ));
+        }
+    delete iRlsXdm;
+    delete iPresenceXdm;
+    delete iXdmEngine;
+    delete iAuxBuffer;
+
+    delete iAuxBuffer2;
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::InitializeXdmL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::InitializeXdmL( TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: InitializeXdmL") );
+#endif
+
+    iOperation = EXdmInit;
+    iClientStatus = &aStatus;
+
+    if ( !iXdmOk )
+        {
+        GetXdmOMAListsL();
+        iXdmState = EGetXdmOMALists;
+        *iClientStatus = KRequestPending;
+        }
+    else if ( !iPresXdmOk )
+        {
+        GetXdmRulesL();
+        *iClientStatus = KRequestPending;
+        }
+    else
+        {
+        // All is ok
+        *iClientStatus = KRequestPending;
+        CompleteClientReq( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::InitializeXdmsOnlyL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::InitializeXdmsOnlyL( TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: InitializeXdmsOnlyL") );
+#endif
+
+    iOperation = EXdmInitXdmsOnly;
+    iClientStatus = &aStatus;
+
+    if ( !iXdmOk )
+        {
+        GetXdmOMAListsL();
+        iXdmState = EGetXdmOMAListsOnly;
+        *iClientStatus = KRequestPending;
+        }
+    else
+        {
+        // All is ok
+        *iClientStatus = KRequestPending;
+        CompleteClientReq( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::RunL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::RunL(  )
+    {
+    TPluginXdmState origState = iXdmState;
+    iXdmState = EStateIdle;
+    TInt myStatus = iStatus.Int();
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: RunL %d"), myStatus );
+#endif
+
+    if ( iTestObs )
+        {
+        // Test suite
+        iTestObs->TestCallbackInRunL(
+            myStatus, origState, iOperation, KNullDesC );
+        }
+
+#ifdef FAKE_XDM_OK
+#ifdef _DEBUG
+    // -191 = KErrHostUnreach in_sock.h
+    if ( myStatus == KErrTimedOut || myStatus == KXcapErrorNetworkNotAvailabe || -191 )
+        {
+        PluginLogger::Log(_L("PluginXdmUtils : RunL FAKE_XDM_OK resets error code %d"), myStatus );
+        myStatus = 0;
+        }
+#endif
+#endif
+
+    DoXdmRunL( origState, myStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoXdmRunL()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoXdmRunL( TPluginXdmState aOrigState, TInt aStatus )
+    {
+
+    switch ( aOrigState )
+        {
+        case EGetXdmOMALists:
+        case EGetXdmOMAListsOnly:
+            {
+            // no OMA resource-list, let's start to create it.
+            if ( CreateXdmOMAListsIfNeededL() )
+                {
+                iXdmState = aOrigState == EGetXdmOMALists ? ECreateXdmOMALists : ECreateXdmOMAListsOnly;
+                }
+            else
+                {
+                iXdmOk = ETrue;
+                if ( !iPresXdmOk && aOrigState == EGetXdmOMALists )
+                    {
+                    GetXdmRulesL();
+                    }
+                else
+                    {
+                    CompleteClientReq( KErrNone );
+                    }
+                }
+            }
+            break;
+        case ECreateXdmOMALists:
+            {
+            if ( aStatus )
+                {
+                CompleteClientReq( aStatus );
+                }
+            else
+                {
+                iXdmOk = ETrue;
+                GetXdmRulesL();
+                }
+            }
+            break;
+        case ECreateXdmOMAListsOnly:
+            {
+            if ( !aStatus )
+                {
+                iXdmOk = ETrue;
+                }
+            CompleteClientReq( aStatus );
+            }
+            break;
+        default:
+            // complete reqular request
+            CompleteClientReq( aStatus );
+            break;
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::CancelWrappers()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::CancelWrappers( )
+    {
+    iOperation = EXdmCancel;
+
+    // Cancel M-class interface methods that calls callback method.
+    if ( iXdmState == EGetRlsServices ||
+         iXdmState == EUpdateRlsServices ||
+         iXdmState == EReUpdateRlsServices )
+        {
+        iXdmState = ECancelDocument;
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginXdm: -> iRlsXdm->Cancel"));
+#endif
+        // Better call Cancel() instead of CancelUpdateL().
+        // It works and is easier to implement. Otherwise we should have here
+        // SetActive(); iStatus=KRequestPending; User::WaitForRequest(iStatus)
+        // and we should have implemented HandleRLSUpdateCancelL that completes
+        // own iStatus.
+        iRlsXdm->Cancel();
+        }
+    else if ( iXdmState == EGetXdmRules ||
+              iXdmState == EUpdateXdmRules )
+        {
+        iXdmState = ECancelDocument;
+#ifdef _DEBUG
+        PluginLogger::Log(_L("PluginXdm: -> iPresenceXdm->Cancel"));
+#endif
+        iPresenceXdm->Cancel();
+        }
+    else
+        {
+        }
+    }
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoCancel(  )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: DoCancel"));
+#endif
+    iOperation = EXdmCancel;
+
+    if ( iXdmState == EGetXdmOMALists || iXdmState == ECreateXdmOMALists ||
+         iXdmState == EGetXdmOMAListsOnly || iXdmState == ECreateXdmOMAListsOnly ||
+         iXdmState == EUpdateXdmOMAList )
+        {
+        // Cancel a request made to XDM Engine.
+        iXdmState = ECancelDocument;
+#ifdef _DEBUG
+      PluginLogger::Log(_L("PluginXdm: iXdmEngine->CancelUpdate"));
+#endif
+        iXdmEngine->CancelUpdate( iXdmDoc );
+        CompleteClientReq( KErrCancel );
+        }
+    else
+        {
+        // Cancel a request where we have completed our own iStatus.
+        // Very rare posibility that this happens when GetXdmOMALists is not ready.
+        // It's very hard to make it happen in test suite.
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CSimplePluginXdmUtils::RunError( TInt aError )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: RunError"));
+#endif
+    // complete the open request
+    CompleteClientReq( aError );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::FetchRlsL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::FetchRlsL(
+    TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: FetchRlsL"));
+#endif
+    _LIT( KMyOper, "FetchRlsL");
+
+    iClientStatus = &aStatus;
+
+    iOperation = EXdmRlsFetch;
+
+    if ( !iRlsXdm )
+        {
+        iRlsXdm = CRLSXDM::NewL( iSettingsId );
+        }
+
+    if ( iTestObs )
+        {
+        // Test suite
+        iTestObs->TestCallbackAsynchL(
+            KErrNone, iXdmState, iOperation, KMyOper );
+        }
+
+    // The following returns in MRLSPresXDMAsyncHandler callback
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: -> iRlsXdm->UpdateAllFromServerL"));
+#endif
+    User::LeaveIfError( iRlsXdm->UpdateAllFromServerL( this ));
+
+    *iClientStatus = KRequestPending;
+
+    iXdmState = EGetRlsServices;
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::AddRlsGroupL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::AddRlsGroupL(
+    const TDesC&  aName )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: AddRlsGroupL"));
+#endif
+    iOperation = EXdmRlsAdd;
+
+    HBufC16* buf = CreateRlsDocumentUri16LC(
+        aName, iConnSets.CurrentSipPresentity(), iConnSets.CurrentDomain() );
+
+    // KErrAlreadyExists
+    TInt errx = iRlsXdm->AddServiceURIL( buf->Des() );
+    if ( errx && errx != KErrAlreadyExists )
+        {
+        User::Leave( errx );
+        }
+    User::LeaveIfError( iRlsXdm->SwitchToServiceURIL( buf->Des() ));
+
+    HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri );
+    CleanupStack::PushL( xcapUri );             // << xcapUri
+
+    HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), aName );
+    CleanupStack::PushL( listUri );             // << listUri
+
+    TInt err = iRlsXdm->AddElementL( KPresResourceList,
+        listUri->Des(), aName );
+    if ( err && err != KErrAlreadyExists )
+        {
+        User::Leave( err );
+        }
+
+    // Save aName for RLS Service URI negoriation handling (HTTP error 409).
+    // Notice: We assume that only one AddRlsGroupL is called between CommitRlsL methods.
+
+    delete iAuxBuffer;
+    iAuxBuffer = NULL;
+    iAuxBuffer = aName.AllocL();
+
+    CleanupStack::PopAndDestroy( listUri );     // >> listUri
+    CleanupStack::PopAndDestroy( xcapUri );     // >> xcapUri
+    CleanupStack::PopAndDestroy( buf );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::RemoveRlsGroupL
+// Use RemoveRlsServiceByResourceListL when possible
+//
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::RemoveRlsGroupL(
+    const TDesC&  aName )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: RemoveRlsGroupL"));
+#endif
+
+    iOperation = EXdmRlsRemove;
+
+    HBufC16* buf = CreateRlsDocumentUri16LC(
+        aName, iConnSets.CurrentSipPresentity(), iConnSets.CurrentDomain() );
+
+    User::LeaveIfError( iRlsXdm->RemoveServiceURIL( buf->Des()));
+    CleanupStack::PopAndDestroy( buf );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::AddEntityToGrantedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::AddEntityToGrantedL(
+    const TDesC&  aUri, TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: AddEntityToGrantedL"));
+#endif
+    iClientStatus = &aStatus;
+
+    iOperation = EXdmAddUserToGroup;
+
+    DoAddUserToListL( iConnSets.Variation().GrantListName(), aUri );
+
+    // send to the server and start wait a response
+    UpdateXdmsL();
+    iXdmState = EUpdateXdmOMAList;
+
+    *iClientStatus = KRequestPending;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::AddEntityToBlockedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::AddEntityToBlockedL(
+    const TDesC&  aUri, TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: AddEntityToBlockedL"));
+#endif
+    iClientStatus = &aStatus;
+
+    iOperation = EXdmAddUserToGroup;
+    DoAddUserToListL( KSimpleOMABlockedList, aUri );
+
+    // send to the server and start wait a response
+    UpdateXdmsL();
+    iXdmState = EUpdateXdmOMAList;
+
+    *iClientStatus = KRequestPending;
+    }
+
+// ----------------------------------------------------
+// CSimplePluginXdmUtils::DoAddUserToListL
+// ----------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoAddUserToListL(
+    const TDesC& aList, const TDesC&  aUri )
+    {
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    RPointerArray<CXdmDocumentNode> lists;
+    CleanupClosePushL( lists );                 // <<  lists
+
+    CXdmDocumentNode* root = iXdmDoc->DocumentRoot();
+    CXdmDocumentNode* foundNode = SearchListUnderParentL( root, aList );
+
+    if ( foundNode )
+        {
+        if ( foundNode->IsEmptyNode() )
+            {
+            foundNode->SetEmptyNode( EFalse );
+            }
+
+        CXdmDocumentNode* newNode = foundNode->CreateChileNodeL( KSimpleEntry );
+        CXdmNodeAttribute* attributeEntryUri = newNode->CreateAttributeL( KSimpleUri );
+        attributeEntryUri->SetAttributeValueL( aUri );
+        iXdmDoc->AppendL( newNode );
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    CleanupStack::PopAndDestroy( &lists  );     // >> lists
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::RemoveEntityFromGrantedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::RemoveEntityFromGrantedL(
+    const TDesC&  aUri, TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: RemoveEntityFromGrantedL"));
+#endif
+    iClientStatus = &aStatus;
+
+    iOperation = EXdmRemoveUserFromGroup;
+    DoRemoveUserFromListL( iConnSets.Variation().GrantListName(), aUri );
+
+    // send to the server and start wait a response
+    UpdateXdmsL();
+    iXdmState = EUpdateXdmOMAList;
+
+    *iClientStatus = KRequestPending;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::RemoveEntityFromBlockedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::RemoveEntityFromBlockedL(
+    const TDesC&  aUri, TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: RemoveEntityFromBlockedL"));
+#endif
+    iClientStatus = &aStatus;
+
+    iOperation = EXdmRemoveUserFromGroup;
+    DoRemoveUserFromListL( KSimpleOMABlockedList, aUri );
+
+    // send to the server and start wait a response
+    UpdateXdmsL();
+    iXdmState = EUpdateXdmOMAList;
+
+    *iClientStatus = KRequestPending;
+    }
+
+// ----------------------------------------------------
+// CSimplePluginXdmUtils::DoRemoveUserFromListL
+// ----------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoRemoveUserFromListL(
+    const TDesC& aList, const TDesC&  aUri )
+    {
+    CXdmNodeAttribute* attr = NULL;
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    RPointerArray<CXdmDocumentNode> lists;
+    CleanupClosePushL( lists );
+
+    RPointerArray<CXdmDocumentNode> nodes;
+    CleanupClosePushL( nodes );
+
+    CXdmDocumentNode* root = iXdmDoc->DocumentRoot();
+    CXdmDocumentNode* foundNode = SearchListUnderParentL( root, aList );
+    if ( foundNode )
+        {
+        User::LeaveIfError( foundNode->Find( KSimpleEntry, nodes ));
+        TInt nodeCount = nodes.Count();
+        for ( TInt i = 0; i < nodeCount; i++ )
+            {
+            CXdmDocumentNode* currNode = nodes[i];
+            attr = ( currNode )->Attribute( KSimpleUri );
+            if ( attr && !attr->AttributeValue().CompareF( aUri ))
+                {
+                // This is the user we are looking for deletion.
+                iXdmDoc->DeleteDataL( currNode );
+                break;
+                }
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    CleanupStack::PopAndDestroy( &nodes ); // >>> nodes
+    CleanupStack::PopAndDestroy( &lists ); // >>> lists
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::RemoveGroupFromGrantedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::RemoveGroupFromGrantedL(
+    const TDesC&  aName, TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: RemoveGroupFromGrantedL"));
+#endif
+    iClientStatus = &aStatus;
+
+    HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri );
+    CleanupStack::PushL( xcapUri );             // << xcapUri
+
+    HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), aName );
+    CleanupStack::PushL( listUri );             // << listUri
+
+    DoRemoveListFromGrantRuleL( listUri->Des() );
+
+    CleanupStack::PopAndDestroy( listUri );
+    CleanupStack::PopAndDestroy( xcapUri );
+
+    iOperation = EXdmWithdrawGroup;
+    }
+
+// ----------------------------------------------------
+// CSimplePluginXdmUtils::DoRemoveListFromGrantRuleL
+// ----------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoRemoveListFromGrantRuleL(
+    const TDesC&  aListUri )
+    {
+    TPresCondMisc misc;
+    misc.Init( iPresenceXdm );
+
+    if ( !misc.DeleteExternalListL( iConnSets.Variation().GrantRuleName(), aListUri ))
+        {
+        // update document in the server only if there was a modification.
+        UpdateXdmRulesL();
+        *iClientStatus = KRequestPending;
+        }
+    else
+        {
+        // Complete without server operation
+        CompleteClientReq( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::AddGroupToGrantedL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::AddGroupToGrantedL(
+    const TDesC&  aName, TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: AddGroupToGrantedL"));
+#endif
+
+    iClientStatus = &aStatus;
+
+    if ( !DoesUserListExistsL( aName )  )
+      {
+      User::Leave( KErrNotFound );
+      }
+
+    HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri );
+    CleanupStack::PushL( xcapUri );             // << xcapUri
+
+    HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), aName );
+    CleanupStack::PushL( listUri );             // << listUri
+
+    iOperation = EXdmGrantGroup;
+
+    DoAddListIntoGrantRuleL( listUri->Des() );
+
+    CleanupStack::PopAndDestroy( listUri );     // >> listUri
+    CleanupStack::PopAndDestroy( xcapUri );     // >> xcapUri
+
+    *iClientStatus = KRequestPending;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoAddListIntoGrantRuleL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoAddListIntoGrantRuleL(
+    const TDesC& aListUri)
+    {
+    TPresCondMisc misc;
+    misc.Init( iPresenceXdm );
+
+    User::LeaveIfError( misc.AddExternListL( iConnSets.Variation().GrantRuleName(), aListUri ));
+
+    UpdateXdmRulesL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::GrantForEveryoneL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::GrantForEveryoneL( TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: GrantForEveryoneL"));
+#endif
+    iClientStatus = &aStatus;
+
+    iOperation = EXdmGrantForAll;
+    DoGrantForAllL();
+
+    *iClientStatus = KRequestPending;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::WithdrawFromEveryoneL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::WithdrawFromEveryoneL( TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: WithdrawFromEveryoneL"));
+#endif
+    iClientStatus = &aStatus;
+
+    iOperation = EXdmWithdrawFromAll;
+    DoWithdrawFromAllL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::SetReactiveAuthL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::SetReactiveAuthL( TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: SetReactiveAuthL"));
+#endif
+    iClientStatus = &aStatus;
+
+    iOperation = EXdmSetReactiveAuth;
+    DoSetReactiveAuthL();
+
+    *iClientStatus = KRequestPending;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::SetProactiveAuthL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::SetProactiveAuthL( TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: SetProactiveAuthL"));
+#endif
+    iClientStatus = &aStatus;
+
+    iOperation = EXdmSetProactiveAuth;
+    DoSetProactiveAuthL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::SubscribeBlockListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::SubscribeBlockListL( CPtrCArray& aMembers )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: SubscribeBlockListL"));
+#endif
+    iOperation = EXdmGetBlockedList;
+    DoGetListMembersL( KSimpleOMABlockedList, aMembers );
+    // The cient will call a method GetEntitiesL that access those arrays
+    // Those member arrays will be emptied after the call. + in destrcutor.
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::UnsubscribeBlockListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::UnsubscribeBlockListL( TRequestStatus& aStatus )
+    {
+    iClientStatus = &aStatus;
+    *iClientStatus = KRequestPending;
+    // Subscription state is always terminated
+    CompleteClientReq( KErrNone );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoGetListMembersL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoGetListMembersL(
+    const TDesC& aList, CPtrCArray& aMembers  )
+    {
+    using namespace NSimplePlugin::NSimpleOma;
+
+    aMembers.Reset();
+
+    RPointerArray<CXdmDocumentNode> nodes;
+    CleanupClosePushL( nodes );
+
+    CXdmNodeAttribute* attr = NULL;
+
+    CXdmDocumentNode* buddylist = DoGetBuddyListL();
+    CXdmDocumentNode* foundNode = SearchListUnderParentL( buddylist, aList );
+    if ( foundNode )
+        {
+        nodes.Reset();
+        // Do not leave if there is nobody blocked
+        TRAP_IGNORE( foundNode->Find( KSimpleEntry, nodes ));
+        TInt nodeCount = nodes.Count();
+        for ( TInt i = 0; i < nodeCount; i++ )
+            {
+            attr = (nodes[i])->Attribute( KSimpleUri );
+            if ( attr )
+                {
+                aMembers.AppendL( attr->AttributeValue() );
+                }
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &nodes );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::HandleRLSUpdateDocumentL
+// RLS Callback
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::HandleRLSUpdateDocumentL( TInt aErrorCode )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: HandleRLSUpdateDocumentL %d"), aErrorCode);
+#ifdef FAKE_XDM_OK
+
+    if ( aErrorCode == KErrTimedOut || aErrorCode == KXcapErrorNetworkNotAvailabe || aErrorCode == KErrHostUnreach )
+        {
+        PluginLogger::Log(
+            _L("PluginXdm : HandleRLSUpdateDocumentL FAKE_XDM_OK resets error code %d"),
+            aErrorCode  );
+        aErrorCode  = 0;
+        }
+#endif
+#endif
+
+    TRAPD( err, DoHandleRLSUpdateDocumentL( aErrorCode ));
+    if ( err )
+        {
+        // Complete with ok or error the last initial opreration
+        CompleteClientReq( err );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoHandleRLSUpdateDocumentL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoHandleRLSUpdateDocumentL( TInt aErrorCode )
+    {
+
+    if ( iTestObs )
+        {
+        // Test suite
+        iTestObs->TestCallbackInRunL( aErrorCode, iXdmState, iOperation, KNullDesC );
+        }
+
+    // Resend 409 failed request only if the server sent a preposal for the right URI
+    // and only once, so that this do not remain in endless loop between server and
+    // a client.
+    if ( aErrorCode == KXcapErrorHttpConflict &&
+         iOperation == EXdmRlsAdd &&
+         iRlsXdm->NegotiatedServiceUri().Length() )
+        {
+        RlsServiceUriNegotiationL();
+        return;
+        }
+
+    switch ( iXdmState )
+        {
+        case EGetRlsServices:
+            if ( aErrorCode == KXcapErrorHttpNotFound || aErrorCode == KErrNotFound )
+                {
+                aErrorCode = KErrNone;
+                }
+            break;
+        default:
+            break;
+        }
+
+    CompleteClientReq( aErrorCode );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::HandleRLSUpdateCancelL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::HandleRLSUpdateCancelL( TInt /*aErrorCode*/ )
+    {
+    // notice: not needed
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::HandleRLSDeleteAllEmptyListsL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::HandleRLSDeleteAllEmptyListsL( TInt /*aErrorCode*/ )
+    {
+    // Notice: Not needed
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::HandlePresUpdateDocumentL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::HandlePresUpdateDocumentL( TInt aErrorCode )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: HandlePresUpdateDocumentL %d"), aErrorCode);
+#ifdef FAKE_XDM_OK
+        if ( aErrorCode == KErrTimedOut || aErrorCode == KXcapErrorNetworkNotAvailabe || aErrorCode == KErrHostUnreach )
+            {
+            PluginLogger::Log(_L("PluginXdm : HandlePresUpdateDocumentL FAKE_XDM_OK resets error code %d"), aErrorCode  );
+            aErrorCode  = 0;
+            }
+#endif
+#endif
+
+    TRAPD( err, DoHandlePresUpdateDocumentL( aErrorCode ));
+    if ( err )
+        {
+        // Complete with ok or error the last initial opreration
+        CompleteClientReq( err );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoHandlePresUpdateDocumentL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoHandlePresUpdateDocumentL( TInt aErrorCode )
+    {
+
+    if ( iTestObs )
+        {
+        // Test suite
+        iTestObs->TestCallbackInRunL(
+            aErrorCode, iXdmState, iOperation, KNullDesC );
+        }
+
+    if ( iXdmState == EGetXdmRules )
+        {
+        iXdmState = EStateIdle;
+        if ( aErrorCode && aErrorCode != KXcapErrorHttpNotFound &&
+             aErrorCode != KErrNotFound )
+            {
+            User::Leave( aErrorCode );
+            }
+        // check and create the rules when needed
+        MakeInitialXdmsDocumentL();
+        }
+    else
+        {
+        iPresXdmOk = ETrue;
+        // Complete with ok or error the last initial opreration
+        CompleteClientReq( aErrorCode );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::HandlePresUpdateCancelL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::HandlePresUpdateCancelL( TInt /*aErrorCode*/ )
+    {
+    // notice: not needed
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::GetXdmOMAListsL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::GetXdmOMAListsL()
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: GetXdmOMAListsL"));
+#endif
+    if ( !iXdmEngine )
+        {
+        // get data from a network if not done so yet
+        CXdmProtocolInfo* info = CXdmProtocolInfo::NewL( iSettingsId );
+        CleanupStack::PushL( info );
+        // Notice: we don't use cache for XDM
+        info->SetCacheUsage( EFalse );
+        iXdmEngine = CXdmEngine::NewL( *info );
+        CleanupStack::PopAndDestroy( info );
+        }
+    if ( !iXdmOk )
+        {
+        using namespace NSimplePlugin::NSimpleOma;
+        if ( iXdmDoc )
+            {
+            // Clean a document from s previous failed case.
+            iXdmEngine->DeleteDocumentModelL( iXdmDoc );
+            iXdmDoc = NULL;
+            }
+
+        // Get data from network
+        iXdmDoc = iXdmEngine->CreateDocumentModelL( KSimpleIndex, EXdmSharedXdm );
+        iXdmDoc->FetchDataL();
+        UpdateXdmsL();
+        iXdmState = EGetXdmOMALists;
+        }
+    else
+        {
+        // Document already exists, no need to search from a server
+        iStatus = KRequestPending;
+        TRequestStatus* s= &iStatus;
+        User::RequestComplete( s, KErrNone );
+        SetActive();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::CreateXdmOMAListsIfNeededL
+// Notice: separate CheckXdmOMAListsL method  (validity)
+// ---------------------------------------------------------------------------
+//
+TBool CSimplePluginXdmUtils::CreateXdmOMAListsIfNeededL( )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: CreateXdmOMAListsIfNeededL"));
+#endif
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    CXdmDocumentNode* root = iXdmDoc->DocumentRoot();
+    if ( !root )
+        {
+        root = iXdmDoc->CreateRootL();
+        root->SetNameL( KSimpleResourceLists );
+        }
+
+    if ( root->IsEmptyNode() )
+        {
+        root->SetEmptyNode( EFalse );
+        }
+
+    TInt isCreated = 0;
+
+    // add all the list nodes
+
+    isCreated += CreateXdmOMAListIfNeededL( root, iConnSets.Variation().SharedXdmTop() );
+
+    isCreated += CreateXdmOMAListIfNeededL( root, KSimpleOMABlockedList );
+
+    // grant-list name is variable issue
+    isCreated += CreateXdmOMAListIfNeededL( root, iConnSets.Variation().GrantListName()  );
+
+    if ( !isCreated )
+        {
+        return EFalse;
+        }
+
+    // send to the server and start wait a response
+    iXdmDoc->AppendL( root );
+    UpdateXdmsL();
+    iXdmState = ECreateXdmOMALists;
+
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::CreateXdmOMAListIfNeededL
+// ---------------------------------------------------------------------------
+//
+TBool CSimplePluginXdmUtils::CreateXdmOMAListIfNeededL(
+    CXdmDocumentNode* aRoot, const TDesC& aName )
+    {
+    TBool isCreated( EFalse );
+    CXdmDocumentNode* nodeFound = SearchListUnderParentL( aRoot, aName );
+    if ( !nodeFound )
+        {
+        CreateResourceListL( aRoot, aName );
+        isCreated = ETrue;
+        }
+    return isCreated;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::CreateResourceListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::CreateResourceListL(
+    CXdmDocumentNode* aParent, const TDesC& aName )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: CreateResourceListL"));
+#endif
+    using namespace NSimplePlugin::NSimpleOma;
+    CXdmDocumentNode* child1 = aParent->CreateChileNodeL( KSimpleList );
+    CXdmNodeAttribute* name = child1->CreateAttributeL( KSimpleName );
+    name->SetAttributeValueL( aName );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::SearchListUnderParentL
+// ---------------------------------------------------------------------------
+//
+CXdmDocumentNode* CSimplePluginXdmUtils::SearchListUnderParentL(
+    CXdmDocumentNode* aParent, const TDesC& aName )
+    {
+    using namespace NSimplePlugin::NSimpleOma;
+
+    if ( !aParent )
+        {
+        return NULL;
+        }
+
+    RPointerArray<CXdmDocumentNode> resultArray;
+    RPointerArray<SXdmAttribute16>  attributeArray;
+
+    CleanupClosePushL( resultArray );           // <<< resultArray
+    CleanupClosePushL( attributeArray );        // <<< attributeArray
+
+    SXdmAttribute16 attr;
+    attr.iName.Set( KSimpleName );
+    attr.iValue.Set( aName );
+    attributeArray.AppendL( &attr );
+
+    CXdmDocumentNode* currNode = NULL;
+
+    aParent->Find( KSimpleList, resultArray, attributeArray );
+
+    TInt count = resultArray.Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        currNode = resultArray[i];
+        CXdmDocumentNode* parent = currNode->Parent();
+        if ( parent == aParent )
+            {
+            break;
+            }
+        currNode = NULL;
+        }
+
+    CleanupStack::PopAndDestroy( &attributeArray); // >>> attributeArray
+    CleanupStack::PopAndDestroy( &resultArray );   // >>> resultArray
+
+    return currNode;
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::MakeRlsUriL
+// ---------------------------------------------------------------------------
+//
+HBufC* CSimplePluginXdmUtils::MakeRlsUriL(
+    const TDesC& aXcapUri, const TDesC& aListName )
+    {
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: MakeRlsUriL"));
+#endif
+
+    /* example:
+        "http://XCAP.EXAMPLE.COM/resource-lists/users/
+        sip:USER@EXAMPLE.COM/index/~~/resource-lists/list%5b@name=%22oma_blockedlist%22%5d"
+        */
+
+    using namespace NSimplePlugin::NSimpleRls;
+
+    TInt myLen = totalSize;
+    myLen += aXcapUri.Length();
+    myLen += aListName.Length();
+    myLen += iConnSets.CurrentSipPresentity().Length();
+    HBufC* myBuf = HBufC::NewL( myLen );
+
+    myBuf->Des().Append( KOne );
+    myBuf->Des().Append( aXcapUri);
+    myBuf->Des().Append( KThree );
+    myBuf->Des().Append( iConnSets.CurrentSipPresentity() );
+    myBuf->Des().Append( KFive );
+    myBuf->Des().Append( aListName );
+    myBuf->Des().Append( KSeven );
+
+    return myBuf;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::MakeRlsBuddyUriL
+// ---------------------------------------------------------------------------
+//
+HBufC* CSimplePluginXdmUtils::MakeRlsBuddyUriL(
+    const TDesC& aXcapUri, const TDesC& aListName )
+    {
+    /* example:
+        "http://XCAP.EXAMPLE.COM/resource-lists/users/
+        sip:USER@EXAMPLE.COM/~~/resource-lists/list%5b@name=%22oma_buddylist%22%5d/
+        list5d@name=%22my_friends%22%5d"
+        */
+
+    using namespace NSimplePlugin::NSimpleRlsBuddy;
+
+    TInt myLen = totalSize + aXcapUri.Length() + aListName.Length() +
+                 iConnSets.CurrentSipPresentity().Length();
+
+    HBufC* myBuf = HBufC::NewL( myLen );
+    TPtr temp = myBuf->Des();
+
+    temp.Append( KOne );
+    temp.Append( aXcapUri);
+    temp.Append( KThree );
+    temp.Append( iConnSets.CurrentSipPresentity() );
+    temp.Append( KFive );
+    temp.Append( aListName );
+    temp.Append( KSeven );
+
+    return myBuf;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::GetXdmRulesL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::GetXdmRulesL()
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: GetXdmRulesL"));
+#endif
+    if ( !iPresenceXdm )
+        {
+        // get data from a network if not done so yet
+        iPresenceXdm = CPresenceXDM::NewL( iSettingsId );
+        }
+    User::LeaveIfError( iPresenceXdm->UpdateAllFromServerL( this ));
+    iXdmState = EGetXdmRules;
+    // The is completed in a callback method, not in RunL
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::MakeInitialXdmsDocumentL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::MakeInitialXdmsDocumentL()
+    {
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: MakeInitialXdmsDocumentL"));
+#endif
+    TBuf<KSimplePluginMaxRuleLength> myRuleId;
+
+    TBool ruleAdded( EFalse );
+
+    TPresenceActionXDM action;
+    action.Init( iPresenceXdm );
+
+    TPresenceTransformXDM transform;
+    transform.Init( iPresenceXdm );
+
+    TPresCondMisc misc;
+    misc.Init( iPresenceXdm );
+
+    TPresCondIdentityOne one;
+    one.Init( iPresenceXdm );
+
+    HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri );
+    CleanupStack::PushL( xcapUri );
+    HBufC* listUri = MakeRlsUriL( xcapUri->Des(), KSimpleOMABlockedList );
+    CleanupStack::PushL( listUri );
+
+    // Default rule
+    // get the rule id, use run-time variation
+    myRuleId = iConnSets.Variation().DefaultRuleName(); // KSimpleXdmDefaultRule;
+    if ( myRuleId.Length() && !iPresenceXdm->IsRuleExist( myRuleId ))
+        {
+        // If default rule does not exist in the variation then do not create it.
+        MakeDefaultRuleL( myRuleId, action, transform, misc );
+        ruleAdded = ETrue;
+        }
+
+    // Block rule
+    // get the rule id, use run-time variation
+    myRuleId = iConnSets.Variation().BlockRuleName();
+    // ruleCreate = EFalse;
+
+    if ( !iPresenceXdm->IsRuleExist( myRuleId ))
+        {
+        iPresenceXdm->CreateNewRuleL( myRuleId );
+        ruleAdded = ETrue;
+
+        // use run-time variation for rule action
+        CSimplePluginVariation::TSimplePluginAuthRule authRule =
+            iConnSets.Variation().BlockRuleAction();
+
+        User::LeaveIfError( misc.AddExternListL( myRuleId, listUri->Des() ));
+
+        switch (authRule)
+            {
+            case CSimplePluginVariation::ERulePoliteBlock:
+                User::LeaveIfError( action.AddOrReplaceActionL(myRuleId, KPresPoliteBlock ));
+                break;
+            default:
+                User::LeaveIfError( action.AddOrReplaceActionL(myRuleId, KPresBlock ));
+            };
+        }
+
+    // Grant rule
+    // get the rule id, use run-time variation
+    myRuleId = iConnSets.Variation().GrantRuleName();
+    if ( !iPresenceXdm->IsRuleExist( myRuleId ))
+        {
+        iPresenceXdm->CreateNewRuleL( myRuleId );
+        ruleAdded = ETrue;
+        CleanupStack::PopAndDestroy( listUri );
+        listUri = NULL;
+        listUri = MakeRlsUriL( xcapUri->Des(), iConnSets.Variation().GrantListName() );
+        CleanupStack::PushL( listUri );
+        User::LeaveIfError( misc.AddExternListL( myRuleId, listUri->Des() ));
+        User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresAllow ));
+        User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL(
+            myRuleId, KPresProvideAllAttributes ));
+        User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL(
+            myRuleId, KPresProvidePersons ));
+        User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL(
+            myRuleId, KPresProvideDevices ));
+        User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL(
+            myRuleId, KPresProvideServices ));
+        }
+
+    // Grant own subscription rule
+    // get the rule id, use run-time variation
+    myRuleId = iConnSets.Variation().GrantOwnRuleName();
+    if ( !iPresenceXdm->IsRuleExist( myRuleId ))
+        {
+        iPresenceXdm->CreateNewRuleL( myRuleId );
+        ruleAdded = ETrue;
+        User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresAllow ));
+        User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL(
+            myRuleId, KPresProvideAllAttributes ));
+        User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL(
+            myRuleId, KPresProvidePersons ));
+        User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL(
+            myRuleId, KPresProvideDevices ));
+        User::LeaveIfError( transform.AddOrRepProvideAllTransComplexL(
+            myRuleId, KPresProvideServices ));
+        // own sip identity
+        User::LeaveIfError( one.AddIdentityL(
+            myRuleId, iConnSets.CurrentSipPresentity() ));
+        }
+
+    // Update into server only when needed.
+    if ( ruleAdded )
+        {
+        UpdateXdmRulesL();
+        }
+    else
+        {
+        iXdmState = EUpdateXdmRules;
+        iPresXdmOk = ETrue;
+        // Complete with ok or error the last initial opreration
+        CompleteClientReq( KErrNone );
+        }
+
+    CleanupStack::PopAndDestroy( listUri );
+    CleanupStack::PopAndDestroy( xcapUri );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoGrantForAllL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoGrantForAllL()
+    {
+    const TInt KMyPresRuleIDLength(30);
+    TBuf<KMyPresRuleIDLength> myRuleId;
+
+    TInt err( KErrNone );
+
+    TPresenceActionXDM action;
+    action.Init( iPresenceXdm );
+
+    // Default rule id is searched
+    myRuleId = iConnSets.Variation().DefaultRuleName(); // KSimpleXdmDefaultRule;
+    TRAP( err, iPresenceXdm->CreateNewRuleL( myRuleId ) );
+    if ( err && err != KErrAlreadyExists )
+        {
+        User::Leave( err );
+        }
+
+    // modify the rule in the server.
+    User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresAllow ));
+    UpdateXdmRulesL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoWithdrawFromAllL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoWithdrawFromAllL()
+    {
+    const TInt KMyPresRuleIDLength(30);
+    TBuf<KMyPresRuleIDLength> myRuleId;
+
+    /* pseudo code:
+        if current rule is ALLOW then {  BLOCK  }
+        otherwise no action.
+    */
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginWatcher: DoWithdrawFromAllL TEST COVERS 3"));
+#endif
+
+
+    TInt err( KErrNone );
+
+    TPresenceActionXDM action;
+    action.Init( iPresenceXdm );
+
+    // Default rule id is searched
+    myRuleId = iConnSets.Variation().DefaultRuleName();
+    TRAP( err, iPresenceXdm->CreateNewRuleL( myRuleId ) );
+    if ( err && err != KErrAlreadyExists )
+        {
+        User::Leave( err );
+        }
+
+    TBuf<KMyPresRuleIDLength> myActionBuf;
+    err = action.GetActionL( myRuleId, myActionBuf);
+
+    if ( !myActionBuf.CompareF( KPresAllow )  )
+        {
+        User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresPoliteBlock ));
+        UpdateXdmRulesL();
+        *iClientStatus = KRequestPending;
+        }
+    else
+        {
+        CompleteClientReq( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoSetReactiveAuthL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoSetReactiveAuthL()
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(
+            _L("PluginWatcher: DoSetReactiveAuthL TEST COVERS 5"));
+#endif
+
+    // Default rule is modified to CONFIRM
+
+    const TInt KMyPresRuleIDLength(30);
+    TBuf<KMyPresRuleIDLength> myRuleId;
+
+    TInt err( KErrNone );
+
+    TPresenceActionXDM action;
+    action.Init( iPresenceXdm );
+
+    // Default rule id is searched
+    myRuleId = iConnSets.Variation().DefaultRuleName();
+    TRAP( err, iPresenceXdm->CreateNewRuleL( myRuleId ) );
+    if ( err && err != KErrAlreadyExists )
+        {
+#ifdef _DEBUG
+        PluginLogger::Log( _L("PluginWatcher: TEST COVERS 5b"));
+#endif
+        User::Leave( err );
+        }
+
+    // modify the rule in the server.
+    User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresConfirm ));
+    UpdateXdmRulesL();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoSetProactiveAuthL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoSetProactiveAuthL()
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(
+            _L("PluginWatcher: DoSetProactiveAuthL TEST COVERS 6"));
+#endif
+
+    /* pseudo code:
+        if current rule is CONFIRM then {  ALLOW  }
+        otherwise no action.
+    */
+
+    const TInt KMyPresRuleIDLength(30);
+    TBuf<KMyPresRuleIDLength> myRuleId;
+
+    TInt err( KErrNone );
+
+    TPresenceActionXDM action;
+    action.Init( iPresenceXdm );
+
+    // Default rule id is searched
+    myRuleId = iConnSets.Variation().DefaultRuleName();
+    TRAP( err, iPresenceXdm->CreateNewRuleL( myRuleId ) );
+    if ( err && err != KErrAlreadyExists )
+        {
+        User::Leave( err );
+        }
+
+    // modify the rule in the server.
+    TBuf<KMyPresRuleIDLength> myActionBuf;
+    err = action.GetActionL( myRuleId, myActionBuf);
+
+    if ( !myActionBuf.CompareF( KPresConfirm )  )
+        {
+        User::LeaveIfError( action.AddOrReplaceActionL( myRuleId, KPresAllow ));
+        UpdateXdmRulesL();
+        *iClientStatus = KRequestPending;
+        }
+    else
+        {
+        CompleteClientReq( KErrNone );
+        }
+
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::CreateEntityGroupL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::CreateEntityGroupL(
+    const TDesC&  aName, const TDesC&  aDisplayName )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: CreateEntityGroupL"));
+#endif
+    iOperation = EXdmCreateGroup;
+    DoCreateEntityGroupL( aName, aDisplayName );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DeleteEntityGroupL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::DeleteEntityGroupL(
+    const TDesC&  aName)
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: DeleteEntityGroupL"));
+#endif
+
+    iOperation = EXdmDeleteGroup;
+    DoDeleteEntityGroupL( aName );
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::AddPresentityGroupMemberL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::AddPresentityGroupMemberL(
+    const TDesC&  aGroup,
+    const TDesC&  aUser,
+    const TDesC&  aDispName,
+    TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: AddPresentityGroupMemberL"));
+#endif
+
+    iClientStatus = &aStatus;
+
+    iOperation = EXdmAddUserToGroup;
+    DoAddUserToUserListL( aGroup, aUser, aDispName );
+
+    // send to the server and start wait a response
+    UpdateXdmsL();
+
+    *iClientStatus = KRequestPending;
+    iXdmState = EUpdateXdmOMAList;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::RemovePresentityGroupMemberL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::RemovePresentityGroupMemberL(
+    const TDesC&  aGroup,
+    const TDesC&  aUser,
+    TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: RemovePresentityGroupMemberL"));
+#endif
+
+    iClientStatus = &aStatus;
+
+    iOperation = EXdmAddUserToGroup;
+    DoRemoveUserFromUserListL( aGroup, aUser );
+
+    // send to the server and start wait a response
+    UpdateXdmsL();
+
+    *iClientStatus = KRequestPending;
+    iXdmState = EUpdateXdmOMAList;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::GetUserListsL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::GetUserListsL(
+    CDesCArrayFlat& aIds, CDesCArrayFlat& aDispNames )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: GetUserListsL"));
+#endif
+    using namespace NSimplePlugin::NSimpleOma;
+
+    aIds.Reset();
+    aDispNames.Reset();
+
+    CXdmDocumentNode* buddylist = DoGetBuddyListL();
+    CXdmDocumentNode* entry = NULL;
+
+    RPointerArray<CXdmDocumentNode> lists;
+    CleanupClosePushL( lists );         // <<< lists
+
+    RPointerArray<CXdmDocumentNode> lists2;
+    CleanupClosePushL( lists2 );        // <<< lists2
+
+    buddylist->Find( KSimpleList, lists );
+    TInt count = lists.Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        // Name
+        entry = lists[i];
+        CXdmNodeAttribute* attr = entry->Attribute( KSimpleName );
+        if ( attr )
+            {
+            aIds.AppendL( attr->AttributeValue() );
+#ifdef _DEBUG
+            TBuf<200> debug_buffer;
+            debug_buffer = attr->AttributeValue();
+            PluginLogger::Log(_L("PluginXdm: add group id into aIds : %S"), &debug_buffer );
+#endif
+            }
+        else
+            {
+            continue;
+            }
+        // Display name
+        TInt err = entry->Find( KSimpleDisplayName, lists2 );
+        // Notice: assume there is only one display-name.
+        // Always when an item is added into aIds we have to add an itmem also into aDispNames.
+        if ( !err )
+            {
+            CXdmDocumentNode* disName = lists2[0];
+            if ( !disName->IsEmptyNode() )
+                {
+                // Convert Display-Name to Unicode.
+                HBufC16* uri16 = NULL;
+                uri16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( disName->LeafNodeContent() );
+                CleanupStack::PushL( uri16 );  // << uri16
+                aDispNames.AppendL( uri16->Des() );
+                CleanupStack::PopAndDestroy( uri16 );  // >> uri16
+                }
+                else
+                    {
+                    aDispNames.AppendL( KNullDesC );
+                    }
+            }
+            else
+                {
+                aDispNames.AppendL( KNullDesC );
+                }
+        }
+
+    CleanupStack::PopAndDestroy( &lists2 ); // >>> lists2
+    CleanupStack::PopAndDestroy( &lists ); // >>> lists
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::GetEntitiesInListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::GetEntitiesInListL(
+    const TDesC&  aList, CPtrCArray& aIds, CPtrCArray& aDispNames )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: GetEntitiesInListL"));
+#endif
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    CXdmDocumentNode* buddylist = DoGetBuddyListL();
+    CXdmDocumentNode* target = DoGetUserListL( aList, buddylist );
+
+    // make a collection of MPresentityGroupMemberInfo
+    RPointerArray<CXdmDocumentNode> entries;
+    CleanupClosePushL(entries);       // <<< entries
+
+    RPointerArray<CXdmDocumentNode> nodes;
+    CleanupClosePushL(nodes);         // <<< nodes
+
+    target->Find( KSimpleEntry, entries );
+    TInt count = entries.Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        // ID
+        CXdmDocumentNode* entry = entries[i];
+        CXdmNodeAttribute* attr = entry->Attribute( KSimpleUri );
+        if ( attr )
+            {
+            aIds.AppendL( attr->AttributeValue() );
+#ifdef _DEBUG
+            TBuf<200> debug_buffer;
+            debug_buffer = attr->AttributeValue();
+            PluginLogger::Log(_L("PluginXdm: add member into collection : %S"), &debug_buffer );
+#endif
+            }
+        else
+            {
+            continue;
+            }
+
+        // Display name
+        TInt err = entry->Find( KSimpleDisplayName, nodes );
+        // Notice: assume there is only one display-name
+        if ( !err )
+            {
+            CXdmDocumentNode* disName = nodes[0];
+            HBufC16* uri16 = NULL;
+            uri16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( disName->LeafNodeContent() );
+            CleanupStack::PushL( uri16 );  // << uri16
+            aDispNames.AppendL( uri16->Des() );
+            CleanupStack::PopAndDestroy( uri16 );  // >> uri16
+            }
+        else
+            {
+            aDispNames.AppendL( TPtrC() );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &nodes ); // >>> nodes
+    CleanupStack::PopAndDestroy( &entries ); // >>> entries
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::CommitXdmL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::CommitXdmL( TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: CommitXdmL"));
+#endif
+    iClientStatus = &aStatus;
+
+    UpdateXdmsL();
+
+    *iClientStatus = KRequestPending;
+    iXdmState = EUpdateXdmOMAList;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::CommitRlsL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::CommitRlsL( TRequestStatus& aStatus )
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: CommitRlsL"));
+#endif
+    iClientStatus = &aStatus;
+    *iClientStatus = KRequestPending;
+    UpdateRlsL();
+
+    iXdmState = EUpdateRlsServices;
+    }
+
+// ----------------------------------------------------
+// CSimplePluginXdmUtils::DoCreateEntityGroupL
+// ----------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoCreateEntityGroupL(
+    const TDesC& aList, const TDesC&  aDisName )
+    {
+    using namespace NSimplePlugin::NSimpleOma;
+
+    CXdmDocumentNode* buddylist = DoGetBuddyListL();
+    if ( buddylist->IsEmptyNode() )
+        {
+        buddylist->SetEmptyNode( EFalse );
+        }
+
+    CXdmDocumentNode* foundNode = SearchListUnderParentL(
+        buddylist, aDisName );
+
+    if ( foundNode )
+        {
+        User::Leave( KErrAlreadyExists );
+        }
+
+    CXdmDocumentNode* newNode = buddylist->CreateChileNodeL( KSimpleList );
+    CXdmNodeAttribute* attributeName = newNode->CreateAttributeL( KSimpleName );
+    attributeName->SetAttributeValueL( aList );
+
+    // Display name
+    CXdmDocumentNode* displayName = newNode->CreateChileNodeL( KSimpleDisplayName );
+    displayName->SetLeafNode( ETrue );
+    displayName->SetLeafNodeContentL( aDisName );
+
+    iXdmDoc->AppendL( newNode );
+    }
+
+// ----------------------------------------------------
+// CSimplePluginXdmUtils::DoDeleteEntityGroupL
+// ----------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoDeleteEntityGroupL(
+    const TDesC& aList )
+    {
+    CXdmDocumentNode* buddylist = DoGetBuddyListL();
+    CXdmDocumentNode* target = DoGetUserListL( aList, buddylist );
+    iXdmDoc->DeleteDataL( target );
+    // iXdmEngine is asked to be updated to a server by CSimplePlugingGroups later.
+    }
+
+// ----------------------------------------------------
+// CSimplePluginXdmUtils::DoAddUserToUserListL
+// ----------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoAddUserToUserListL(
+    const TDesC& aList, const TDesC&  aUser, const TDesC&  aDisName )
+    {
+    RPointerArray<CXdmDocumentNode> resultArray;
+    RPointerArray<SXdmAttribute16>  attributeArray;
+
+    CleanupClosePushL( resultArray );           // << resultArray
+    CleanupClosePushL( attributeArray );        // << attributeArray
+
+    CXdmDocumentNode* buddylist = DoGetBuddyListL();
+    CXdmDocumentNode* target = DoGetUserListL( aList, buddylist );
+
+    if ( target->IsEmptyNode() )
+        {
+        target->SetEmptyNode( EFalse );
+        }
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    SXdmAttribute16 attr;
+    attr.iName.Set( KSimpleUri );
+    attr.iValue.Set( aUser );
+    attributeArray.AppendL( &attr );
+
+    // If member already exists then leave
+    target->Find( KSimpleEntry, resultArray, attributeArray );
+    if ( resultArray.Count() > 0 )
+        {
+        User::Leave( KErrAlreadyExists );
+        }
+
+    CXdmDocumentNode* newNode = target->CreateChileNodeL( KSimpleEntry );
+    CXdmNodeAttribute* attributeName = newNode->CreateAttributeL( KSimpleUri );
+    attributeName->SetAttributeValueL( aUser );
+
+    // Display name
+    CXdmDocumentNode* displayName = newNode->CreateChileNodeL( KSimpleDisplayName );
+    displayName->SetLeafNode( ETrue );
+    displayName->SetLeafNodeContentL( aDisName );
+
+    iXdmDoc->AppendL( newNode );
+
+    CleanupStack::PopAndDestroy( &attributeArray );
+    CleanupStack::PopAndDestroy( &resultArray );
+    }
+
+// ----------------------------------------------------
+// CSimplePluginXdmUtils::DoRemoveUserFromUserListL
+// ----------------------------------------------------
+//
+void CSimplePluginXdmUtils::DoRemoveUserFromUserListL(
+    const TDesC& aList, const TDesC&  aUri )
+    {
+    CXdmNodeAttribute* attr = NULL;
+    TBool myFound( EFalse );
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    CXdmDocumentNode* buddylist = DoGetBuddyListL();
+    CXdmDocumentNode* target = DoGetUserListL( aList, buddylist );
+
+    RPointerArray<CXdmDocumentNode> entries;
+    CleanupClosePushL( entries );           // <<< entries
+
+    User::LeaveIfError( target->Find( KSimpleEntry, entries ));
+    TInt nodeCount = entries.Count();
+    for ( TInt i = 0; i < nodeCount; i++ )
+        {
+        CXdmDocumentNode* currNode = entries[i];
+        attr = currNode->Attribute( KSimpleUri );
+        if ( attr && !attr->AttributeValue().CompareF( aUri ))
+            {
+            // This is the user we are looking for deletion.
+            iXdmDoc->DeleteDataL( currNode );
+            myFound = ETrue;
+            break;
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &entries ); // >>> entries
+
+    if ( !myFound )
+        {
+        // If the member is not found then leave
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoGetBuddyListL
+// ---------------------------------------------------------------------------
+//
+CXdmDocumentNode* CSimplePluginXdmUtils::DoGetBuddyListL()
+    {
+    CXdmDocumentNode* root = iXdmDoc->DocumentRoot();
+    CXdmDocumentNode* ret = SearchListUnderParentL( root, iConnSets.Variation().SharedXdmTop() );
+    if ( !ret )
+        {
+        User::Leave( KErrNotFound );
+        }
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoGetUserListL
+// ---------------------------------------------------------------------------
+//
+CXdmDocumentNode* CSimplePluginXdmUtils::DoGetUserListL(
+    const TDesC& aList, CXdmDocumentNode* aBuddyList )
+    {
+    CXdmDocumentNode* listNode = NULL;
+    CXdmNodeAttribute* attr = NULL;
+    TBool found( EFalse );
+
+    using namespace NSimplePlugin::NSimpleOma;
+
+    RPointerArray<CXdmDocumentNode> lists;
+    CleanupClosePushL( lists );
+
+    User::LeaveIfError( aBuddyList->Find( KSimpleList, lists ));
+    TInt count = lists.Count();
+    for ( TInt i=0; i < count; i++ )
+        {
+        listNode = lists[i];
+        attr = listNode->Attribute( KSimpleName );
+        if ( attr && !attr->AttributeValue().CompareF( aList ))
+            {
+            // List is found
+            found = ETrue;
+            break;
+            }
+        }
+    if ( !found )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    CleanupStack::PopAndDestroy( &lists );
+    return listNode;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::UpdateXdmRulesL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::UpdateXdmRulesL()
+    {
+    _LIT( KMyOper, "UpdateXdmRulesL");
+    if ( iTestObs )
+        {
+        // Test suite
+        iTestObs->TestCallbackAsynchL(
+            KErrNone, iXdmState, iOperation, KMyOper );
+        }
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: UpdateXdmRulesL -> iPresenceXdm->UpdateToServerL"));
+#endif
+    User::LeaveIfError( iPresenceXdm->UpdateToServerL( this ));
+    iXdmState = EUpdateXdmRules;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::UpdateXdmsL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::UpdateXdmsL()
+    {
+    _LIT( KMyOper, "UpdateXdmsL");
+    if ( iTestObs )
+        {
+        // Test suite
+        iTestObs->TestCallbackAsynchL(
+            KErrNone, iXdmState, iOperation, KMyOper );
+        }
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: UpdateXdmsL -> iXdmEngine->UpdateToServerL"));
+#endif
+    iXdmEngine->UpdateL( iXdmDoc, iStatus );
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::UpdateRlsL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::UpdateRlsL()
+    {
+    _LIT( KMyOper, "UpdateRlsL");
+
+    if ( iTestObs )
+        {
+        // Test suite
+        iTestObs->TestCallbackAsynchL(
+            KErrNone, iXdmState, iOperation, KMyOper );
+        }
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: -> iRlsXdm->UpdateToServerL"));
+#endif
+    User::LeaveIfError( iRlsXdm->UpdateToServerL( this ));
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::SetTestObserver
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::SetTestObserver( MSimplePluginTestObs* aObs )
+    {
+    iTestObs = aObs;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::CreateRlsDocumentUri16LC
+// ---------------------------------------------------------------------------
+//
+HBufC16* CSimplePluginXdmUtils::CreateRlsDocumentUri16LC(
+    const TDesC16& aGroup,
+    const TDesC16& aPresentityUri,
+    const TDesC16& aDomain )
+    {
+
+    TPtrC uriTemplate( iConnSets.Variation().RlsGroupUriTemplate() );
+
+    // Calculate URI length
+    TInt uriSize = uriTemplate.Length() + KMyLenPrefix;
+    if ( uriTemplate.Find( KSimpleGroupTag ) != KErrNotFound )
+        {
+        TPtrC p8( KSimpleGroupTag );
+        uriSize = uriSize - p8.Length() + aGroup.Length();
+        }
+    if ( uriTemplate.Find( KSimpleUserTag ) != KErrNotFound )
+        {
+        TPtrC p8( KSimpleUserTag );
+        uriSize = uriSize - p8.Length() + aPresentityUri.Length();
+        }
+    if ( uriTemplate.Find( KSimpleDomainTag ) != KErrNotFound )
+        {
+        TPtrC p8( KSimpleDomainTag );
+        uriSize = uriSize - p8.Length() + aDomain.Length();
+        }
+
+    // allocate new buffer for URI
+    // Temporarily the buffer might need more space then the final URI length
+    // (when tags are longer than the real values replacing them).
+    if ( uriSize < uriTemplate.Length() + KMyLenPrefix )
+        {
+        uriSize = uriTemplate.Length() + KMyLenPrefix +
+                  aGroup.Length() + aPresentityUri.Length() + aDomain.Length();
+        }
+    HBufC16* buf = HBufC16::NewLC( uriSize );
+    TPtr16 pBuf(buf->Des());
+
+    // Append "sip:" prefix
+    pBuf.Append( KMySip );
+
+    // Append template
+    pBuf.Append( uriTemplate );
+
+    // Replace tags in URI template with the real values.
+    ReplaceGroupTag( buf, aGroup );
+    ReplaceDomainTag( buf, aDomain );
+    ReplaceUserTag( buf, aPresentityUri );
+
+    return buf;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoesUserListExistsL
+// ---------------------------------------------------------------------------
+//
+TBool CSimplePluginXdmUtils::DoesUserListExistsL( const TDesC& aName )
+  {
+    CXdmDocumentNode* buddylist = DoGetBuddyListL();
+    CXdmDocumentNode* foundNode = SearchListUnderParentL( buddylist, aName );
+    return foundNode ? ETrue : EFalse;
+  }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::AuxBuffer
+// ---------------------------------------------------------------------------
+//
+TPtrC CSimplePluginXdmUtils::AuxBuffer( )
+    {
+    return iAuxBuffer ? iAuxBuffer->Des() : TPtrC();
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::RemoveRlsServiceByResourceListL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::RemoveRlsServiceByResourceListL(
+    const TDesC& aGroup, TRequestStatus& aStatus )
+    {
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: RemoveRlsServiceByResourceListL"));
+#endif
+
+    TBool ret( EFalse );
+
+    iOperation = EXdmRlsRemove;
+    iClientStatus = &aStatus;
+
+    // convert a Group into resource-list value
+    HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri );
+    CleanupStack::PushL( xcapUri );             // << xcapUri
+
+    HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), aGroup );
+    CleanupStack::PushL( listUri );             // << listUri
+
+    // remove service-uri in the rls-services document
+    ret = DoRemoveRlsServiceByResourceListL( listUri->Des() );
+
+    CleanupStack::PopAndDestroy( listUri );
+    CleanupStack::PopAndDestroy( xcapUri );
+
+    *iClientStatus = KRequestPending;
+
+    if ( ret )
+        {
+        // Update RLS document when needed.
+        UpdateRlsL();
+        iXdmState = EUpdateRlsServices;
+        }
+    else
+        {
+        CompleteClientReq( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoRemoveRlsServiceByResourceListL
+// ---------------------------------------------------------------------------
+//
+TBool CSimplePluginXdmUtils::DoRemoveRlsServiceByResourceListL( const TDesC& aResourceList )
+    {
+    TBool ret( EFalse );
+
+    CDesC16Array* myArray = new (ELeave) CDesC16ArraySeg(10);
+    CleanupStack::PushL( myArray );
+
+    CDesC16Array* myValues = new (ELeave) CDesC16ArraySeg(10);
+    CleanupStack::PushL( myValues );
+
+    iRlsXdm->GetServiceUrisL( *myArray );
+    TInt myCount = myArray->MdcaCount();
+
+    for ( TInt i=0; i < myCount && !ret; i++ )
+        {
+        iRlsXdm->SwitchToServiceURIL( myArray->MdcaPoint( i ));
+        iRlsXdm->GetElementsL( KPresResourceList, *myValues);
+        TInt myValuesCount = myValues->MdcaCount();
+        for ( TInt j=0; j < myValuesCount; j++ )
+            {
+            if ( !myValues->MdcaPoint( i ).Compare( aResourceList ) )
+                {
+                // delete service with the URI
+                iRlsXdm->RemoveServiceURIL( myArray->MdcaPoint( i ) );
+                ret = ETrue;
+                break;
+                }
+            }
+        }
+
+    CleanupStack::PopAndDestroy( myValues );
+    CleanupStack::PopAndDestroy( myArray );
+
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::RlsServiceByResourceListL
+// ---------------------------------------------------------------------------
+//
+HBufC* CSimplePluginXdmUtils::RlsServiceByResourceListLC(
+    const TDesC& aGroup )
+    {
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: :RlsServiceByResourceListLC"));
+#endif
+
+    HBufC* myRet = NULL;
+
+    // convert a Group into resource-list value
+    HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri );
+    CleanupStack::PushL( xcapUri );             // << xcapUri
+
+    HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), aGroup );
+    CleanupStack::PushL( listUri );             // << listUri
+
+    // remove service-uri in the rls-services document
+    myRet = DoGetRlsServiceByResourceListL( listUri->Des() );
+
+    CleanupStack::PopAndDestroy( listUri );
+    CleanupStack::PopAndDestroy( xcapUri );
+
+    CleanupStack::PushL( myRet );
+
+    return myRet;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::DoGetRlsServiceByResourceListL
+// ---------------------------------------------------------------------------
+//
+HBufC* CSimplePluginXdmUtils::DoGetRlsServiceByResourceListL( const TDesC& aResourceList )
+    {
+
+    HBufC* ret = NULL;
+
+    CDesC16Array* myArray = new (ELeave) CDesC16ArraySeg(10);
+    CleanupStack::PushL( myArray );
+
+    CDesC16Array* myValues = new (ELeave) CDesC16ArraySeg(10);
+    CleanupStack::PushL( myValues );
+
+    iRlsXdm->GetServiceUrisL( *myArray );
+    TInt myCount = myArray->MdcaCount();
+
+    for ( TInt i=0; i < myCount && !ret; i++ )
+        {
+        iRlsXdm->SwitchToServiceURIL( myArray->MdcaPoint( i ));
+        iRlsXdm->GetElementsL( KPresResourceList, *myValues);
+        TInt myValuesCount = myValues->MdcaCount();
+        for ( TInt j=0; j < myValuesCount; j++ )
+            {
+            if ( !myValues->MdcaPoint( i ).Compare( aResourceList ) )
+                {
+                // save the URI
+                ret = myArray->MdcaPoint( i ).AllocL();
+                break;
+                }
+            }
+        }
+
+    CleanupStack::PopAndDestroy( myValues );
+    CleanupStack::PopAndDestroy( myArray );
+
+    if ( !ret )
+        {
+        User::Leave( KErrNotFound );
+        }
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::RlsServiceUriNegotiationL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::RlsServiceUriNegotiationL()
+    {
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: :RlsServiceUriNegotiationL"));
+#endif
+    // Handle RLS Service URI negotiation
+
+    HBufC16* buf = CreateRlsDocumentUri16LC(
+        AuxBuffer(), iConnSets.CurrentSipPresentity(), iConnSets.CurrentDomain() );
+
+    TRAP_IGNORE( iRlsXdm->RemoveServiceURIL( buf->Des() ));
+
+    TInt errx = iRlsXdm->AddServiceURIL( iRlsXdm->NegotiatedServiceUri() );
+    if ( errx && errx != KErrAlreadyExists )
+        {
+        User::Leave( errx );
+        }
+    User::LeaveIfError( iRlsXdm->SwitchToServiceURIL( iRlsXdm->NegotiatedServiceUri() ));
+
+    HBufC* xcapUri = TXdmSettingsApi::PropertyL( iSettingsId, EXdmPropUri );
+        CleanupStack::PushL( xcapUri );             // << xcapUri
+
+    HBufC* listUri = MakeRlsBuddyUriL( xcapUri->Des(), AuxBuffer() );
+    CleanupStack::PushL( listUri );             // << listUri
+
+    TInt err = iRlsXdm->AddElementL( KPresResourceList, listUri->Des(), AuxBuffer() );
+    if ( err && err != KErrAlreadyExists )
+        {
+        User::Leave( err );
+        }
+
+    CleanupStack::PopAndDestroy( listUri );     // >> listUri
+    CleanupStack::PopAndDestroy( xcapUri );     // >> xcapUri
+    CleanupStack::PopAndDestroy( buf );
+
+    delete iAuxBuffer;
+    iAuxBuffer = NULL;
+    iAuxBuffer = iRlsXdm->NegotiatedServiceUri().AllocL();
+
+    UpdateRlsL();
+    iXdmState = EReUpdateRlsServices;
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::MakeDefaultRuleL
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::MakeDefaultRuleL(
+    TDes& aRuleId,
+    TPresenceActionXDM& aAction,
+    TPresenceTransformXDM& aTransform,
+    TPresCondMisc& aMisc )
+    {
+
+#ifdef _DEBUG
+    PluginLogger::Log(_L("PluginXdm: :MakeDefaultRuleL"));
+#endif
+
+    iPresenceXdm->CreateNewRuleL( aRuleId );
+    User::LeaveIfError( aMisc.AddOtherIdentityL(aRuleId) );
+
+    // use run-time variation for rule action
+    CSimplePluginVariation::TSimplePluginAuthRule authRule =
+        iConnSets.Variation().DefaultRuleAction();
+
+    switch (authRule)
+        {
+        case CSimplePluginVariation::ERuleConfirm:
+            User::LeaveIfError( aAction.AddOrReplaceActionL(aRuleId, KPresConfirm ));
+            break;
+        case CSimplePluginVariation::ERulePoliteBlock:
+            User::LeaveIfError( aAction.AddOrReplaceActionL(aRuleId, KPresPoliteBlock ));
+            break;
+        case CSimplePluginVariation::ERuleBlock:
+            User::LeaveIfError( aAction.AddOrReplaceActionL(aRuleId, KPresBlock ));
+            break;
+        default:
+            User::LeaveIfError( aAction.AddOrReplaceActionL(aRuleId, KPresAllow ));
+        };
+    User::LeaveIfError( aTransform.AddOrRepProvideAllTransComplexL(
+        aRuleId, KPresProvideAllAttributes ));
+    User::LeaveIfError( aTransform.AddOrRepProvideAllTransComplexL(
+        aRuleId, KPresProvidePersons ));
+    User::LeaveIfError( aTransform.AddOrRepProvideAllTransComplexL(
+        aRuleId, KPresProvideDevices ));
+    User::LeaveIfError( aTransform.AddOrRepProvideAllTransComplexL(
+        aRuleId, KPresProvideServices ));
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::ReplaceGroupTag
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::ReplaceGroupTag( HBufC16* aBuf, const TDesC16& aGroup )
+    {
+    // Replace group if found
+    TPtr pBuf( aBuf->Des() );
+    TInt pos = pBuf.Find( KSimpleGroupTag );
+    if ( pos != KErrNotFound )
+        {
+        TPtrC p8( KSimpleGroupTag );
+        pBuf.Replace( pos, p8.Length(), aGroup );
+        }
+    else
+        {
+        // No tag
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::ReplaceDomainTag
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::ReplaceDomainTag( HBufC16* aBuf, const TDesC16& aDomain )
+    {
+    // Replace domain if found
+    TPtr pBuf( aBuf->Des() );
+    TInt pos = pBuf.Find( KSimpleDomainTag );
+    if ( pos != KErrNotFound )
+        {
+        // remove leading "@"
+        TPtrC p8( KSimpleDomainTag );
+        if ( aDomain[0] == '@')
+            {
+            pBuf.Replace( pos, p8.Length(), aDomain.Mid( 1 ));
+            }
+        else
+            {
+            pBuf.Replace( pos, p8.Length(), aDomain );
+            }
+        }
+    else
+        {
+        // No tag
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::ReplaceUserTag
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::ReplaceUserTag(
+    HBufC16* aBuf, const TDesC16& aPresentityUri )
+    {
+    TPtr pBuf( aBuf->Des() );
+    TInt presentityUriLen = aPresentityUri.Length();
+    // Replace user if found
+    TInt pos = pBuf.Find( KSimpleUserTag );
+    if ( pos != KErrNotFound )
+        {
+        TPtrC p8( KSimpleUserTag );
+
+        // Remove leading "sip:" or "tel:" prefix and strip off domain part from aPresentityUri.
+        TInt domainPos = presentityUriLen;
+        TInt userIdPos = 0;
+
+        if ( !aPresentityUri.Left( KMyLenPrefix ).CompareF( KMySip ) ||
+             !aPresentityUri.Left( KMyLenPrefix ).CompareF( KMyTel ))
+            {
+            userIdPos = KMyLenPrefix;
+            }
+
+        for ( TInt i = userIdPos; i < presentityUriLen; i++ )
+            {
+            if ( aPresentityUri[i] == '@' )
+                {
+                domainPos = i;
+                break;
+                }
+            }
+
+        TPtrC userId( aPresentityUri.Mid( userIdPos, domainPos - userIdPos ));
+        pBuf.Replace( pos, p8.Length(), userId );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimplePluginXdmUtils::CompleteClientReq
+// ---------------------------------------------------------------------------
+//
+void CSimplePluginXdmUtils::CompleteClientReq( TInt aStatus )
+    {
+    iXdmState = EStateIdle;
+    iOperation = ENoOperation;
+    TRequestStatus* s = iClientStatus;
+    User::RequestComplete( s, aStatus );
+    }
+
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/data/10281ef0.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 1028 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    ECOM plugin resource file for Presence Settings UI GS plugin.
+*
+*/
+
+
+
+#include <registryinfo.rh>
+#include "psuigspluginids.hrh"
+
+RESOURCE REGISTRY_INFO theInfo
+    {
+    dll_uid     = PSUIGSPluginDllUid;
+    interfaces  = 
+        {
+        INTERFACE_INFO
+            {
+            interface_uid   = 0x10207236;//KGSPluginInterfaceUid
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid  = PSUIGSPluginImplUid;
+                    version_no          = 1;
+                    display_name        = "Presence Settings GS plugin"; 
+                    default_data        = "0x10283341";//KGSAdminPluginUid;
+                    opaque_data         = "30"; // Order number
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/data/psuigspluginrsc.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,496 @@
+/*
+* Copyright (c) 2006-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:    Resource file for Presence Settings UI GS plugin
+*
+*/
+
+
+
+
+//  RESOURCE IDENTIFIER
+NAME    UIPS // 4 letter ID
+
+//  INCLUDES
+#include    <bldvariant.hrh>
+#include    <avkon.rh>
+#include    <avkon.hrh>
+#include    <avkon.rsg>
+#include    <avkon.mbg>
+#include    <EIKCORE.RSG>
+#include    <eikon.rh>
+#include    <eikon.rsg>
+#include    <avkon.loc>
+#include    <gscommon.rh> // Common GS resource structures
+#include    <data_caging_paths_strings.hrh>
+#include    <psuigsplugin.loc>
+#include    "psuigsplugin.hrh"
+
+// CONSTANTS
+#define KPSUICompulsoryChar "*"
+#define KPSUIMaxServerNameLength 100
+#define KPSUIURILength 255
+#define KPSUIMaxObjectSize 999999999
+#define KPSUIObjectSizeEditorLength 9
+#define KPSUIPublIntervalEditorLength 6
+#define KPSUISubscriptionsEditorLength 4
+
+//  RESOURCE DEFINITIONS 
+
+// ---------------------------------------------------------------------------
+// RSS_SIGNATURE
+// ---------------------------------------------------------------------------
+//
+RESOURCE RSS_SIGNATURE {}
+
+// ---------------------------------------------------------------------------
+// r_psui_mainview_menubar - menubar
+// Settings mainview's titles
+// ---------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_psui_mainview_menubar
+    {
+    titles = 
+        {
+        MENU_TITLE { menu_pane = r_psui_mainview_menupane; }
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_mainview_menupane - menupane
+// Settings mainview's menuitems
+// ---------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_psui_mainview_menupane
+    {
+    items =
+        {
+        MENU_ITEM 
+            { 
+            command = EPSUICmdEdit; 
+            txt = qtn_presence_settings_edit;
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM 
+            { 
+            command = EPSUICmdNewSettings;
+            txt = qtn_presence_settings_new;
+            cascade = r_psui_newsettings_menu;
+            },
+        MENU_ITEM 
+            {
+            command = EPSUICmdDelete;
+            txt = qtn_presence_settings_delete;
+            },
+        MENU_ITEM 
+            { 
+            command = EAknCmdHelp;
+            txt = qtn_options_help;
+            },
+        MENU_ITEM 
+            { 
+            command = EAknCmdExit;
+            txt = qtn_options_exit;
+            }
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_newsettings_menu - titlepane
+// Settings mainview's menuitems in New Settings cascade menu
+// ---------------------------------------------------------------------------
+// 
+RESOURCE MENU_PANE r_psui_newsettings_menu
+    {
+    items =
+        {
+        MENU_ITEM 
+            { 
+            command = EPSUICmdNewSettingsDefault;
+            txt = qtn_presence_settings_new_default;
+            },
+        MENU_ITEM 
+            { 
+            command = EPSUICmdNewSettingsExisting;
+            txt = qtn_presence_settings_new_existing;
+            }
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_mainview_title - titlepane
+// Settings mainview's title
+// ---------------------------------------------------------------------------
+//    
+RESOURCE TITLE_PANE r_psui_mainview_title
+    {
+    txt = qtn_presence_settings_title;
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_main_view - view
+// Settings mainview's menubar and command button area definitions
+// ---------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_psui_main_view
+    {
+    menubar = r_psui_mainview_menubar;
+    cba = r_psui_mainview_softkeys;
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_mainview_softkeys - cba
+// Settings mainview's command button area definitions
+// ---------------------------------------------------------------------------
+//
+RESOURCE CBA r_psui_mainview_softkeys
+    {
+    flags = 0;
+    buttons = 
+        {
+        CBA_BUTTON {id=EAknSoftkeyOptions; txt= text_softkey_option;},
+        CBA_BUTTON {id=EAknSoftkeyBack; txt= text_softkey_back;},
+        CBA_BUTTON {id=EPSUICmdEdit; txt= qtn_msk_edit ;}
+        };
+    }
+    
+// ---------------------------------------------------------------------------
+// r_psui_setting_view - view
+// Setting view's menubar and command button area definitions
+// ---------------------------------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_psui_setting_view
+    {
+    menubar = r_psui_settingview_menubar;
+    cba = r_psui_settingview_softkeys;
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_settingview_softkeys - cba
+// Settings mainview's command button area definitions
+// ---------------------------------------------------------------------------
+//
+RESOURCE CBA r_psui_settingview_softkeys
+    {
+    flags = 0;
+    buttons = 
+        {
+        CBA_BUTTON {id=EAknSoftkeyOptions; txt= text_softkey_option;},
+        CBA_BUTTON {id=EAknSoftkeyBack; txt= text_softkey_back;},
+        CBA_BUTTON {id=EPSUICmdChange; txt= qtn_msk_change ;}
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_settingview_menubar - menubar
+// Settingview's titles
+// ---------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_psui_settingview_menubar
+    {
+    titles = 
+        {
+        MENU_TITLE { menu_pane = r_psui_settingview_menupane; }
+        };
+    }    
+
+// ---------------------------------------------------------------------------
+// r_psui_settingview_menupane - menupane
+// Settingview's menuitems
+// ---------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_psui_settingview_menupane
+    {
+    items =
+        {
+        MENU_ITEM 
+            { 
+            command = EPSUICmdChange;
+            txt = qtn_presence_settings_change;
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EAknCmdHelp;
+            txt = qtn_options_help;
+            },
+        MENU_ITEM
+            {
+            command = EEikCmdExit;
+            txt = qtn_options_exit;
+            }
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_setting_items - AVKON_SETTING_ITEM_LIST
+// Setting items for presence settings
+// ---------------------------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_ITEM_LIST r_psui_setting_items
+    {
+    items = 
+        {
+        AVKON_SETTING_ITEM
+            {
+            identifier = EPSUIServerNameId;
+            setting_page_resource = r_psui_server_name_setting_page;
+            name = qtn_presence_settings_name;
+            compulsory_ind_string = KPSUICompulsoryChar;
+            empty_item_text = qtn_selec_setting_compulsory;
+            },
+        AVKON_SETTING_ITEM
+            {
+            identifier = EPSUISIPProfileId;
+            setting_page_resource = r_radiobutton_setting_page;
+            name = qtn_presence_settings_sip_profile;
+            compulsory_ind_string = KPSUICompulsoryChar;
+            empty_item_text = qtn_selec_setting_compulsory;
+            },
+        AVKON_SETTING_ITEM
+            {
+            identifier = EPSUIXDMSettingsId;
+            setting_page_resource = r_radiobutton_setting_page;
+            name = qtn_presence_settings_xdm_settings;
+            },
+        AVKON_SETTING_ITEM
+            {
+            identifier = EPSUIObjectSizeId;
+            setting_page_resource = r_psui_object_size_setting_page;
+            name = qtn_presence_settings_object_size;
+            compulsory_ind_string = KPSUICompulsoryChar;
+            empty_item_text = qtn_selec_setting_compulsory;
+            },
+/* server address disabled       
+        AVKON_SETTING_ITEM
+            {
+            identifier = EPSUIServerAddrId;
+            setting_page_resource = r_psui_server_addr_setting_page;
+            name = qtn_presence_settings_url;
+            },*/
+        AVKON_SETTING_ITEM
+            {
+            identifier = EPSUIPublishingIntervalId;
+            setting_page_resource = r_psui_publ_interval_setting_page;
+            name = qtn_presence_settings_time_interval;
+            },
+        AVKON_SETTING_ITEM
+            {
+            identifier = EPSUIMaxSubscriptionsId;
+            setting_page_resource = r_psui_subscriptions_setting_page;
+            name = qtn_presence_settings_number_subscriptions;
+            },
+        AVKON_SETTING_ITEM
+            {
+            identifier = EPSUIMaxContactsInListId;
+            setting_page_resource = r_psui_subscriptions_list_setting_page;
+            name = qtn_presence_settings_number_subsc_lists;
+            },
+        AVKON_SETTING_ITEM
+            {
+            identifier = EPSUIDomainSyntaxId;
+            setting_page_resource = r_psui_domain_syntax_setting_page;
+            name = qtn_presence_settings_domain;
+            compulsory_ind_string = KPSUICompulsoryChar;
+            empty_item_text = qtn_selec_setting_compulsory;
+            }                                    
+        };
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_server_name_setting_page
+// ---------------------------------------------------------------------------
+RESOURCE AVKON_SETTING_PAGE r_psui_server_name_setting_page
+    {
+    label= qtn_presence_settings_name;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    type = EEikCtEdwin;
+    editor_resource_id = r_psui_server_name_editor;
+    }
+
+RESOURCE EDWIN r_psui_server_name_editor
+    {
+    flags = EEikEdwinNoLineOrParaBreaks;
+    width = 0;
+    lines = 0;    
+    maxlength = KPSUIMaxServerNameLength;
+    }
+
+// ---------------------------------------------------------------------------
+// r_radiobutton_setting_page
+// ---------------------------------------------------------------------------
+RESOURCE AVKON_SETTING_PAGE r_radiobutton_setting_page
+    {
+    number = EAknSettingPageNoOrdinalDisplayed; 
+    label = qtn_presence_settings_sip_profile;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    type =  EAknSetListBox;
+    editor_resource_id = r_setting_listbox;
+    }
+    
+RESOURCE LISTBOX r_setting_listbox
+    {
+    flags = EAknListBoxMultiselectionList;//no actual multiselection, just to make radiobutton visible in previously chosen item
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_object_size_setting_page
+// ---------------------------------------------------------------------------
+RESOURCE AVKON_SETTING_PAGE r_psui_object_size_setting_page
+    {
+    label= qtn_presence_settings_object_size;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    type = EAknCtIntegerEdwin;
+    editor_resource_id = r_psui_object_size_editor;
+    }
+
+RESOURCE AVKON_INTEGER_EDWIN r_psui_object_size_editor
+    {
+    maxlength = KPSUIObjectSizeEditorLength;
+    min = 1;
+    max = KPSUIMaxObjectSize;// needed since default value is smaller
+    unset_value = -1;//KErrNotFound
+    }
+
+// ---------------------------------------------------------------------------
+// r_server_addr_setting_page
+// ---------------------------------------------------------------------------
+/* server address disabled
+RESOURCE AVKON_SETTING_PAGE r_psui_server_addr_setting_page
+    {
+    label= qtn_presence_settings_url;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    type = EEikCtEdwin;
+    editor_resource_id = r_psui_uri_editor;
+    }*/
+
+RESOURCE EDWIN r_psui_uri_editor
+    {
+    width = 0;
+    lines = 0;
+    maxlength = KPSUIURILength;
+    flags = EEikEdwinAutoSelection | EAknEditorLowerCase | EEikEdwinNoLineOrParaBreaks;
+    allowed_case_modes = EAknEditorLowerCase | EAknEditorUpperCase;
+    numeric_keymap=EAknEditorCalculatorNumberModeKeymap;
+    allowed_input_modes = EAknEditorTextInputMode | EAknEditorNumericInputMode;
+    default_input_mode = EAknEditorTextInputMode;
+    special_character_table = R_AVKON_URL_SPECIAL_CHARACTER_TABLE_DIALOG;
+    default_case = EAknEditorLowerCase;
+    avkon_flags = EAknEditorFlagLatinInputModesOnly;
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_publ_interval_setting_page
+// ---------------------------------------------------------------------------
+RESOURCE AVKON_SETTING_PAGE r_psui_publ_interval_setting_page
+    {
+    label= qtn_presence_settings_time_interval;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    type = EAknCtIntegerEdwin;
+    editor_resource_id = r_psui_publ_interval_editor;
+    }
+
+RESOURCE AVKON_INTEGER_EDWIN r_psui_publ_interval_editor
+    {
+    maxlength = KPSUIPublIntervalEditorLength;
+    min = 1;
+    unset_value = -1;//KErrNotFound
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_subscriptions_setting_page
+// ---------------------------------------------------------------------------
+RESOURCE AVKON_SETTING_PAGE r_psui_subscriptions_setting_page
+    {
+    label= qtn_presence_settings_number_subscriptions;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    type = EAknCtIntegerEdwin;
+    editor_resource_id = r_psui_subscriptions_editor;
+    }
+
+RESOURCE AVKON_INTEGER_EDWIN r_psui_subscriptions_editor
+    {
+    maxlength = KPSUISubscriptionsEditorLength;
+    min = 0;
+    unset_value = -1;//KErrNotFound
+    }
+
+// ---------------------------------------------------------------------------
+// r_psui_subscriptions_setting_page
+// ---------------------------------------------------------------------------
+RESOURCE AVKON_SETTING_PAGE r_psui_subscriptions_list_setting_page
+    {
+    label= qtn_presence_settings_number_subsc_lists;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    type = EAknCtIntegerEdwin;
+    editor_resource_id = r_psui_subscriptions_editor;
+    }    
+    
+// ---------------------------------------------------------------------------
+// r_psui_domain_syntax_setting_page
+// ---------------------------------------------------------------------------
+RESOURCE AVKON_SETTING_PAGE r_psui_domain_syntax_setting_page
+    {
+    label= qtn_presence_settings_domain;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    type = EEikCtEdwin;
+    editor_resource_id = r_psui_uri_editor;
+    }
+
+// ---------------------------------------------------------
+//    r_deletesettingsconf_query - query
+//    Query when deleting settings
+// ---------------------------------------------------------
+//
+RESOURCE DIALOG r_psui_conf_query
+    {
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_YES_NO;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_CONFIRMATION_QUERY
+                { 
+                layout = EConfirmationLayout;
+                };
+            }
+        };
+    }
+    
+// ---------------------------------------------------------------------------
+// resource texts
+// ---------------------------------------------------------------------------
+//
+RESOURCE TBUF r_qtn_presence_settings_empty_primary     { buf = qtn_presence_settings_empty_primary; }
+RESOURCE TBUF r_qtn_presence_settings_empty_secondary   { buf = qtn_presence_settings_empty_secondary; }
+RESOURCE TBUF r_qtn_presence_propmt_use_exist           { buf = qtn_presence_propmt_use_exist; }    
+RESOURCE TBUF r_qtn_presence_name_default               { buf = qtn_presence_name_default; } 
+RESOURCE TBUF r_qtn_presence_name_default_number        { buf = qtn_presence_name_default_number; } 
+RESOURCE TBUF r_qtn_query_common_conf_delete            { buf = qtn_query_common_conf_delete; }
+RESOURCE TBUF r_qtn_presence_settings_delete_last       { buf = qtn_presence_settings_delete_last; }
+RESOURCE TBUF r_qtn_presence_settings_not_filled        { buf = qtn_presence_settings_not_filled; }
+RESOURCE TBUF r_qtn_presence_settings_name_exists       { buf = qtn_presence_settings_name_exists; }
+RESOURCE TBUF r_qtn_set_folder_presence                 { buf = qtn_set_folder_presence; }
+   
+//End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Build information file for Presence Settings UI GS plugin.
+*
+*/
+
+
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+// Help exports
+#include "../help/group/bld.inf"
+
+PRJ_EXPORTS
+// IBYs
+../rom/psuigsplugin.iby CORE_MW_LAYER_IBY_EXPORT_PATH(psuigsplugin.iby)
+../rom/psuigspluginresources.iby LANGUAGE_MW_LAYER_IBY_EXPORT_PATH(psuigspluginresources.iby)
+// LOC
+../loc/psuigsplugin.loc MW_LAYER_LOC_EXPORT_PATH(psuigsplugin.loc)
+
+PRJ_EXTENSIONS
+START EXTENSION s60/mifconv
+	OPTION TARGETFILE psuigsplugin.mif
+	OPTION HEADERFILE psuigsplugin.mbg
+	OPTION SOURCES -c8,8 qgn_prop_set_conn_presence
+END
+
+PRJ_MMPFILES
+psuigsplugin.mmp
+
+PRJ_TESTMMPFILES
+//../internal/tsrc/test/group/ut_presencesettingsui.mmp
+
+PRJ_TESTEXPORTS
+// none
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/group/psuigsplugin.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2006-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:    This is project specification file for Presence UI Settings GS plugin.
+*
+*/
+
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+// definitions
+CAPABILITY          CAP_ECOM_PLUGIN
+TARGET              psuigsplugin.dll
+TARGETTYPE          PLUGIN
+UID                 0x10009D8D 0x10281EF0 //PSUIGSPluginDllUid
+VENDORID            VID_DEFAULT
+
+// sources
+SOURCEPATH          ../data
+SOURCEPATH          ../src
+SOURCE              psuigspluginimplementationtable.cpp
+SOURCE              psuigsplugin.cpp
+SOURCE              psuigsplugincontainer.cpp
+SOURCE              psuigspluginmodel.cpp
+SOURCE              psuigspluginsettingview.cpp
+SOURCE              psuigspluginsettingviewcontainer.cpp
+SOURCE              psuisipxdmsettingitem.cpp
+SOURCE              psuiintegersettingitem.cpp
+
+// includes
+USERINCLUDE         ../inc
+USERINCLUDE         ../data
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE       /epoc32/include/ecom
+
+//ECOM resource definition
+START RESOURCE      ../data/10281ef0.rss
+TARGET              psuigsplugin.rsc 
+END
+
+// resources
+START RESOURCE      ../data/psuigspluginrsc.rss 
+HEADER
+TARGETPATH          RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+// dependancies
+LIBRARY             euser.lib
+LIBRARY             avkon.lib
+LIBRARY             bafl.lib 
+LIBRARY             cone.lib 
+LIBRARY             eikcoctl.lib 
+LIBRARY             eikcore.lib 
+LIBRARY             commonengine.lib
+LIBRARY             featmgr.lib
+LIBRARY             hlplch.lib
+LIBRARY             gsframework.lib
+LIBRARY             gsecomplugin.lib
+LIBRARY             aknskins.lib
+LIBRARY             sipprofilecli.lib
+LIBRARY             inetprotutil.lib
+LIBRARY             xdmsettingsapi.lib
+LIBRARY             presencesettingsapi.lib
+LIBRARY             serviceprovidersettings.lib
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/group/psuigspluginicons.mk	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,55 @@
+#
+# Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:    Icons for presence settings ui gs plugin
+#
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=\epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=\epoc32\data\z
+endif
+
+TARGETDIR=$(ZDIR)\resource\apps
+HEADERDIR=\epoc32\include
+ICONTARGETFILENAME=$(TARGETDIR)\psuigsplugin.mif
+HEADERFILENAME=$(HEADERDIR)\psuigsplugin.mbg
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN :
+	if exist $(ICONTARGETFILENAME) erase $(ICONTARGETFILENAME)
+	if exist $(HEADERFILENAME) erase $(HEADERFILENAME)
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE :
+	mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \
+		/c8,8 qgn_prop_set_conn_presence.bmp
+
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(HEADERFILENAME)&& \
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
Binary file presencesettingsui/help/data/xhtml.zip has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/help/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -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:
+* Export help related files.
+*
+*/
+
+#include <platform_paths.hrh>				
+PRJ_EXPORTS
+:zip ../data/xhtml.zip   /epoc32/data/z/resource/ overwrite
+:zip ../data/xhtml.zip   /epoc32/winscw/c/resource/ overwrite
+
+../inc/pre.hlp.hrh	MW_LAYER_PLATFORM_EXPORT_PATH(csxhelp/pre.hlp.hrh)
+../rom/presencesettingsuihelps_variant.iby		CUSTOMER_APP_LAYER_IBY_EXPORT_PATH(presencesettingsuihelps_variant.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/help/inc/pre.hlp.hrh	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description:
+*
+*/
+	
+//
+// pre.hlp.hrh generated by CSXHelp Utilities.
+//           
+
+#ifndef __PRE_HLP_HRH__
+#define __PRE_HLP_HRH__
+
+_LIT(KPRE_HLP_EDIT_SET, "PRE_HLP_EDIT_SET"); // 
+_LIT(KPRE_HLP_LIST_VIEW, "PRE_HLP_LIST_VIEW"); // 
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/help/rom/presencesettingsuihelps_variant.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+#ifndef __PRESENCESETTINGSUIHELPS_VARIANT_IBY__
+#define __PRESENCESETTINGSUIHELPS_VARIANT_IBY__
+
+#if defined(FF_S60_HELPS_IN_USE)
+    data=LOCALISE(DATAZ_/resource/xhtml/%02d/0x10281EF0/contents.zip, RESOURCE_FILES_DIR/xhtml/%02d/0x10281EF0/contents.zip)
+    data=LOCALISE(DATAZ_/resource/xhtml/%02d/0x10281EF0/index.xml, RESOURCE_FILES_DIR/xhtml/%02d/0x10281EF0/index.xml)
+    data=LOCALISE(DATAZ_/resource/xhtml/%02d/0x10281EF0/keywords.xml, RESOURCE_FILES_DIR/xhtml/%02d/0x10281EF0/keywords.xml)
+    data=LOCALISE(DATAZ_/resource/xhtml/%02d/0x10281EF0/meta.xml, RESOURCE_FILES_DIR/xhtml/%02d/0x10281EF0/meta.xml)
+#endif
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/inc/psuigsplugin.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,226 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    GSFW plugin header for Presence Settings UI GS plugin.
+*
+*/
+
+
+
+
+#ifndef PSUIGSPLUGIN_H
+#define PSUIGSPLUGIN_H
+
+//  INCLUDES
+#include <eikmobs.h>
+#include <ConeResLoader.h>
+#include <gsbaseview.h>
+
+// FORWARD DECLARATIONS
+class CPSUIGSPluginContainer;
+class CPSUIGSPluginModel;
+
+// CLASS DECLARATION
+
+/**
+* Header of CPSUIGSPlugin which implements the CGSPluginInterface.
+*
+* @lib PSUIGSPlugin.lib
+* @since Series60_3.2
+*/
+class CPSUIGSPlugin : 
+    public CGSBaseView,
+    public MCoeViewDeactivationObserver,
+    public MEikListBoxObserver
+    {
+    
+    public: // Constructors and destructor
+            
+        /**
+        * Symbian OS two-phased constructor
+        */
+        static CPSUIGSPlugin* NewL( TAny* aAppUi );
+    
+        /**
+        * Destructor.
+        */
+        ~CPSUIGSPlugin();
+
+    private: // Functions from base classes
+                
+        /**
+        * From CAknView
+        * See base class.
+        */
+        TUid Id() const;
+
+        /**
+        * From CAknView
+        * See base class.
+        */
+        void DoActivateL( const TVwsViewId& aPrevViewId,
+                          TUid aCustomMessageId,
+                          const TDesC8& aCustomMessage );
+        
+        /**
+        * From CAknView
+        * See base class.
+        */
+        void DoDeactivate();
+        
+        /**
+        * From CAknView
+        * See base class.
+        */
+        void HandleCommandL( TInt aCommand );
+        
+        /**
+        * From CGSBaseView
+        * See base class.
+        */        
+        void NewContainerL();
+       
+        /**
+        * From CGSBaseView
+        * See base class.
+        */   
+        void HandleListBoxSelectionL();
+       
+        /**
+         * From CGSPluginInterface
+         * See base class.
+         */
+        void GetCaptionL( TDes& aCaption ) const;
+        
+        /**
+        * From CGSPluginInterface
+        * See base class.
+        */
+        TInt PluginProviderCategory() const;
+
+        /**
+        * From CGSPluginInterface
+        * See base class.
+        */
+        CGulIcon* CreateIconL( const TUid aIconType );
+
+        /**
+        * From MEikMenuObserver
+        * See base class.
+        */
+        void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane *aMenuPane );
+
+        /**
+        * From MCoeViewDeactivationObserver
+        * Used to be able to free memory when plugin get's closed.
+        * See base class.
+        */        
+        void HandleViewDeactivation ( 
+            const TVwsViewId& aViewIdToBeDeactivated,
+            const TVwsViewId& aNewlyActivatedViewId );
+            
+        /**
+        * From MEikListBoxObserver
+        * See base class.
+        */
+        void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
+        
+    public: // New
+
+        /**
+        * Gives a handle to PS Model. Ownership is not transferred.
+        *
+        * @return handle to PS Model
+        */       
+        CPSUIGSPluginModel* PSModel();
+
+        /**
+        * Takes care of settings deletion.
+        */        
+        void DeleteSettingsL();        
+    
+    private: // New
+    
+        /**
+        * Returns count and index of current item in listbox.
+        *
+        * @param aIndex returns the index. If no items, KErrNotFound.
+        * @return TInt containing the count.
+        */
+        TInt SettingCountAndIndex( TInt& aIndex );
+
+        /**
+        * Shows the delete certain setting set confirmation note.
+        *
+        * @param aCount is the amount of all settings
+        * @param aIndex is the to be deleted setting set
+        * @return TBool about proceed with deletion.
+        */        
+        TBool AcceptDeletionL( TInt aCount, TInt aIndex );
+    
+        /**
+        * Constructs the setting view
+        */        
+        void ConstructSettingViewL();
+
+        /**
+        * Removes the setting view
+        */
+        void RemoveSettingView();
+
+        /**
+        * Create new default settings and launch setting view
+        */        
+        void CreateNewDefaultSettingsL();
+
+        /**
+        * Create new a copy of existing settings and launch setting view
+        */        
+        void CreateCopyOfExistingSettingsL();
+        
+        /**
+        * Toggles visibility of MSK depending on the amount of setting sets
+        */        
+        void UpdateMSK();
+            
+    private: // Constructors
+
+        /**
+        * C++ default constructor.
+        */
+        CPSUIGSPlugin();
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+    private: // Data
+        
+        // Presence UI model
+        CPSUIGSPluginModel* iPSModel;
+        // Presence Setting view
+        CAknView* iSettingView;
+        // Indicates when PSUIGSPlugin's views are closed
+        TBool iClosing;
+        // Previous view
+        TVwsViewId iPSUIGSPrevViewId; 
+        
+#ifdef _DEBUG
+    friend class UT_CPSUIGSPlugin;
+    friend class UT_CPSUIGSPluginContainer;
+#endif
+    };
+
+#endif // PSUIGSPLUGIN_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/inc/psuigsplugin.hrh	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Presence Settings UI command definitions.
+*
+*/
+
+
+
+
+#ifndef PSUIGSPLUGIN_HRH
+#define PSUIGSPLUGIN_HRH
+
+/**
+* Commands used from menus
+*/
+enum TPSUIMenuCommands
+    {
+    EPSUICmdEdit = 100,
+    EPSUICmdNewSettings,
+    EPSUICmdNewSettingsDefault,
+    EPSUICmdNewSettingsExisting,
+    EPSUICmdDelete,
+    EPSUICmdChange
+    };
+
+/**
+* Ids for different setting fields
+*/
+enum TPSUISettingItemId
+    {
+    EPSUIServerNameId,
+    EPSUISIPProfileId,
+    EPSUIXDMSettingsId,
+    EPSUIObjectSizeId,
+    EPSUIServerAddrId,
+    EPSUIPublishingIntervalId,
+    EPSUIMaxSubscriptionsId,
+    EPSUIMaxContactsInListId,
+    EPSUIDomainSyntaxId
+    }; 
+    
+#endif //PSUIGSPLUGIN_HRH
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/inc/psuigsplugincontainer.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Header for Presence Settings UI GS plugin container.
+*
+*/
+
+
+
+
+#ifndef PSUIGSPLUGINCONTAINER_H
+#define PSUIGSPLUGINCONTAINER_H
+
+// INCLUDES
+#include <eikmobs.h>
+#include <gsbasecontainer.h>
+
+// FORWARD DECLARATIONS
+class CPSUIGSPlugin;
+
+// CLASS DECLARATION
+
+/**
+* CPSUIGSPluginContainer container class
+* @since Series60_3.2
+*/
+class CPSUIGSPluginContainer : public CGSBaseContainer,
+                               public MEikMenuObserver
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Default constructor.
+        */        
+        CPSUIGSPluginContainer( CPSUIGSPlugin* aView );
+
+        /**
+        * Destructor.
+        */
+        ~CPSUIGSPluginContainer();
+    
+    private: // Functions from base classes
+        
+        /**
+        * From CGSBaseContainer
+        * See base class.        
+        */    
+        void ConstructListBoxL( TInt aResLbxId );
+
+        /**
+        * From CGSBaseContainer
+        * See base class.        
+        */    
+        TKeyResponse OfferKeyEventL( 
+            const TKeyEvent& aKeyEvent,
+            TEventCode aType );        
+
+        /**
+        * From CCoeControl
+        * See base class.        
+        */ 
+        void GetHelpContext( TCoeHelpContext& aContext ) const;
+        
+        /**
+         * From MEikMenuObserver
+         */
+        void SetEmphasis( CCoeControl* /*aMenuControl*/, TBool /*aEmphasis*/ ){};
+      
+        
+        /**
+         * From MEikMenuObserver
+         */
+        void ProcessCommandL( TInt /*aCommandId*/ ){};
+        
+    private: // New
+
+        /**
+        * Sets empty texts to listbox
+        *
+        * @param none
+        */
+        void SetEmptyTextsToListboxL();
+
+    private: // Constructor
+    
+        /**
+        * Symbian OS constructor.
+        *
+        * @param aRect Listbox's rect.
+        */
+        void ConstructL( const TRect& aRect );
+        
+    private: // Data
+    
+        // Handle to view        
+        CPSUIGSPlugin* iView; // not owned
+        
+        /**
+         * Menubar.
+         * Own.
+         */
+        CEikMenuBar* iEikMenuBar;
+        
+#ifdef _DEBUG
+    friend class UT_CPSUIGSPluginContainer;
+#endif
+    };
+
+#endif //PSUIGSPLUGINCONTAINER_H   
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/inc/psuigspluginids.hrh	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Header file for Presence Settings GS plugin id consts
+*
+*/
+
+
+
+
+#ifndef __PSUIGSPLUGINIDS_HRH_
+#define __PSUIGSPLUGINIDS_HRH_
+
+/**
+* UID of the Presence Settings GS plugin dll
+*/
+#define PSUIGSPluginDllUid    0x10281EF0
+
+/**
+* UID of the Presence Settings GS plugin implementation
+*/
+#define PSUIGSPluginImplUid     0x10281EF1
+
+#endif // PSUIGSPLUGINIDS_HRH_
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/inc/psuigspluginmodel.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,390 @@
+/*
+* Copyright (c) 2006-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:    Presence settings UI model header.
+*
+*/
+
+
+
+
+#ifndef PSUIGSPLUGINMODEL_H
+#define PSUIGSPLUGINMODEL_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <badesca.h>
+#include <sipprofileregistryobserver.h>
+#include <pressettingsapi.h>
+#include "psuigsplugin.hrh"
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+class RPresenceSettingsArray;
+class CSIPManagedProfileRegistry;
+class CSIPManagedProfile;
+
+// Constants
+_LIT( KPSUIGSPluginPanicCategory, "PSUIGSPlugin" );
+
+/**
+* Presence settings UI model
+*
+* @lib PSUIGSPlugin.lib
+* @since Series60_3.2
+*/
+class CPSUIGSPluginModel : 
+    public CBase, 
+    public MDesCArray,
+    public MSIPProfileRegistryObserver
+    {
+
+    public: // Constructors and destructor
+            
+        /**
+        * Symbian OS two-phased constructor
+        */    
+        static CPSUIGSPluginModel* NewL();
+
+        /**
+        * Destructor.
+        */
+        ~CPSUIGSPluginModel();
+
+    public: // New
+    
+        //
+        //
+        // Presence settings related
+    
+        /**
+        * Retrieves current presence settings from system
+        */
+        void RetrieveSettingsL();
+
+        /**
+        * Stores current presence settings to system
+        */
+        void SaveSettingsL();
+        
+        /**
+        * Checks are the compulsory fields filled.
+        *
+        * @return boolean about filled fields
+        */        
+        TBool AllCompulsoryFieldsFilled();
+        
+        /**
+        * Prepares iSettingSet for editing
+        *
+        * @param aIndex of presence settings to be edited
+        */
+        void EditSettingsL( TInt aIndex );
+        
+        /**
+        * Refreshes the presence settings related arrays
+        */
+        void RefreshPSArraysL();
+
+        /**
+        * Prepares the iSettingSet and iSettingId
+        * with default values
+        */
+        void CreateDefaultSettingsL();
+
+        /**
+        * Prepares the iSettingSet and iSettingId
+        * with values from indexed presence setting
+        *
+        * @param aIndex is the presence settings to be duplicated
+        */
+        void DuplicateExistingSettingsL( TInt aIndex );
+
+        /**
+        * Creates new name for to be created settings. If aOriginal
+        * provided, then will use that as a base. If not, then will
+        * create the name based on default naming. Adds numbering to
+        * end of name if needed.
+        * Note : aOriginal will be stored to cleanupstack if provided
+        *
+        * @param aOriginal is optional base name
+        *
+        */
+        HBufC* CreateSettingNameLC( HBufC* aOriginal = NULL );
+
+        /**
+        * Deletes indexed settings through presence settings API.
+        *
+        * @param aToBeDeleted to be deleted settings
+        * @param aIsIndex tells is aToBeDeleted index or id
+        */
+        void DeleteSettingsL( TInt aToBeDeleted, TBool aIsIndex );
+        
+        /**
+        * Returns name of the indexed settings.
+        *
+        * @param aIndex of the wanted name
+        * @return HBufC* containing the name
+        */
+        HBufC* SettingNameLC( TInt aIndex );
+
+        /**
+        * Checks if there already is settings with the same name.
+        */
+        TBool IsItDuplicatePSName();
+
+        /**
+        * Returns iPSNameArray, which contains names of the
+        * different setting sets. Ownership of array stays in
+        * CPSUIGSPluginModel.
+        *
+        * @return CDesCArray* containing the names of the settings
+        */
+        CDesCArray* SettingNames();
+
+        /**
+        * Returns a reference to iSettingSet.
+        *
+        * @return TPresSettingsSet& containing one set of the settings
+        */        
+        TPresSettingsSet& SettingsSet();
+
+        /**
+        * Checks the validity of SIP- and XDM-fields, 
+        * if not valid empties the fields.
+        */     
+        void ClearInvalidSIPAndXDMSettingsL();
+        
+        /**
+        * Returns a reference to iSettingSetId.
+        *
+        * @return TInt& containing setting id
+        */        
+        TInt& SettingsId();
+
+        /**
+        * Returns a reference to iPSIdArray.
+        *
+        * @return RArray<TInt>& containing iPSIdArray
+        */        
+        RArray<TInt>& SettingsIDArray();
+
+        //
+        //
+        // SIP related
+        
+        /**
+        * Fetches names of defined SIP-profiles
+        * Refreshes also SIP related arrays.
+        *
+        * @return descriptor array of names
+        */
+        CDesCArray* SipProfilesLC();
+        
+        /**
+        * Fetches the ID of indexed SIP profile
+        *
+        * @param aIndex is the index in the array
+        * @return ID of the SIP profile
+        */
+        TInt SipProfileId( TInt aIndex );
+        
+        /**
+        * Fetches the index of ID'ed SIP profile
+        *
+        * @param aId is ID of the SIP profile
+        * @return index in the array
+        */        
+        TInt SipProfileIndex( TInt aId );
+        
+        /**
+        * Fetches the name of ID'ed SIP profile
+        * Refreshes also SIP related arrays.        
+        *
+        * @param aId is ID of the SIP profile
+        * @return descriptor containing the name
+        */        
+        HBufC* SipProfileNameL( TInt aId );
+        
+	    /**
+        * Checks if SIP profile used by presence settings is in use
+        *
+        * @param aIndex is the index in the array
+        * @return ETrue if profile is registered
+        */    
+        TBool IsSipProfileRegisteredL( TInt aIndex );
+        
+        //
+        //
+        // XDM related
+
+        /**
+        * Fetches names of defined XDM settings.
+        * Refreshes also XDM related arrays.
+        *
+        * @return descriptor array of names
+        */        
+        CDesCArray* XdmCollectionNamesL();
+        
+        /**
+        * Fetches the name of ID'ed XDM setting
+        *
+        * @param aId is ID of the SIP profile
+        * @return descriptor containing the name
+        */ 
+        HBufC* XdmCollectionNameL( TInt aId );
+        
+        /**
+        * Fetches the index of ID'ed XDM setting
+        *
+        * @param aId is ID of the SIP profile
+        * @return index in the array
+        */ 
+        TInt XdmSettingIndex( TInt aId );
+        
+        /**
+        * Fetches the ID of indexed XDM setting
+        *
+        * @param aIndex is the index in the array
+        * @return ID of the SIP profile
+        */        
+        TInt XdmSettingId( TInt aIndex );        
+
+    private: // New
+    
+        /**
+        * Destroys given array. Used with TCleanupItem.
+        *
+        * @param pointerarray to be deleted
+        */      
+        static void ResetAndDestroy( TAny* aPointerArray );
+
+        /**
+        * Refreshes the SIP profile array. Needs to be
+        * called before calling most of the SIP-related methods.
+        */
+        void ReadSipArrayFromEngineL();
+        
+        /** 
+        * Checks if there is ordinal numbering at the end of
+        * descriptor and rips it off if there is.
+        *
+        * @return HBufC* containing the name ready for the numbering
+        */
+        HBufC* GetPrefixL( HBufC* aName );
+
+        /** 
+        * Re-arranges presence settings (name and id arrays) 
+        * to alphabetical order.
+        */
+        void ReArrangePresenceSettingsL();   
+        
+        /** 
+        * Cleans links to specific presence settings for 
+        * service provider settings.
+        * 
+        * @param aPresenceId presence settings id.
+        */
+        void CleanServiceProviderSettingsDataL( TInt aPresenceId );
+             
+    private: // Functions from base classes
+
+        /** 
+        * from MSIPProfileRegistryObserver
+        * Refreshes in most cases SIP related arrays.
+        *
+        * See base class.
+        */
+        void ProfileRegistryEventOccurred(
+            TUint32 aSIPProfileId, 
+            TEvent aEvent );
+
+        /**
+        * from MSIPProfileRegistryObserver
+        * Refreshes SIP related arrays.
+        *
+        * See base class.
+        */
+        void ProfileRegistryErrorOccurred(                  
+            TUint32 aSIPProfileId,
+            TInt aError);
+
+        /**
+        * from MDesCArray
+        * See base class.
+        */
+        TInt MdcaCount() const;
+        
+        /**
+        * from MDesCArray
+        * See base class.
+        */        
+        TPtrC16 MdcaPoint( TInt aIndex ) const;
+
+    private: // Constructors
+        
+        /**
+        * C++ default constructor.
+        */
+        CPSUIGSPluginModel();
+        
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+    private: // Data
+
+        // Currently edited presence settings
+        TPresSettingsSet iSettingSet;
+        // Setting identifier
+        TInt iSettingId;
+        // SIP profile registry
+        CSIPManagedProfileRegistry* iSIPEngine;
+        // SIP profile array
+        CArrayPtrFlat<CSIPManagedProfile>* iSIPProfiles;
+        // XDM ID array
+        RArray<TInt> iXdmIdArray;
+        // XDM name array
+        CDesCArray* iXdmNameArray;
+        // Presence settings id array
+        RArray<TInt> iPSIdArray;
+        // Presence settings name array
+        CDesCArray* iPSNameArray;
+        // Texts for the MDesCArray
+        HBufC* iVisibleSettingName;
+        
+    };
+
+/**
+* Small utility class to store presence settings
+* name and id. 
+* Used in CPSUIGSPluginModel::ReArrangePresenceSettingsL().
+*
+* @lib PSUIGSPlugin.lib
+* @since Series60_3.2
+*/
+class CPSUINameIDPair :
+    public CBase
+    {
+    public :
+    inline ~CPSUINameIDPair() { delete iName; };
+    
+    public :
+    TInt iID;
+    HBufC* iName;
+    };
+
+#endif // PSUIGSPLUGINMODEL_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/inc/psuigspluginsettingview.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,157 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Presence Settings UI's setting view.
+*
+*/
+
+
+
+
+#ifndef PSUIGSPLUGINSETTINGVIEW_H
+#define PSUIGSPLUGINSETTINGVIEW_H
+
+//  INCLUDES
+#include <aknview.h>
+
+// FORWARD DECLARATIONS
+class CPSUIGSPluginContainer;
+class CPSUIGSPluginSettingViewContainer;
+class CPSUIGSPlugin;
+
+const TUid KPreSettingViewId = {313};
+
+// CLASS DECLARATION
+
+/**
+* Header of CPSUIGSPluginSettingView.
+*
+* @lib PSUIGSPlugin.lib
+* @since Series60_3.2
+*/
+class CPSUIGSPluginSettingView : 
+    public CAknView
+    {
+    
+    public: // Constructors and destructor
+            
+        /**
+        * Symbian OS two-phased constructor
+        */
+        static CPSUIGSPluginSettingView* NewL( CPSUIGSPlugin* aMainView );
+    
+        /**
+        * Destructor.
+        */
+        ~CPSUIGSPluginSettingView();
+
+    private: // Functions from base classes
+                
+        /**
+        * From CAknView
+        * See base class.
+        */
+        TUid Id() const;
+
+        /**
+        * From CAknView
+        * See base class.
+        */
+        void DoActivateL( const TVwsViewId& aPrevViewId,
+                          TUid aCustomMessageId,
+                          const TDesC8& aCustomMessage );
+        
+        /**
+        * From CAknView
+        * See base class.
+        */
+        void DoDeactivate();
+        
+        /**
+        * From CAknView
+        * See base class.
+        */
+        void HandleCommandL( TInt aCommand );
+        
+        /**
+        * From CAknView
+        * See base class.
+        */
+        void HandleViewRectChange();
+    
+    public : // New
+
+        /**
+        * Gives a handle to plugin main view. Ownership is not transferred.
+        *
+        * @return handle to plugin main view
+        */          
+        CPSUIGSPlugin* MainView();
+        
+        /**
+        * Uses model to check if name is a duplicate and if it
+        * is shows a note.
+        *
+        * @return TBool about if duplicates were found
+        */  
+        TBool HandleDuplicatePSNamesL();
+    
+    private: // New
+    
+        /**
+        * Creates the setting view container
+        *
+        * @param none
+        */
+        void CreateContainerL();
+
+        /**
+        * Handles back-key presses. Checks if all compulsory
+        * fields are filled and if there is duplicates. Based on
+        * this saves and switches view back to main view.
+        */  
+        void HandleBackKeyL();
+        
+        /**
+        * Handles saving funtionality when Exit is chosen from Menu. 
+        * Checks if all compulsory fields are filled and in case of 
+        * duplicate changes name, after this saves settings.
+        */
+        void HandleMenuExitL();
+        
+    private: // Constructors
+
+        /**
+        * C++ default constructor.
+        */
+        CPSUIGSPluginSettingView( CPSUIGSPlugin* aMainView );
+
+        /**
+        * Symbian OS default constructor.
+        */
+        void ConstructL();
+
+    private: // Data
+    
+        // Previous view ID
+        TVwsViewId iPrevViewId;  
+        // Pointer to application UI.
+        CAknViewAppUi* iAppUi;        
+        // Presence setting view container
+        CPSUIGSPluginSettingViewContainer* iPSUIContainer;
+        // Handle to main view        
+        CPSUIGSPlugin* iMainView; // not owned
+    };
+
+#endif // PSUIGSPLUGINSETTINGVIEW_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/inc/psuigspluginsettingviewcontainer.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Header for Presence Settings UI setting view container.
+*
+*/
+
+
+
+
+#ifndef PSUIGSPLUGINSETTINGVIEWCONTAINER_H
+#define PSUIGSPLUGINSETTINGVIEWCONTAINER_H
+
+// INCLUDES
+#include <aknsettingitemlist.h>
+
+// FORWARD DECLARATIONS
+class CAknColumnListBox;
+class CPSUIGSPluginSettingView;
+
+// CLASS DECLARATION
+
+/**
+* CPSUIGSPluginSettingViewContainer container class
+* @since Series60_3.2
+*/
+class CPSUIGSPluginSettingViewContainer : 
+    public CAknSettingItemList
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * Default constructor.
+        */        
+        CPSUIGSPluginSettingViewContainer( CPSUIGSPluginSettingView* aView );
+
+        /**
+        * Destructor.
+        */
+        ~CPSUIGSPluginSettingViewContainer();
+   
+    private: // Functions from base classes
+        
+        /**
+        * From CAknSettingItemList
+        * See base class.        
+        */    
+        CAknSettingItem* CreateSettingItemL( TInt aSettingId );
+
+        /**
+        * From CCoeControl
+        * See base class.        
+        */ 
+        void GetHelpContext( TCoeHelpContext& aContext ) const;
+
+        /**
+        * From CCoeControl
+        * See base class.        
+        */         
+        void HandleResourceChange(TInt aType);
+
+        /**
+        * From CCoeControl
+        * See base class.        
+        */         
+        void SizeChanged();      
+
+    private: // New
+    
+        /**
+        * Update titlepane with setting name
+        *
+        * @param none
+        */
+        void UpdateTitleL();
+
+    public: // Functions from base classes
+           
+        /**
+        * From CAknSettingItemList
+        * See base class.        
+        */    
+        void EditItemL( TInt aIndex, TBool aCalledFromMenu );
+
+    public: // New
+    
+        /**
+        * Edit setting which is currently under focus.
+        *
+        * @param none
+        */
+        void EditCurrentItemL();
+        
+    public: // Constructor
+    
+        /**
+        * Symbian OS constructor.
+        *
+        * @param aRect Listbox's rect.
+        */
+        void ConstructL( const TRect& aRect );
+        
+    private: // Data        
+
+        // Pointer to view
+        CPSUIGSPluginSettingView* iView;
+    };
+
+#endif //PSUIGSPLUGINSETTINGVIEWCONTAINER_H   
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/inc/psuiintegersettingitem.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,73 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Setting item for integer values
+*
+*/
+
+
+
+
+#ifndef PSUIINTEGERSETTINGITEM_H
+#define PSUIINTEGERSETTINGITEM_H
+
+// INCLUDES
+#include <aknsettingitemlist.h>
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+* CPSUIIntegerSettingItem setting class. Needed to be able to
+* keep default values invisible.
+* @since Series60_3.2
+*/
+class CPSUIIntegerSettingItem : public CAknIntegerEdwinSettingItem
+    {
+    public : // Constructors and destructor
+    
+        /*
+        * C++ default constructor.
+        */
+        CPSUIIntegerSettingItem( TInt aIdentifier, TInt& aValue );
+
+        /**
+        * Destructor
+        */         
+        ~CPSUIIntegerSettingItem();
+    
+    private: // Functions from base classes
+    
+        /**
+        * From CAknSettingItem
+        * See base class.
+        */
+        virtual const TDesC& SettingTextL();
+
+        /**
+        * From CAknSettingItem
+        * See base class.
+        */
+        virtual void CompleteConstructionL();
+
+    private: // Data
+        
+        // since no access to base classes descriptors,
+        // here are similar ones        
+        HBufC* iPSUIInternalText;
+        TPtr iPSUIInternalTextPtr;
+    };
+
+#endif //PSUIINTEGERSETTINGITEM_H   
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/inc/psuisipxdmsettingitem.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,110 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Setting item for SIP / XDM settings
+*
+*/
+
+
+
+
+#ifndef PSUISIPXDMSETTINGITEM_H
+#define PSUISIPXDMSETTINGITEM_H
+
+// INCLUDES
+#include <aknsettingitemlist.h>
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+class CPSUIGSPluginModel;
+
+/**
+* CPSUISipXdmSettingItem setting class
+* @since Series60_3.2
+*/
+class CPSUISipXdmSettingItem : public CAknSettingItem
+    {
+    
+    public: // Constructors and destructor
+
+        /*
+        * C++ default constructor.
+        */
+        CPSUISipXdmSettingItem( TInt aIdentifier, TInt& aId, CPSUIGSPluginModel* iPSModel );
+
+        /**
+        * Destructor
+        */ 
+        ~CPSUISipXdmSettingItem();
+
+    private: // New
+    
+        /**
+        * Like in CAknSettingItem, but SIP specific.
+        */   
+        void EditSipItemL();
+        
+        /**
+        * Like in CAknSettingItem, but XDM specific.
+        */           
+        void EditXdmItemL();
+        
+        /**
+        * Launches the actual radio button setting dialog with data given.
+        *
+        * @param aIndex is currently selected setting
+        * @param aArray contains the settings to choose from
+        */           
+        void LaunchSettingDlgL( TInt& aIndex, CDesCArray* aArray );
+
+    private: // Functions from base classes
+
+        /**
+        * From CAknSettingItem
+        * See base class.
+        */
+        virtual void StoreL();
+
+        /**
+        * From CAknSettingItem
+        * See base class.
+        */
+        virtual void LoadL();
+
+        /**
+        * From CAknSettingItem
+        * See base class.
+        */
+        virtual const TDesC& SettingTextL();
+
+        /**
+        * From CAknSettingItem
+        * See base class.
+        */
+        virtual void EditItemL( TBool aCalledFromMenu );
+
+    protected: // Data
+        
+        // reference to external value
+        TInt& iExtChosenSettingID;
+        // internal value
+        TInt iIntChosenSettingID;
+        // pointer to PSUI model
+        CPSUIGSPluginModel* iPSModel;// owned elsewhere
+        // internal text having the listbox text
+        HBufC* iPSUIInternalText;// owned
+};
+
+#endif //PSUISIPXDMSETTINGITEM_H   
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/loc/psuigsplugin.loc	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,197 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Localisation strings for Presence Settings UI
+*
+*/
+
+
+
+
+
+/////////////////////////////////////////////////
+// Main view related
+
+// d:Title shown in title pane of main state.
+// l:title_pane_t2/opt9
+// r:3.2
+//
+#define qtn_presence_settings_title "Presence settings"
+
+// d:This is shown in listbox when no settings are defined. Primary text.
+// l:main_pane_empty_t1/opt2
+// r:3.2
+//
+#define qtn_presence_settings_empty_primary "No presence settings"
+
+// d:This is shown in listbox when no settings are defined. Secondary text.
+// l:main_list_empty_pane/opt2
+// r:3.2
+//
+#define qtn_presence_settings_empty_secondary "Please contatct your service provider for Presence settings"
+
+// d:Command in options menu for editing one set of presence settings
+// l:list_single_pane_t1_cp2
+// r:3.2
+//
+#define qtn_presence_settings_edit "Edit"
+
+// d:Submenu in options menu for commands for creating new settings.
+// l:list_single_pane_t1_cp2/opt3
+// r:3.2
+//
+#define qtn_presence_settings_new "New settings"
+
+// d:Command in submenu for creating new settings based on default settings.
+// l:list_single_popup_submenu_pane_t1
+// r:3.2
+//
+#define qtn_presence_settings_new_default "Default settings"
+
+// d:Command in submenu for creating new settings based on settings chosen by user.
+// l:list_single_popup_submenu_pane_t1
+// r:3.2
+//
+#define qtn_presence_settings_new_existing "Use existing"
+
+// d:Command in options menu for deleting one setting set.
+// l:list_single_pane_t1_cp2
+// r:3.2
+//
+#define qtn_presence_settings_delete "Delete"
+
+// d:Title of listbox when selecting which set to copy as a base of new settings.
+// l:heading_pane_t1
+// r:3.2
+//
+#define qtn_presence_propmt_use_exist "Use existing set"
+
+
+/////////////////////////////////////////////////
+// Setting view related
+
+// d:Command in options menu for changing setting values.
+// l:list_single_pane_t1_cp2
+// r:3.2
+//
+#define qtn_presence_settings_change "Change"
+
+// d:Title for the service name setting field in setting listbox.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_presence_settings_name "Service Name"
+
+// d:Title of chosen SIP profile -setting field in setting listbox.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_presence_settings_sip_profile "SIP Profile"
+
+// d:Title of chosen XDM settings -setting field in setting listbox.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_presence_settings_xdm_settings "XDM Settings"
+
+// d:Title of object size -setting field in setting listbox. This defines
+// d:the maximum size of the MIME object data in bytes when PUBLISH and NOTIFY methods are used.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_presence_settings_object_size "Object size"
+
+// d:Title of server address -setting field in setting listbox. This
+// d:defines the HTTP URL of the content server.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_presence_settings_url "Server address"
+
+// d:Title of publishing interval -setting field in setting listbox. This defines 
+// d:the minimum time interval (in seconds) between two consecutive publications.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_presence_settings_time_interval "Publishing interval (sec)"
+
+// d:Title of maximum subscriptions -setting field in setting listbox. This
+// d:defines the maximum number of presence subscriptions.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_presence_settings_number_subscriptions "Maximum subscriptions"
+
+// d:Title of max contacts in list -setting field in setting listbox. This
+// d:defines the maximum number of contacts in the subscription list.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_presence_settings_number_subsc_lists "Max. contacts in list"
+
+// d:Title for the domain name setting field in setting listbox.
+// d:This defines the domain name part of the service URL including the at-sign.
+// l:list_setting_pane_t1
+// r:3.2
+//
+#define qtn_presence_settings_domain "Domain Name"
+
+// d:Confirmation query text for deleting the last setting set defined.
+// l:popup_note_window
+// r:3.2
+//
+#define qtn_presence_settings_delete_last "%U is the last presence settings. Are you sure to delete it?"
+
+// d:Confirmation query text shown when trying to go back from edit view 
+// d:to main view (saves settings) without all the compulsory setting fields filled.
+// l:popup_note_window
+// r:3.2
+//
+#define qtn_presence_settings_not_filled "Presence settings are incomplete. Delete created settings?"
+
+// d:Confirmation query text shown when trying to go back from edit view 
+// d:to main view (saves settings) and there are already a setting set named with same name.
+// l:popup_note_window
+// r:3.2
+//
+#define qtn_presence_settings_name_exists "Name %U already in use"
+
+
+/////////////////////////////////////////////////
+// Both main and setting view related
+
+// d:Default name for the presence settings.
+// d:Used in couple of different layouts and the smallest space available is in list_set_graphic_pane_t1.
+// l:list_set_graphic_pane_t1
+// r:3.2
+//
+#define qtn_presence_name_default "Default name"
+
+// d:Version with numbering if the default name for settings is already used.
+// d:Used in couple of different layouts and the smallest space available is in list_set_graphic_pane_t1.
+// l:list_set_graphic_pane_t1
+// r:3.2
+//
+#define qtn_presence_name_default_number "Default name(%N)"
+
+
+/////////////////////////////////////////////////
+// Other
+
+// d:Title of presence settings in general settings/connection tab.
+// l:list_single_large_graphic_pane_t1
+// r:3.2
+//
+#define qtn_set_folder_presence "Presence"
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/rom/psuigsplugin.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    ROM creation file for presence settings ui
+*
+*/
+
+
+
+
+#ifndef __PSUIGSPLUGIN_IBY__
+#define __PSUIGSPLUGIN_IBY__
+
+#include <bldvariant.hrh>
+
+#ifdef RD_GS_RENOVATION_PHASE2
+#ifdef __SIP_SIMPLE_PRESENCE_PROTOCOL
+
+ECOM_PLUGIN(psuigsplugin.dll,10281ef0.rsc) 
+data=DATAZ_/BITMAP_DIR/psuigsplugin.mif BITMAP_DIR/psuigsplugin.mif
+
+#endif RD_GS_RENOVATION_PHASE2
+#endif __SIP_SIMPLE_PRESENCE_PROTOCOL
+
+#endif //__PSUIGSPLUGIN_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/rom/psuigspluginresources.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    ROM creation file for presence settings ui resources
+*
+*/
+
+
+
+
+#ifndef __PSUIGSPLUGINRESOURCES_IBY__
+#define __PSUIGSPLUGINRESOURCES_IBY__
+
+#include <bldvariant.hrh>
+
+#ifdef RD_GS_RENOVATION_PHASE2
+#ifdef __SIP_SIMPLE_PRESENCE_PROTOCOL
+
+data=DATAZ_/RESOURCE_FILES_DIR/psuigspluginrsc.rsc RESOURCE_FILES_DIR/psuigspluginrsc.rsc
+
+#endif RD_GS_RENOVATION_PHASE2
+#endif __SIP_SIMPLE_PRESENCE_PROTOCOL
+
+#endif //__PSUIGSPLUGINRESOURCES_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/src/psuigsplugin.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,561 @@
+/*
+* Copyright (c) 2006-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:    GSFW implementation for Presence Settings UI GS plugin.
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <bautils.h>
+#include <gsprivatepluginproviderids.h>
+#include <gsfwviewuids.h>
+#include <psuigspluginrsc.rsg>
+#include <psuigsplugin.mbg>
+#include <gsbaseview.h>
+#include <eiktxlbx.h>
+#include <eikmenup.h>
+#include <eiktxlbm.h>
+#include <featmgr.h>
+#include <hlplch.h>
+#include <coeaui.h>
+#include <aknlists.h>
+#include <aknPopup.h>
+#include <StringLoader.h>
+#include <AknQueryDialog.h>
+
+#include "psuigsplugin.h"
+#include "psuigsplugin.hrh"
+#include "psuigsplugincontainer.h"
+#include "psuigspluginids.hrh"
+#include "psuigspluginmodel.h"
+#include "psuigspluginsettingview.h"
+
+// CONSTANTS
+_LIT( KPSUIGSPluginResourceFileName, "z:\\resource\\psuigspluginrsc.rsc" );
+
+#ifdef __SCALABLE_ICONS
+// bitmap
+_LIT( KPSUIGSPluginIconFileName, "\\resource\\apps\\psuigsplugin.mif");
+#else //__SCALABLE_ICONS
+// svg file
+_LIT( KPSUIGSPluginIconFileName, "\\resource\\apps\\psuigsplugin.mbm");
+#endif //__SCALABLE_ICONS
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::CPSUIGSPlugin()
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPlugin::CPSUIGSPlugin()
+    : iClosing ( EFalse )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::~CPSUIGSPlugin()
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPlugin::~CPSUIGSPlugin()
+    {
+    delete iPSModel;
+    FeatureManager::UnInitializeLib();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::ConstructL
+// Symbian 2nd phase constructor can leave.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPlugin::ConstructL()
+    {
+    // preparing resources for use
+    TFileName fileName( KPSUIGSPluginResourceFileName );
+    BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
+    iResourceLoader.OpenL( fileName );
+    // base construct (base needs the resources to be loaded 1st)
+    BaseConstructL( R_PSUI_MAIN_VIEW );
+    FeatureManager::InitializeLibL();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::NewL()
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPlugin* CPSUIGSPlugin::NewL( TAny* /*aAppUi*/ )
+    {
+    CPSUIGSPlugin* self = new( ELeave ) CPSUIGSPlugin();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::Id()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+TUid CPSUIGSPlugin::Id() const
+    {
+    return TUid::Uid( PSUIGSPluginImplUid );
+    }
+   
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::NewContainerL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//  
+void CPSUIGSPlugin::NewContainerL()
+    {
+    iContainer = new ( ELeave ) CPSUIGSPluginContainer( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::DoActivateL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//  
+void CPSUIGSPlugin::DoActivateL( const TVwsViewId& aPrevViewId,
+                                  TUid aCustomMessageId,
+                                  const TDesC8& aCustomMessage )
+    {
+    if ( KPreSettingViewId != aPrevViewId.iViewUid )
+        {        
+        iPSUIGSPrevViewId = aPrevViewId;
+        }
+    
+    // model & observer constructed only when needed
+    if ( !iPSModel )
+        {
+        iPSModel = CPSUIGSPluginModel::NewL();
+        iAppUi->AddViewDeactivationObserverL( this );        
+        }
+
+    const TInt id = iPSModel->SettingsId();
+    if ( id )
+        {// readjust the focus
+        SetCurrentItem( iPSModel->SettingsIDArray().Find( id ));
+        }
+
+    iClosing = EFalse;
+    CGSBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
+    UpdateMSK();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::DoDeactivate()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPlugin::DoDeactivate()
+    {
+    CGSBaseView::DoDeactivate();
+    if ( iClosing )
+        {// PSUI plugin is going to be closed so it is safe to free some memory
+        delete iPSModel;
+        iPSModel = NULL;
+        delete iSettingView;
+        iSettingView = NULL;        
+        }    
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::HandleViewDeactivation()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPlugin::HandleViewDeactivation(
+    const TVwsViewId& aViewIdToBeDeactivated,
+    const TVwsViewId& aNewlyActivatedViewId)
+    {
+    if ( TUid::Uid( PSUIGSPluginImplUid ) == aViewIdToBeDeactivated.iViewUid && 
+        iPSUIGSPrevViewId.iViewUid == aNewlyActivatedViewId.iViewUid )
+        {
+        iClosing = ETrue;
+        iAppUi->RemoveViewDeactivationObserver( this );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::HandleCommandL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPlugin::HandleCommandL( TInt aCommand )
+    {
+    switch ( aCommand )
+        {
+        case EAknSoftkeyBack:
+            {
+            RemoveSettingView();
+            iAppUi->ActivateLocalViewL( iPSUIGSPrevViewId.iViewUid );
+            break;
+            }
+        case EPSUICmdEdit:
+            {
+            HandleListBoxSelectionL();
+            break;
+            }
+        case EPSUICmdDelete:
+            {
+            DeleteSettingsL();
+            break;
+            }
+        case EPSUICmdNewSettingsDefault:
+            {
+            CreateNewDefaultSettingsL();
+            break;
+            }
+        case EPSUICmdNewSettingsExisting:
+            {
+            CreateCopyOfExistingSettingsL();
+            break;
+            }
+        case EAknCmdHelp:
+            {
+            if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
+                {
+                HlpLauncher::LaunchHelpApplicationL(
+                    iEikonEnv->WsSession(), iAppUi->AppHelpContextL() );
+                }
+            break;
+            }                       
+        default:
+            {
+            iAppUi->HandleCommandL( aCommand );
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::SettingCountAndIndex()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+TInt CPSUIGSPlugin::SettingCountAndIndex( TInt& aIndex )
+    {
+    CEikTextListBox* listbox = Container()->iListBox;// not owned
+    TInt count = listbox->Model()->NumberOfItems();
+    aIndex = count ? listbox->CurrentItemIndex() : KErrNotFound;
+        
+    return count;        
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::HandleListBoxSelectionL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPlugin::HandleListBoxSelectionL()
+    {
+    TInt index = KErrNotFound;
+    if ( SettingCountAndIndex( index ))
+        {
+        iPSModel->EditSettingsL( index );
+
+        ConstructSettingViewL();    
+        iAppUi->ActivateLocalViewL( KPreSettingViewId );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::DeleteSettingsL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPlugin::DeleteSettingsL()
+    {
+    TInt index = KErrNotFound;
+    TInt count = SettingCountAndIndex( index );
+    if ( count )
+        {
+        if ( AcceptDeletionL( count, index ))
+            {
+            iPSModel->DeleteSettingsL( index, ETrue );
+            CEikTextListBox* listbox = Container()->iListBox;// not owned
+            AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(
+                listbox, index, ETrue );
+            listbox->DrawNow();
+            UpdateMSK();    
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::AcceptDeletionL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+TBool CPSUIGSPlugin::AcceptDeletionL( TInt aCount, TInt aIndex )
+    {
+    HBufC* currentName = iPSModel->SettingNameLC( aIndex );
+    HBufC* string = NULL;
+    if ( aCount == 1 )
+        {
+        string = StringLoader::LoadLC( R_QTN_PRESENCE_SETTINGS_DELETE_LAST, *currentName );
+        }
+    else
+        {
+        string = StringLoader::LoadLC( R_QTN_QUERY_COMMON_CONF_DELETE, *currentName );
+        }
+
+    CAknQueryDialog* query = CAknQueryDialog::NewL( CAknQueryDialog::EConfirmationTone );        
+    TInt ok = query->ExecuteLD( R_PSUI_CONF_QUERY,  *string );
+    
+    CleanupStack::PopAndDestroy( 2, currentName );//currentName, string       
+        
+    return ( ok );    
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::GetCaptionL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPlugin::GetCaptionL( TDes& aCaption ) const
+    {
+    StringLoader::Load( aCaption, R_QTN_SET_FOLDER_PRESENCE );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::PluginProviderCategory()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+TInt CPSUIGSPlugin::PluginProviderCategory() const
+    {
+    return KGSPluginProviderInternal;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::CreateIconL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+CGulIcon* CPSUIGSPlugin::CreateIconL( const TUid aIconType )
+    {
+    CGulIcon* icon = NULL;
+    if( aIconType == KGSIconTypeLbxItem )
+        {
+        icon = AknsUtils::CreateGulIconL(
+            AknsUtils::SkinInstance(), 
+            KAknsIIDQgnPropSetConnPresence,
+            KPSUIGSPluginIconFileName,
+            EMbmPsuigspluginQgn_prop_set_conn_presence,
+            EMbmPsuigspluginQgn_prop_set_conn_presence_mask );
+        }
+     else
+        {
+        icon = CGSPluginInterface::CreateIconL( aIconType );
+        }
+    
+    return icon;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::DynInitMenuPaneL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPlugin::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane *aMenuPane )
+    {
+    // remove some of the items if no settings available
+    const TInt count = Container()->iListBox->Model()->NumberOfItems();
+    if ( aResourceId == R_PSUI_MAINVIEW_MENUPANE && 
+        0 == count )
+        {
+        aMenuPane->DeleteMenuItem( EPSUICmdEdit );
+        aMenuPane->DeleteMenuItem( EPSUICmdDelete );
+        }
+    if ( aResourceId == R_PSUI_NEWSETTINGS_MENU && 
+        0 == count )
+        {
+        aMenuPane->DeleteMenuItem( EPSUICmdNewSettingsExisting );
+        }
+    
+    // help-item handling
+    if ( aResourceId == R_PSUI_MAINVIEW_MENUPANE && 
+        !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
+        {
+        aMenuPane->DeleteMenuItem( EAknCmdHelp );
+        }
+    
+    TInt index( KErrNotFound );
+    SettingCountAndIndex( index );
+    
+    if ( KErrNotFound < index )
+        {
+        // Hide delete option if sip profile used with presence settings
+        // is registered.
+        if ( iPSModel->IsSipProfileRegisteredL( index ) )
+            {
+            TInt pos( KErrNotFound );
+            if ( aMenuPane->MenuItemExists( EPSUICmdDelete, pos ) )
+                {
+                aMenuPane->SetItemSpecific( EPSUICmdDelete, EFalse );
+                aMenuPane->SetItemDimmed( EPSUICmdDelete, ETrue );
+                }
+            }
+        else
+            {
+            TInt pos( KErrNotFound );
+            if ( aMenuPane->MenuItemExists( EPSUICmdDelete, pos ) )
+                {
+                aMenuPane->SetItemSpecific( EPSUICmdDelete, ETrue );
+                aMenuPane->SetItemDimmed( EPSUICmdDelete, EFalse );
+                }
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::PSModel()
+// See header for details.
+// ---------------------------------------------------------------------------
+//    
+CPSUIGSPluginModel* CPSUIGSPlugin::PSModel()
+    {
+    __ASSERT_DEBUG( iPSModel,User::Panic( KPSUIGSPluginPanicCategory, KErrNotFound ));
+    return iPSModel;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::ConstructSettingViewL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//    
+void CPSUIGSPlugin::ConstructSettingViewL()
+    {
+    if ( !iSettingView )
+        {// no view yet, construct it
+        CAknView* view = CPSUIGSPluginSettingView::NewL( this );
+        CleanupStack::PushL( view );
+        iAppUi->AddViewL( view );
+        CleanupStack::Pop( view );
+        iSettingView = view;
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::RemoveSettingView()
+// See header for details.
+// ---------------------------------------------------------------------------
+//    
+void CPSUIGSPlugin::RemoveSettingView()
+    {
+    // Remove view from iAppUi -> View is deleted by iAppUi automatically.
+    if ( iSettingView )
+        {
+        iAppUi->RemoveView( KPreSettingViewId );
+        iSettingView = NULL;
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::CreateNewDefaultSettingsL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+void CPSUIGSPlugin::CreateNewDefaultSettingsL()
+    {
+    iPSModel->CreateDefaultSettingsL();
+    ConstructSettingViewL();
+    iAppUi->ActivateLocalViewL( KPreSettingViewId );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::CreateCopyOfExistingSettingsL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+void CPSUIGSPlugin::CreateCopyOfExistingSettingsL()
+    {
+    CAknSinglePopupMenuStyleListBox* list = 
+        new ( ELeave ) CAknSinglePopupMenuStyleListBox;
+    CleanupStack::PushL( list );
+
+    CAknPopupList* popupList = 
+        CAknPopupList::NewL( list, R_AVKON_SOFTKEYS_OK_CANCEL );
+    CleanupStack::PushL( popupList );    
+    
+    HBufC* title = StringLoader::LoadLC( R_QTN_PRESENCE_PROPMT_USE_EXIST );
+    popupList->SetTitleL( *title );
+    CleanupStack::PopAndDestroy( title );
+
+    list->ConstructL( popupList, CEikListBox::ELeftDownInViewRect );
+    list->CreateScrollBarFrameL( ETrue );
+    list->ScrollBarFrame()->SetScrollBarVisibilityL( 
+        CEikScrollBarFrame::EOff, 
+        CEikScrollBarFrame::EAuto );
+
+    CTextListBoxModel* model = list->Model();
+    model->SetItemTextArray( iPSModel->SettingNames() );// setting names not owned
+    model->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    list->HandleItemAdditionL();
+
+    CleanupStack::Pop( popupList );
+    TInt keyPress = popupList->ExecuteLD();
+    
+    if ( keyPress )
+        {
+        iPSModel->DuplicateExistingSettingsL( list->CurrentItemIndex() );
+        ConstructSettingViewL();
+        iAppUi->ActivateLocalViewL( KPreSettingViewId );        
+        }
+    
+    CleanupStack::PopAndDestroy( list );
+    }   
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::UpdateMSK()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+void CPSUIGSPlugin::UpdateMSK()
+    {
+    if ( !Cba() )
+        {
+        return;
+        }
+    
+    TBool showEdit = ( 0 < Container()->iListBox->Model()->NumberOfItems());
+    CEikCba* cba = static_cast< CEikCba* >( Cba()->ButtonGroup() );
+    cba->MakeCommandVisible( EPSUICmdEdit, showEdit );
+    cba->DrawNow();
+    }
+    
+// ---------------------------------------------------------------------------
+// CPSUIGSPlugin::HandleListBoxEventL()
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPlugin::HandleListBoxEventL(
+	  CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
+    {
+    // if the Select Key has been pressed
+    if ((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) ||
+    (aListBoxEvent == MEikListBoxObserver::EEventItemSingleClicked))
+        {
+        HandleListBoxSelectionL();   
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/src/psuigsplugincontainer.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Presence Settings UI GS plugin container implementation
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <psuigspluginrsc.rsg>
+#include <aknlists.h>
+#include <gsbasecontainer.h>
+#include "psuigsplugincontainer.h"
+#include "psuigspluginmodel.h"
+#include "psuigsplugin.h"
+#include "psuigspluginids.hrh"
+#include <csxhelp/pre.hlp.hrh>
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginContainer::CPSUIGSPluginContainer()
+// Default constructor.
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPluginContainer::CPSUIGSPluginContainer( CPSUIGSPlugin* aView )
+    : iView ( aView )
+    {
+    }
+    
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginContainer::ConstructL(const TRect& aRect)
+// Symbian OS phase 2 constructor
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginContainer::ConstructL( const TRect& aRect )
+    {
+    iListBox = new ( ELeave ) CAknSingleStyleListBox();// base needs the iListBox to be prepared 1st
+    BaseConstructL( aRect, R_PSUI_MAINVIEW_TITLE, 0 );// last parameter 0, since dynamic listbox
+    
+    iEikMenuBar = new ( ELeave ) CEikMenuBar();
+    iEikMenuBar->ConstructL( this, NULL, R_PSUI_MAINVIEW_MENUBAR );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginContainer::~CPSUIGSPluginContainer()
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPluginContainer::~CPSUIGSPluginContainer()
+    {
+    delete iEikMenuBar;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginContainer::ConstructListBoxL()
+// See header for details. 
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginContainer::ConstructListBoxL( TInt /*aResLbxId*/ )
+    {
+    // listbox creation and initialization
+    iListBox->SetContainerWindowL( *this );
+    iListBox->ConstructL( this, EAknListBoxLoopScrolling );
+    iListBox->CreateScrollBarFrameL( ETrue );
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
+        CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
+
+    SetEmptyTextsToListboxL();
+    
+    CPSUIGSPluginModel* psuiModel = iView->PSModel();// not owned
+    CTextListBoxModel* model = iListBox->Model();
+    model->SetItemTextArray( psuiModel );
+    model->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginContainer::SetEmptyTextsToListboxL()
+// See header for details. 
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginContainer::SetEmptyTextsToListboxL()
+    {
+    // empty texts
+    _LIT ( KPSUIEmptyStringHeader, "%S\n%S" );
+    HBufC* emptyText = iEikonEnv->AllocReadResourceLC( 
+        R_QTN_PRESENCE_SETTINGS_EMPTY_PRIMARY );
+    HBufC* emptyText2 = iEikonEnv->AllocReadResourceLC( 
+        R_QTN_PRESENCE_SETTINGS_EMPTY_SECONDARY );   
+    HBufC* emptyFinal = HBufC::NewLC( 
+        emptyText->Length() + emptyText2->Length() + 2 );// 2 is length of "\n" 
+    emptyFinal->Des().Format( KPSUIEmptyStringHeader, emptyText, emptyText2 );
+    iListBox->View()->SetListEmptyTextL( *emptyFinal );
+    CleanupStack::PopAndDestroy( 3, emptyText );// emptyText, emptyText2, emptyFinal
+    }
+    
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginContainer::OfferKeyEventL()
+// See header for details. 
+// ---------------------------------------------------------------------------
+//
+TKeyResponse CPSUIGSPluginContainer::OfferKeyEventL( 
+    const TKeyEvent& aKeyEvent, 
+    TEventCode aType )
+    {
+    if ( iView && aType == EEventKey 
+        && aKeyEvent.iCode == EKeyBackspace && 
+        iEikMenuBar->ItemSpecificCommandsEnabled() )
+        {
+        iView->DeleteSettingsL();
+        return EKeyWasConsumed;
+        }
+    else
+        {
+        return iListBox->OfferKeyEventL( aKeyEvent, aType );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CPSUIGSPluginContainer::GetHelpContext()
+// See header for details.
+// -----------------------------------------------------------------------------
+//
+void CPSUIGSPluginContainer::GetHelpContext( TCoeHelpContext& aContext ) const
+    {
+    aContext.iMajor = TUid::Uid( PSUIGSPluginDllUid );
+    aContext.iContext = KPRE_HLP_LIST_VIEW;
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/src/psuigspluginimplementationtable.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   
+*        ECOM proxy table for this plugin
+*
+*/
+
+
+
+
+// System includes
+#include <e32std.h>
+#include <implementationproxy.h>
+#include "psuigspluginids.hrh"
+#include "psuigsplugin.h"
+
+// Constants
+const TImplementationProxy PSUIGSPluginImplementationTable[] = 
+    {
+    IMPLEMENTATION_PROXY_ENTRY( PSUIGSPluginImplUid, CPSUIGSPlugin::NewL )
+    };
+
+// ---------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Gate/factory function
+//
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( 
+    TInt& aTableCount )
+    {
+    aTableCount = sizeof( PSUIGSPluginImplementationTable ) 
+        / sizeof( TImplementationProxy );
+    return PSUIGSPluginImplementationTable;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/src/psuigspluginmodel.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,877 @@
+/*
+* Copyright (c) 2006-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:    Presence settings UI model implementation.
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <escapeutils.h>
+#include <sipmanagedprofileregistry.h>
+#include <sipprofileregistryobserver.h>
+#include <sipmanagedprofile.h>
+#include <sipprofile.h>
+#include <StringLoader.h>
+#include <psuigspluginrsc.rsg>
+#include <XdmSettingsApi.h>
+#include <spentry.h>
+#include <spproperty.h>
+#include <spsettings.h>
+
+#include "psuigspluginmodel.h"
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::CPSUIGSPluginModel()
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPluginModel::CPSUIGSPluginModel()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::~CPSUIGSPluginModel()
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPluginModel::~CPSUIGSPluginModel()
+    {
+    delete iSIPEngine;
+    if ( iSIPProfiles )
+        {
+        iSIPProfiles->ResetAndDestroy();
+        delete iSIPProfiles;
+        }     
+        
+    iXdmIdArray.Close();
+    delete iXdmNameArray;
+    
+    iPSIdArray.Close();
+    delete iPSNameArray;    
+    delete iVisibleSettingName;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::ConstructL
+// Symbian 2nd phase constructor can leave.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginModel::ConstructL()
+    {
+    RetrieveSettingsL();
+    ReadSipArrayFromEngineL();
+    iVisibleSettingName = HBufC::NewL( 
+        KPresSetNameMaxLength + 2 );// max chars + KColumnListSeparator
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::NewL()
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPluginModel* CPSUIGSPluginModel::NewL()
+    {
+    CPSUIGSPluginModel* self = new ( ELeave ) CPSUIGSPluginModel();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self ); // self
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::RetrieveSettingsL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginModel::RetrieveSettingsL()
+    {
+    RefreshPSArraysL();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::SaveSettingsL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//    
+void CPSUIGSPluginModel::SaveSettingsL()
+    {
+    if ( iSettingId == 0 )
+        {// new settings
+        iSettingId = PresSettingsApi::CreateSetL( iSettingSet );
+        }
+    else
+        {// old & edited settings
+        PresSettingsApi::UpdateSetL( iSettingSet, iSettingId );
+        }
+    RefreshPSArraysL();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::CreateDefaultSettingsL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//    
+void CPSUIGSPluginModel::CreateDefaultSettingsL()
+    {
+    iSettingId = 0; // new settings
+    
+    iSettingSet.iSetName.Zero();
+    HBufC* name = CreateSettingNameLC();
+    iSettingSet.iSetName.Append( *name );
+    CleanupStack::PopAndDestroy( name );// name
+    
+    iSettingSet.iSipProfile = KErrNotFound;
+    iSettingSet.iXDMSetting = KErrNotFound;
+    iSettingSet.iObjectSize = KErrNotFound;
+    iSettingSet.iContSrvrAdd.Zero();
+    iSettingSet.iPublicationInt = KErrNotFound;
+    iSettingSet.iMaxSubscriptions = KErrNotFound;
+    iSettingSet.iMaxContactsInList = KErrNotFound;
+    iSettingSet.iDomainSyntax.Zero();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::DuplicateExistingSettingsL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//    
+void CPSUIGSPluginModel::DuplicateExistingSettingsL( TInt aIndex )
+    {
+    __ASSERT_DEBUG( aIndex < iPSIdArray.Count() ,User::Panic( KPSUIGSPluginPanicCategory, KErrOverflow ));
+    
+    iSettingId = 0; // new settings
+    TPresSettingsSet originalSettings;
+    PresSettingsApi::SettingsSetL( iPSIdArray[ aIndex ], originalSettings );
+    
+    iSettingSet.iSetName.Zero();
+    HBufC* name = CreateSettingNameLC( originalSettings.iSetName.AllocL() );
+    iSettingSet.iSetName.Append( *name );
+    CleanupStack::PopAndDestroy( name );// name
+    
+    iSettingSet.iSipProfile = originalSettings.iSipProfile;
+    iSettingSet.iXDMSetting = originalSettings.iXDMSetting;
+    iSettingSet.iObjectSize = originalSettings.iObjectSize;
+    iSettingSet.iContSrvrAdd = originalSettings.iContSrvrAdd;
+    iSettingSet.iPublicationInt = originalSettings.iPublicationInt;
+    iSettingSet.iMaxSubscriptions = originalSettings.iMaxSubscriptions;
+    iSettingSet.iMaxContactsInList = originalSettings.iMaxContactsInList;
+    iSettingSet.iDomainSyntax = originalSettings.iDomainSyntax;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::AllCompulsoryFieldsFilled()
+// See header for details.
+// ---------------------------------------------------------------------------
+//    
+TBool CPSUIGSPluginModel::AllCompulsoryFieldsFilled()
+    {
+    TBool returnValue = ETrue;
+    for ( TInt i = EPSUIServerNameId ; i <= EPSUIDomainSyntaxId && returnValue ; i++ )
+        {
+        switch( i ) 
+            {
+            case EPSUIServerNameId:
+                returnValue = ( iSettingSet.iSetName.Length() != 0 );
+                break;
+            case EPSUISIPProfileId:
+                returnValue = ( iSettingSet.iSipProfile != KErrNotFound );
+                break;
+            case EPSUIObjectSizeId:
+                returnValue = ( iSettingSet.iObjectSize != KErrNotFound );
+                break;
+            case EPSUIDomainSyntaxId:
+                returnValue = ( iSettingSet.iDomainSyntax.Length() != 0 );
+                break;
+            default:
+                // do nothing with non-compulsory ones
+                break;
+            }        
+        }    
+    return returnValue;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::IsItDuplicatePSName()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+TBool CPSUIGSPluginModel::IsItDuplicatePSName()
+    {
+    TBool found = KErrNone;
+    TInt pos = 0;
+    found = ( iPSNameArray->Find( iSettingSet.iSetName, pos ) == KErrNone );
+    if ( found )
+        {// dupe found, let's check it's not the same setting
+        __ASSERT_DEBUG( pos < iPSIdArray.Count() ,User::Panic( KPSUIGSPluginPanicCategory, KErrOverflow ));
+        found = !( iSettingId == iPSIdArray[ pos ]);
+        }
+    return found;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::EditSettingsL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+void CPSUIGSPluginModel::EditSettingsL( TInt aIndex )
+    {
+    __ASSERT_DEBUG( aIndex < iPSIdArray.Count() ,User::Panic( KPSUIGSPluginPanicCategory, KErrOverflow ));
+    TInt settingId = iPSIdArray[ aIndex ];
+    PresSettingsApi::SettingsSetL( settingId, iSettingSet );
+    iSettingId = settingId;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::DeleteSettingsL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+void CPSUIGSPluginModel::DeleteSettingsL( TInt aToBeDeleted, TBool aIsIndex )
+    {
+    if ( aIsIndex )
+        {// is index
+        __ASSERT_DEBUG( aToBeDeleted < iPSIdArray.Count() ,
+            User::Panic( KPSUIGSPluginPanicCategory, KErrOverflow ));
+        PresSettingsApi::RemoveSetL( iPSIdArray[ aToBeDeleted ]);
+        CleanServiceProviderSettingsDataL( iPSIdArray[ aToBeDeleted ] );
+        }
+    else
+        {// is id
+        PresSettingsApi::RemoveSetL( aToBeDeleted );
+        CleanServiceProviderSettingsDataL( aToBeDeleted );
+        }
+    RefreshPSArraysL();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::RefreshPSArraysL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+void CPSUIGSPluginModel::RefreshPSArraysL()
+    {
+    delete iPSNameArray;
+    iPSNameArray = NULL;
+    iPSIdArray.Reset();
+    
+    iPSNameArray = PresSettingsApi::GetAllSetsNamesLC( iPSIdArray );
+    CleanupStack::Pop( iPSNameArray );// iPSNameArray
+    ReArrangePresenceSettingsL();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::ReArrangePresenceSettingsL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+void CPSUIGSPluginModel::ReArrangePresenceSettingsL()
+    {
+    const TInt settingsCount = iPSNameArray->Count();
+    __ASSERT_DEBUG( 
+        settingsCount == iPSIdArray.Count(), 
+        User::Panic( KPSUIGSPluginPanicCategory, KErrArgument ));
+   
+    // make a tables of the original pairs
+    RPointerArray<CPSUINameIDPair> pairArray;
+    TCleanupItem clItem( ResetAndDestroy, &pairArray );
+    CleanupStack::PushL( clItem );
+    CPSUINameIDPair* pair = NULL;
+    for( TInt i = 0;i < settingsCount;i++ )
+        {
+        pair = new ( ELeave ) CPSUINameIDPair;
+        CleanupStack::PushL( pair );
+        pair->iID = iPSIdArray[ i ];
+        pair->iName = iPSNameArray->MdcaPoint( i ).AllocL();
+        pairArray.AppendL( pair );
+        CleanupStack::Pop( pair );// pair is in array's responsibility now
+        }
+
+    // sort the original
+    iPSNameArray->Sort( ECmpCollated );
+    
+    // re-arrange the iPSIdArray based on order of iPSNameArray
+    iPSIdArray.Reset();
+    for( TInt i = 0;i < settingsCount;i++ )
+        {
+        for( TInt ii = 0;ii < pairArray.Count();ii++ )
+            {
+            if ( !iPSNameArray->MdcaPoint( i ).Compare(  
+                *pairArray[ii]->iName ))
+                {
+                iPSIdArray.AppendL( pairArray[ii]->iID );
+                delete pairArray[ii];
+                pairArray.Remove(ii);
+                break;// no need to go through if already found
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy( &pairArray );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::CleanServiceProviderSettingsDataL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+void CPSUIGSPluginModel::CleanServiceProviderSettingsDataL( TInt aPresenceId )
+    {
+    CSPSettings* spSettings = CSPSettings::NewLC();
+    
+    RArray<TUint> serviceIds; 
+    CleanupClosePushL( serviceIds );
+    spSettings->FindServiceIdsL( serviceIds );
+	
+    for ( TInt i( 0 ) ; i < serviceIds.Count() ; i++ )
+        {
+        CSPEntry* spEntry = CSPEntry::NewLC(); 
+        CSPProperty* property1 = CSPProperty::NewLC();
+
+        TInt err = spSettings->FindPropertyL( 
+            serviceIds[ i ],
+            ESubPropertyPresenceSettingsId,
+            *property1 );
+
+        if ( KErrNone == err )
+            {           
+            User::LeaveIfError(
+                spSettings->FindEntryL( serviceIds[ i ], *spEntry ) );
+				
+            TInt presenceId( 0 );
+            User::LeaveIfError( property1->GetValue( presenceId ) );
+			
+            if ( presenceId == aPresenceId )
+                {
+                // Delete all presence related properties from services which
+                // has this presence id (ESubPropertyPresenceSettingsId).                  
+                RPropertyNameArray propertyNameArray;
+                CleanupClosePushL( propertyNameArray );
+                RPropertyNameArray propertyNameArrayToBeDeleted;
+                CleanupClosePushL( propertyNameArrayToBeDeleted );
+                
+                // presence properties to be removed if found
+                propertyNameArray.Append( EPropertyPCSPluginId );
+                propertyNameArray.Append( EPropertyPresenceSubServicePluginId );
+                propertyNameArray.Append( ESubPropertyPresenceSettingsId );
+                propertyNameArray.Append( ESubPropertyPresencePreferredSNAPId );
+                propertyNameArray.Append( ESubPropertyPresencePreferredIAPId );
+                propertyNameArray.Append( ESubPropertyPresencePresentityIDFieldType );
+                propertyNameArray.Append( ESubPropertyPresenceLaunchMethod );
+                propertyNameArray.Append( ESubPropertyPresenceLaunchUid );
+                propertyNameArray.Append( ESubPropertyPresenceAddrScheme );
+                propertyNameArray.Append( ESubPropertyPresenceEnabled );
+                propertyNameArray.Append( ESubPropertyPresenceRequestPreference );
+
+                for ( TInt j( 0 ) ; j < propertyNameArray.Count() ; j++ )
+                    {
+                    CSPProperty* property2 = CSPProperty::NewLC();
+                
+                    TInt err = spSettings->FindPropertyL( 
+                        serviceIds[ i ],
+                        propertyNameArray[ j ],
+                        *property2 );
+						
+                    // if property found add to be deleted array
+                    if ( !err )
+                        {
+                        propertyNameArrayToBeDeleted.Append( 
+                            propertyNameArray[ j ] );
+                        }
+                        
+                    CleanupStack::PopAndDestroy( property2 ); 
+                    }
+                
+                spSettings->DeleteServicePropertiesL( 
+                    serviceIds[ i ], propertyNameArrayToBeDeleted );
+
+                CleanupStack::PopAndDestroy( &propertyNameArrayToBeDeleted );
+                CleanupStack::PopAndDestroy( &propertyNameArray );
+                }
+            }
+        
+        CleanupStack::PopAndDestroy( property1 );
+        CleanupStack::PopAndDestroy( spEntry );
+        }
+    
+    CleanupStack::PopAndDestroy( &serviceIds );
+    CleanupStack::PopAndDestroy( spSettings );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::MdcaCount()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+TInt CPSUIGSPluginModel::MdcaCount() const
+    {
+    return iPSNameArray->MdcaCount();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::MdcaPoint()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+TPtrC16 CPSUIGSPluginModel::MdcaPoint( TInt aIndex ) const
+    {
+    TPtr tempText = iVisibleSettingName->Des();
+    tempText.Zero();
+    tempText.Append( KColumnListSeparator );
+    tempText.Append( iPSNameArray->MdcaPoint( aIndex ));
+
+    return tempText;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::CreateSettingNameLC()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+HBufC* CPSUIGSPluginModel::CreateSettingNameLC( HBufC* aOriginalName )
+    {
+    _LIT( KPSUIGSPluginNumbering, "(%N)" );
+    const TInt KPSUIFormattingExtraLength = 6;
+    
+    // prepare
+    HBufC* settingName = aOriginalName ? 
+        aOriginalName : 
+        StringLoader::LoadL( R_QTN_PRESENCE_NAME_DEFAULT );
+
+    if ( settingName->Length() + KPSUIFormattingExtraLength > KPresSetNameMaxLength )
+        {//if there is no room for duplicate-numbering, let user take care of that when saving settings
+        CleanupStack::PushL( settingName );
+        return settingName;
+        }
+    
+    settingName = settingName->ReAlloc( 
+        settingName->Length() + KPSUIFormattingExtraLength );// enough for formatting
+    CleanupStack::PushL( settingName );
+    HBufC* tempSetName = NULL;
+    TInt pos = 0;// used as dummy
+    TInt found = 0;
+    TInt index = 1;
+    TPtr ptr = settingName->Des();
+    
+    // do the actual checking of name
+    found = iPSNameArray->Find( *settingName, pos );
+    while ( found == 0 )
+        {
+        if ( !tempSetName )
+            {
+            if ( aOriginalName )
+                {// aOriginalName given
+                tempSetName = GetPrefixL( settingName );
+                tempSetName = tempSetName->ReAlloc( 
+                    tempSetName->Length() + KPSUIFormattingExtraLength );// enough for formatting
+                CleanupStack::PushL( tempSetName );
+                tempSetName->Des().Append( KPSUIGSPluginNumbering );
+                }
+            else
+                {// aOriginalName not given
+                tempSetName = StringLoader::LoadLC( R_QTN_PRESENCE_NAME_DEFAULT_NUMBER );
+                }
+            }
+        StringLoader::Format( ptr, *tempSetName, -1, index );
+        found = iPSNameArray->Find( *settingName, pos );
+        index++;
+        }
+
+    // cleanup
+    if ( tempSetName )
+        {
+        CleanupStack::PopAndDestroy( tempSetName ); //tempSetName
+        }
+
+    return settingName;    
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::GetPrefixL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+HBufC* CPSUIGSPluginModel::GetPrefixL( HBufC* aName )
+    {
+    TPtrC prefix = aName->Des();
+    TInt lastBrace = aName->LocateReverse('(');
+    if ( lastBrace != KErrNotFound )
+        {
+        // aName looks like "<prefix><brace><something>".
+        // See if <something> is an integer number and
+        // <something> ends to a brace.
+        TPtrC num = aName->Right( aName->Length() - lastBrace - 1 );
+        TInt val;
+        TLex lex( num );
+        if ( lex.Val( val ) == KErrNone && num.Locate(')') == num.Length() - 1 )
+            {
+            // Yes, the trailer is an integer.
+            prefix.Set( aName->Left( lastBrace ) );
+            }
+        }
+    return prefix.AllocL();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::CurrentSettingName()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+HBufC* CPSUIGSPluginModel::SettingNameLC( TInt aIndex )
+    {
+    return iPSNameArray->MdcaPoint( aIndex ).AllocLC();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::SettingNames()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+CDesCArray* CPSUIGSPluginModel::SettingNames()
+    {
+    return iPSNameArray;// ownership stays in CPSUIGSPluginModel
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::SettingsSet()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+TPresSettingsSet& CPSUIGSPluginModel::SettingsSet()
+    {
+    return iSettingSet;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::ClearInvalidSIPAndXDMSettingsL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+void CPSUIGSPluginModel::ClearInvalidSIPAndXDMSettingsL()
+    {
+    // SIP
+    ReadSipArrayFromEngineL();
+    if ( iSettingSet.iSipProfile != KErrNotFound && 
+        KErrNotFound == SipProfileIndex( iSettingSet.iSipProfile ))
+        {
+        iSettingSet.iSipProfile = KErrNotFound;
+        }
+    // XDM
+    XdmCollectionNamesL();
+    if ( iSettingSet.iXDMSetting != KErrNotFound && 
+        KErrNotFound == XdmSettingIndex( iSettingSet.iXDMSetting ))
+        {
+        iSettingSet.iXDMSetting = KErrNotFound;
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::SettingsId()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+TInt& CPSUIGSPluginModel::SettingsId()
+    {
+    return iSettingId;
+    }    
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::SettingsIDArray()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+RArray<TInt>& CPSUIGSPluginModel::SettingsIDArray()
+    {
+    return iPSIdArray;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::SipProfilesLC()
+// See header for details.
+// ---------------------------------------------------------------------------
+//   
+CDesCArray* CPSUIGSPluginModel::SipProfilesLC()
+    {
+    ReadSipArrayFromEngineL();
+    CDesCArray* array = new ( ELeave ) CDesCArrayFlat( 2 );
+    CleanupStack::PushL( array );
+    const TInt arrayCount = iSIPProfiles->Count();
+    for ( TInt i = 0; i < arrayCount; i++ )
+        {
+        const TDesC8* profileName;
+        iSIPProfiles->At( i )->GetParameter( KSIPProviderName, profileName );
+        HBufC* profileName16 = 
+            EscapeUtils::ConvertToUnicodeFromUtf8L( *profileName );
+        CleanupStack::PushL( profileName16 );
+        array->AppendL( profileName16->Des() );
+        CleanupStack::PopAndDestroy( profileName16 );// profileName16
+        }
+    return array;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::SipProfileId()
+// See header for details.
+// ---------------------------------------------------------------------------
+//   
+TInt CPSUIGSPluginModel::SipProfileId( TInt aIndex )
+    {
+    __ASSERT_DEBUG( iSIPProfiles, User::Panic( KPSUIGSPluginPanicCategory, KErrNotFound ));
+
+    TUint32 id = 0;
+    if ( aIndex < iSIPProfiles->Count())
+        {        
+        iSIPProfiles->At( aIndex )->GetParameter( KSIPProfileId, id );
+        }
+
+    __ASSERT_DEBUG( id < KMaxTInt ,User::Panic( KPSUIGSPluginPanicCategory, KErrOverflow ));
+    return id ? TInt( id ) : KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::SipProfileIndex()
+// See header for details.
+// ---------------------------------------------------------------------------
+//   
+TInt CPSUIGSPluginModel::SipProfileIndex( TInt aId )
+    {
+    __ASSERT_DEBUG( iSIPProfiles, User::Panic( KPSUIGSPluginPanicCategory, KErrNotFound ));    
+    const TInt arrayCount = iSIPProfiles->Count();
+    TUint32 idValue = aId;
+    for ( TInt i = 0; i < arrayCount; i++ )
+        {
+        TUint32 tempValue;
+        iSIPProfiles->At( i )->GetParameter( KSIPProfileId, tempValue );
+        if ( tempValue == idValue )
+            {
+            return i;
+            }
+        }
+    return KErrNotFound;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::SipProfileNameL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//   
+HBufC* CPSUIGSPluginModel::SipProfileNameL( TInt aId )
+    {
+    const TInt arrayCount = iSIPProfiles->Count();
+    TUint32 idValue = aId;
+    for ( TInt i = 0; i < arrayCount; i++ )
+        {
+        TUint32 tempValue;
+        iSIPProfiles->At( i )->GetParameter( KSIPProfileId, tempValue );
+        if ( tempValue == idValue )
+            {
+            const TDesC8* profileName;
+            iSIPProfiles->At( i )->GetParameter( KSIPProviderName, profileName );
+            return EscapeUtils::ConvertToUnicodeFromUtf8L( *profileName );// name found
+            }
+        }
+    return HBufC::NewL( 0 );// name not found
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::IsSipProfileRegisteredL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+TBool CPSUIGSPluginModel::IsSipProfileRegisteredL( TInt aIndex )
+    {
+    TBool registered( EFalse );  
+    TInt sipProfileId = SipProfileId( aIndex );
+    const TInt arrayCount = iSIPProfiles->Count();
+	
+    for ( TInt i = 0; i < arrayCount; i++ )
+        {
+        TUint32 tempValue;
+        iSIPProfiles->At( i )->GetParameter( KSIPProfileId, tempValue );
+		
+        if ( tempValue == sipProfileId )
+            {
+            iSIPProfiles->At( i )->GetParameter( 
+                KSIPProfileRegistered, registered );
+            }
+        }
+		
+    return registered;
+    }
+ 
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::ReadSipArrayFromEngineL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//       
+void CPSUIGSPluginModel::ReadSipArrayFromEngineL()
+    {
+    RArray<TSIPProfileTypeInfo> array;
+    CleanupClosePushL( array );
+    
+    if ( !iSIPEngine )
+        {
+        iSIPEngine = CSIPManagedProfileRegistry::NewL( *this );
+        }
+    
+    // Get the supported profile types
+    iSIPEngine->SupportedProfileTypesL( array );
+    
+    // check iSIPProfiles, if exists delete
+    if ( iSIPProfiles )
+        {
+        iSIPProfiles->ResetAndDestroy();
+        delete iSIPProfiles;
+        }
+
+    // Create the profile pointer array
+    iSIPProfiles = 
+        new ( ELeave ) CArrayPtrFlat<CSIPManagedProfile>( 2 );
+
+    RPointerArray<CSIPProfile> profilePointerArray;
+    TCleanupItem clItem( ResetAndDestroy, &profilePointerArray );
+    CleanupStack::PushL( clItem );
+    
+    // Get all profiles based on profile types
+    const TInt arrayCount = array.Count();
+    for ( TInt i = 0; i < arrayCount; i++ )
+        {        
+        iSIPEngine->ProfilesL( array[i], profilePointerArray );
+        while ( profilePointerArray.Count() > 0 )
+            {
+            CSIPManagedProfile* profile = 
+                static_cast<CSIPManagedProfile*>( profilePointerArray[ 0 ]);
+            iSIPProfiles->AppendL( profile );
+            profilePointerArray.Remove( 0 ); 
+            }                    
+        profilePointerArray.Reset();    
+        }
+
+    CleanupStack::PopAndDestroy( 2, &array ); // array
+    }    
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::ResetAndDestroy()
+// See header for details.
+// ---------------------------------------------------------------------------
+//   
+void CPSUIGSPluginModel::ResetAndDestroy( 
+    TAny* aPointerArray )
+    {
+    RPointerArray<CSIPProfile>* array =
+        static_cast<RPointerArray<CSIPProfile>*>( aPointerArray );
+    array->ResetAndDestroy();
+    array->Close();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::ProfileRegistryEventOccurred()
+// See header for details.
+// ---------------------------------------------------------------------------
+//   
+void CPSUIGSPluginModel::ProfileRegistryEventOccurred( 
+    TUint32 /*aSIPProfileId*/, TEvent aEvent )
+    {
+    switch( aEvent )    
+        {
+        case EProfileCreated:
+        case EProfileUpdated:   
+        case EProfileDestroyed:
+            // update sip profile array
+            TRAP_IGNORE( ReadSipArrayFromEngineL() );
+            break;
+        default:
+            // do nothing.
+            break;
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::ProfileRegistryErrorOccurred()
+// See header for details.
+// ---------------------------------------------------------------------------
+//       
+void CPSUIGSPluginModel::ProfileRegistryErrorOccurred(                  
+    TUint32 /*aSIPProfileId*/,
+    TInt /*aError*/ )
+    {        
+    // update sip profile array
+    TRAP_IGNORE( ReadSipArrayFromEngineL() );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::XdmCollectionNamesL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//  
+CDesCArray* CPSUIGSPluginModel::XdmCollectionNamesL()
+    {
+    delete iXdmNameArray;
+    iXdmNameArray = NULL;
+    iXdmIdArray.Reset();
+    
+    iXdmNameArray = TXdmSettingsApi::CollectionNamesLC( iXdmIdArray );
+    CleanupStack::Pop( iXdmNameArray );// iXdmNameArray
+    return iXdmNameArray;// pointer is given, but ownership stays here
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::XdmCollectionNameL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//  
+HBufC* CPSUIGSPluginModel::XdmCollectionNameL( TInt aId )
+    {
+    HBufC* buf = NULL;
+    TRAPD( err, buf = TXdmSettingsApi::PropertyL( aId, EXdmPropName ));
+    return ( err == KErrNone ) ? buf : HBufC::NewL( 0 );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::XdmSettingIndex()
+// See header for details.
+// ---------------------------------------------------------------------------
+//  
+TInt CPSUIGSPluginModel::XdmSettingIndex( TInt aId )
+    {
+    const TInt arrayCount = iXdmIdArray.Count();
+    for ( TInt i = 0; i < arrayCount; i++ )
+        {
+        if ( aId == iXdmIdArray[ i ] )
+            {
+            return i;
+            }
+        }    
+    return KErrNotFound;    
+    }
+    
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginModel::XdmSettingId()
+// See header for details.
+// ---------------------------------------------------------------------------
+//  
+TInt CPSUIGSPluginModel::XdmSettingId( TInt aIndex )
+    {
+    TInt id = KErrNotFound;
+    if ( aIndex+1 <= iXdmIdArray.Count())
+        {        
+        id = iXdmIdArray[ aIndex ];
+        }
+    return id;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/src/psuigspluginsettingview.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,319 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Presence Settings UI setting view implementation.
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <bautils.h>
+#include <psuigspluginrsc.rsg>
+#include <StringLoader.h>
+#include <AknQueryDialog.h>
+#include <aknnotewrappers.h>
+#include <aknViewAppUi.h>
+#include <featmgr.h>
+#include <hlplch.h>
+#include "psuigsplugin.h"
+#include "psuigspluginsettingview.h"
+#include "psuigspluginmodel.h"
+#include "psuigspluginsettingviewcontainer.h"
+
+// CONSTANTS
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::CPSUIGSPluginSettingView()
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPluginSettingView::CPSUIGSPluginSettingView( CPSUIGSPlugin* aMainView )
+    : iMainView ( aMainView )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::~CPSUIGSPluginSettingView()
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPluginSettingView::~CPSUIGSPluginSettingView()
+    {
+    // iAppUi, iMainView deleted elsewhere
+    if ( iPSUIContainer && iAppUi )
+        {
+        iAppUi->RemoveFromViewStack( *this, iPSUIContainer );
+        delete iPSUIContainer;
+        iPSUIContainer = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::ConstructL
+// Symbian 2nd phase constructor can leave.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginSettingView::ConstructL()
+    {
+    // base construct
+    BaseConstructL( R_PSUI_SETTING_VIEW );
+    iAppUi = AppUi();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::NewL()
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPluginSettingView* CPSUIGSPluginSettingView::NewL( CPSUIGSPlugin* aMainView )
+    {
+    CPSUIGSPluginSettingView* self = new( ELeave ) CPSUIGSPluginSettingView( aMainView );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::Id()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+TUid CPSUIGSPluginSettingView::Id() const
+    {
+    return KPreSettingViewId;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::HandleViewRectChange()
+// See header for details.
+// ---------------------------------------------------------------------------
+//  
+void CPSUIGSPluginSettingView::HandleViewRectChange()
+    {
+    if ( iPSUIContainer && iPSUIContainer->ListBox() )
+        {
+        iPSUIContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::DoActivateL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//  
+void CPSUIGSPluginSettingView::DoActivateL( const TVwsViewId& aPrevViewId,
+                                  TUid /*aCustomMessageId*/,
+                                  const TDesC8& /*aCustomMessage*/ )
+    {
+    iPrevViewId = aPrevViewId;
+
+    CreateContainerL();
+    iAppUi->AddToViewStackL( *this, iPSUIContainer );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::DoDeactivate()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginSettingView::DoDeactivate()
+    {
+    if ( iPSUIContainer )
+        {
+        iAppUi->RemoveFromViewStack( *this, iPSUIContainer );
+        delete iPSUIContainer;
+        iPSUIContainer = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::HandleCommandL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginSettingView::HandleCommandL( TInt aCommand )
+    {
+    switch ( aCommand )
+        {
+        case EAknSoftkeyBack:
+            {
+            HandleBackKeyL();
+            break;
+            }
+        case EPSUICmdChange:
+            {
+            iPSUIContainer->EditCurrentItemL();
+            break;
+            }
+        case EAknCmdHelp:
+            {
+            if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
+                {
+                HlpLauncher::LaunchHelpApplicationL(
+                    iEikonEnv->WsSession(), iAppUi->AppHelpContextL() );
+                }
+            break;
+            }              
+        default:
+            {
+            if ( EEikCmdExit == aCommand )
+                {
+                HandleMenuExitL();
+                }            
+            
+            iAppUi->HandleCommandL( aCommand );
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::CreateContainerL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginSettingView::CreateContainerL()
+    {
+    // delete container if present
+    if( iPSUIContainer )
+        {
+        iAppUi->RemoveFromViewStack( *this, iPSUIContainer );
+        delete iPSUIContainer;
+        iPSUIContainer = NULL;
+        }
+    
+    // check the data    
+    iMainView->PSModel()->ClearInvalidSIPAndXDMSettingsL();  
+    
+    // create container
+    iPSUIContainer = new ( ELeave ) CPSUIGSPluginSettingViewContainer( this );
+    iPSUIContainer->SetMopParent( this );
+    iPSUIContainer->ConstructL( ClientRect() );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::HandleBackKeyL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//    
+void CPSUIGSPluginSettingView::HandleBackKeyL()
+    {
+    CPSUIGSPluginModel* psModel = iMainView->PSModel();// not owned
+    
+    TBool okToGoBack = ETrue;
+    TBool okToSave = ETrue;
+    psModel->ClearInvalidSIPAndXDMSettingsL();
+    const TInt id = psModel->SettingsId();
+    
+    // compulsory-field handling
+    if ( !psModel->AllCompulsoryFieldsFilled())
+        {// empty compulsory fields found
+        okToSave = EFalse;
+        HBufC* string = StringLoader::LoadLC( 
+            R_QTN_PRESENCE_SETTINGS_NOT_FILLED );
+        CAknQueryDialog* query = CAknQueryDialog::NewL( 
+            CAknQueryDialog::EConfirmationTone );        
+        if ( !query->ExecuteLD( R_PSUI_CONF_QUERY,  *string ))
+            {
+            okToGoBack = EFalse;
+            }
+        CleanupStack::PopAndDestroy( string );// string         
+        }
+        
+    // same name checking        
+    if ( okToSave && HandleDuplicatePSNamesL() )
+        {// same name found
+        okToGoBack = EFalse;
+        okToSave = EFalse;
+        iPSUIContainer->EditItemL( EPSUIServerNameId, ETrue );
+        }
+     
+    if ( okToSave )
+        {// save settings
+        psModel->SaveSettingsL();
+        }
+    else if ( !okToSave && okToGoBack && id )
+        {// old settings, delete and go back
+        psModel->DeleteSettingsL( id, EFalse );
+        }
+    if ( okToGoBack )
+        {// go back, no save or delete
+        iAppUi->ActivateLocalViewL( iPrevViewId.iViewUid );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::HandleMenuExitL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//  
+void CPSUIGSPluginSettingView::HandleMenuExitL()
+    {
+    CPSUIGSPluginModel* psModel = iMainView->PSModel();// not owned
+    if ( !psModel )
+        {// no model, can't do anything
+        // (leaving would stop exiting, so just return)
+        return;
+        }
+    
+    if ( psModel->AllCompulsoryFieldsFilled() )
+        {// needed fields filled, proceed saving
+        if ( psModel->IsItDuplicatePSName() )
+            {// a dupe name -> change name
+            HBufC* newName = psModel->CreateSettingNameLC( 
+                psModel->SettingsSet().iSetName.AllocL() );
+            psModel->SettingsSet().iSetName.Copy( newName->Des() );
+            CleanupStack::PopAndDestroy( newName );            
+            }
+        // save settings
+        psModel->SaveSettingsL();            
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::HandleDuplicatePSNamesL()
+// See header for details.
+// ---------------------------------------------------------------------------
+// 
+TBool CPSUIGSPluginSettingView::HandleDuplicatePSNamesL()
+    {
+    TBool found = iMainView->PSModel()->IsItDuplicatePSName();
+    if ( found )
+        {
+        HBufC* fullText = StringLoader::LoadLC( 
+            R_QTN_PRESENCE_SETTINGS_NAME_EXISTS, 
+            iMainView->PSModel()->SettingsSet().iSetName );
+        CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue ); //wait-flag on
+        note->ExecuteLD( *fullText );
+        CleanupStack::PopAndDestroy( fullText );
+        }
+    return found;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingView::MainView()
+// See header for details.
+// ---------------------------------------------------------------------------
+//    
+CPSUIGSPlugin* CPSUIGSPluginSettingView::MainView()
+    {
+    return iMainView;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/src/psuigspluginsettingviewcontainer.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,221 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Presence Settings UI view container implementation
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <psuigspluginrsc.rsg>
+#include <aknlists.h>
+#include <aknnavi.h>
+#include <akntitle.h>
+#include <AknUtils.h>
+#include "psuigspluginsettingviewcontainer.h"
+#include "psuigspluginsettingview.h"
+#include "psuigspluginmodel.h"
+#include "psuisipxdmsettingitem.h"
+#include "psuiintegersettingitem.h"
+#include "psuigsplugin.h"
+#include "psuigspluginids.hrh"
+#include <csxhelp/pre.hlp.hrh>
+#include <akntextsettingpage.h>
+
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingViewContainer::CPSUIGSPluginSettingViewContainer()
+// Default constructor.
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPluginSettingViewContainer::CPSUIGSPluginSettingViewContainer( 
+    CPSUIGSPluginSettingView* aView )
+    : iView ( aView )
+    {
+    }
+    
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingViewContainer::ConstructL(const TRect& aRect)
+// Symbian OS phase 2 constructor
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginSettingViewContainer::ConstructL( const TRect& aRect )
+    {
+    UpdateTitleL();
+    CreateWindowL();
+    ConstructFromResourceL( R_PSUI_SETTING_ITEMS );
+    SetRect( aRect );
+    ActivateL();
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingViewContainer::~CPSUIGSPluginSettingViewContainer()
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CPSUIGSPluginSettingViewContainer::~CPSUIGSPluginSettingViewContainer()
+    {
+    // iView is deleted elsewhere
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingViewContainer::CreateSettingItemL()
+// See header for details. 
+// ---------------------------------------------------------------------------
+//
+CAknSettingItem* CPSUIGSPluginSettingViewContainer::CreateSettingItemL( 
+    TInt aSettingId )
+    {
+    CAknSettingItem* settingItem = NULL;
+    TPresSettingsSet& settingSet = iView->MainView()->PSModel()->SettingsSet();
+
+    switch ( aSettingId )
+        {
+        case EPSUIServerNameId:
+            settingItem = new (ELeave) CAknTextSettingItem( 
+                aSettingId, settingSet.iSetName );
+            break;
+        case EPSUISIPProfileId:
+            settingItem = new (ELeave) CPSUISipXdmSettingItem( 
+                aSettingId, settingSet.iSipProfile, iView->MainView()->PSModel() );
+            break;
+        case EPSUIXDMSettingsId:
+            settingItem = new (ELeave) CPSUISipXdmSettingItem( 
+                aSettingId, settingSet.iXDMSetting, iView->MainView()->PSModel() );
+            break;
+        case EPSUIObjectSizeId:
+            settingItem = new (ELeave) CPSUIIntegerSettingItem( 
+                aSettingId, settingSet.iObjectSize );
+            break;
+/* server address disabled             
+        case EPSUIServerAddrId:
+            settingItem = new (ELeave) CAknTextSettingItem( 
+                aSettingId, settingSet.iContSrvrAdd );
+            break;*/
+        case EPSUIPublishingIntervalId:
+            settingItem = new (ELeave) CPSUIIntegerSettingItem(
+                aSettingId, settingSet.iPublicationInt );
+            break;
+        case EPSUIMaxSubscriptionsId:
+            settingItem = new (ELeave) CPSUIIntegerSettingItem(
+                aSettingId, settingSet.iMaxSubscriptions );
+            settingItem->SetSettingPageFlags(
+                    CAknIntegerSettingPage::EEmptyValueAllowed);// Empty input allowed      
+            break;
+        case EPSUIMaxContactsInListId:
+            settingItem = new (ELeave) CPSUIIntegerSettingItem( 
+                aSettingId, settingSet.iMaxContactsInList );
+            settingItem->SetSettingPageFlags(
+                    CAknIntegerSettingPage::EEmptyValueAllowed);// Empty input allowed      
+            break;
+        case EPSUIDomainSyntaxId:
+            settingItem = new (ELeave) CAknTextSettingItem( 
+                aSettingId, settingSet.iDomainSyntax );
+            break;            
+        default:
+            __ASSERT_DEBUG( 0, User::Panic( KPSUIGSPluginPanicCategory, KErrNotFound ));
+            break;
+        }
+
+    return settingItem;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingViewContainer::EditItemL()
+// See header for details. 
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginSettingViewContainer::EditItemL( 
+    TInt aIndex, TBool aCalledFromMenu )
+    {
+    CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
+
+    // update setting to setting-object
+    (*SettingItemArray())[aIndex]->StoreL();
+    (*SettingItemArray())[aIndex]->UpdateListBoxTextL();
+    ListBox()->DrawNow();
+    
+    if ( EPSUIServerNameId == aIndex )
+        {
+        UpdateTitleL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingViewContainer::EditCurrentItemL()
+// See header for details. 
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginSettingViewContainer::EditCurrentItemL()
+    {
+    EditItemL( ListBox()->CurrentItemIndex(), ETrue );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIGSPluginSettingViewContainer::UpdateTitleL()
+// See header for details. 
+// ---------------------------------------------------------------------------
+//
+void CPSUIGSPluginSettingViewContainer::UpdateTitleL()
+    {
+    // title construction
+    static_cast<CAknTitlePane*>( 
+        iAvkonAppUi->StatusPane()->ControlL( TUid::Uid( 
+        EEikStatusPaneUidTitle )))->SetTextL( 
+        iView->MainView()->PSModel()->SettingsSet().iSetName );
+    }
+    
+// -----------------------------------------------------------------------------
+// CPSUIGSPluginSettingViewContainer::GetHelpContext()
+// See header for details.
+// -----------------------------------------------------------------------------
+//
+void CPSUIGSPluginSettingViewContainer::GetHelpContext( TCoeHelpContext& aContext ) const
+    {
+    aContext.iMajor = TUid::Uid( PSUIGSPluginDllUid );
+    aContext.iContext = KPRE_HLP_EDIT_SET;
+    }
+
+// -----------------------------------------------------------------------------
+// CPSUIGSPluginSettingViewContainer::HandleResourceChange()
+// See header for details.
+// -----------------------------------------------------------------------------
+//    
+void CPSUIGSPluginSettingViewContainer::HandleResourceChange(TInt aType)
+    {
+    CAknSettingItemList::HandleResourceChange( aType );
+	if ( aType == KAknsMessageSkinChange ||
+         aType == KEikDynamicLayoutVariantSwitch )
+        {
+        TRect mainPaneRect;
+        AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
+                                           mainPaneRect);
+        SetRect( mainPaneRect );
+        }        
+    }
+
+// -----------------------------------------------------------------------------
+// CPSUIGSPluginSettingViewContainer::SizeChanged()
+// See header for details.
+// -----------------------------------------------------------------------------
+//   
+void CPSUIGSPluginSettingViewContainer::SizeChanged()
+    {
+    ListBox()->SetRect( Rect() );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/src/psuiintegersettingitem.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Setting item for integer settings
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <aknradiobuttonsettingpage.h>
+#include <akntextsettingpage.h>
+#include "psuigspluginmodel.h"
+#include "psuiintegersettingitem.h"
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CPSUIIntegerSettingItem::CPSUIIntegerSettingItem()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+CPSUIIntegerSettingItem::CPSUIIntegerSettingItem( TInt aIdentifier, TInt& aValue )
+    : CAknIntegerEdwinSettingItem ( aIdentifier, aValue ), 
+    iPSUIInternalTextPtr( 0,0 )
+    {
+    }
+    
+// ---------------------------------------------------------------------------
+// CPSUIIntegerSettingItem::~CPSUIIntegerSettingItem()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+CPSUIIntegerSettingItem::~CPSUIIntegerSettingItem()
+    {
+    delete iPSUIInternalText;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIIntegerSettingItem::CompleteConstructionL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//        
+void CPSUIIntegerSettingItem::CompleteConstructionL()
+    {
+    const TInt KPSUIMaxIntegerDigits = 2 * EAknMaxIntegerDigits;// a bit longer for storing also empty texts
+    iPSUIInternalText = HBufC::NewMaxL( KPSUIMaxIntegerDigits );
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUIIntegerSettingItem::SettingTextL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//    
+const TDesC& CPSUIIntegerSettingItem::SettingTextL()
+    {
+    _LIT( KAknIntegerFormat, "%d" );
+    iPSUIInternalTextPtr.Set( iPSUIInternalText->Des() );
+    TInt& intValueRef = InternalValueRef();
+    if ( intValueRef == KErrNotFound )
+        {
+        iPSUIInternalTextPtr.Zero();
+        iPSUIInternalTextPtr.Append( EmptyItemText() );
+        iPSUIInternalTextPtr.Append( KColumnListSeparator );
+        }
+    else
+        {
+        iPSUIInternalTextPtr.Format( KAknIntegerFormat, intValueRef );
+        AknTextUtils::DisplayTextLanguageSpecificNumberConversion(
+            iPSUIInternalTextPtr );
+        }
+
+    return iPSUIInternalTextPtr;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/presencesettingsui/src/psuisipxdmsettingitem.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,193 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:    Setting item for SIP / XDM settings
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <psuigspluginrsc.rsg>
+#include <aknradiobuttonsettingpage.h>
+#include <akntextsettingpage.h>
+#include "psuigspluginmodel.h"
+#include "psuisipxdmsettingitem.h"
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CPSUISipXdmSettingItem::CPSUISipXdmSettingItem()
+// Default constructor.
+// ---------------------------------------------------------------------------
+//
+CPSUISipXdmSettingItem::CPSUISipXdmSettingItem( 
+    TInt aIdentifier, TInt& aId, CPSUIGSPluginModel* aPSModel ): 
+        CAknSettingItem( aIdentifier ),
+        iExtChosenSettingID ( aId ),
+        iPSModel ( aPSModel )
+    {
+    }        
+
+// ---------------------------------------------------------------------------
+// CPSUISipXdmSettingItem::~CPSUISipXdmSettingItem()
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CPSUISipXdmSettingItem::~CPSUISipXdmSettingItem()
+    {
+    // iPSModel deleted elsewhere
+    delete iPSUIInternalText;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUISipXdmSettingItem::LoadL()
+// See header for details. 
+// ---------------------------------------------------------------------------
+//    
+void CPSUISipXdmSettingItem::LoadL()
+    {
+    delete iPSUIInternalText;
+    iPSUIInternalText = 0;
+    
+    TInt id = Identifier();
+    if ( id == EPSUISIPProfileId )
+        {// SIP
+        iPSUIInternalText = iPSModel->SipProfileNameL( iExtChosenSettingID );
+        }
+    else if ( id ==  EPSUIXDMSettingsId )
+        {// XDM
+        iPSUIInternalText = iPSModel->XdmCollectionNameL( iExtChosenSettingID );
+        }
+    else
+        {
+        __ASSERT_DEBUG( 0,User::Panic( KPSUIGSPluginPanicCategory, KErrNotFound ));
+        }        
+
+    iIntChosenSettingID = iExtChosenSettingID;
+    }    
+
+// ---------------------------------------------------------------------------
+// CPSUISipXdmSettingItem::StoreL()
+// See header for details. 
+// ---------------------------------------------------------------------------
+// 
+void CPSUISipXdmSettingItem::StoreL()
+    {
+    iExtChosenSettingID = iIntChosenSettingID;
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUISipXdmSettingItem::SettingTextL()
+// See header for details. 
+// ---------------------------------------------------------------------------
+// 
+const TDesC& CPSUISipXdmSettingItem::SettingTextL()
+    {
+    if ( iPSUIInternalText->Length() > 0 )
+        return *iPSUIInternalText;
+    else
+        return EmptyItemText();
+    }    
+
+// ---------------------------------------------------------------------------
+// CPSUISipXdmSettingItem::EditItemL()
+// See header for details. 
+// ---------------------------------------------------------------------------
+//     
+void CPSUISipXdmSettingItem::EditItemL( TBool /*aCalledFromMenu*/ )
+    {
+    TInt id = Identifier();
+    if ( id == EPSUISIPProfileId )
+        {// SIP
+        EditSipItemL();
+        }
+    else if ( id ==  EPSUIXDMSettingsId )
+        {// XDM
+        EditXdmItemL();
+        }
+    else
+        {
+        __ASSERT_DEBUG( 0,User::Panic( KPSUIGSPluginPanicCategory, KErrNotFound ));
+        }
+    }    
+
+// ---------------------------------------------------------------------------
+// CPSUISipXdmSettingItem::EditSipItemL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//  
+void CPSUISipXdmSettingItem::EditSipItemL()
+    {
+    CDesCArray* array = iPSModel->SipProfilesLC();
+    TInt index = iPSModel->SipProfileIndex( iIntChosenSettingID );
+    LaunchSettingDlgL( index, array );
+    CleanupStack::PopAndDestroy( array );  // array
+    
+    if ( index != KErrNotFound )
+        {// update only if index available
+        iIntChosenSettingID = iPSModel->SipProfileId( index );
+
+        delete iPSUIInternalText;
+        iPSUIInternalText = 0;
+        iPSUIInternalText = iPSModel->SipProfileNameL( iIntChosenSettingID );
+        
+        UpdateListBoxTextL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPSUISipXdmSettingItem::EditXdmItemL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//  
+void CPSUISipXdmSettingItem::EditXdmItemL()
+    {
+    CDesCArray* array = iPSModel->XdmCollectionNamesL();// array not owned
+    TInt index = iPSModel->XdmSettingIndex( iIntChosenSettingID );
+    LaunchSettingDlgL( index, array );
+
+    if ( index != KErrNotFound )
+        {// update only if index available
+        iIntChosenSettingID = iPSModel->XdmSettingId( index );
+
+        delete iPSUIInternalText;
+        iPSUIInternalText = 0;
+        iPSUIInternalText = iPSModel->XdmCollectionNameL( iIntChosenSettingID );
+        
+        UpdateListBoxTextL();
+        }
+    } 
+
+// ---------------------------------------------------------------------------
+// CPSUISipXdmSettingItem::LaunchSettingDlgL()
+// See header for details.
+// ---------------------------------------------------------------------------
+//
+void CPSUISipXdmSettingItem::LaunchSettingDlgL( TInt& aIndex, CDesCArray* aArray )
+    {
+    CAknRadioButtonSettingPage* dlg = new (ELeave ) CAknRadioButtonSettingPage(
+        R_RADIOBUTTON_SETTING_PAGE, 
+        aIndex, 
+        aArray );
+    CleanupStack::PushL( dlg );
+    dlg->SetSettingTextL( SettingName() );
+    SetSettingPage( dlg );
+    SettingPage()->SetSettingPageObserver( this );
+    CleanupStack::Pop( dlg );  // dlg
+    SettingPage()->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted );
+    SetSettingPage( 0 ); // dlg deleted
+    }
+
+// End of File
--- a/pressrv_plat/registration_api/inc/simplefactory.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/pressrv_plat/registration_api/inc/simplefactory.h	Wed Sep 01 12:23:14 2010 +0100
@@ -162,6 +162,15 @@
     IMPORT_C static MSimpleContent* NewContentL( 
         const TDesC8& aContentID, const TDesC8& aContentType );    
 
+    /**
+     * Create new simple engine Connection entity.
+     * @since S60 3.2
+     * @param aObserver client callback observer
+     * @param aServiceId serviceId of current service
+     * @return MSimpleConnection, ownership is transferred.
+     */
+    IMPORT_C static MSimpleConnection* NewConnectionL(
+        MSimpleConnectionObserver& aObserver, TInt32 aServiceId );
     };
 
 #endif
--- a/pressrv_plat/simple_documents_api/inc/msimplecontent.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/pressrv_plat/simple_documents_api/inc/msimplecontent.h	Wed Sep 01 12:23:14 2010 +0100
@@ -22,7 +22,7 @@
 #define M_simplecontent_H
 
 #include <e32std.h>
-// #include <S32strm.h>
+// #include <s32strm.h>
 
 // FORWARD DECLARATION
 
--- a/pressrv_plat/xdm_api/inc/XdmDocument.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/pressrv_plat/xdm_api/inc/XdmDocument.h	Wed Sep 01 12:23:14 2010 +0100
@@ -40,7 +40,9 @@
     EXdmIetfCommonPolicy,
     EXdmOmaCommonPolicy,
     EXdmIetfPresenceRules,
-    EXdmOmaPresenceRules
+    EXdmOmaPresenceRules,
+    EXdmPresContent,
+    EXdmPresContentNSN
     };
 
 //Helper class for searching documents; 16-bit 
--- a/pressrv_plat/xdm_api/inc/XdmProtocolUidList.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/pressrv_plat/xdm_api/inc/XdmProtocolUidList.h	Wed Sep 01 12:23:14 2010 +0100
@@ -43,6 +43,8 @@
 const TInt KXdmOmaCommonPolicyUsageUid    = 0x10275082;
 const TInt KXdmIetfPresRulesUsageUid      = 0x10275083;
 const TInt KXdmOmaPresRulesUsageUid       = 0x102750AB;
+const TInt KXdmUsageUid                   = 0x20028701;
+const TInt KXdmNSNUsageUid                = 0x20028702;
 
 #endif      //__XDMPROTOCOLUIDLIST__
             
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/group/10275464.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM registery info for SIP/Presence Protocol Plugin
+*
+*/
+
+
+#include <ecom/registryinfov2.rh>
+#include <ximpprotocolpluginifids.hrh>
+
+#include "presenceplugin_resource.hrh"
+
+
+
+// ---------------------------------------------------------------------------
+// ECOM registery info for Presence Framework ECOM hook
+// ---------------------------------------------------------------------------
+//
+RESOURCE REGISTRY_INFO theInfo
+    {
+    resource_format_version = RESOURCE_FORMAT_VERSION_2;
+    dll_uid = PRESENCEPLUGIN_DLL_UID_PRESENCE_PROTOCOL;
+
+    interfaces =
+        {
+        INTERFACE_INFO
+            {
+            // implemented interface
+            interface_uid = XIMP_ECOM_IF_UID_PROTOCOL_PLUGIN_BASE_INTERFACE;
+
+            implementations =
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = PRESENCEPLUGIN_1_IMPLEMENTATION_UID;
+                    version_no         = PRESENCEPLUGIN_1_VERSION_NO;
+                    display_name       = PRESENCEPLUGIN_1_DISPLAY_NAME;
+                    default_data       = PRESENCEPLUGIN_1_DEFAULT_DATA;
+                    opaque_data        = PRESENCEPLUGIN_1_OPAQUE_DATA;
+                    }
+                };
+            }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   Build information file for SIP/Simple Protocol Plugin
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+#ifdef GC_AREA_PARTIAL_INCLUDE_CHANGE_ON
+#else
+#endif
+
+../rom/simpledatamodeladapter.iby CORE_MW_LAYER_IBY_EXPORT_PATH(simpledatamodeladapter.iby)
+
+PRJ_MMPFILES
+presenceplugin.mmp
+#include "../simpleimplugin/group/bld.inf"
+
+PRJ_TESTMMPFILES
+//../internal/tsrc/group/T_SIMPLEDataModelAdapter.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/group/presenceplugin.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2006-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:   Project definition file for SIP/Simple Protocol Plugin
+*
+*/
+
+
+// To get the APP_LAYER_SYSTEMINCLUDE-definition
+#include <platform_paths.hrh>
+#include "presenceplugin_resource.hrh"
+
+TARGET          presenceplugin.dll
+TARGETTYPE      plugin
+
+UID             PRESENCEPLUGIN_DLL_UID_ECOM_PLUGIN PRESENCEPLUGIN_DLL_UID_PRESENCE_PROTOCOL
+VENDORID        VID_DEFAULT
+CAPABILITY      CAP_ECOM_PLUGIN
+
+// RESOURCE
+START RESOURCE  10275464.rss
+TARGET          presenceplugin
+TARGETPATH      resource/plugins
+END
+
+SOURCEPATH      ../src
+SOURCE          presenceplugin.cpp
+SOURCE          presencepluginconnection.cpp
+SOURCE          presencepluginsession.cpp
+SOURCE          presencepluginwinfo.cpp
+SOURCE          presencepluginwatcher.cpp
+SOURCE          presencepluginauthorization.cpp
+SOURCE          presencepluginpublisher.cpp
+SOURCE          presencepluginentitywatcher.cpp
+SOURCE          presenceplugindata.cpp
+SOURCE	        presencepluginxdmutils.cpp
+SOURCE          presencepluginxdmpresrules.cpp
+SOURCE          presenceplugingroup.cpp
+SOURCE          presencepluginwatcherinfo.cpp
+SOURCE          presencepluginvirtualgroup.cpp
+SOURCE          presenceconnectioninfo.cpp
+SOURCE          presencepluginutility.cpp
+SOURCE          presenceplugincontacts.cpp
+SOURCE          presenceplugincontactstatehandler.cpp
+SOURCE          presenceplugincontactstate.cpp
+SOURCE          presenceplugincontactstateopen.cpp
+SOURCE          presenceplugincontactstateresolve.cpp
+SOURCE          presenceplugincontactstatesearch.cpp
+SOURCE          presenceplugincontactstateend.cpp
+SOURCE          presensepluginlocalstore.cpp
+
+USERINCLUDE     .
+USERINCLUDE     ../inc
+USERINCLUDE     ../simpleimplugin/inc
+
+// Default system include paths for middleware layer modules.
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+LIBRARY         euser.lib   // Base
+LIBRARY         ecom.lib
+LIBRARY         simpleengine.lib
+LIBRARY         estor.lib
+LIBRARY         bafl.lib
+LIBRARY         charconv.lib
+
+LIBRARY         xdmengine.lib
+LIBRARY         xdmsettingsapi.lib
+LIBRARY         presencesettingsapi.lib
+
+LIBRARY         efsrv.lib
+LIBRARY         edbms.lib 
+LIBRARY         avkon.lib
+
+//presence cache
+LIBRARY         presencecacheclient2.lib
+LIBRARY         presencecacheutils.lib
+
+// access to service table
+LIBRARY         serviceprovidersettings.lib
+
+// access to uiservicetabsettings
+LIBRARY         vimpstsettings.lib
+
+// access to Virtual Phonebook contact database
+LIBRARY         vpbkeng.lib
+LIBRARY     inetprotutil.lib 
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/group/presenceplugin_resource.hrh	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  resource definitions
+*
+*/
+
+#ifndef PRESENCEPLUGIN_RESOURCE_HRH
+#define PRESENCEPLUGIN_RESOURCE_HRH
+
+/**
+ * System wide UID 2:s for ECom plugin dlls.
+ */
+#define PRESENCEPLUGIN_DLL_UID_ECOM_PLUGIN			0x10009D8D
+
+/**
+ * Officially reserved UID 3 for the Presence Framework
+ * PRESENCE protocol dll.
+ */
+#define PRESENCEPLUGIN_DLL_UID_PRESENCE_PROTOCOL      0x10275464
+
+
+/**
+ * Resource file compatible defintions for ximp test protocols.
+ *
+ * This must be kept in-sync with definitions in
+ * "ximptestprotocols.h"
+ */
+
+#define PRESENCEPLUGIN_1_IMPLEMENTATION_UID      0x10282EF2
+#define PRESENCEPLUGIN_1_VERSION_NO              1
+#define PRESENCEPLUGIN_1_DISPLAY_NAME            "IETF SIMPLE PRESENCE protocol"
+#define PRESENCEPLUGIN_1_DEFAULT_DATA            "PRESENCE"
+
+// Protocol capabilities: "<tag1>value<tag2>value..."
+//
+// <p>Provider
+// <f>Feature id
+// <s>Supported schema
+//
+// Example:
+// "<p>Nokia<f>feat/pres/foo<f>feat/pres/bar<s>sip"
+//
+#define PRESENCEPLUGIN_1_OPAQUE_DATA            "<p>Nokia<f>feat/pres/pub<f>feat/pres/fetch<f>feat/pres/subs<s>sip"
+
+
+#endif // SIMPLEPLUGIN_RESOURCE_HRH
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/mpresencepluginconnectionobs.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,247 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef MPRESENCEPLUGINCONNECTIONOBS_H
+#define MPRESENCEPLUGINCONNECTIONOBS_H
+
+#include <e32std.h>
+#include <ximpbase.h>
+#include <ximpprotocolpluginhostifids.hrh>
+
+class TXIMPRequestId;
+class MXIMPObjectFactory;
+class CPresencePluginWinfo;
+class MSimpleWinfo;
+class MXIMPProtocolConnectionHost;
+class CPresencePluginXdmUtils;
+class CPresencePluginWatcher;
+class MPresenceObjectFactory;
+class MProtocolPresenceDataHost;
+class MProtocolPresenceAuthorization;
+class CPresencePluginVirtualGroup;
+class CPresencePluginAuthorization;
+class CPresencePluginGroups;
+
+/**
+ *  MPresencePluginConnectionObs
+ *
+ *  presence engine connection
+ *
+ *  @lib presenceplugin.dll
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( MPresencePluginConnectionObs )
+    {
+
+public:
+
+    enum TReqType
+        {
+        /** undefined */
+        ENoReq = 0,
+        /** Connection initializing */
+        EOpenSess,
+        /** Connection close */
+        ECloseSess,
+        /** Publish own data */
+        EPublish,
+        /** Subscribe Own data */
+        ESubscribeOwn,
+        /** Subscribe other user */
+        ESubscribeOther
+        };
+    
+    /**
+     * CPresencePluginWatcher accessor
+     * @return CPresencePluginWatcher
+     */    
+    virtual CPresencePluginWatcher* WatcherHandlerL() = 0;
+    
+    /**
+     * Complete the request
+     *
+     * @param aType request type
+     * @param aStatus status
+     */
+    virtual void CompleteReq(TReqType aType, TInt aStatus ) = 0;
+
+    /**
+     * Complete the request
+     *
+     * @param aReqId ximp request id
+     * @param aStatus status
+     */
+    virtual void CompleteReq(TXIMPRequestId aReqId, TInt aStatus ) = 0;
+
+    /**
+     * XIMP Object Factory accessor
+     * @return ximp Object Factory
+     */
+    virtual MXIMPObjectFactory& ObjectFactory()=0;
+       
+    /**
+     * XIMP Object Factory accessor
+     * @return PrFw Object Factory
+     */
+    virtual MPresenceObjectFactory& PresenceObjectFactoryOwn()=0;
+    
+    /**
+     * XIMP presence authorization accessor
+     * @return PrFw Protocol Presence Authorization
+     */
+    virtual MProtocolPresenceAuthorization& PresenceAuthorization() = 0;
+    
+    /**
+     * XIMP presence authorization accessor as own internal type
+     * @return Presence Authorization
+     */
+    virtual CPresencePluginAuthorization& InternalPresenceAuthorization() = 0;    
+    
+    /**
+     * Gets reference to
+     * MProtocolPresenceDataHost interface.
+     *
+     * Presence protocol connection implementation uses returned
+     * data host interface to manage the Presence connection's
+     * presence auhtorization data.
+     *
+     * @return MProtocolPresenceAuthorizationDataHost interface.
+     * Interface ownership is not returned caller.
+     * Returned interface is guaranteed to remain valid (usable)
+     * as long as this source interface.
+     */
+    virtual MProtocolPresenceDataHost& ProtocolPresenceHost() = 0;
+    
+    /**
+     * CPresencePluginWinfo accessor
+     * @return CPresencePluginWinfo, ownership is not transferred.
+     */
+    virtual CPresencePluginWinfo* WinfoHandlerL()=0;  
+    
+    /**
+     * CPresencePluginWinfoObserver is terminated
+     * @param aReason reason code
+     */
+    virtual void WinfoTerminatedL( TInt aReason )=0;  
+    
+    /**
+     * Watcher info subscription notification is received
+     * @aWinfo notification content
+     */
+    virtual void WinfoNotification( MSimpleWinfo& aWinfo ) = 0;  
+      
+    /**
+     * Current registered SIP entity
+     */
+    virtual TPtrC8 CurrentSipPresentity8() = 0;             
+    
+    /**
+     * Access connection host
+     * @return MximpProtocolConnectionHost
+     */
+    virtual MXIMPProtocolConnectionHost* Host() = 0;
+    
+    /**
+     * Current domain syntax accessor
+     */
+    virtual TPtrC16 CurrentDomain() = 0;
+    
+    /**
+     * Access CPresencePluginXdmUtils
+     * @return CPresencePluginXdmUtils entity
+     */
+    virtual CPresencePluginXdmUtils* XdmUtilsL() = 0;
+    
+    /**
+     * Get ETag
+     * @return TDesC8, etag value
+     */
+    virtual const TDesC8& GetETag() const = 0;
+    
+    /**
+     * Set ETag
+     * @return none
+     */
+    virtual void SetETag( const TDesC8& aETag ) = 0;
+    
+    /**
+     * Get client session time tupleId
+     * @return TInt, tuple value
+     */
+    virtual TInt GetTupleId() const = 0;
+    
+    /**
+     * Set session time tupleId
+     * @return none
+     */
+    virtual void SetTupleId( const TInt aTupleId ) =0;
+    
+    /**
+     * Get Stop publish state
+     * @return TBool, stop publish state
+     */
+    virtual TBool GetStopPublishState() = 0;
+    
+    /**
+     * Is Stop publish called
+     * @return TBool, stop publish called state
+     */
+    virtual TBool IsStopPublishCalled() = 0;
+    
+    /**
+     * Get Stop publish state
+     * @return TBool, stop publish state
+     */
+    virtual void SetStopPublishState( TBool aState ) = 0;
+    
+    /**
+     * Get Stop publish state
+     * @return TBool, session status
+     */
+    virtual TBool GetSessionStatus( ) = 0; 
+    
+    /**
+     * Return instace of subcribed contact
+     * @return TBool, session status
+     */
+    virtual CPresencePluginVirtualGroup* SubscribedContacts( ) = 0;
+    
+    /** 
+     * Get grand request list subscribe state
+     */
+    virtual TBool GrandListState() = 0;
+    
+    /** 
+     * Terminate connection
+     */
+    virtual void TerminateConnectionL( ) = 0;
+    
+    /** 
+     * Return Groups API implemention
+     */
+    virtual CPresencePluginGroups& GroupsL( ) = 0;  
+    
+    /** 
+     * Return service id
+     */
+    virtual TInt& ServiceId( ) = 0;        
+    };
+
+#endif
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/mpresrulesasynchandler.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef __MPRESRULESASYNCHANDLER_H__
+#define __MPRESRULESASYNCHANDLER_H__
+
+class CXdmDocument;
+// Class declaration
+
+NONSHARABLE_CLASS( MPresRulesAsyncHandler )
+    {
+    public:
+
+       /**
+        * This method handles the async. 
+        * call to function CPresenceXDM::UpdateToServerL
+        * and CPresenceXDM::UpdateAllFromServerL. 
+        * Clients should implement this method to get a callback.
+        *
+        * @param aErrorCode, XDMengine error codes
+        */
+       virtual void HandlePresUpdateDocumentL(
+           TInt aErrorCode ) = 0;
+
+    };
+    
+#endif //__MPRESRULESASYNCHANDLER_H__
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceconnectioninfo.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,190 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCECONNECTIONARRAY_H
+#define CPRESENCECONNECTIONARRAY_H
+
+#include <e32base.h>
+#include "presencelogger.h"
+#include "presenceplugincommon.h"
+#include "presencepluginconnection.h"
+
+class MXIMPProtocolConnection;
+
+/**
+ * CPresencePlugin
+ *
+ * Implementation of CXIMPProtocolPluginBase
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+
+
+NONSHARABLE_CLASS( CPresenceConnectionInfo ) : public CBase
+    {
+    public:
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param none
+        */
+        static CPresenceConnectionInfo* NewL( 
+        		MXIMPProtocolConnection* aConnection );
+    
+        /**
+         * SetConnectionStatus()
+         *
+         * @since S60 3.2 
+         * @param TConnectionStatus
+         * @return none
+         */
+        void SetConnectionStatus( 
+        		CPresencePluginConnection::TConnectionStatus aStatus );
+        
+        /**
+         * SetConnectionETag()
+         *
+         * @since S60 3.2 
+         * @param TDesC8 aETag
+         * @return none
+         */
+        void SetConnectionETag( const TDesC8& aETag );
+        
+        /**
+         * GetConnectionStatus()
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return TConnectionStatus connection status
+         */
+        CPresencePluginConnection::TConnectionStatus GetConnectionStatus();
+        
+        /**
+         * GetConnectionEtag()
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return TDesC8 ETag
+         */
+        TDesC8* GetConnectionEtag();
+        
+        /**
+         * GetConnection()
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return MXIMPProtocolConnection connection instance
+         */
+        MXIMPProtocolConnection* GetConnection();
+        
+        /**
+         * IncreaseClientCount()
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return none
+         */
+        void IncreaseClientCount();
+        
+        /**
+         * DecreaseClientCount()
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return none
+         */        
+        void DecreaseClientCount();
+        
+        /**
+         * GenerateClientId()
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return TInt uniqueclient id
+         */ 
+        TInt GenerateClientId();
+        
+        /**
+         * GenerateClientId()
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return TInt uniqueclient id
+         */ 
+        TInt GetClientId();
+        
+        /**
+         * GenerateClientId()
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return TInt client count
+         */
+        TInt ClientCount();
+        
+         /**
+          * Standard C++ destructor
+          */
+         ~CPresenceConnectionInfo();
+               
+     private:
+     
+         /**
+          * Standard C++ constructor
+          */   
+         CPresenceConnectionInfo( MXIMPProtocolConnection* aConnection );
+         
+    public: // data
+        
+        /**
+         * Connection ETag
+         * Own.
+         */
+        HBufC8* iETag;
+        
+        /**
+         * Connection
+         * Own.
+         */
+        MXIMPProtocolConnection* iConnection;
+        
+        /**
+         * Connection status
+         * Own.
+         */
+        CPresencePluginConnection::TConnectionStatus iConnectStatus;
+        
+        /**
+         * Connection status
+         * Own.
+         */
+        TInt iClientCount;
+        
+        /**
+         * Client id
+         * Own.
+         */
+        TUint iClientId;
+                  
+        SIMPLE_UNIT_TEST( T_CPresenceConnectionInfo )
+        
+    };
+
+#endif // CPRESENCEPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencecontactscontextbase.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,72 @@
+/*
+* Copyright (c) 20010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef M_MPRESENCECONTACTSCONTEXTBASE_H
+#define M_MPRESENCECONTACTSCONTEXTBASE_H
+
+
+class MVPbkContactLinkArray;
+class MVPbkContactLink;
+
+
+/**
+ *  Base class to state context
+ *
+ *  @lib presenceplugin.dll
+ *  @since S60 v5.0
+ */
+class MPresenceContactsContextBase
+    {
+
+public:
+
+    /**
+     * Open virtual phonebook contact stores
+     *
+     * @since S60 v5.0
+     */
+    virtual void OpenL() = 0;
+
+    /**
+     * Start virtual phonebook contacts search
+     *
+     * @since S60 v5.0
+     */
+    virtual void SearchL() = 0;
+
+    /**
+     * Return virtual phonebook contact links
+     *
+     * @since S60 v5.0
+     * @return virtual phonebook contact links
+     */
+    virtual const MVPbkContactLinkArray& ContactLinkArrayL() = 0;
+    
+    /**
+     * Resolve virtual phonebook contact from contact link
+     *
+     * @since S60 v5.0
+     * @param aContactLink contact link to resolve
+     */
+    virtual void RetrieveContactL(
+            const MVPbkContactLink& aContactLink ) = 0;
+
+    };
+
+
+#endif // M_MPRESENCECONTACTSCONTEXTBASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencelogger.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef DATAMODELADAPTERLOGGER_H
+#define DATAMODELADAPTERLOGGER_H
+
+#define DP_TP_PRINT(s) L##s
+#define DP_STRA_PRINT(s) DP_TP_PRINT(s)
+#define DP_STR_PRINT(t) DP_STRA_PRINT("[PrwAdapter]") L##t
+#define DP_LIT_PRINT(s) TPtrC((const TText *) DP_STR_PRINT(s))
+#ifdef _DEBUG     
+    #include <e32svr.h>
+    #define _DEBUG_SIMPLE_DATAMODEL_ADAPTER
+#endif
+
+#ifdef _DEBUG_SIMPLE_DATAMODEL_ADAPTER
+    #define DP_SDA(a) {RDebug::Print(DP_LIT_PRINT(a));}
+    #define DP_SDA2(a, b) {RDebug::Print(DP_LIT_PRINT(a),b);}
+    #define DP_SDA3(a, b, c) RDebug::Print(DP_LIT_PRINT(a), b, c);
+#else
+    #define DP_SDA(a);
+    #define DP_SDA2(a, b);
+    #define DP_SDA3(a, b, c);
+#endif
+
+#ifdef SIMPLE_EUNIT
+#define SIMPLE_UNIT_TEST(ClassName) friend class ClassName;
+#else 
+#define SIMPLE_UNIT_TEST(ClassName)
+#endif // SIMPLE_EUNIT
+
+#endif //DATAMODELADAPTERLOGGER_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugin.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,140 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCEPLUGIN_H
+#define CPRESENCEPLUGIN_H
+
+#include <e32base.h>
+#include <ximpprotocolpluginbase.h>
+
+#include "presencelogger.h"
+
+class CPresencePluginConnection;
+class MXIMPProtocolConnection;
+class MXIMPServiceInfo;
+class CPresenceConnectionInfo;
+
+/**
+ * CPresencePlugin
+ *
+ * Implementation of CXIMPProtocolPluginBase
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePlugin ) : public CXIMPProtocolPluginBase
+    {
+    public:
+    
+         /**
+         * Two-phased constructor.
+         *
+         * @param none
+         */
+        static CPresencePlugin* NewL();
+        
+        /**
+         * Two-phased constructor.
+         *
+		 * @param none
+         */
+        static CPresencePlugin* NewLC();
+
+        /**
+         * Standard C++ destructor
+         */
+        ~CPresencePlugin();
+    
+    private:
+    
+        /**
+         * Standard C++ constructor
+         */   
+        CPresencePlugin();
+        
+        /**
+         * Delete connection from arrays
+         * @param TInt aIndex, array index
+         * @return none
+         */  
+        void DeleteConnection( TInt aIndex );
+                
+    public: // from base class MXIMPProtocolPlugin
+
+        /**
+         * Defined in a base class
+         */ 
+        void PrimeHost( MXIMPProtocolPluginHost& aHost );
+        
+        /**
+         * Defined in a base class
+         */ 
+        MXIMPProtocolConnection& AcquireConnectionL(
+            const MXIMPServiceInfo& aService,
+            const MXIMPContextClientInfo& aContextClient );
+                     
+        /**
+         * Defined in a base class
+         */                 
+        void ReleaseConnection( MXIMPProtocolConnection& aConnection );
+        
+    public: // from base class MXIMPBase
+
+        /**
+         * Defined in a base class
+         */ 
+        TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps );
+
+        /**
+         * Defined in a base class
+         */ 
+        const TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps ) const;
+
+        /**
+         * Defined in a base class
+         */ 
+        TInt32 GetInterfaceId() const;
+        
+    private: // Data
+        
+        /**
+         * Prime host
+         * Own.
+         */
+        MXIMPProtocolPluginHost* iHost;
+        
+        /**
+         * connection array
+         * Own.
+         */
+        RPointerArray< CPresencePluginConnection > iConnections;
+        
+        /**
+         * connection data array
+         * Own.
+         */
+        RPointerArray< CPresenceConnectionInfo > iConnectionArray;
+        
+        SIMPLE_UNIT_TEST( T_CPresencePlugin )
+        
+    };
+#endif // CPRESENCEPLUGIN_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginauthorization.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,660 @@
+/*
+* Copyright (c) 2006-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCEPLUGINAUTHORIZATION_H
+#define CPRESENCEPLUGINAUTHORIZATION_H
+
+#include <e32base.h>
+#include <ximpbase.h>
+#include <protocolpresenceauthorization.h>
+#include "mpresencepluginconnectionobs.h"
+#include "presenceplugincontactsobs.h"
+#include "presencelogger.h"
+
+class TXIMPRequestId;
+class MXIMPIdentity;
+class MPresenceInfoFilter;
+class MProtocolPresenceAuthorizationDataHost;
+class MSimpleWinfo;
+class CPresencePluginData;
+class CPresencePluginContacts;
+
+/**
+ * CPresencePluginAuthorization
+ *
+ * Simple Engine Connection
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginAuthorization ) :
+    public CActive,
+    public MProtocolPresenceAuthorization,
+    public MPresencePluginContactsObs
+    {
+    public: // Constructor and destructor
+
+        /**
+         * Current operation
+         */
+        enum TPluginAuthOperation
+            {
+            ENoOperation,
+            EGrantPresenceForPresentity,
+            EGrantPresenceForPresentityGroupMembers,
+            EWithdrawFromPresentity,
+            EWithdrawFromGroupMembers,
+            EGrantForEveryone,
+            EWithdrawFromEveryone,
+            ESubscribeBlockList,
+            EUnsubscribeBlockList,
+            EBlockPresentity,
+            EUnblockPresentity
+            };
+        
+        /**
+         * Block state
+         */
+        enum TPluginAuthState
+            {
+            EStateIdle,
+            EStateBlocked,
+            EStateDoBlock,
+            EStateIsContactBlockedBuddyRequest,
+            EStateDoUnBlock,
+            EStatePresenceGranted,
+            EStateRemovePresentityFromGranted,
+            EStateAcceptBuddyRequest,
+            EStateSubscribe
+            };
+        
+        /**
+         * Constructor.
+         * @param aObs callback for complete requests
+         */ 
+        static CPresencePluginAuthorization* NewL(
+            MPresencePluginConnectionObs& aObs,
+            CPresencePluginData* aPresenceData );
+            
+        /**
+         * Standard C++ destructor
+         */ 
+        virtual ~CPresencePluginAuthorization();
+
+        /**
+         * SetDataHost
+         *
+         * @since S60 3.2         
+         * @param aDataHost, XIMP Plugin Authorization Data Host
+         */
+        void SetDataHost( MProtocolPresenceAuthorizationDataHost& aDataHost );
+
+        /**
+         * WinfoTerminatedL
+         *
+         * @since S60 3.2          
+         * SIMPLE Winfo watcher sunscription is terminated
+         * @param aReason reason code
+         */
+        void WinfoTerminatedL( TInt aReason );
+         
+        /** 
+         * WINFO received from SIMPLE
+         * @since S60 3.2
+         * @param aWinfo WINFO
+         */
+        void WinfoNotificationL( MSimpleWinfo& aWinfo ); 
+
+        /** 
+         * Return List subscribe state
+         *
+         * @since S60 3.2
+         * @param none
+         * @return TBool subscribe state
+         */
+        TBool ReturnListSubsState(); 
+        
+        /** 
+         * Returns plugin data handler.
+         *
+         * @since S60 5.0
+         * @param none
+         * @return CPresencePluginData data handler reference
+         */        
+        CPresencePluginData& PluginData();
+        
+        /** 
+         * Internal grant operation for group operation.
+         *
+         * @since S60 5.0
+         * @param aPresentityId, identity to be subscribed
+         * @param aClientStatus, client status to be completed
+         * @return none
+         */             
+        void DoPerformGrantPresenceForPresentityL(
+            const MXIMPIdentity& aPresentityId,
+            TRequestStatus& aClientStatus );
+        
+        /** 
+         * Internal withdraw grant operation for group operation.
+         *
+         * @since S60 5.0
+         * @param aPresentityId, identity to be ungranted
+         * @param aClientStatus, client status to be completed
+         * @return none
+         */                     
+        void DoPerformWithdrawPresGrantFromPresentityL(
+            const MXIMPIdentity& aPresentityId,
+            TRequestStatus& aClientStatus );
+        
+        /** 
+         * Internal block operation for group operation.
+         *
+         * @since S60 5.0
+         * @param aPresentityId, identity to be blocked
+         * @param aClientStatus, client status to be completed
+         * @return none
+         */                     
+         void DoPerformBlockPresenceForPresentityL(
+            const MXIMPIdentity& aPresentityId,
+            TRequestStatus& aClientStatus );
+
+        /** 
+         * Internal unblock operation for group operation.
+         *
+         * @since S60 5.0
+         * @param aPresentityId, identity to be unblocked
+         * @param aClientStatus, client status to be completed
+         * @return none
+         */    
+         void DoPerformCancelPresenceBlockFromPresentityL(
+            const MXIMPIdentity& aPresentityId,
+            TRequestStatus& aClientStatus );
+
+         /**
+          * Resolve is blocked contact a blocked friend request
+          *
+          * @since S60 5.0
+          * @param aPresenceId, identity to be resolved
+          * @param aObserver, Returns results
+          * @param aStatus, client status
+          */
+         void IsBlockedContactFriendRequestL(
+             const TDesC& aPresenceId,
+             MPresencePluginContactsObs& aObserver,
+             TRequestStatus& aStatus );
+
+    private:
+
+        /**
+         * Standard C++ constructor
+         * @param aObs callback for complete requests         
+         */ 
+        CPresencePluginAuthorization(
+            MPresencePluginConnectionObs& aObs,
+            CPresencePluginData* aPresenceData );
+        
+        void ConstructL();
+
+    public:	 // from base class MXIMPBase
+
+        /**
+         * Defined in a base class
+         */
+        TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps );
+
+        /**
+         * Defined in a base class
+         */
+        const TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps ) const;
+
+        /**
+         * Defined in a base class
+         */
+        TInt32 GetInterfaceId() const;
+        
+
+    public: // from base class MXIMPProtocolPresenceAuthorization
+
+        /**
+         * Defined in a base class
+         */
+        void DoSubscribePresenceGrantRequestListL(
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUnsubscribePresenceGrantRequestListL(
+            TXIMPRequestId aReqId );
+
+        // Granting presence information access to single presentities
+
+        /**
+         * Defined in a base class
+         */
+        void DoGrantPresenceForPresentityL(
+            const MXIMPIdentity& aPresentityId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUpdatePresenceGrantPifForPresentityL(
+            const MXIMPIdentity& aPresentityId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoWithdrawPresenceGrantFromPresentityL(
+            const MXIMPIdentity& aPresentityId,
+            TXIMPRequestId aReqId );
+
+        // Granting presence information access to presentity group members
+
+        /**
+         * Defined in a base class
+         */
+        void DoGrantPresenceForPresentityGroupMembersL(
+            const MXIMPIdentity& aGroupId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUpdatePresenceGrantPifForPresentityGroupMembersL(
+            const MXIMPIdentity& aGroupId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoWithdrawPresenceGrantFromPresentityGroupMembersL(
+            const MXIMPIdentity& aGroupId,
+            TXIMPRequestId aReqId );
+
+        // Granting presence information access to everyone
+
+        /**
+         * Defined in a base class
+         */
+        void DoGrantPresenceForEveryoneL(
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUpdatePresenceGrantPifForEveryoneL(
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoWithdrawPresenceGrantFromEveryoneL(
+            TXIMPRequestId aReqId );
+
+        // Subscribe presence block list
+
+        /**
+         * Defined in a base class
+         */
+        void DoSubscribePresenceBlockListL(
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUnsubscribePresenceBlockListL(
+            TXIMPRequestId aReqId );
+
+        // Blocking presence information access from single presentities
+
+        /**
+         * Defined in a base class
+         */
+        void DoBlockPresenceForPresentityL(
+            const MXIMPIdentity& aPresentityId,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoCancelPresenceBlockFromPresentityL(
+            const MXIMPIdentity& aPresentityId,
+            TXIMPRequestId aReqId );
+
+    public: // MPresencePluginContactsObs
+	
+        /**
+         * Request Complete 
+         *
+         * @param aResult Result data returned, ownership changed to client.
+         *                In operation EOperationIsPresenceStoredToContacts
+         *                return type is TBool*.
+         * @param aOperation Operation type
+         * @param aError Completion error code
+         */
+        void RequestComplete( TAny* aResult,
+                TPresenceContactsOperation aOperation,  TInt aError );
+    
+    protected: // from base class CActive
+
+        /**
+         * Defined in a base class
+         */
+        void RunL();
+
+        /**
+         * Defined in a base class
+         */
+        TInt RunError( TInt aError );
+
+        /**
+         * Defined in a base class
+         */
+        void DoCancel();
+
+    private:
+
+        /** 
+         * Save presentity id
+         *
+         * @since S60 3.2
+         * @param aPresentityId presentity id
+         * @param aFormatUri, attempt to format URI (set
+         * ETrue is aPresentityId is uri identity)
+         * @return none
+         */
+        void SetPresIdentityL(
+            const MXIMPIdentity& aPresentityId,
+            TBool aFormatUri );
+
+        /**
+         * Complete client request
+         *
+         * @since S60 3.2        
+         * @param aStatus
+         * @return none
+         */
+        void CompleteXIMPReq( TInt aStatus ); 
+        
+        /**
+         * Start XDM operation
+         *
+         * @since S60 3.2
+         * @param aId, XIMP identity
+         * @param aReqId, request id
+         * @param aOperation, plugin operation
+         * @return none
+         */
+        void StartXdmOperationL(
+            const MXIMPIdentity& aId,
+            TXIMPRequestId aReqId,
+            TPluginAuthOperation aOperation );
+           
+        /**
+         * Start XDM operation
+         *
+         * @since S60 5.0
+         * @param aId, XIMP identity
+         * @param aOperation, plugin operation
+         * @param aClientStatus, client status to complete
+         * @return none
+         */            
+        void StartXdmOperationL(
+            const MXIMPIdentity& aId,
+            TPluginAuthOperation aOperation,
+            TRequestStatus& aClientStatus );
+
+        /**
+         * Call actual xdm operation from xdm utils
+         *
+         * @since S60 3.2         
+         * @param none
+         * @return none
+         */
+        void CallActualXdmOperationL();
+        
+        /**
+         * Subscribe block list
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none         
+         */
+        void SubscribeBlockListL( );
+        
+        /**
+         * Unsubscribe block list
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none         
+         */
+        void UnSubscribeBlockListL();
+        
+        /**
+         * Handle full winfo notification
+         *
+         * @since S60 3.2
+         * @param MSimpleWinfo winfo notification
+         * @return none         
+         */
+        void HandleFullWinfoNotificationL( MSimpleWinfo& aWinfo );
+        
+        /**
+         * Handle partial winfo notification
+         *
+         * @since S60 3.2
+         * @param MSimpleWinfo winfo notification
+         * @return none         
+         */
+        void HandlePartialWinfoNotificationL( MSimpleWinfo& aWinfo );
+        
+        /**
+         * Handle received grant request
+         *
+         * @since S60 3.2
+         * @param TDesC userid
+         * @return none         
+         */
+        void CallHandlePresenceGrantRequestReceivedL( const TDesC& aUserId );
+        
+        /**
+         * Handle obsolated grantrequest
+         *
+         * @since S60 3.2
+         * @param TDesC userid
+         * @return none         
+         */
+        void CallHandlePresenceGrantRequestObsoletedL( const TDesC& aUserId );
+        
+        /**
+         * Grant presence for presentity
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none         
+         */
+        void GrantPresenceForPresentityL();
+        
+        /**
+         * Withdraw from presentity
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none         
+         */
+        void WithdrawFromPresentityL();
+        
+        /**
+         * Set presentity blocked to XIMP
+         *
+         * @since S60 5.1
+         * @param none
+         * @return none
+         */
+        void SetPresentityBlockedToXIMPL();
+        
+        /**
+         * Block presentity
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void BlockPresentityL();
+        
+        /**
+         * Unblock presentity
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void UnblockPresentityL();
+        
+        /**
+         * Unsubscribe presentity presence
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none         
+         */
+        void UnsubscribePresentityPresenceL();
+        
+    private: // Data
+
+        /**
+         * XIMP Plugin connection observer
+         * Own.
+         */
+        MPresencePluginConnectionObs& iConnObs;
+
+        /**
+         * XIMP Plugin Authorization Data Host
+         * Not own.
+         */
+        MProtocolPresenceAuthorizationDataHost* iDataHost;
+
+        /**
+         * XDM Settings id
+         * Own.         
+         */
+        TInt iSettingsId;
+
+        /**
+         * PrFW request id
+         * Own.
+         */
+        TXIMPRequestId iXIMPId;
+        
+        /**
+         * PrFW request id for own requests
+         * Own.
+         */
+        TXIMPRequestId iXIMPIdOwn;    
+        
+        /**
+         * Simple Engine request id
+         * Own.
+         */
+        TInt iSimpleId;
+        
+        /**
+         * Subscribed items.
+         * Own.
+         */
+        TBool iSubscribed; 
+        
+        /**
+         * Current operation
+         * Own.
+         */    
+        TPluginAuthOperation iOperation;     
+        
+        /**
+         * Current presentity in progress
+         * Own.
+         */
+        HBufC16* iPresIdentity;   
+
+        /**
+         * Whether Presence XDM is up-to-date
+         * Own.         
+         */
+        TBool iXdmOk;
+
+        /**
+         * XDM Utils
+         * Not own.
+         */
+        CPresencePluginXdmUtils* iXdmUtils;
+        
+        /**
+         * Authorization complete
+         * Own.
+         */
+        TBool iComplete;
+        
+        /**
+         * Presence Data
+         * Not Own
+         */
+        CPresencePluginData* iPresenceData;
+        
+        /**
+         * client statutus.
+         * Not own.
+         */
+        TRequestStatus* iClientStatus;      
+        
+        /**
+         * Block state.
+         * Own.
+         */
+        TPluginAuthState iAuthState;
+        
+        /*
+         * Virtual phone book contact database operations
+         * Own.
+         */
+        CPresencePluginContacts* iContacts;
+        
+        /*
+         * Data Returned by CPresencePluginContacts
+        */
+        TBool iContactIsStored;
+        
+        SIMPLE_UNIT_TEST( T_CPresencePluginAuthorization )
+        SIMPLE_UNIT_TEST( T_CPresencePluginXdmUtils )
+         
+    };
+
+#endif // CPresencePluginAuthorization_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugincommon.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,177 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+#ifndef PRESENCEPLUGINCOMMON_H
+#define PRESENCEPLUGINCOMMON_H
+
+#include <e32std.h>
+
+/**
+ * common definitions for Presence Plugin
+ */
+
+//Define max tuple and person id integer
+const TInt KMaxNumber = 99999999;
+
+//Buf size defines
+
+const TInt KBufSize100 = 100;
+const TInt KBufSize200 = 200;
+const TInt KBufSize255 = 255;
+const TInt KBufSize20 = 20;
+const TInt KBufSize10 = 10;
+
+// Presence Plugin specifications
+
+_LIT( KPluginName, "CPresencePlugin");
+
+/** Nothing subscribed */
+const TUint KPresencePluginSubsNone = 0x00000000;
+/** Grant list subscribed */
+const TUint KPresencePluginSubsGrant = 0x00000001;
+/** Block list subscribed */
+const TUint KPresencePluginSubsBlock = 0x00000002;
+/** Winfo list subscribed */
+const TUint KPresencePluginSubsWinfo = 0x00000004;
+
+//XDM Resourcelist
+/** buddy list id */
+_LIT( KPresenceBuddyList, "buddylist");
+/**  blocked list id */
+_LIT( KPresenceBlockedList, "blockedcontacts");
+/** for virtual online buddy group */
+_LIT( KPresenceOnlineBuddy ,"online_buddies");
+/** Subscribed buddys */
+_LIT( KPresenceSubcribedBuddys, "subs_buddys");
+
+//XDM Presencerules list 
+/** Presence XDM block rule id */
+_LIT( KPresenceXdmBlockRule, "pres_blacklist");
+/** Presence XDM whitelist*/
+_LIT( KPresenceXdmWhiteList, "pres_whitelist");
+/** Presence XDM grant rule id */
+_LIT( KPresenceXdmGrantRule, "pres_whitelist");
+/** S60 Shared XDM list for granted entities */
+_LIT( KPresenceS60GrantedList, "s60_granted_list");
+
+//For localmode check
+_LIT(KLocalhost, "http://localhost");
+
+// when contact goes offline this is content of aBasicElement->ContentUnicodeL()
+_LIT( KClose ,"close");
+
+//For own presence status NOTIFY
+_LIT(KIndent, "t"); // for tupleId
+_LIT(KPersonId, "p"); // for person
+
+// Temporary hard coded values for presence cache 2 support. Common definitions needed!
+_LIT( KDefaultAvailableStatus, "available" );
+
+
+namespace NPresencePlugin
+    {
+    namespace NPresence
+        {
+        _LIT( KPresenceDisplayName, "display-name");        
+        _LIT( KPresenceIndex,   "index");
+        _LIT( KPresenceResourceLists, "resource-lists");
+        _LIT( KPresenceResourceList, "resource-list.xml");
+        _LIT( KPresenceConditions, "conditions");
+        _LIT( KPresenceIdentity, "identity");
+        _LIT( KPresenceRuleset, "ruleset" );
+        _LIT( KPresenceRule, "rule");
+        _LIT( KPresenceAction, "actions");
+        _LIT( KPresenceAllow, "allow");
+        _LIT8( KPresenceAllow8, "allow");
+        _LIT( KPresenceBlock, "block");
+        _LIT8( KPresenceBlock8, "block");        
+        _LIT( KPresenceSub, "sub-handling");
+        _LIT( KPresencePresRules, "presrules");
+        _LIT( KPresenceList, "list");
+        _LIT( KPresenceName, "name");
+        _LIT( KPresenceEntry, "entry");
+        _LIT( KPresenceOne , "one");
+        _LIT( KPresencePerson, "person");
+        _LIT8( KPresencePerson8, "person"); 
+        _LIT8( KPresenceWatcher8, "watcher"); 
+        _LIT8( KPresenceWatherInfo8, "watcherinfo");                   
+        _LIT8( KPresenceWatcherList8, "watcher-list"); 
+        _LIT8( KPresenceStatus8, "status");  
+        _LIT8( KPresenceActive8, "active");
+        _LIT8( KPresenceEvent8, "event");        
+        _LIT8( KPresencePending8, "pending");
+        _LIT8( KPresenceBasic8, "basic"); 
+        _LIT( KPresenceBasic, "basic");    
+        _LIT8( KPresenceStatusicon8, "status-icon");
+        _LIT8( KPresenceNote8, "note");                               
+        _LIT8( KPresenceSubscribe8, "subscribe");                                                                 
+        _LIT( KPresenceUri, "uri");
+        _LIT8( KPresenceUri8, "uri");
+        _LIT8( KPresenceState8, "state");
+        _LIT8( KPresenceInstance8, "instance");
+        _LIT8( KPresenceTerminated8, "terminated");
+        _LIT8( KPresenceResource8, "resource");
+        _LIT8( KPresenceList8, "list");
+        _LIT8( KPresenceTuple8, "tuple");
+        _LIT( KPresenceTuple, "tuple"); 
+        _LIT( KPresenceId, "id");
+        _LIT8( KPresenceId8, "id");      
+        _LIT( KPresenceActivities, "activities");
+        _LIT8( KPresenceActivities8, "activities");
+        _LIT8( KPresenceFull8, "full");
+        _LIT( KPresencePartial, "partial");
+        _LIT8( KPresencePartial8, "partial");       
+        }
+    namespace NPresenceStates
+        {
+        _LIT( KPresenceOpen, "open");
+        _LIT( KPresenceClosed, "closed");
+        _LIT( KPresenceClose, "close");
+        _LIT( KPresenceOffline, "offline");
+        _LIT8( KPresenceOffline8, "offline");
+        _LIT( KPresenceAvailable, "available");
+        _LIT8( KPresenceAvailable8, "available");
+        _LIT( KPresenceUnknow, "unknown");      
+        _LIT8( KPresenceUnknow8, "unknown");
+        _LIT( KPresenceBusy, "busy");
+        _LIT8( KPresenceBusy8, "busy");
+        _LIT( KPresenceOnThePhone, "on-the-phone");
+        _LIT8( KPresenceOnThePhone8, "on-the-phone");
+        _LIT( KPresenceAway, "away");
+        _LIT8( KPresenceAway8, "away");
+        _LIT( KPresenceDoNotDisturb, "do-not-disturb");
+        _LIT8( KPresenceDoNotDisturb8, "do-not-disturb");
+        _LIT( KPresencePending, "pending" );
+        }
+    namespace NPresenceTransformations
+        {
+        _LIT( KPresenceTRUE, "TRUE");
+        _LIT( KPresenceFALSE, "FALSE");
+        _LIT( KPresenceTrasformations, "transformations");
+        _LIT( KPresenceProvideServices, "provide-services");
+        _LIT( KPresenceAllServices, "all-services");
+        _LIT( KPresenceProvidePersons, "provide-persons");
+        _LIT( KPresenceAllPersons, "all-persons");
+        _LIT( KPresenceProvidedevices, "provide-devices");
+        _LIT( KPresenceAlldevices, "all-devices");
+        _LIT( KPresenceProvideAllAttributes, "provide-all-attributes");
+        _LIT( KPresenceProvideActivities, "provide-activities");
+        _LIT( KPresenceProvideNote, "provide-note");
+        } 
+    }
+    
+#endif // PRESENCEPLUGINCOMMON_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginconnection.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,642 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef PRESENCEPLUGINCONNECTION_H
+#define PRESENCEPLUGINCONNECTION_H
+
+#include <e32base.h>
+#include <ximpprotocolconnection.h>
+#include <protocolpresencefeatures.h>
+//Connection obs
+#include "mpresencepluginconnectionobs.h"
+#include "simpleimfeatures.h"
+#include "presencelogger.h"
+
+//FORWARD
+class MXIMPServiceInfo;
+class MXIMPObjectFactory; 
+class MXIMPProtocolConnectionHost;
+class MProtocolPresenceWatching;
+class MProtocolPresencePublishing;
+class MProtocolPresentityGroups;
+class MProtocolPresenceAuthorization;
+class MProtocolPresenceFeatures;
+class MProtocolPresenceDataHost;
+class CPresencePluginSession;
+class CPresencePluginWinfo;
+class CPresencePluginWatcher;
+class CPresencePluginAuthorization;
+class CPresencePluginPublisher;
+class CPresencePluginXdmUtils;
+class CPresencePluginGroups;
+class CPresencePluginVirtualGroup;
+class CPresencePluginData;
+class CPresenceConnectionInfo;
+class MProtocolImFeatures;
+
+
+/**
+ * CPrecensePluginSession
+ *
+ * presence Engine Connection
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS(CPresencePluginConnection) : public CActive,
+    public MXIMPProtocolConnection,
+    public MProtocolPresenceFeatures,
+    public MPresencePluginConnectionObs
+    {
+    public:
+    
+    	enum TConnectionStatus
+            {
+            /** undefined */
+            ENotActive = 0,
+            /** Connection initializing */
+            EActive,
+            /** Connection close */
+            ETerminated
+            };
+
+        /**
+         * Two-phased constructor.
+         *
+         * @param aServiceInfo, XIMP service info
+         * @param aClientCtxInfo, XIMP contex client info
+         */
+        static CPresencePluginConnection* NewL( 
+            const MXIMPServiceInfo& aServiceInfo,
+            const MXIMPContextClientInfo& aClientCtxInfo );
+        
+        /**
+         * Two-phased constructor loaded.
+         *
+         * @param aServiceInfo, XIMP service info
+         * @param aClientCtxInfo, XIMP contex client info
+         */
+        static CPresencePluginConnection* NewL( 
+            const MXIMPServiceInfo& aServiceInfo,
+            const MXIMPContextClientInfo& aClientCtxInfo,
+            const TDesC8& aETag );
+        
+        /**
+         * Standard C++ destructor
+         */ 
+        ~CPresencePluginConnection();
+
+        /**
+         * Grand list subscribe state
+         *
+         * @since S60 3.2
+         * @param none
+         * @return TBool grand list subscribe state
+         */
+        TBool GrandListState( );
+
+        /**
+         * Set connection info array
+         *
+         * @since S60 3.2
+         * @param connection info
+         * @return none
+         */
+        void SetConnectionArray( CPresenceConnectionInfo* aArray );
+
+        /**
+         * Get connection info array
+         *
+         * @since S60 3.2
+         * @param none
+         * @return return info 
+         */
+        CPresenceConnectionInfo* GetConnectionArray( );
+
+
+        /**
+         * Gets protocol interface. In error cases returns NULL
+         *
+         * @since S60 5.0
+         * @param none
+         * @return protocol interface 
+         */        
+        TAny* GetProtocolInterface( TInt aInterfaceId );
+        
+    private:
+    
+        /**
+         * Standard C++ constructor
+         */         
+        CPresencePluginConnection( );
+
+        /**
+         * Performs the 2nd phase of construction.
+         *
+         * @param aService, XIMP service info
+         * @param aClientCtxInfo, XIMP contex client info
+         */  
+        void ConstructL(
+            const MXIMPServiceInfo& aService,
+            const MXIMPContextClientInfo& aClientCtxInfo );
+        
+        /**
+         * Performs the 2nd phase of construction. Overload
+         *
+         * @param aService, XIMP service info
+         * @param aClientCtxInfo, XIMP contex client info
+         */  
+        void ConstructL(
+            const MXIMPServiceInfo& aService,
+            const MXIMPContextClientInfo& aClientCtxInfo,
+            const TDesC8& aETag );
+        
+    private: //Own private functions
+    	
+    	/**
+         * DeRegister
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+    	void DeRegister( );
+    	
+        /**
+          * CreateImFeaturesPlugin
+          *
+          * @since S60 5.0
+          * @param none
+          * @return none
+          */
+    	void CreateImFeaturesPluginL();
+    	
+        /**
+          * DeleteImFeaturesPlugin
+          *
+          * @since S60 5.0
+          * @param none
+          * @return none
+          */
+    	void DeleteImFeaturesPlugin();
+    	
+    protected: // from base class CActive
+
+        /**
+         * Defined in a base class
+         */
+        void RunL();
+
+        /**
+         * Defined in a base class
+         */
+        TInt RunError( TInt aError );
+
+        /**
+         * Defined in a base class
+         */
+        void DoCancel();
+    
+    public: // from base class MPrFwBase
+        
+        TInt32 GetPresenceSetId() const;
+        
+        /**
+         * Defined in a base class
+         */
+        TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps );
+
+        /**
+         * Defined in a base class
+         */
+        const TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps ) const;
+
+        /**
+         * Defined in a base class
+         */
+        TInt32 GetInterfaceId() const;
+        
+    public:// from base class MPresencePluginConnectionObs
+    
+        /**
+         * Return subscribed buddy virtual group
+         *
+         * @since S60 3.2
+         * @param none
+         * @return CPresencePluginVirtualGroup, virtual group
+         */
+        CPresencePluginVirtualGroup* SubscribedContacts();
+        
+        /**
+         * Get Stop Publish state
+         *
+         * @since S60 3.2
+         * @param none
+         * @return TBOOL, Stop Publish state
+         */
+        TBool GetStopPublishState();
+        
+        /**
+         * Is stop publish called
+         *
+         * @since S60 3.2
+         * @param none
+         * @return TBOOL, Stop Publish
+         */
+        TBool IsStopPublishCalled();
+        
+        /**
+         * Set Stop Publish state
+         *
+         * @since S60 3.2
+         * @param aState, stop publish state TRUE/FALSE
+         * @return none
+         */
+        void SetStopPublishState( TBool aState );
+    
+        /**
+         * Get Tuple id
+         *
+         * @since S60 3.2
+         * @param none
+         * @return TInt, tupleid
+         */
+        TInt GetTupleId() const;
+        
+        /**
+         * Set Tuple id
+         *
+         * @since S60 3.2
+         * @param aTupleId, generated tupleid
+         * @return none
+         */
+        void SetTupleId( const TInt aTupleId );
+        
+        /**
+         * Get ETag
+         *
+         * @since S60 3.2
+         * @param none
+         * @return TDesC8, Etag value
+         */
+        const TDesC8& GetETag() const;
+   
+        /**
+         * Set ETag
+         *
+         * @since S60 3.2
+         * @param aEtag, Etag value
+         * @return none
+         */
+        void SetETag( const TDesC8& aETag );
+        
+        /**
+         * Defined in a base class
+         */
+        void CompleteReq( TReqType aType, TInt aStatus );
+
+        /**
+         * Defined in a base class
+         */
+        void CompleteReq( TXIMPRequestId aReqId, TInt aStatus );
+
+        /**
+         * Defined in a base class
+         */
+        MXIMPObjectFactory& ObjectFactory();
+    
+        /**
+         * Defined in a base class
+         */    
+        MPresenceObjectFactory& PresenceObjectFactoryOwn();
+            
+        /**
+         * Defined in a base class
+         */
+        CPresencePluginWinfo* WinfoHandlerL();   
+    
+        /**
+         * Defined in a base class
+         */
+        CPresencePluginWatcher* WatcherHandlerL();
+        
+        /**
+         * Defined in a base class
+         */    
+        void WinfoTerminatedL( TInt aReason ); 
+    
+        /**
+         * Defined in a base class
+         */     
+        void WinfoNotification( MSimpleWinfo& aWinfo );      
+ 
+        /**
+         * Defined in a base class
+         */ 
+        TPtrC8 CurrentSipPresentity8();
+        
+        /**
+         * Defined in a base class
+         */
+        CPresencePluginXdmUtils* XdmUtilsL();
+        
+        /**
+         * Defined in a base class
+         */
+        TBool GetSessionStatus( );
+        
+        /** 
+         * Termiante connection
+         */
+        void TerminateConnectionL( );
+        
+        /** 
+         * Returns groups api implementation. Leaves if 
+         * pointer not available.
+         */        
+        CPresencePluginGroups& GroupsL();
+        
+        /** 
+         * Returns service id
+         */                
+        TInt& ServiceId();                
+                         
+    public: // from MXIMPProtocolConnection
+               
+        /**
+         * Defined in a base class
+         */
+        MProtocolPresenceDataHost& ProtocolPresenceHost();
+        
+        /**
+         * Defined in a base class
+         */
+        MProtocolPresenceFeatures& ProtocolPresenceFeatures();
+        
+        /**
+         * PrimeHost
+         *
+         * @since S60 3.2
+         * @param [in] aHost
+         * Reference to host interface, what this MXIMPProtocolConnection
+         * instance must use to communicate back to Presence Framework
+         * direction.
+         */
+        void PrimeHost( MXIMPProtocolConnectionHost& aHost );
+
+        /**
+         * OpenSessionL
+         *
+         * @since S60 3.2 
+         * @param [in] aReqId
+         * Request ID identifying the request. Presence protocol
+         * connection implementation must cache here given ID and
+         * use it when completing the request later through the
+         * MXIMPProtocolConnectionHost::HandleRequestCompleted().
+         */
+        void OpenSessionL( const MXIMPContextClientInfo& aClientCtxInfo,
+            TXIMPRequestId aReqId );
+        
+        /**
+         * OpenSessionL
+         *
+         * @since S60 3.2 
+         * @param [in] aReqId
+         * Request ID identifying the request. Presence protocol
+         * connection implementation must cache here given ID and
+         * use it when completing the request later through the
+         * MXIMPProtocolConnectionHost::HandleRequestCompleted().
+         */
+        void OpenSessionL( const TInt& aSettingsId,
+            TXIMPRequestId aReqId );
+         
+        /**
+         * CloseSession
+         *
+         * @since S60 3.2
+         * @param [in] aReqId
+         * Request ID identifying the request. Presence protocol
+         * connection implementation must cache here given ID and
+         * use it when completing the request later through the
+         * MXIMPProtocolConnectionHost::HandleRequestCompleted().
+         */               
+        void CloseSession( const MXIMPContextClientInfo& aContextClient,
+            TXIMPRequestId aReqId );
+            
+        /**
+         * GetSupportedFeaturesL
+         * 
+         * @since S60 3.2
+         * @param [out] aFeatures
+         * Return parameter where to append supported
+         * presence protocol connection features.
+         * Feature IDs are defined in NXIMPFeature namespace.
+         */               
+        void GetSupportedFeaturesL( CDesC8Array& aFeatures ) const;
+
+        /**
+         * PresenceWatching
+         *
+         * @since S60 3.2 
+         * @return Requested interface.
+         * interface ownership is not returned caller.
+         */
+        MProtocolPresenceWatching& PresenceWatching();
+
+        /**
+         * PresencePublishing
+         *
+         * @since S60 3.2 
+         * @return Requested interface.
+         * interface ownership is not returned caller.
+         */
+        MProtocolPresencePublishing& PresencePublishing(); 
+
+        /**
+         * PresentityGroups
+         * 
+         * @since S60 3.2 
+         * @return Requested interface.
+         * interface ownership is not returned caller.
+         */
+        MProtocolPresentityGroups& PresentityGroups();
+
+        /**
+         * PresenceAuthorization
+         * 
+         * @since S60 3.2
+         * @return Requested interface.
+         * interface ownership is not returned caller.
+         */
+        MProtocolPresenceAuthorization& PresenceAuthorization();
+        
+        /**
+         * PresenceAuthorization
+         * 
+         * @since S60 3.2
+         * @return Requested interface as own type
+         * interface ownership is not returned caller.
+         */        
+        CPresencePluginAuthorization& InternalPresenceAuthorization();
+
+        /**
+         * Defined in a base class
+         */
+        MXIMPProtocolConnectionHost* Host();
+
+        /**
+         * Defined in a base class
+         */
+        TPtrC16 CurrentDomain();
+          
+        /**
+         * Defined in a base class
+         */
+        MXIMPServiceInfo& ServiceInfo();
+                        
+    private:  //data
+     
+        /**
+         * Presence Engine session
+         * Own.
+         */
+        CPresencePluginSession* iSession;
+        
+        /**
+         * CPresencePluginWinfo
+         * Own.
+         */    
+        CPresencePluginWinfo* iPluginWinfo;
+        
+        /**
+         * CPresencePluginWatcher
+         * Own.
+         */
+        CPresencePluginWatcher* iWatcher;
+        
+        /**
+         * current request id
+         * Own
+         */
+        TXIMPRequestId iXIMPId;  
+        
+        /**
+         * Host for connection.
+         * Not own.
+         */
+        MXIMPProtocolConnectionHost*  iConnectionHost;  
+        
+        /**
+         * MXIMPProtocolPresenceauthorization implementation.
+         * Own.
+         */
+        CPresencePluginAuthorization* iAuth;
+        
+        /**
+         * CSimplePluginPublisher
+         * Own.
+         */
+        CPresencePluginPublisher* iPublisher;
+        
+        /**
+         * CSimplePluginGroups
+         * Own.
+         */
+        CPresencePluginGroups* iGroups;
+        
+        /**
+         * CPresencePluginImFeatures
+         * Own.
+         */
+        CSimpleImFeatures* iImFeatures;
+        
+        /**
+         * Current user SIP identity
+         * Own.
+         */
+        HBufC16* iSipPresentity; 
+        
+        /**
+         * XDM utils
+         * Own.
+         */
+        CPresencePluginXdmUtils* iXdmUtils;
+        
+        /**
+         * TupleId
+         * Own.
+         */
+        TInt iOwnTupleId;
+         
+        /**
+         * Document Etag
+         * Own.
+         */
+        HBufC8* iETag;
+
+        /**
+         * Virtual groups
+         * Own
+         */
+        CPresencePluginVirtualGroup* iSubscribedBuddys;   
+
+        /**
+         * Plugin Data
+         * Own.
+         */
+        CPresencePluginData* iPresenceData;
+        
+        /**
+         * Stop publish state
+         * Own
+         */
+        TBool iStopPublishState;
+        
+        /**
+         * Grant list subscribe state
+         * Own
+         */
+        TBool iGrantListSubs;
+        
+        /**
+         * Is stop publish called
+         * Own
+         */
+        TBool iStopPublishCall;
+        
+        /**
+         * Terminated state called
+         * Own.
+         */
+        TBool iTerminatedCall;
+        
+        /**
+         * Connection Array instance
+         * Own.
+         */
+        CPresenceConnectionInfo* iConnectionArray;
+        
+        SIMPLE_UNIT_TEST( T_CPresencePluginConnection )
+        SIMPLE_UNIT_TEST( T_SIMPLEDataModelAdapter )
+    };
+
+#endif // PRESENCEPLUGINCONNECTION_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugincontacts.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,344 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef C_CPRESENCEPLUGINCONTACTS_H
+#define C_CPRESENCEPLUGINCONTACTS_H
+
+
+#include <e32base.h>
+#include <MVPbkContactFindObserver.h>
+#include <MVPbkSingleContactOperationObserver.h>
+#include <MVPbkContactStoreListObserver.h>
+#include "presencecontactscontextbase.h"
+#include "presencelogger.h"
+
+class CVPbkContactManager;
+class MVPbkContactOperationBase;
+class MVPbkContactLinkArray;
+class MVPbkStoreContact;
+class CVPbkFieldTypeRefsList;
+class CPresencePluginContactStateHandler;
+class MPresencePluginContactsObs;
+
+
+/**
+ * CPrecensePluginContacts Operation states
+ */
+enum TPresenceContactsOperation
+    {
+    EOperationIsPresenceStoredToContacts
+    };
+
+
+/**
+ * Access to virtual phonebook contacts database
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CPresencePluginContacts ) :
+    public CActive,
+    public MVPbkContactStoreListObserver,
+    public MVPbkContactFindObserver,
+    public MVPbkSingleContactOperationObserver,
+    public MPresenceContactsContextBase
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aServiceId Service ID.
+     * @param aServiceName Service name
+     * @param aObserver Callback results
+     */
+    static CPresencePluginContacts* NewL(
+        TInt aServiceId,
+        const TDesC& aServiceName,
+        MPresencePluginContactsObs& aObserver );
+    
+    /**
+     * Two-phased constructor.
+     * @param aServiceId Service ID.
+     * @param aServiceName Service name
+     * @param aObserver Callback results
+     */
+    static CPresencePluginContacts* NewLC(
+        TInt aServiceId,
+        const TDesC& aServiceName,
+        MPresencePluginContactsObs& aObserver );
+    
+    /**
+    * Destructor.
+    */
+    virtual ~CPresencePluginContacts();
+    
+    /**
+     * Query to virtual bhonebook contacts database
+     * to ensure is the presence service stored to database
+     *
+     * Calls MPresencePluginContactsObs::RequestComplete() when comlete
+     *
+     * @since S60 v5.0
+     * @param aPresenceId Presence ID.
+     * @param aStatus Client status
+     */
+    void IsPresenceIdStoredL( const TDesC16& aPresenceId,
+	    TRequestStatus& aStatus );
+    
+protected:
+
+// from base class CActive
+    
+    void RunL();
+    
+    void DoCancel();
+
+    TInt RunError( TInt aError );
+    
+// from base class MVPbkContactStoreListObserver
+     
+    /**
+     * Called when the opening process is complete. 
+     *
+     * Before this all stores have sent StoreReady or StoreUnavailable 
+     * event. The client can not trust that all stores are available
+     * for use when this is called.
+     */
+    void OpenComplete();
+    
+// from base class MVPbkContactStoreObserver ( from MVPbkContactStoreListObserver )
+     
+    /**
+     * Called when a contact store is ready to use.
+     *
+     * @param aContactStore The store that is ready.
+     */
+    void StoreReady( MVPbkContactStore& aContactStore );
+
+    /**
+     * Called when a contact store becomes unavailable.
+     *
+     * Client may inspect the reason of the unavailability and decide
+     * whether or not it will keep the store opened (ie. listen to 
+     * the store events).
+     *
+     * @param aContactStore The store that became unavailable.
+     * @param aReason The reason why the store is unavailable.
+     *                This is one of the system wide error codes.
+     */
+    void StoreUnavailable( MVPbkContactStore& aContactStore, 
+            TInt aReason );
+
+    /**
+     * Called when changes occur in the contact store.
+     *
+     * @see TVPbkContactStoreEvent
+     * @param aContactStore A store whose event it is.
+     * @param aStoreEvent The event that has occurred.
+     */
+    void HandleStoreEventL(
+             MVPbkContactStore& aContactStore, 
+             TVPbkContactStoreEvent aStoreEvent );
+    
+// from base class MVPbkContactFindObserver
+
+    /**
+     * Called when find is complete. Caller takes ownership of the results
+     * In case of an error during find, the aResults may contain only 
+     * partial results of the find
+     *
+     * @param aResults Array of contact links that matched the find
+     *                 Callee must take ownership of this object in
+     *                 the start of the function, ie. in case the 
+     *                 function leaves the results must be destroyed. 
+     *                 The find operation can be destroyed at the end 
+     *                  of this callback.
+     */
+    void FindCompleteL( MVPbkContactLinkArray* aResults );
+    
+    /**
+    * Called in case the find fails for some reason. The find operation
+    * can be destroyed at the end of this callback.
+    * 
+    * @param aError One of the system wide error codes.
+    *        KErrNotReady if store is not ready (not open or unavailable)
+    */
+    void FindFailed( TInt aError );
+    
+// from base class MVPbkSingleContactOperationObserver
+
+    /**
+     * Called when the operation is completed.
+     *
+     * A client has the operation as a member and it can delete the operation
+     * instance in this function call. If the implementation of the store
+     * calls the function from the operation instance it must not handle
+     * any member data after calling it.
+     *
+     * @param aOperation The completed operation.
+     * @param aContact The contact returned by the operation.
+     *                 A client must take the ownership immediately.
+     *
+     *                  NOTE:
+     *                  If you use CleanupStack for MVPbkStoreContact
+     *                  Use MVPbkStoreContact::PushL or
+     *                  CleanupDeletePushL from e32base.h.
+     *                  (Do Not Use CleanupStack::PushL(TAny*) because
+     *                  then the virtual destructor of the M-class
+     *                  won't be called when the object is deleted).
+     */
+    void VPbkSingleContactOperationComplete(
+            MVPbkContactOperationBase& aOperation,
+            MVPbkStoreContact* aContact );
+
+    /**
+     * Called if the operation fails.
+     *
+     * A client has the operation as a member and it can delete the operation
+     * instance in this function call. If the implementation of the store
+     * calls the function from the operation instance it must not handle
+     * any member data after calling it.
+     *
+     * @param aOperation The failed operation.
+     * @param aError An error code of the failure.
+     */
+    void VPbkSingleContactOperationFailed(
+            MVPbkContactOperationBase& aOperation, 
+            TInt aError );
+    
+// from base class MPresenceContactsContextBase
+
+    /**
+     * Open virtual phonebook contact stores
+     *
+     * @since S60 v5.0
+     */
+    void OpenL();
+
+    /**
+     * Start virtual phonebook contacts search
+     *
+     * @since S60 v5.0
+     */
+    void SearchL();
+
+    /**
+     * Return virtual phonebook contact links
+     *
+     * @since S60 v5.0
+     * @return virtual phonebook contact links
+     */
+    const MVPbkContactLinkArray& ContactLinkArrayL();
+
+    /**
+    * Resolve virtual phonebook contact from contact link
+    *
+    * @since S60 v5.0
+    * @param aContactLink contact link to resolve
+    */
+    void RetrieveContactL(
+        const MVPbkContactLink& aContactLink );
+
+private:
+
+    CPresencePluginContacts( TInt aServiceId, MPresencePluginContactsObs& aObserver );
+
+    void ConstructL( const TDesC& aServiceName );
+
+    HBufC* ContactStoreNameL();
+    
+private: //data
+    
+    /**
+     * Service id.
+     */
+    TInt iServiceId;
+    
+    /**
+     * Service name.
+     * Own.
+     */
+    HBufC* iServiceName;
+
+    /**
+     * Text used in search
+     * Own.
+     */
+    HBufC* iSearchText;
+    
+    /**
+     * Observer.
+     * Not own.
+     */
+    MPresencePluginContactsObs* iObserver;
+    
+    /**
+     * Presence Plugin Contacts Operation
+     */
+    TPresenceContactsOperation iOperation;
+    
+    /**
+     * Virtual Phonebook field types
+     * Own.
+     */
+    CVPbkFieldTypeRefsList* iFieldTypeRefList;
+
+    /**
+     * Virtual Phonebook contact manager
+     * Own.
+     */
+    CVPbkContactManager* iContactManager;
+
+    /**
+     * VPbk operation
+     * Own.
+     */
+    MVPbkContactOperationBase* iContactOperation;
+    
+    /**
+     * VPbk contact links
+     * Own.
+     */
+    MVPbkContactLinkArray* iContactLinkArray;
+
+    /**
+     * VPbk Store contact array
+     * Own.
+     */
+    RPointerArray<MVPbkStoreContact> iStoreContactArray;
+    
+    /**
+     * state handler
+     * Own.
+     */
+    CPresencePluginContactStateHandler* iStateHandler;
+    
+    /**
+     * Client status
+     * Not own.
+     */
+    TRequestStatus* iClientStatus;
+
+    
+    SIMPLE_UNIT_TEST( UT_CPresencePluginContacts )
+
+    };
+
+
+#endif // C_CPRESENCEPLUGINCONTACTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugincontactsobs.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef M_MPRESENCEPLUGINCONTACTSOBS_H
+#define M_MPRESENCEPLUGINCONTACTSOBS_H
+
+
+#include <e32std.h>
+#include "presenceplugincontacts.h"
+
+
+/**
+ *  Callback from virtual phonebook contacts handler
+ *
+ *  @lib presenceplugin.dll
+ *  @since S60 v5.0
+ */
+class MPresencePluginContactsObs
+    {
+
+public:
+
+    /**
+     * Informs the observer that the operation is completed
+     *
+     * @param aResult Result data returned,ownership is
+     *                transferred to the client.
+     *                In operation EOperationIsPresenceStoredToContacts
+     *                return type is TBool*.
+     * @param aOperation Operation type
+     * @param aError Completion error code
+     */
+    virtual void RequestComplete( TAny* aResult,
+        TPresenceContactsOperation aOperation, TInt aError ) = 0;
+    
+    };
+
+
+#endif // M_PRESENCEPLUGINCONTACTSOBS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugincontactstate.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,65 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+#ifndef C_CPRESENCEPLUGINCONTACTSTATE_H
+#define C_CPRESENCEPLUGINCONTACTSTATE_H
+
+#include <e32base.h>
+
+class CPresencePluginContactStateHandler;
+class MPresenceContactsContextBase;
+
+/**
+ *  Base class for presenceplugin contacts states
+ * 
+ *  @lib presenceplugin.dll
+ *  @since S60 V5.0
+ */
+class CPresencepluginContactState : public CBase
+    {
+
+public:
+
+    CPresencepluginContactState( MPresenceContactsContextBase& aContext,
+        CPresencePluginContactStateHandler& aStateHandler );
+    
+    virtual ~CPresencepluginContactState();
+
+    virtual void HandleL() = 0;
+    
+    virtual void Complete();
+    
+    virtual void Error( TInt aError );
+    
+protected: // data
+    
+    /**
+     * Context
+     * Not own.
+     */
+    MPresenceContactsContextBase* iContext;
+    
+    /**
+     * State handler
+     * Not own.
+     */
+    CPresencePluginContactStateHandler* iStateHandler;
+    
+    };
+
+
+#endif // C_CPRESENCEPLUGINCONTACTSTATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugincontactstateend.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef C_CPRESENCEPLUGINCONTACTSTATEEND_H
+#define C_CPRESENCEPLUGINCONTACTSTATEEND_H
+
+
+#include "presenceplugincontactstate.h"
+
+/**
+ *  CPresencePluginContactStateEnd
+ */
+class CPresencePluginContactStateEnd :
+    public CPresencepluginContactState
+    {
+
+public:
+
+    /**
+     * Constructor
+     */
+    CPresencePluginContactStateEnd( MPresenceContactsContextBase& aContext,
+        CPresencePluginContactStateHandler& aStateHandler );
+
+    virtual ~CPresencePluginContactStateEnd();
+
+    void HandleL();
+
+    };
+
+
+#endif // C_CPRESENCEPLUGINCONTACTSTATEEND_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugincontactstatehandler.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,115 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef C_CPRESENCEPLUGINCONTACTSTATEHANDLER_H
+#define C_CPRESENCEPLUGINCONTACTSTATEHANDLER_H
+
+
+#include <e32base.h>
+
+class CPresencepluginContactState;
+
+/**
+ * States handler
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v5.0
+ */
+class CPresencePluginContactStateHandler : public CBase
+    {
+
+public:
+
+    static CPresencePluginContactStateHandler* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CPresencePluginContactStateHandler();
+    
+    /**
+     * Add states to queue
+     *
+     * @since S60 v5.0
+     * @param aState State to add, ownership is transferred.
+     */
+    void AddStateL( CPresencepluginContactState* aState );
+    
+    /**
+     * Start State machine.
+     * States must be added before
+     *
+     * @since S60 v5.0
+     * @param aStatus Client status
+     */
+    void Start( TRequestStatus* aStatus );
+
+    /**
+     * States are progressed to end
+     * or error occured
+     *
+     * @since S60 v5.0
+     * @param aError Possible error
+     */
+    void Complete( TInt aError );
+    
+    /**
+     * State getter
+     *
+     * @since S60 v5.0
+     * @return State
+     */
+    CPresencepluginContactState* State();
+    
+    /**
+     * Order statehandler to move next state
+     *
+     * @since S60 v5.0
+     */
+    void ProgressToNextState();
+    
+private:
+
+    CPresencePluginContactStateHandler();
+
+    void HandleNextState();
+
+private: // data
+    
+    /**
+     * Current state index
+     * own.
+     */
+    TInt iCurrentStateIndex;
+    
+    /**
+     * States to process
+     * own.
+     */
+    RPointerArray< CPresencepluginContactState > iStateArray;
+    
+    /**
+     * Client status
+     * Not own.
+     */
+    TRequestStatus* iClientStatus;
+
+    };
+
+
+#endif // C_CPRESENCEPLUGINCONTACTSTATEHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugincontactstateopen.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef C_CPRESENCEPLUGINCONTACTSTATEOPEN_H
+#define C_CPRESENCEPLUGINCONTACTSTATEOPEN_H
+
+
+#include "presenceplugincontactstate.h"
+
+/**
+ *  CPresencePluginContactStateOpen
+ * 
+ */
+class CPresencePluginContactStateOpen :
+    public CPresencepluginContactState
+    {
+
+public:
+
+    /**
+     * Constructor
+     */
+    CPresencePluginContactStateOpen( MPresenceContactsContextBase& aContext,
+        CPresencePluginContactStateHandler& aStateHandler );
+
+
+    virtual ~CPresencePluginContactStateOpen();
+
+    void HandleL();
+
+    };
+
+
+#endif // C_CPRESENCEPLUGINCONTACTSTATEOPEN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugincontactstateresolve.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef C_CPRESENCEPLUGINCONTACTSTATERESOLVE_H
+#define C_CPRESENCEPLUGINCONTACTSTATERESOLVE_H
+
+
+#include "presenceplugincontactstate.h"
+
+/**
+ *  CPresencePluginContactStateResolve
+ * 
+ */
+class CPresencePluginContactStateResolve :
+    public CPresencepluginContactState
+    {
+
+public:
+
+    /**
+     * Constructor
+     */
+    CPresencePluginContactStateResolve( MPresenceContactsContextBase& aContext,
+            CPresencePluginContactStateHandler& aStateHandler );
+
+    virtual ~CPresencePluginContactStateResolve();
+
+    void HandleL();
+    
+    void Complete();
+    
+private: // Data
+    
+    TInt iContactLinkIndex;
+
+    TInt iContactLinkCount;
+
+    };
+
+
+#endif // C_CPRESENCEPLUGINCONTACTSTATERESOLVE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugincontactstatesearch.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef C_CPRESENCEPLUGINCONTACTSTATESEARCH_H
+#define C_CPRESENCEPLUGINCONTACTSTATESEARCH_H
+
+
+#include "presenceplugincontactstate.h"
+
+/**
+ *  CPresencePluginContactStateSearch
+ * 
+ */
+class CPresencePluginContactStateSearch :
+    public CPresencepluginContactState
+    {
+
+public:
+
+    /**
+     * Constructor
+     */
+    CPresencePluginContactStateSearch( MPresenceContactsContextBase& aContext,
+            CPresencePluginContactStateHandler& aStateHandler );
+
+    virtual ~CPresencePluginContactStateSearch();
+
+    void HandleL();
+
+    };
+
+
+#endif // C_CPRESENCEPLUGINCONTACTSTATESEARCH_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugindata.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,470 @@
+/*
+* Copyright (c) 2006-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef C_PRESENCEPLUGINDATA_H
+#define C_PRESENCEPLUGINDATA_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include <presenceinfo.h>
+#include <mpresencebuddyinfo2.h>
+
+#include "mpresencepluginconnectionobs.h"
+#include "presencelogger.h"
+
+class MXIMPObjectFactory;
+class MPresenceObjectFactory;
+class MSimpleDocument;
+class MPresenceInfo;
+class MSimplePresenceList;
+class MPresenceInfoFieldCollection;
+class MXIMPObjectCollection;
+class MPersonPresenceInfo;
+class MPresenceInfoField;
+class MSimpleElement;
+class MPresenceCacheWriter2;
+class MPresenceCacheReader2;
+
+/**
+ * CPresencePluginData
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginData ): public CBase
+    {
+    public:
+    
+        /**
+         * Two-phased constructor.
+         *
+         * @param none
+         * @param none
+         */
+        static CPresencePluginData* NewL( 
+			MPresencePluginConnectionObs& aObs,
+			TInt aServiceId );
+
+        /**
+         * Two-phased constructor.
+         *
+         * @param none
+         * @param none
+         */
+        static CPresencePluginData* NewLC( 
+            MPresencePluginConnectionObs& aObs,
+            TInt aServiceId );
+
+        /**
+         * Standard C++ destructor
+         */
+        virtual ~CPresencePluginData();
+
+        /**
+         * Convert to engine notification to MXIMPPresenceInfo
+         *
+         * @since S60 5.0
+         * @param aPresenceFactory object factory
+         * @param aPrInfo ximp info structure [out]
+         * @param aUnicodeNoteContent note field content [out]
+         */
+        void NotifyToBlockedToXIMPL(
+            MPresenceObjectFactory& aPresenceFactory,
+            MPresenceInfo& aPrInfo,
+            const TDesC& aUnicodeNoteContent = KNullDesC );
+
+        /**
+         * Convert to engine notification to MXIMPPresenceInfo
+         *
+         * @since S60 3.2
+         * @param aFactory ximp Factory
+         * @param aPrInfo ximp info structure [out]
+         * @param aUnicodeNoteContent note field content [out]
+         */
+        void NotifyToPendingToXIMPL(
+            MPresenceObjectFactory& aPresenceFactory,
+            MPresenceInfo& aPrInfo,
+            const TDesC& aUnicodeNoteContent = KNullDesC );
+            
+        /**
+         * Convert to engine notification to MXIMPPresenceInfo
+         *
+         * @since S60 3.2
+         * @param aFactory ximp Factory
+         * @param aPrInfo ximp info structure [out]
+         * @param aUnicodeNoteContent note field content [out]
+         */
+        void NotifyTerminatedToXIMPL(
+            MPresenceObjectFactory& aPresenceFactory,
+            MPresenceInfo& aPrInfo,
+            const TDesC& aUnicodeNoteContent = KNullDesC );
+            
+        /**
+         * Convert to engine notification to MXIMPPresenceInfo
+         *
+         * @since S60 3.2
+         * @param aFactory ximp Factory
+         * @param aPrInfo ximp info structure [out]
+         * @param aUnicodeNoteContent note field content [out]
+         * @param aAvailability availability value for cache entry [out]
+         */
+        void NotifyToActiveToXIMPL(
+            MPresenceObjectFactory& aPresenceFactory,
+            MPresenceInfo& aPrInfo,
+            const TDesC& aUnicodeNoteContent = KNullDesC,
+            NPresenceInfo::TAvailabilityValues aAvailability = 
+                NPresenceInfo::EAvailable );
+            
+        /**
+         * Convert to engine notification to MximpPresenceInfo
+         *
+         * @since S60 3.2
+         * @param aFactory ximp Factory
+         * @param aDocument notification
+         * @param aPrInfo ximp info structure [out]
+         */
+        void NotifyToPrInfoL(
+            MXIMPObjectFactory& aFactory,
+            MPresenceObjectFactory& aPresenceFactory,
+            MSimpleDocument& aDocument,
+            MPresenceInfo& aPrInfo );
+           
+        /**
+         * Extracts cache data entries from presence info object.
+         *
+         * @since S60 5.0
+         * @param aPrInfo ximp info structure
+         * @param aAvailability will store cache availability
+         * @param aExtendedAvailability will store extended availability
+         * @param aStatusMessage will store custom status message
+         */            
+        void CacheEntriesFromPrInfo(
+            MPresenceInfo& aPrInfo,
+            MPresenceBuddyInfo2::TAvailabilityValues& aAvailability,
+            TPtr& aExtendedAvailability,
+            TPtr& aStatusMessage );
+
+        /**
+         * Convert to engine list notification to MximpPresenceInfo elements
+         *
+         * @since S60 3.2         
+         * @param aFactory ximp Factory
+         * @param aList notification
+         * @param aEntities array of ximp info structure [out]
+         * @param aTerminated array of ximp info structure for
+         *        terminated  entities [out]
+         */
+        void NotifyListToPrInfoL(
+            MXIMPObjectFactory& aFactory,
+            MPresenceObjectFactory& aPresenceFactory,
+            MSimplePresenceList& aList,
+            RPointerArray<MPresenceInfo>& aEntities,
+            RPointerArray<MXIMPIdentity>& aActives,
+            RPointerArray<MXIMPIdentity>& aTerminated );
+
+        /**
+         * AddPrPersToSimpleDocumentL
+         *
+         * @since S60 3.2         
+         * Add subscribed or blocked person to document
+         * @param aInfo, presence info
+         * @param aDocument, xml document
+         * @param aSipId, sip identity
+         * @param aTupleId, client tupleId
+         */
+        void AddPrPersToSimpleDocumentL(
+            const MPersonPresenceInfo* aInfo,
+            MSimpleDocument& aDocument,
+            const TDesC8& aSipId,
+            TInt aTupleId );
+        
+        /**
+         * Creates document.
+         *
+         * @since S60 3.2         
+         * @param aDocument XDM document
+         * @param aSipId SIP profile id
+         * @param aStatusField, status enum field 
+         * @param aMessageField, message field 
+         */    
+        void DoCreateDocumentL(
+            MSimpleDocument& aDocument,
+            const TDesC8& aSipId,
+            const MPresenceInfoField* aStatusField,
+            const MPresenceInfoField* aMessageField ); 
+        
+        /**
+         * DoCheckBasicStatusValueL
+         *
+         * @since S60 3.2         
+         * @param aField 
+         * @return TPtrC basic status value
+         */ 
+        TPtrC DoCheckBasicStatusValueL(
+        	const MPresenceInfoField& aField );
+        
+        /**
+         * DoCheckActivitiesValueL
+         *
+         * @since S60 3.2         
+         * @param aField 
+         * @return TPtrC activities value
+         */ 
+        TPtrC8 DoCheckActivitiesValueL(
+        	const MPresenceInfoField& aField );
+        
+        /**
+         * DoCheckNoteValueL
+         *
+         * @since S60 3.2         
+         * @param aField 
+         * @return TPtrC activities value
+         */
+        TPtrC DoCheckNoteValueL(
+            const MPresenceInfoField& aField );
+        
+        /**
+         * CreatePresenceUri8LC
+         *
+         * @since S60 3.2
+         * @param aPresentityUri
+         * @return presence URI
+         */ 
+        HBufC8* CreatePresenceUri8LC( 
+            const TDesC8& aPresentityUri );          
+
+        /**
+         * GenerateTupleId()
+         * Generate Tuple id for status document
+         *
+         * @since S60 3.2         
+         * @param none
+         * @return TInt, tupleid
+         */
+        TInt GenerateTupleId();
+        
+           
+        /**
+         * Removes prefix from uri.
+         *
+         * @since S60 3.2
+         * @param aPresentityUri, presentity url
+         * @return HBufC16, URL without prefix
+         */            
+        HBufC16* RemovePrefixLC( 
+            const TDesC& aPresentityUri );
+            
+        /**
+         * Returns service id.
+         *
+         * @since S60 5.0
+         * @return TInt, service id related to this data instance
+         */            
+        TInt ServiceId();            
+        
+        /**
+         * Resolve service name
+         * 
+         * @since   S60 5.0
+         * @param   aServiceId Service Id.
+         * @return  resolved service name, ownership returned to caller
+         */
+        HBufC* ServiceNameLC( TInt aServiceId ) const;
+        
+        /**
+         * Writes status to presence cache
+         *
+         * @since S60 5.0
+         * @param aPresentityId, identity of status
+         * @param aAvailability, availability value to set
+         * @param aAvailabilityText, text for extended states
+         * @param aStatusMessage, status message from remote party
+         * @return None
+         */                    
+        void WriteStatusToCacheL(
+            const TDesC& aPresentityId, 
+            MPresenceBuddyInfo2::TAvailabilityValues aAvailability,
+            const TDesC& aAvailabilityText,
+            const TDesC& aStatusMessage );
+            
+        /**
+         * Removes cache entries for this service.
+         *
+         * @since S60 5.0
+         * @return None
+         */                             
+        void RemoveCacheL();
+        
+        /**
+         * Removes cache entries for certain person.
+         *
+         * @since S60 5.0
+         * @param aIdentity, identity of presence entry
+         * @return None
+         */                                     
+        void DeletePresenceL( const TDesC& aIdentity );
+        
+        /**
+         * Stores own presence values to permanent storage.
+         *
+         * @since S60 5.0
+         * @param aServiceId, service id
+         * @param aAvailability, availability enumeration
+         * @param aStatusMessage, custom status message
+         * @return None
+         */                                             
+        void StorePresenceOwnPresenceL(
+            const TUint aServiceId, 
+            NPresenceInfo::TAvailabilityValues aAvailability,
+            const TDesC& aStatusMessage );
+            
+        /**
+         * Reads document id from permanent storage.
+         *
+         * @since S60 5.0
+         * @param aServiceId, service id
+         * @param aDocumentId, document id
+         * @return None
+         */                                   
+        void ReadDocumentIdL(
+            const TInt aServiceId, 
+            TDes8& aDocumentId );
+            
+        /**
+         * Deletes permanent data from storage
+         *
+         * @since S60 5.0
+         * @param aServiceId, service id
+         * @return None
+         */                                               
+        void DeletePresenceVariablesL( const TInt aServiceId );
+        
+    private:
+
+        /**
+         * Standard C++ constructor
+         */ 
+        CPresencePluginData( 
+            MPresencePluginConnectionObs& aObs,
+            TInt aServiceId );
+            
+        /**
+         * Standard C++ constructor
+         */             
+        void ConstructL();
+        
+        /**
+         * UserNoteToXIMPL
+         *
+         * @since S60 3.2 
+         * This method not yet used
+         * @param aPresenceFactory ximp Factory
+         * @param aElement Simple elemnt
+         * @param aCollection Field Collection
+         */ 
+        void UserNoteToXIMPL(
+            MPresenceObjectFactory& aPresenceFactory,
+            MSimpleElement* aElement,
+            MPresenceInfoFieldCollection& aCollection );
+        
+        /**
+         * SingleUserStatusToXIMPL
+         *
+         * @since S60 3.2          
+         * @param aPresenceFactory ximp Factory
+         * @param aElement Simple element
+         * @param aActivitiesElement Simple element
+         * @param aNoteElement Simple element for note elems (can be null)
+         * @param aCollection Field Collection
+         */     
+        void SingleUserStatusToXIMPL(
+            MPresenceObjectFactory& aPresenceFactory,
+            MSimpleElement* aBasicElement,
+            MSimpleElement* aActivitiesElement,
+            MSimpleElement* aNoteElement,
+            MPresenceInfoFieldCollection& aCollection );
+        
+        /**
+         * Returns <note> element or NULL if no <note> is found in the given 
+         * element list. <note> element which matches best current locale is 
+         * returned.
+         * 
+         * @since   S60 5.1
+         * @param   aElements   Element array.
+         * @return  Best matching <note> or NULL.
+         */
+        MSimpleElement* ResolveNoteElementL( 
+            const RPointerArray<MSimpleElement>& aElements ) const;
+        
+        /**
+         * Checks if element has language attribute compatible with the 
+         * current locale.
+         *
+         * @since   S60 5.1
+         * @param   aElement    Simple element containing language attribute.
+         * @return  ETrue if compatible language attribute is found, 
+         *          EFalse otherwise.
+         */ 
+        TBool IsElementLanguageValidForCurrentLocaleL( 
+            MSimpleElement& aElement ) const;
+        
+        /**
+         * Resolve cache used identifier
+         * 
+         * @since   S60 5.0
+         * @param   aIdentity presence id without prefix
+         * @return  resolved cache identifier, ownership returned to caller
+         */
+        HBufC* ResolveCacheXspIdentifierL( const TDesC& aIdentity ) const;
+        
+        
+    private: // data
+
+        /**
+         * Generated tuple/person id
+         * Own.
+         */
+        TInt  iNumBuf;
+
+        /**
+         * ximp Plugin connection observer
+         * Not Own.
+         */
+        MPresencePluginConnectionObs& iConnObs;
+        
+        /**
+         * Stores service id.
+         */        
+        TInt iServiceId;
+        
+        /**
+         * Writes service status to presence cache.
+         * Own.
+         */        
+        MPresenceCacheWriter2* iPresenceCacheWriter;
+              
+        /**
+         * Reads service status from presence cache.
+         * Own.
+         */        
+        MPresenceCacheReader2* iPresenceCacheReader;  
+        
+        SIMPLE_UNIT_TEST( T_CPresencePluginData )
+    };
+
+#endif //C_PRESENCEPLUGINDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugindef.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+#ifndef PRESENCEPLUGINDEF_H
+#define PRESENCEPLUGINDEF_H
+
+#include <e32std.h>
+
+
+/**
+ * C++ compatible definitions for XIMP PRESENCE protocol.
+ *
+ * This must be kept in-sync with definitions in
+ * "simpleplugin_resource.hrh"
+ */
+
+//XIMP primary test protocol
+const TInt K_PRESENCEPLUGIN_1_VERSION_NO          = 1;
+_LIT( K_PRESENCEPLUGIN_1_DISPLAY_NAME,            "XIMP PRESENCE protocol" );
+_LIT( K_PRESENCEPLUGIN_1_DEFAULT_DATA,            "PRESENCE" );
+_LIT( K_PRESENCEPLUGIN_1_OPAQUE_DATA ,             "<p>Nokia<f>feat/pres/pub<f>feat/pres/fetch<f>feat/pres/subs<s>sip" );
+
+
+#endif // PRESENCEPLUGINDEF_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginentitywatcher.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,301 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCEPLUGINENTITYWATCHER_H
+#define CPRESENCEPLUGINENTITYWATCHER_H
+
+#include <e32base.h>
+#include <ximpbase.h>
+#include <protocolpresencewatching.h>
+#include <msimplewatcherobserver.h>
+#include "presenceplugincommon.h"
+#include "mpresencepluginconnectionobs.h"
+#include "presencelogger.h"
+
+class TXIMPRequestId;
+class MSimpleDocument;
+class MSimpleWatcher;
+class CPresencePluginWatcher;
+class MSimpleConnection;
+class CPresencePluginData;
+ 
+/**
+ * CPresencePluginEntityWatcher
+ *
+ * Simple Engine Connection
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginEntityWatcher ): public CBase,
+    public MSimpleWatcherObserver
+    {
+    private:
+        
+    /**
+    * Current operation
+    */
+	enum TPluginEntityWatcherOperation
+        {
+        EPluginIdle,
+        EPluginStop,
+        EPluginStart,
+        EPluginModify,
+        EPluginStartNotifyClient
+        };
+            
+    public:
+       
+        /**
+         * Constructor.
+         * @param aObs callback for complete requests
+         * @param aConn Simple Engine connection
+         * @param aHost XIMP connection host 
+         */ 
+        static CPresencePluginEntityWatcher* NewL(
+            MPresencePluginConnectionObs& aObs,
+            MSimpleConnection& aConn,
+       		CPresencePluginWatcher& aWatcher,
+        	CPresencePluginData* aPresenceData );
+        	
+        /**
+         * Standard C++ destructor
+         */
+        virtual ~CPresencePluginEntityWatcher();
+      
+        /**
+         * Access Request id
+         *
+         * @since S60 3.2 
+         * @return XIMP request id
+         */
+        TXIMPRequestId XIMPRequestId();
+        
+        /**
+         * Access Presentity id
+         *
+         * @since S60 3.2 
+         * @return Presentity id
+         */    
+         TPtrC8 PresentityId(); 
+        
+        /**
+         * Start subscribe
+         *
+         * @since S60 3.2 
+         * @param aPresentityId presentity id
+         */
+        void StartSubscribeL( const TDesC8& aPresentityId );  
+        
+        /**
+         * Start subscribe
+         *
+         * @since S60 5.0
+         * @param aPresentityId presentity id
+         * @param aClientRequst client status to complete
+         */        
+        void StartSubscribeL(
+            const TDesC8& aPresentityId, 
+            TRequestStatus& aClientRequst );
+        
+        /**
+         * Stop Subscrib
+         *
+         * @since S60 3.2 
+		 * @param none
+         * @return none         
+         */
+        void StopSubscribeL();
+        
+        /**
+         * Stop subscribe
+         *
+         * @since S60 5.0
+         * @param aClientRequst client status to complete
+         */                
+        void StopSubscribeL( 
+            TRequestStatus& aClientRequst );
+        
+        /**
+         * Set active status to XIMP
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void SetActiveToXIMPL( const TDesC& aIdentity );
+        
+        /**
+         * Set terminated status to XIMP
+         *
+         * @since S60 3.2
+         * @param aIdentity identity
+         * @return none
+         */
+        void SetTerminatedToXIMPL( const TDesC& aIdentity );
+        
+    private:
+    
+        /**
+         * Standard C++ constructor
+         * 
+         * @param aObs, connection observer
+         * @param aConn, SIMPLE connection
+         * @param aWatcher, plugin watcher
+         */ 
+        CPresencePluginEntityWatcher(
+            MPresencePluginConnectionObs& aObs,
+            MSimpleConnection& aConn,
+            CPresencePluginWatcher& aWatcher );
+
+        /**
+         * Performs the 2nd phase of construction.
+         *
+         * @since S60 3.2 
+         * @param none
+         * @param none
+         */ 
+        void ConstructL( CPresencePluginData* aPresenceData );
+
+    public: // from base class MSimpleWatcherObserver
+
+        /**
+         * Defined in a base class
+         */
+        void WatcherReqCompleteL( TInt aOpId, TInt aStatus );
+
+        /**
+         * Defined in a base class
+         */
+        void WatcherNotificationL( MSimpleDocument& aDocument );
+
+        /**
+         * Defined in a base class
+         */
+        void WatcherListNotificationL( MSimplePresenceList& aList );
+
+        /**
+         * Defined in a base class
+         */
+        void WatcherTerminatedL(
+            TInt aOpId, TInt aReason );
+                
+    private:
+        
+        /**
+         * Set active status to XIMP
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void SetActiveToXIMPL( MSimpleDocument& aDocument );
+        
+        /**
+         * Set terminated status to XIMP
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void SetTerminatedToXIMPL( );
+        
+        /**
+         * Set pending status to XIMP
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void SetPendingToXIMPL( );
+
+        /**
+         * Completes client request
+         *
+         * @since S60 5.0
+         * @param aStatus, complete code
+         * @return none
+         */
+        void CompleteClientReq( TInt aStatus );
+           
+    private: // Data
+
+        /**
+         * XIMP Plugin connection observer
+         */
+        MPresencePluginConnectionObs& iConnObs;
+        
+        /**
+         * SIMPLE engine connection
+         * Not Own.
+         */
+        MSimpleConnection& iConnection;
+        
+        /**
+         * SIMPLE engine watcher
+         * Own.
+         */
+        MSimpleWatcher* iWatcher;    
+        
+        /**
+         * PrFW request id
+         * Own.
+         */
+        TXIMPRequestId iXIMPId;
+        
+        /**
+         * Subscribed entity Id.
+         * Own.
+         */
+        HBufC8* iEntityId; 
+             
+        /**
+         * Simple Engine request id
+         * Own.
+         */
+        TInt iSimpleId;
+                          
+        /**
+         * host class
+         * Own.
+         */
+        CPresencePluginWatcher& iPluginWatcher;
+        
+        /**
+         * current pending operation
+         * Own.
+         */
+        TPluginEntityWatcherOperation iOperation;
+        
+        /**
+         * instance to Presence data
+         * Own.
+         */
+        CPresencePluginData* iPresenceData;
+
+        /**
+         * Client status.
+         * Not own.
+         */
+        TRequestStatus* iClientStatus;                
+
+        SIMPLE_UNIT_TEST( T_CPresencePluginEntityWatcher )
+        SIMPLE_UNIT_TEST( T_CPresencePluginWatcher )        
+    };
+
+#endif // CPRESENCEPLUGINENTITYWATCHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presenceplugingroup.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,428 @@
+/*
+* Copyright (c) 2006-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCEPLUGINGROUP_H
+#define CPRESENCEPLUGINGROUP_H
+
+#include <e32base.h>
+#include <ximpbase.h>
+#include <protocolpresentitygroups.h>
+
+#include "presenceplugincommon.h"
+#include "mpresencepluginconnectionobs.h"
+#include "presencelogger.h"
+
+class TXIMPRequestId;
+class MXIMPIdentity;
+class MXIMPProtocolPresentityGroupsDataHost;
+class MXIMPObjectCollection;
+class CPresencePluginVirtualGroup;
+class CPresencePluginData;
+
+/**
+ * CPresencePluginGroups
+ *
+ * Simple Engine Connection
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginGroups ) : public CActive,
+    public MProtocolPresentityGroups
+    {
+    public:
+
+        /**
+         * Current operation
+         */
+        enum TPluginGroupsOperation
+            {
+            ENoOperation,
+            ECreatePresentityGroup,
+            EDeletePresentityGroup,
+            EAddPresentityGroupMember,
+            EGrantPresentityGroupMember,
+            ERemovePresentityGroupMember,
+            EWithdrawGrantFromMember,
+            EGetListOfLists,
+            EGetListContent,
+            EBlockPresentityGroupMember,
+            EUnblockPresentityGroupMember,
+            EUnblockInAddPresentityGroupMember
+            };
+
+        /**
+         * Current actibe object state
+         */
+        enum TPluginGroupsState
+            {
+            EPluginIdle,
+            EPluginInitXdm,
+            EPluginFetchRls,
+            EPluginAddGroupMember,
+            EPluginRemoveGroupMember,
+            EPluginCommitRls,
+            EPluginCommitXdm
+            };
+
+        /**
+         * Constructor.
+         * @param aObs callback for complete requests
+         * @param aConn Simple Engine connection
+         */
+        static CPresencePluginGroups* NewL(
+            MPresencePluginConnectionObs& aObs,
+            CPresencePluginVirtualGroup* aSubscribedBuddies,
+            CPresencePluginData* aPresenceData );
+
+        /**
+         * Constructor.
+         * @param aObs callback for complete requests
+         * @param aConn Simple Engine connection
+         */
+        static CPresencePluginGroups* NewLC(
+            MPresencePluginConnectionObs& aObs,
+            CPresencePluginVirtualGroup* aSubscribedBuddies,
+            CPresencePluginData* aPresenceData );
+
+        /**
+         * Standard C++ destructor
+         */ 
+        virtual ~CPresencePluginGroups();
+
+    private:
+    
+        /**
+         * Standard C++ constructor
+         */
+        CPresencePluginGroups(
+            MPresencePluginConnectionObs& aObs,
+            CPresencePluginVirtualGroup* aSubscribedBuddies,
+            CPresencePluginData* aPresenceData );
+
+    public: // from base class MXIMPBase
+
+        /**
+         * Defined in a base class
+         */
+        TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps );
+
+        /**
+         * Defined in a base class
+         */
+        const TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps ) const;
+
+        /**
+         * Defined in a base class
+         */
+        TInt32 GetInterfaceId() const;
+
+
+    public: // from base class MXIMPProtocolPresentityGroups
+
+        /**
+         * Defined in a base class
+         */
+        void DoSubscribePresentityGroupListL(
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUnsubscribePresentityGroupListL(
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoCreatePresentityGroupL(
+            const MXIMPIdentity& aGroupId,
+            const TDesC16& aDisplayName,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoDeletePresentityGroupL(
+            const MXIMPIdentity& aGroupId,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUpdatePresentityGroupDisplayNameL(
+            const MXIMPIdentity& aGroupId,
+            const TDesC16& aDisplayName,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoSubscribePresentityGroupContentL(
+            const MXIMPIdentity& aGroupId,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUnsubscribePresentityGroupContentL(
+            const MXIMPIdentity& aGroupId,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoAddPresentityGroupMemberL(
+            const MXIMPIdentity& aGroupId,
+            const MXIMPIdentity& aMemberId,
+            const TDesC16& aMemberDisplayName,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoRemovePresentityGroupMemberL(
+            const MXIMPIdentity& aGroupId,
+            const MXIMPIdentity& aMemberId,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUpdatePresentityGroupMemberDisplayNameL(
+            const MXIMPIdentity& aGroupId,
+            const MXIMPIdentity& aMemberId,
+            const TDesC16& aMemberDisplayName,
+            TXIMPRequestId aReqId );
+
+    protected: // from base class CActive
+
+        /**
+         * Defined in a base class
+         */
+        void RunL();
+
+        /**
+         * Defined in a base class
+         */
+        TInt RunError( TInt aError );
+
+        /**
+         * Defined in a base class
+         */
+        void DoCancel();
+
+    private:
+
+        /**
+         * Save presentity id
+         *
+         * @since S60 3.2 
+         * @param aPresentityId presentity id
+         * @param aFormatUri, attempt to format uri
+         * @return none
+         */
+        void SetPresIdentityL(
+            const MXIMPIdentity& aPresentityId,
+            TBool aFormatUri );
+
+        /**
+         * Calls MXIMPProtocolConnectionHost callback
+         *
+         * @since S60 3.2 
+         * @param aStatus error status
+         * @return none
+         */
+        void CompleteXIMPReq( TInt aStatus );
+
+        /**
+         * Start XDM operation
+         *
+         * @since S60 3.2 
+         * @param aReqId, request id
+         * @param aOperation, groups operation
+         * @return none
+         */
+        void StartXdmOperationL(
+            TXIMPRequestId aReqId,
+            TPluginGroupsOperation aOperation );
+
+        /**
+         * Start XDM operation
+         *
+         * @since S60 3.2 
+         * @param aReqId, request id
+         * @param aOperation, groups operation
+         * @return none
+         */
+        void StartXdmOperationL(
+            const MXIMPIdentity& aId,
+            TXIMPRequestId aReqId,
+            TPluginGroupsOperation aOperation );
+
+        /**
+         * Start XDM operation
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return none
+         */
+        void StartXdmOperationL();
+
+        /**
+         * Call actual XDM operation
+         *
+         * @since S60 3.2 
+         * @param aCompleteStatus, success or not
+         * @return none
+         */
+        void CallActualXdmOperationL( TInt aCompleteStatus );
+
+        /**
+         * Get List of lists
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return none
+         */
+        void GetListOfListsL();
+
+        /**
+         * Get List content
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return none
+         */
+        void GetListContentL();
+
+        /**
+         * Do Get BuddyList form XDM list
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return none
+         */
+        void DoGetBuddyListL();
+        
+        /**
+         * Do Get subscribed BuddyList form virtual list
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return none
+         */
+        void DoGetSubscribedBuddyListL();
+        
+        /**
+         * Removes cache entries for certain person.
+         *
+         * @since S60 5.0
+         * @param none
+         * @return none
+         */        
+        void DeletePersonCacheL();
+
+    private:  // Data
+
+        /**
+         * XIMP Plugin connection observer
+         * Own.
+         */
+        MPresencePluginConnectionObs& iConnObs;
+
+        /**
+         * XDM Settings id
+         * Own.
+         */
+        TInt iSettingsId;
+
+        /**
+         * PrFW request id
+         * Own.
+         */
+        TXIMPRequestId iXIMPId;
+
+        /**
+         * PrFW request id for own requests
+         * Own.
+         */
+        TXIMPRequestId iXIMPIdOwn;
+
+        /**
+         * Simple Engine request id
+         * Own.
+         */
+        TInt iSimpleId;
+
+        /**
+         * Current operation
+         * Own.
+         */
+        TPluginGroupsOperation iOperation;
+
+        /**
+         * Current presentity in progress
+         * Own.
+         */
+        HBufC16* iPresIdentity;
+
+        /**
+         * XDM Utils
+         * Not own.
+         */
+        CPresencePluginXdmUtils* iXdmUtils;
+
+        /**
+         * Display name
+         * Own
+         */
+        HBufC* iDisplayName;
+        
+        /**
+         * Active object state
+         * Own.         
+         */
+        TPluginGroupsState iState;
+        
+        /**
+         * Group request complete
+         * Own.         
+         */
+        TBool iCompleted;
+        
+        /**
+         * Virtual groups
+         * Not Own
+         */
+        CPresencePluginVirtualGroup* iSubscribedBuddies;
+        
+        /**
+         * Plugin data.
+         * Not Own
+         */        
+        CPresencePluginData*    iPresenceData;
+        
+        SIMPLE_UNIT_TEST( T_CPresencePluginGroups )
+    };
+
+#endif // CPRESENCEPLUGINGROUP_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginlanguagecodes.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,184 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef T_PRESENCEPLUGINLANGUAGECODES_H
+#define T_PRESENCEPLUGINLANGUAGECODES_H
+
+#include <e32base.h>
+
+/** ISO 639-1 language code length. */
+const TInt KIsoLanguageCodeLength = 2;
+
+/**
+ *  Maps Symbian and ISO 639 language codes.
+ *
+ *  @since S60 v5.1
+ */
+class TLanguageCodeMapping
+    {
+
+public:
+
+    /**
+     * Returns Symbian language code.
+     * 
+     * @since   S60 5.1
+     * @return  Symbian language code.
+     */
+    TInt SymbianLanguageCode() const 
+        { return iSymbianLanguageCode; }
+    
+    /**
+     * Returns ISO language code.
+     * 
+     * @since   S60 5.1
+     * @return  ISO language code.
+     */
+    TPtrC8 IsoLanguageCode() const
+        { return TPtrC8( iIsoLanguageCode ); }
+    
+public: // data
+
+    /**
+     * Symbian language code as specified in e32lang.h.
+     */
+    TInt iSymbianLanguageCode;
+    
+    /**
+     * ISO 639 language code.
+     */
+    TText8 iIsoLanguageCode[__Align8( KIsoLanguageCodeLength + sizeof( "" ) )];
+    };
+
+/** Mapping table for Symbian and ISO 639 language codes. */
+static const TLanguageCodeMapping KLanguageCodeMappings[] =
+    {
+        { ELangEnglish,             "en" },
+        { ELangFrench,              "fr" },
+        { ELangGerman,              "de" },
+        { ELangSpanish,             "es" },
+        { ELangItalian,             "it" },
+        { ELangSwedish,             "sv" },
+        { ELangDanish,              "da" },
+        { ELangNorwegian,           "no" },
+        { ELangFinnish,             "fi" },
+        { ELangAmerican,            "en" },
+        { ELangSwissFrench,         "fr" },
+        { ELangSwissGerman,         "de" },
+        { ELangPortuguese,          "pt" },
+        { ELangTurkish,             "tr" },
+        { ELangIcelandic,           "is" },
+        { ELangRussian,             "ru" },
+        { ELangHungarian,           "hu" },
+        { ELangDutch,               "nl" },
+        { ELangBelgianFlemish,      "nl" },
+        { ELangAustralian,          "en" },
+        { ELangBelgianFrench,       "fr" },
+        { ELangAustrian,            "de" },
+        { ELangNewZealand,          "en" },
+        { ELangInternationalFrench, "fr" },
+        { ELangCzech,               "cs" },
+        { ELangSlovak,              "sk" },
+        { ELangPolish,              "pl" },
+        { ELangSlovenian,           "sl" },
+        { ELangTaiwanChinese,       "zh" },
+        { ELangHongKongChinese,     "zh" },
+        { ELangPrcChinese,          "zh" },
+        { ELangJapanese,            "ja" },
+        { ELangThai,                "th" },
+        { ELangArabic,              "ar" },
+        { ELangAfrikaans,           "af" },
+        { ELangAlbanian,            "sq" },
+        { ELangAmharic,             "am" },
+        { ELangArabic,              "ar" },
+        { ELangArmenian,            "hy" },
+        { ELangTagalog,             "tl" },
+        { ELangBelarussian,         "be" },
+        { ELangBengali,             "bn" },
+        { ELangBulgarian,           "bg" },
+        { ELangBurmese,             "my" },
+        { ELangCatalan,             "ca" },
+        { ELangCroatian,            "hr" },
+        { ELangCanadianEnglish,     "en" },
+        { ELangInternationalEnglish,"en" },
+        { ELangSouthAfricanEnglish, "en" },
+        { ELangEstonian,            "et" },
+        { ELangFarsi,               "fa" },
+        { ELangCanadianFrench,      "fr" },
+        { ELangScotsGaelic,         "gd" },
+        { ELangGeorgian,            "ka" },
+        { ELangGreek,               "el" },
+        { ELangCyprusGreek,         "el" },
+        { ELangGujarati,            "gu" },
+        { ELangHebrew,              "he" },
+        { ELangHindi,               "hi" },
+        { ELangIndonesian,          "id" },
+        { ELangIrish,               "ga" },
+        { ELangSwissItalian,        "it" },
+        { ELangKannada,             "kn" },
+        { ELangKazakh,              "kk" },
+        { ELangKhmer,               "km" },
+        { ELangKorean,              "ko" },
+        { ELangLao,                 "lo" },
+        { ELangLatvian,             "lv" },
+        { ELangLithuanian,          "lt" },
+        { ELangMacedonian,          "mk" },
+        { ELangMalay,               "ms" },
+        { ELangMalayalam,           "ml" },
+        { ELangMarathi,             "mr" },
+        { ELangMoldavian,           "mo" },
+        { ELangMongolian,           "mn" },
+        { ELangNorwegianNynorsk,    "no" },
+        { ELangBrazilianPortuguese, "pt" },
+        { ELangPunjabi,             "pa" },
+        { ELangRomanian,            "ro" },
+        { ELangSerbian,             "sr" },
+        { ELangSinhalese,           "si" },
+        { ELangSomali,              "so" },
+        { ELangInternationalSpanish,"es" },
+        { ELangLatinAmericanSpanish,"es" },
+        { ELangSwahili,             "sw" },
+        { ELangFinlandSwedish,      "sv" },
+        { ELangTamil,               "ta" },
+        { ELangTelugu,              "te" },
+        { ELangTibetan,             "bo" },
+        { ELangTigrinya,            "ti" },
+        { ELangCyprusTurkish,       "tr" },
+        { ELangTurkmen,             "tk" },
+        { ELangUkrainian,           "uk" },
+        { ELangUrdu,                "ur" },
+        { ELangVietnamese,          "vi" },
+        { ELangWelsh,               "cy" },
+        { ELangZulu,                "zu" },
+        { ELangManufacturerEnglish, "en" },
+        { ELangSouthSotho,          "st" },
+        { ELangBasque,              "eu" },
+        { ELangGalician,            "gl" },
+        { ELangEnglish_Apac,        "en" },
+        { ELangEnglish_Taiwan,      "en" },
+        { ELangEnglish_HongKong,    "en" },
+        { ELangEnglish_Prc,         "en" },
+        { ELangEnglish_Japan,       "en" },
+        { ELangEnglish_Thailand,    "en" },
+        { ELangMalay_Apac,          "ms" }
+    };
+
+/** Number of language code mappings. */
+static const TInt KLanguageCodeMappingsCount =
+    sizeof ( KLanguageCodeMappings ) / sizeof ( TLanguageCodeMapping );
+
+#endif // T_PRESENCEPLUGINLANGUAGECODES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginlocalstore.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,113 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef C_CPRESENCEPLUGINLOCALSTORE_H
+#define C_CPRESENCEPLUGINLOCALSTORE_H
+
+
+#include <e32base.h>
+#include <d32dbms.h>
+#include <s32file.h>
+
+
+/**
+ * Service contacts local store reader
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v5.0
+ */
+class CPresencePluginLocalstore : public CBase
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aServiceName Service name
+     */
+    static CPresencePluginLocalstore* NewL( const TDesC& aServiceName );
+
+    /**
+     * Two-phased constructor.
+     * @param aServiceName Service name
+     */
+    static CPresencePluginLocalstore* NewLC( const TDesC& aServiceName );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CPresencePluginLocalstore();
+
+    /**
+     * Seeks given id at contact column
+     *
+     * @since S60 v5.0
+     * @param aIdentifier Id. to search
+     * @return ETrue if found
+     */
+    TBool SeekRowAtContactColL( TInt32& aIdentifier );
+
+private:
+	  
+    CPresencePluginLocalstore();
+	  
+    void ConstructL( const TDesC& aServiceName );
+
+    TBool DbExists();
+
+    void OpenDbL();
+
+private: // data
+
+    /**
+     * File stream
+     */
+    RFs iFs;
+    
+    /**
+     * Store database
+     */
+    RDbStoreDatabase iDb;
+    
+    /**
+     * Table
+     */
+    RDbTable iTable;
+    
+    /**
+     * Column definitions
+     * Own.
+     */
+    CDbColSet* iColset;
+
+    /**
+     * DB Store
+     * Own.
+     */
+    CPermanentFileStore* iFileStore;
+
+    /**
+     * Local database name
+     * Own.
+     */
+    HBufC* iLocalDBName;
+
+    };
+
+
+#endif // C_CPRESENCEPLUGINLOCALSTORE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginpublisher.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,512 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCEPLUGINPUBLISHER_H
+#define CPRESENCEPLUGINPUBLISHER_H
+
+#include <e32base.h>
+
+#include <ximpbase.h>
+#include <protocolpresencepublishing.h>
+#include <msimplepublishobserver.h>
+#include <msimplewatcherobserver.h>
+#include <mpresencebuddyinfo2.h>
+#include <presenceinfo.h>
+
+#include "presencepluginentitywatcher.h"
+#include "presenceplugincommon.h"
+#include "mpresencepluginconnectionobs.h"
+#include "msimpleetagobserver.h"
+#include "presencelogger.h"
+
+class TXIMPRequestId;
+class MXIMPProtocolConnectionHost;
+class MPersonPresenceInfo;
+class MServicePresenceInfo;
+class MDevicePresenceInfo;
+class MSimplePublisher;
+class MSimpleDocument;
+class MSimpleElement;
+class MSimpleWatcher;
+class CPresencePluginXdmUtils;
+class CPresencePluginData;
+class CPresencePluginWatcherInfo;
+
+/**
+ * CPresencePluginPublisher
+ *
+ * Simple Engine Connection
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginPublisher ): public CActive,
+    public MSimplePublishObserver,
+    public MSimpleWatcherObserver,
+    public MProtocolPresencePublishing,
+    public MSimpleETagObserver
+    {
+    public:
+
+        /**
+         * Current operation
+         */
+        enum TPluginPublishOperation
+            {
+            ENoOperation,
+            EPublishOwn,
+            ESubscribeOwn,
+            EUnsubscribeOwn,
+            ESubscribeWinfo,
+            EUnsubscribeWinfo,
+            EPublishReq
+            };     
+
+        /**
+         * NewL
+         * @param aObs callback for complete requests
+         * @param aConn Simple Engine connection
+         */ 
+        static CPresencePluginPublisher* NewL(
+            MPresencePluginConnectionObs& aObs,
+            MSimpleConnection& aConn,
+            CPresencePluginData* aPresenceData );
+            
+        /**
+         * Standard C++ destructor
+         */
+        virtual ~CPresencePluginPublisher();
+        
+        /**
+         * WinfoTerminatedL
+         * 
+         * SIMPLE Winfo watcher sunscription is terminated
+         * @param aReason reason code
+         */
+        void WinfoTerminatedL( TInt aReason );
+         
+        /** 
+         * WINFO received from SIMPLE
+         * @param aWinfo WINFO
+         */
+        void WinfoNotificationL( MSimpleWinfo& aWinfo );
+    
+    private:
+    
+        /**
+         * Standard C++ constructor
+         * @param aObs, connection observer
+         * @param aConn, SIMPLE connection 
+         */ 
+        CPresencePluginPublisher(
+            MPresencePluginConnectionObs& aObs,
+            MSimpleConnection& aConn );
+            
+        /**
+         * Performs the 2nd phase of construction.
+         */ 
+        void ConstructL( CPresencePluginData* aPresenceData );
+    
+    public: //Own public methods
+
+        /**
+         * StopPublishL()
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return none
+         */
+        void StopPublishL( TRequestStatus& aStatus ); 
+        
+        /**
+         * Published()
+         *
+         * @since S60 3.2 
+         * @param none
+         * @return none
+         */
+        TBool Published();
+
+    public:  // from MSimpleETagObserver
+
+	    /**
+	     * Defined in a base class
+	     */
+        void NewETagL( const TDesC8& aVal );
+
+    public: // from base class MSimplePublishObserver
+
+        /**
+         * Defined in a base class
+         */
+        void PublishReqCompleteL( TInt aOpid, TInt aStatus);
+
+        /**
+         * Defined in a base class
+         */
+        void PublishTerminatedL( TInt aOpid );
+    
+    public: // from base class MSimpleWatcherObserver
+
+        /**
+         * Defined in a base class
+         */
+        void WatcherReqCompleteL( TInt aOpId, TInt aStatus );
+
+        /**
+         * Defined in a base class
+         */
+        void WatcherNotificationL( MSimpleDocument& aDocument );
+
+        /**
+         * Defined in a base class
+         */
+        void WatcherListNotificationL( MSimplePresenceList& aList );
+
+        /**
+         * Defined in a base class
+         */
+        void WatcherTerminatedL(
+            TInt aOpId, TInt aReason );
+       
+    public: // from base class MximpBase
+
+        /**
+         * Defined in a base class
+         */
+        TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps );
+
+        /**
+         * Defined in a base class
+         */
+        const TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps ) const;
+
+        /**
+         * Defined in a base class
+         */
+        TInt32 GetInterfaceId() const;
+    
+    public:     // from base class MximpProtocolPresencePublishing
+
+        /**
+         * Defined in a base class
+         */
+        void DoPublishOwnPresenceL(
+            const MPresenceInfo& aOwnPresence,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoSubscribeOwnPresenceL(
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUpdateOwnPresenceSubscriptionPifL(
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUnsubscribeOwnPresenceL(
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoSubscribePresenceWatcherListL(
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUnsubscribePresenceWatcherListL(
+            TXIMPRequestId aReqId );
+
+    protected: // from base class CActive
+
+        /**
+         * Defined in a base class
+         */
+        void RunL();
+
+        /**
+         * Defined in a base class
+         */
+        TInt RunError( TInt aError );
+
+        /**
+         * Defined in a base class
+         */
+        void DoCancel();
+
+    private:
+          
+        /**
+         * Calls MximpProtocolConnectionHost callback
+         *
+         * @since S60 3.2          
+         * @param aStatus error status     
+         */
+        void CompleteXIMPReq( TInt aStatus );
+        
+        /**
+         * Complete client request
+         *
+         * @since S60 3.2          
+         * @param aStatus error status     
+         */
+        void CompleteClientReq( TInt aStatus );
+        
+        /**
+         * Initialize a document
+         */
+        void InitializeSimpleDocumentL( );    
+        
+        /**
+         * Add person information to the document.
+         *
+         * @since S60 3.2         
+         * @param aPersInfo personal information
+         */
+        void AddSimpleDocumentPersL( 
+            const MPersonPresenceInfo* aInfo );
+                       
+        /**
+         * Make a publish request
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none 
+         */    
+        void MakePublishReqL();            
+        
+        /**
+         * Start XDM initialization
+         *
+         * @since S60 3.2
+         * @param aReqId, XIMP request id           
+         */
+        void StartXdmOperationL( TXIMPRequestId aReqId );
+        
+        /**
+         * Delete watcher information
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none         
+         */
+        void DeleteWatchers();  
+        
+        /**
+         * Add Watcher if not exist
+         *
+         * @since S60 3.2
+         * @param aId, watcher identity
+         * @param aSipId, watcher sip URL
+         * @return none
+         */ 
+        void AddWatcherIfNotExistsL( 
+            const TDesC8& aId, 
+            const TDesC& aSipId );
+         
+        /**
+         * Remove Watcher if not exist
+         *
+         * @since S60 3.2
+         * @param aId, watcher identity
+         * @param aSipId, watcher sip URL
+         * @return none
+         */    
+        void RemoveWatcherIfExists( 
+            const TDesC8& aId, 
+            const TDesC& aSipId );
+        
+        /**
+         * Make current watcher list
+         *
+         * @since S60 3.2
+         * @param none
+         * @return CDesCArrayFlat, watcher array
+         */ 
+        CDesCArrayFlat* MakeCurrentWatcherListLC(); 
+        
+        /**
+         * Collect watcher from winfo
+         *
+         * @since S60 3.2
+         * @param aElems element array
+         * @return none
+         */
+        void CollectWatchersL(  
+			RPointerArray<MSimpleElement>& aElems );
+        
+        /**
+         * CreatePublisherL()
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void CreatePublisherL();
+		
+        /**
+         * Stores own presence status to presence cache
+         *
+         * @since S60 5.0
+         * @return none
+         */			
+        void StoreOwnStatusToCacheL();
+
+        /**
+         * Resolves presence cache values according to provided
+         * unicode string content.
+         *
+         * @since S60 5.0
+         * @param aUnicodeContent, string containing info data
+         * @param aActivities, activities string
+         * @param aCacheAvailability, will store enumerated status
+         * @param aCacheAvailability, will store extended status string
+         * @param aXimpApiAvailability, will store ximp api availabiltiy
+         * @return TBool, was handled or not
+         */
+        TBool ResolveOwnCacheValues( 
+            const TDesC& aUnicodeContent,
+            const TDesC& aActivities, 
+            MPresenceBuddyInfo2::TAvailabilityValues& aCacheAvailability,
+            TPtr& aExtendedCacheAvailability,
+            NPresenceInfo::TAvailabilityValues& aXimpApiAvailability );
+      
+    private: // Data
+
+        /**
+         * ximp Plugin connection observer
+         * Own.
+         */
+        MPresencePluginConnectionObs& iConnObs;
+        
+        /**
+         * ximp Host.     
+         * Not Own.
+         */    
+        MXIMPProtocolConnectionHost* iHost;
+
+        /**
+         * SIMPLE engine connection
+         * Not Own.
+         */
+        MSimpleConnection& iConnection;
+
+        /**
+         * SIMPLE engine publisher
+         * Own.
+         */
+        MSimplePublisher* iPublisher;
+        
+        /**
+         * SIMPLE engine watcher
+         * Own.
+         */
+        MSimpleWatcher* iWatcher;    
+        
+        /**
+         * ximp request id
+         * Own.
+         */
+        TXIMPRequestId iXIMPId;
+        
+        /**
+         * Simple Engine request id
+         * Own.
+         */
+        TInt iSimpleId;
+        
+        /**
+         * Subscribed winfo
+         * Own.
+         */
+        TBool iSubscribed; 
+        
+        /**
+         * Subscribed own data
+         * Own.         
+         */
+        TBool iSubscribedOwn;     
+        
+        /**
+         * Published own data
+         * Own.
+         */
+        TBool iPublished;  
+
+        /**
+         * RePublish status
+         * Own.
+         */
+        TBool iRePublish;
+        
+        /**
+         * Current operation
+         * Own.
+         */
+        TPluginPublishOperation iOperation;     
+           
+        /**
+         * Simple publish document
+         * Own.
+         */
+        MSimpleDocument* iDocument;
+       
+        /**
+         * XDM Utils
+         * Not own.
+         */
+        CPresencePluginXdmUtils* iXdmUtils; 
+        
+        /**
+         * WINFO watchers
+         * Own.
+         */
+        TDblQue<CPresencePluginWatcherInfo> iWatcherList;
+        
+        /**
+         * Presence Data
+         * Not Own
+         */
+        CPresencePluginData* iPresenceData;
+        
+        /**
+         * client statutus.
+         * Not own.
+         */
+        TRequestStatus* iClientStatus;
+        
+        SIMPLE_UNIT_TEST( T_CPresencePluginPublisher )
+
+        
+    };
+
+#endif // CPRESENCEPLUGINPUBLISHER_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginsession.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,306 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCEPLUGINSESSION_H
+#define CPRESENCEPLUGINSESSION_H
+
+
+#include <e32base.h>
+#include <msimpleconnectionobserver.h>
+#include "mpresencepluginconnectionobs.h"
+#include "presencelogger.h"
+
+//FORWARD
+class MXIMPServiceInfo;
+class MPresencePluginConnectionObs;
+
+/**
+ * CPrecensePluginSession
+ *
+ * presence Engine Connection
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginSession ): public CActive,
+    public MSimpleConnectionObserver                       
+    {
+    public:
+
+    	/**
+         * Current operation
+         */
+        enum TPluginSessionOperation
+            {
+            ENoOperation,
+            EInitializeXdm,
+            };  
+        
+        /**
+         * Two-phased constructor.
+         *
+         * @param aService, XIMP Service info
+         * @param aObs, Connection observer
+         */
+        static CPresencePluginSession* NewL( 
+            const MXIMPServiceInfo& aService,
+            MPresencePluginConnectionObs& aObs );
+
+        /**
+         * Standard C++ destructor
+         */
+        virtual ~CPresencePluginSession();
+
+    public: //New function
+    
+         TInt32 GetPresenceSetId( ) const;
+        
+        /**
+         * MSimpleConnection accessor
+         *
+         * @since S60 3.2
+         * @return MSImpleConnection instance
+         */
+        MSimpleConnection* SimpleConnection();
+         
+        /**
+         * OpenSessionL
+         *
+         * @since S60 3.2         
+         * Opens the SIP connection (registers when needed)
+         * @param none
+         * @return none
+         */
+        void OpenSessionL();
+        
+        /**
+         * XDMSettings accessor
+         *
+         * @since S60 3.2
+         * @param none
+         * @return XDM Settings ID
+         */
+        TInt XdmSettingsId();
+         
+        /**
+         * Current registered SIP entity
+         *
+         * @since S60 3.2
+         * @param none
+         * @return TPrtC8, current sip presentity
+         */ 
+        TPtrC8 CurrentSipPresentity();
+        
+        /**
+         * Domain syntax for current settings
+         *
+         * @since S60 3.2
+         * @param none
+         * @return TPrtC16, current domain
+         */    
+        TPtrC16 CurrentDomain();
+        
+        /**
+         * Close Connection
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */ 
+        void CloseConnection();
+        
+        /**
+         * Connection status
+         *
+         * @since S60 3.2
+         * @param none
+         * @return TBool, connection TRUE/FALSE
+         */
+        TBool ConnectionStatus();
+        
+        /**
+        * Connection status
+        *
+        * @since S60 3.2
+        * @param none
+        * @return TBool, connection TRUE/FALSE
+        */
+        TBool IsXdmLocalmode();
+        
+        /**
+         * Check XDM settings valid
+         *
+         * @since S60 5.0
+         * @param aServiceId, service if owning this session
+         * @return none
+         */
+        void CheckXDMSettingsL( TUint aServiceId );
+        
+        /**
+         * Accessor to valid XdmUtils
+         *
+         * @since S60 3.2
+         * @param none
+         * @return XdmUtils instance
+         */
+        CPresencePluginXdmUtils* XdmUtilsL();
+        
+        /**
+         * Returns service id owning this session.
+         *
+         * @since S60 5.0
+         * @param none
+         * @return TInt, service id
+         */        
+        TInt& ServiceId();
+ 
+    private:
+    
+        /**
+         * Standard C++ constructor
+         * @param aObs, connection observer.
+         */ 
+        CPresencePluginSession( 
+            MPresencePluginConnectionObs& aObs );
+
+        /**
+         * Performs the 2nd phase of construction.
+         *
+         * @param aService, XIMP service info
+         */ 
+        void ConstructL( const MXIMPServiceInfo& aService );
+
+    public:// from base class MSimpleConnectionObserver
+
+        /**
+         * Defined in a base class
+         */
+        void ConnectionStatusL( 
+            MSimpleConnection::TSimpleState aState );
+
+        /**
+         * Defined in a base class
+         */
+        void RequestCompleteL( TInt aOpId, TInt aStatus );
+        
+    protected: // from base class CActive
+
+        /**
+         * Defined in a base class
+         */
+        void RunL();
+
+        /**
+         * Defined in a base class
+         */
+        TInt RunError( TInt aError );
+
+        /**
+         * Defined in a base class
+         */
+        void DoCancel();
+    
+    private: // Data
+
+        /**
+         * XIMP Plugin connection observer
+         * Own.         
+         */
+        MPresencePluginConnectionObs& iObs;
+        
+        /**
+         * Simple Engine connection.
+         * Own.
+         */
+        MSimpleConnection* iConnection;
+        
+        /**
+         * Current Simple Engine operation id
+         * Own.
+         */
+        TInt iOpId;
+        
+        /**
+         * Request type
+         * Own.
+         */
+        MPresencePluginConnectionObs::TReqType iType;
+
+        /**
+         * presence settings Id
+         * Own.
+         */
+        TInt iPresSettingId;
+        
+        /**
+         * XDM Settings id
+         * Own.
+         */
+        TInt iXdmSetting;
+
+        /**
+         * Domain syntax for current settings
+         * Own,
+         */
+        HBufC16* iDomain;
+        
+        /**
+         * Current User ID, User's SIP identity
+         * Own.
+         */
+        HBufC8* iUserId8;
+        
+        /**
+         * Whether conncted to network
+         * Own.
+         */
+        TBool iSipConnected;
+        
+        /**
+         * Whether conncted to network
+         * Own.
+         */
+        TBool iXdmConnected;
+        
+        /**
+         * Xdm local mode
+         * Own.
+         */
+        TBool iXdmLocalMode;
+        
+        /**
+         * XDM utils
+         * Own.
+         */
+        CPresencePluginXdmUtils* iXdmUtils;
+        
+        /**
+         * Session operation.
+         */        
+        TPluginSessionOperation iOperation; 
+        
+        /**
+         * Service id owning this session.
+         */                
+        TInt     iServiceId;
+
+        SIMPLE_UNIT_TEST( T_CPresencePluginSession )
+        SIMPLE_UNIT_TEST( T_CPresencePluginConnection )
+    };
+
+#endif // CPRESENCEPLUGINSESSION_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginutility.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef T_PRESENCEPLUGINUTILITY_H
+#define T_PRESENCEPLUGINUTILITY_H
+
+/**
+*  Static utility functions for presence adapter.
+*
+*  @lib presenceplugin.dll
+*  @since S60 v5.0
+*/
+NONSHARABLE_CLASS( TPresencePluginUtility )
+    {
+
+    public:
+                              
+       /**
+        * Implementation for cleanup item.
+        * Resets and destroys array of the MXIMPIdentity
+        * entries and closes array.
+        * @param anArray RPointerArray pointer.
+        */
+        static void ResetAndDestroyIdentities( TAny* anArray );
+
+    };
+
+#endif      // T_PRESENCEPLUGINUTILITY_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginvirtualgroup.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,160 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol, creating virtualgroup
+*
+*/
+
+
+#ifndef CPRESENCEPLUGINVIRTUALGROUP_H
+#define CPRESENCEPLUGINVIRTUALGROUP_H
+
+#include <e32base.h>
+#include <e32std.h>
+#include <ximpbase.h>
+#include <badesca.h>
+
+#include "mpresencepluginconnectionobs.h"
+#include "presencelogger.h"
+
+class MXIMPObjectCollection;
+class CPresencePluginData;
+
+/**
+ * CPresencePluginVirtualGroup
+ *
+ * virtual groups
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginVirtualGroup ): public CBase
+    {
+    public:
+
+        /**
+         * Constructor.
+         * @param aId watcher id
+         * @param aSipId watcher SIP identity
+         */
+        static CPresencePluginVirtualGroup* NewL( 
+            MPresencePluginConnectionObs& aObs,
+            const TDesC16& aListName,
+            CPresencePluginData* aPresenceData );
+
+        /**
+         * Standard C++ destructor
+         */ 
+        virtual ~CPresencePluginVirtualGroup();           
+        
+    private:
+    
+        /**
+         * Standard C++ constructor
+         * @param aObs, Presence plugin connection             
+         * @param aPresenceData, access to presence data
+         */
+        CPresencePluginVirtualGroup( MPresencePluginConnectionObs& aObs,
+            CPresencePluginData* aPresenceData );
+        
+        /**
+         * Performs the 2nd phase of construction.
+         */ 
+        void ConstructL( const TDesC16& aListName );
+        
+        /**
+         * IdentityExists()
+         *
+         * @since S60 3.2 
+         * @param aIdentityUri, identity url
+         * @return TInt, return KErrNotFound if indentity not exists 
+         */ 
+        TInt IdentityExists( const TDesC& aIdentityUri ); 
+
+    public:
+        
+        /**
+         * GetVirtualIdentityArray()
+         *
+         * @since S60 3.2 
+         * @param aColl, XIMP object collection
+         * @return none
+         */     
+        CDesCArray* GetVirtualIdentityArray( );
+        
+        /**
+         * GetOnlineEntitiesL()
+         *
+         * @since S60 3.2 
+         * @param aColl, XIMP object collection
+         * @return none
+         */     
+        void GetVirtualEntitiesL( MXIMPObjectCollection& aColl );
+        
+        /**
+         * AddOnlineEntity()
+         *
+         * @since S60 3.2 
+         * @param aIdentityUri, identity url
+         * @return none
+         */ 
+        void AddEntityL( const TDesC& aIdentityUri );
+        
+        /**
+         * RemoveOnlineEntity()
+         *
+         * @since S60 3.2 
+         * @param aIdentityUri, identity url
+         * @return none
+         */ 
+        void RemoveEntityL( const TDesC& aIdentityUri );       
+        
+        /**
+         * HandlePresentityGroupMemberAddedL()
+         *
+         * @since S60 5.1 
+         * @param aIdentityUri, identity url
+         * @return none
+         */ 
+        void HandlePresentityGroupMemberAddedL( const TDesC& aIdentityUri );
+        
+    private: // data
+        
+        /**
+         * XIMP Plugin connection observer
+         */
+        MPresencePluginConnectionObs& iConnObs;
+        
+        /**
+         * Access to presence data.
+         * Not Own.
+         */        
+        CPresencePluginData*    iPresenceData;
+        
+        /**
+         * Identities/Uri of online Buddies.
+         */        
+        CDesCArray* iVirtualMember;
+        
+        /**
+         * list ident
+         * own
+         */
+        HBufC16* iListName;
+        
+        SIMPLE_UNIT_TEST( T_CPresencePluginVirtualGroup )
+        SIMPLE_UNIT_TEST( T_CPresencePluginXdmUtils )
+        
+    };
+    
+#endif // CPRESENCEPLUGINVIRTUALGROUP_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginwatcher.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,408 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCEPLUGINWATCHER_H
+#define CPRESENCEPLUGINWATCHER_H
+
+#include <e32base.h>
+#include <s32strm.h>
+#include <ximpbase.h>
+#include <protocolpresencewatching.h>
+
+#include "mpresencepluginconnectionobs.h"
+#include "presencelogger.h"
+
+class TXIMPRequestId;
+class MXIMPIdentity;
+class MXIMPProtocolConnectionHost;
+class MSimpleConnection;
+class CPresencePluginEntityWatcher;
+class CPresencePluginData;
+
+/**
+ * CPresencePluginWatcher
+ *
+ * Simple Engine Connection
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginWatcher ): public CActive,
+    public MProtocolPresenceWatching
+    {
+    public:
+
+        /**
+         * Current operation
+         */
+        enum TPluginWatcherOperation
+            {
+            EPluginUndef,
+            EPluginSubscribeGroup,
+            EPluginUnsubscribeGroup,
+            EPluginSubscribeSingle,
+            EPluginSubscribeByAdding,
+            EPluginUnSubscribeByRemoving
+            };
+            
+        /**
+         * Current actibe object state
+         */
+        enum TPluginXdmState
+            {
+            EPluginIdle,
+            EPluginInitXdm,
+            EPluginFetchRls,
+            EPluginAddGroupMember,
+            EPluginRemoveGroupMember
+            };        
+
+        /**
+         * Constructor.
+         * @param aObs callback for complete requests
+         * @param aConn Simple Engine connection
+         */ 
+        static CPresencePluginWatcher* NewL(
+            MPresencePluginConnectionObs& aObs,
+            MSimpleConnection& aConn,
+            CPresencePluginData* aPresenceData );
+        
+        /**
+         * Standard C++ destructor
+         */ 
+        virtual ~CPresencePluginWatcher();
+
+        /**
+         * SIP Watcher is complets it's task.
+         * @param aStatus error status
+         * @return none         
+         */
+        void CompleteWatcher( TInt aStatus );
+
+        /**
+         * Delete a single entity watcher
+         * @param aPresentityid presentity id
+         * @return none         
+         */
+        void DeleteWatcher(
+            const TDesC8& aPresentityid );
+        
+        /**
+         * SubscribeL()
+         *
+         * @since S60 5.1
+         * @param aIdentity presentity id to subscribe
+         * @return none
+         */
+        void SubscribeL( const TDesC& aIdentity );
+        
+        /**
+         * SubscribeAllL()
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void SubscribeAllL();
+        
+        /**
+         * UnSubscribeAllL()
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void UnSubscribeAllL(); 
+        
+        /**
+         * Subscribes presentity presence.
+         *
+         * @since S60 5.0
+         * @param aPresentityId, presentity id
+         * @param aStatus, client status to complete
+         * @return none
+         */            
+        void DoPerformSubscribePresentityPresenceL(
+            const MXIMPIdentity& aPresentityId,
+            TRequestStatus& aStatus );    
+            
+        /**
+         * Unsubscribes presentity presence.
+         *
+         * @since S60 5.0
+         * @param aPresentityId, presentity id
+         * @param aStatus, client status to complete
+         * @return none
+         */            
+        void DoPerformUnsubscribePresentityPresenceL(
+            const MXIMPIdentity& aPresentityId,
+            TRequestStatus& aStatus );
+              
+        /**
+         * Accept watcher to watcher list
+         *
+         * @since S60 5.1
+         * @param aWatcher, watcher
+         * @return none
+         */
+        void AcceptL( const CPresencePluginEntityWatcher* aWatcher );
+        
+    private:
+
+        /**
+         * Standard C++ constructor
+         * @param aObs, Presence plugin connection
+         * @param aConn, SIMPLE connection             
+         */ 
+        CPresencePluginWatcher(
+            MPresencePluginConnectionObs& aObs,
+            MSimpleConnection& aConn,
+            CPresencePluginData* aPresenceData );
+            
+    public: // from base class MXIMPBase
+
+        /**
+         * Defined in a base class
+         */
+        TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps );
+
+        /**
+         * Defined in a base class
+         */
+        const TAny* GetInterface(
+            TInt32 aInterfaceId,
+            TIfGetOps aOps ) const;
+
+        /**
+         * Defined in a base class
+         */
+        TInt32 GetInterfaceId() const;
+        
+    public: // from base class MXIMPProtocolPresenceWatching
+
+        /**
+         * Defined in a base class
+         */
+        void DoSubscribePresentityPresenceL(
+            const MXIMPIdentity& aPresentityId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUpdatePresentityPresenceSubscriptionPifL(
+            const MXIMPIdentity& aPresentityId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUnsubscribePresentityPresenceL(
+            const MXIMPIdentity& aPresentityId,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoSubscribePresentityGroupMembersPresenceL(
+            const MXIMPIdentity& aGroupId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUpdatePresentityGroupMembersPresenceSubscriptionPifL(
+            const MXIMPIdentity& aGroupId,
+            const MPresenceInfoFilter& aPif,
+            TXIMPRequestId aReqId );
+
+        /**
+         * Defined in a base class
+         */
+        void DoUnsubscribePresentityGroupMembersPresenceL(
+            const MXIMPIdentity& aGroupId,
+            TXIMPRequestId aReqId );
+
+    public:
+
+         /**
+         * Save presentity id
+         *
+         * @since S60 3.2
+         * @param aPresentityId presentity id
+         * @param aFormatUri, attempt to format uri
+         * @return none         
+         */
+        void SetPresIdentityL(
+            const MXIMPIdentity& aPresentityId,
+            TBool aFormatUri );
+            
+        /**
+         * Calls MXIMPProtocolConnectionHost callback
+         *
+         * @since S60 3.2
+         * @param aStatus error status
+         * @return none     
+         */
+        void CompleteXIMPReq( TInt aStatus );
+        
+        /**
+         * Set XIMP request id
+         *
+         * @since S60 3.2
+         * @param aId, request id
+         * @return none    
+         */
+        void SetXIMPId( TXIMPRequestId aId );
+
+        /**
+         * Check if ID matches with existing watcher
+         *
+         * @since S60 5.1
+         * @param aPresentityId presentity ID
+         * @return ETrue if matching watcher found
+         */
+        TBool MatchWatcherId( const TDesC8& aPresentityId ) const;
+
+    protected: // from base class CActive
+
+        /**
+         * Defined in a base class
+         */
+        void RunL();
+
+        /**
+         * Defined in a base class
+         */
+        TInt RunError( TInt aError );
+
+        /**
+         * Defined in a base class
+         */
+        void DoCancel();
+
+    private:
+    
+        /**
+         * Match existing watcher
+         *
+         * @since S60 3.2         
+         * @param aPresentityId presentity id
+         * @return watcher or NULL when not found
+         */
+        CPresencePluginEntityWatcher* MatchWatcherL(
+            const TDesC8& aPresentityId, TBool aCreate );   
+        
+        /**
+         * StartXdmOperationL
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void StartXdmOperationL();
+                                      
+    private: // Data
+
+        /**
+         * XIMP Plugin connection observer
+         * Own.
+         */
+        MPresencePluginConnectionObs& iConnObs;
+        
+        /**
+         * XIMP Host.     
+         * Not Own.
+         */    
+        MXIMPProtocolConnectionHost* iHost;
+
+        /**
+         * SIMPLE engine connection
+         * Not Own.
+         */
+        MSimpleConnection& iConnection;
+
+        /**
+         * SIMPLE engine watchers
+         * Own.
+         */
+        RPointerArray<CPresencePluginEntityWatcher> iWatchers;    
+        
+        /**
+         * Watcher candidates
+         * Own.
+         */
+        RPointerArray<CPresencePluginEntityWatcher> iWatcherCandidates;
+        
+        /**
+         * Current PrFW request id
+         * Own.
+         */
+        TXIMPRequestId iXIMPId;
+        
+        /**
+         * Simple Engine request id
+         * Own.         
+         */
+        TInt iSimpleId;
+        
+         /**
+         * XDM Utils
+         * Not own.
+         */
+        CPresencePluginXdmUtils* iXdmUtils;
+         
+        /**
+         * Current presentity in progress
+         * Own.
+         */
+        HBufC16* iPresIdentity;
+        
+        /**
+         * Presence data
+         * Own
+         */
+        CPresencePluginData* iPresenceData;
+        
+        /**
+         * XDM state
+         */
+        TPluginXdmState iXdmState;
+        
+        /**
+         * Whether the request is completed
+         * Own.
+         */
+        TBool iCompleted;
+        
+        /**
+         * Current operation
+         * Own.
+         */
+        TPluginWatcherOperation iOperation;    
+        
+        SIMPLE_UNIT_TEST( T_CPresencePluginWatcher )
+        SIMPLE_UNIT_TEST( T_CPresencePluginXdmUtils )
+    };
+
+#endif // CPRESENCEPLUGINWATCHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginwatcherinfo.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,124 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCEPLUGINWATCHERINFO_H
+#define CPRESENCEPLUGINWATCHERINFO_H
+
+#include <e32std.h>
+#include <ximpbase.h>
+
+#include "presencelogger.h"
+
+/**
+ * CPresencePluginWatcherInfo
+ *
+ * watcher info.
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginWatcherInfo ): public CBase
+    {
+    public:
+
+        /**
+         * Constructor.
+         * @param aId watcher id
+         * @param aSipId watcher SIP identity
+         */
+        static CPresencePluginWatcherInfo* NewL(
+            const TDesC8& aId,
+            const TDesC& aSipId );
+
+        /**
+         * Standard C++ destructor
+         */
+        virtual ~CPresencePluginWatcherInfo();
+                
+        /**
+         * Destructor
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void Destroy();
+        
+        /** 
+         * Match to given info
+         *
+         * @since S60 3.2
+         * @param aId watcher id
+         * @param aSipId watcher SIP identity     
+         * @return ETrue if current entity matches to the parameters
+         */
+        TBool Match( const TDesC8& aId,
+            const TDesC& aSipId ); 
+        /**
+         * SipId
+         *
+         * @since S60 3.2
+         * @param none
+         * @return TPtrC, sip Uri
+         */   
+        TPtrC SipId();     
+        
+        static TInt LinkOffset();   
+        
+    private:
+
+        CPresencePluginWatcherInfo( );
+
+        /** 
+         * Constructor
+         *
+         * @since S60 3.2
+         * @param aId watcher id
+         * @param aSipId watcher SIP identity     
+         */
+        void ConstructL( 
+            const TDesC8& aId,
+            const TDesC& aSipId ); 
+       
+    public: // data        
+
+        /**
+         * Linked list
+         * own
+         */
+        TDblQueLink iLink;
+        
+    private: // data
+        
+        /**
+         * ident id
+         * own
+         */
+        HBufC8* iId;
+        
+        /**
+         * sip id
+         * own
+         */
+        HBufC* iSipId;
+
+        SIMPLE_UNIT_TEST( T_SIMPLEDataModelAdapter )
+
+    };
+    
+#endif // CPRESENCEPLUGINWATCHERINFO_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginwinfo.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,179 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCEPLUGINWINFO_H
+#define CPRESENCEPLUGINWINFO_H
+
+#include <e32base.h>
+#include <ximpbase.h>
+#include <msimplewinfoobserver.h>
+
+#include "mpresencepluginconnectionobs.h"
+#include "presencelogger.h"
+
+class MSimpleWinfo;
+class TximpRequestId;
+class MSimpleWinfoWatcher;
+class MSimpleConnection;
+class MximpProtocolConnectionHost;
+class MPresencePluginConnectionObs;
+
+/**
+ * CPresencePluginWinfo
+ *
+ * Simple Engine Connection
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginWinfo ): public CBase,
+    public MSimpleWinfoObserver
+    {
+    public:
+
+        /**
+         * Constructor.
+         * @param aObs callback for complete requests
+         * @param aConn Simple Engine connection
+         */ 
+        static CPresencePluginWinfo* NewL(
+            MPresencePluginConnectionObs& aObs,    
+            MSimpleConnection& aConn );
+            
+        /**
+         * Standard C++ destructor
+         */
+        virtual ~CPresencePluginWinfo();
+
+        /**
+         * SetHost
+         * Set ximp Host
+         *
+         * @since S60 3.2         
+         * @param aHost ximp Host
+         */
+        void SetHost( MXIMPProtocolConnectionHost* aHost );
+        
+        /**
+         * SubscribeWinfoListL
+         *
+         * @since S60 3.2         
+         * @param aReqId ximp req id
+         */
+        void SubscribeWinfoListL( TXIMPRequestId aReqId ); 
+        
+        /**
+         * UnsubscribeWinfoListL
+         *
+         * @since S60 3.2
+         * @param aReqId ximp req id
+         */
+        void UnsubscribeWinfoListL( TXIMPRequestId aReqId );           
+       
+    private:
+    
+        /**
+         * Standard C++ constructor
+         *
+         * @param aObs, plugin connection observer
+         * @param aConn, SIMPLE connection 
+         */  
+        CPresencePluginWinfo(
+            MPresencePluginConnectionObs& aObs,    
+            MSimpleConnection& aConn );
+            
+        /**
+         * Performs the 2nd phase of construction.
+         */ 
+        void ConstructL( );
+
+    public: // from base class MSimpleWinfoObserver
+
+        // Subscribe presence grant request list
+
+        /**
+         * Defined in a base class
+         */
+        void WinfoReqCompleteL( TInt aOpid, TInt aStatus );
+
+        /**
+         * Defined in a base class
+         */
+        void WinfoTerminatedL(
+            TInt aOpid, TInt aReason );
+
+        /**
+         * Defined in a base class
+         */
+        void WinfoNotificationL( MSimpleWinfo& aWinfo );
+
+    private: // Data
+
+        /**
+         * ximp Plugin connection observer
+         * Own.
+         */
+        MPresencePluginConnectionObs& iConnObs;
+        
+        /**
+         * ximp Host.     
+         * Not Own.
+         */    
+        MXIMPProtocolConnectionHost* iHost;
+
+        /**
+         * SIMPLE engine connection
+         */
+        MSimpleConnection& iConnection;
+
+        /**
+         * SIMPLE engine winfo watcher.
+         * Own.
+         */
+        MSimpleWinfoWatcher* iWinfoWatcher;
+        
+        /**
+         * ximp request id
+         * Own.
+         */
+        TXIMPRequestId iXIMPId;
+        
+        /**
+         * Simple Engine request id
+         * Own.
+         */
+        TInt iSimpleId;
+        
+        /**
+         * Subscribed
+         * Own.
+         */
+        TBool iSubscribed;  
+        
+        /**
+         * Winfo subscribe completed
+         * Own.
+         */
+        TBool iWinfoCompleted;  
+        
+        SIMPLE_UNIT_TEST( T_CPresencePluginAuthorization )
+        SIMPLE_UNIT_TEST( T_CPresencePluginWinfo )
+        SIMPLE_UNIT_TEST( CSimpleDataModelAdapterTestObserver )        
+    };
+
+#endif // CPRESENCEPLUGINWINFO_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginxdmpresrules.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,413 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCEPLUGINXDMPRESRULES_H
+#define CPRESENCEPLUGINXDMPRESRULES_H
+
+#include <e32base.h>
+#include <ximpbase.h>
+
+#include "presenceplugincommon.h"
+#include "presencelogger.h"
+
+class CXdmEngine;
+class CXdmDocument;
+class CXdmDocumentNode;
+class TRequestStatus;
+class MPresRulesAsyncHandler;
+
+/**
+ * CPresencePluginXdmPresRules
+ *
+ * Simple Engine Connection
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginXdmPresRules ): public CActive
+    {
+    public: // Constructor and destructor
+         
+        /**
+         * XDM presrules state
+         */
+        enum TPluginPresRulesXdmState
+            {
+ 			EStateIdle,
+            EGetXdmRules,
+            EUpdateXdmRules,
+            ECreateXdmPresrules
+            };
+            
+        /**
+         * Operation state for rules update
+         */     
+        enum TPluginPresRulesUpdateState
+            {
+            EStateNoOperation,
+            EStateAddToWhiteList,
+            EStateAddToBlockList,
+            EStateRemoveFromWhiteList,
+            EStateRemoveFromBlackList,
+            EStateInitializeRules
+            };
+            
+        /**
+         * Current operation
+         */
+        enum TPluginPresRulesXdmOperation
+            {
+            ENoOperation,
+            ECancelDocument,
+            EXdmInit,   
+            EXdmDeleteAll,
+            EXdmCancel,
+            EXdmGetRulesFromServer,
+            EXdmInitialPresDoc,
+            EXdmUpdateRules,
+            EXdmUpdateRulesFromServer
+            };
+        
+        /**
+         * Two-phased constructor.
+         *         
+         * @param aXmdId xdm settings id
+         * @param aLocalMode, local or server mode TRUE/FALSE
+         */       
+        static CPresencePluginXdmPresRules* NewL( const TInt aXmdId, TBool  );
+
+        /**
+         * Two-phased constructor.
+         *         
+         * @param aXmdId xdm settings id
+         * @param aLocalMode, local or server mode TRUE/FALSE
+         */ 
+        static CPresencePluginXdmPresRules* NewLC( 
+        		const TInt aSettingId,
+        		TBool aLocalMode );
+
+        /**
+         * Standard C++ destructor
+         */ 
+        virtual ~CPresencePluginXdmPresRules( );
+    
+    public: // Own functions
+        
+        /**
+         * Updates XDM rules into server
+         *
+         * @since S60 3.2
+         * @param aHandler, MPresRulesAssyncHandler
+         * @return TInt, Error code
+         */
+        TInt UpdateXdmRulesL( MPresRulesAsyncHandler* const aHandler );
+        
+        /** 
+         * Add white list tag to presrules document
+         *
+         * @since S60 3.2
+         * @param aRoot, xml document root
+         * @return none
+         */
+        void AddWhiteListL( CXdmDocumentNode* aRoot );
+         
+        /** 
+         * Add black list tag to presrules document
+         *
+         * @since S60 3.2
+         * @param aRoot, xml document root
+         * @return none
+         */
+        void AddBlackListL( CXdmDocumentNode* aRoot );
+         
+        /**
+         * Get presence rules from server
+         *
+         * @since S60 3.2
+         * @param aHandler, PresRules assync handler
+         * @return TInt, error code
+         */
+        TInt GetXdmRulesL( MPresRulesAsyncHandler* const aHandler );
+        
+        /**
+         * Making initial presence rules document
+         *
+         * @since S60 3.2
+         * @param aHandler, PresRules assync handler
+         * @return none
+         */
+        void MakeInitialRulesDocumentL( 
+        		MPresRulesAsyncHandler* const aHandler );
+            
+        /**
+         * Remove entiry from blocked rules
+         *
+         * @since S60 3.2
+         * @param aUri, entity url
+         * @aHandler, PresRules assync handler 
+         * @return none
+         */   
+        void RemoveEntityBlockedRulesL( 
+            const TDesC&  aUri,
+            MPresRulesAsyncHandler* const aHandler );
+            
+        /**
+         * Remove entity from presrules white list
+         *
+         * @since S60 3.2
+         * @param aUri, entity url
+         * @aHandler, PresRules assync handler 
+         * @return none
+         */
+        void RemoveEntityFromWhiteListL( 
+            const TDesC&  aUri,
+            MPresRulesAsyncHandler* const aHandler );
+                
+        /**
+         * Add entity to presrules white list
+         *
+         * @since S60 3.2
+         * @param aUri, entity url
+         * @aHandler, PresRules assync handler 
+         * @return none
+         */
+        void AddEntityToWhiteListL(
+            const TDesC&  aUri,
+            MPresRulesAsyncHandler* const aHandler );
+
+        /**
+         * Add entity to blocked rules
+         *
+         * @since S60 3.2
+         * @param aUri, entity url
+         * @aHandler, PresRules assync handler 
+         * @return none
+         */
+        void AddEntityToBlockedRulesL( 
+            const TDesC&  aUri,
+            MPresRulesAsyncHandler* const aHandler );
+                
+        /**
+         * Remove one from rule list
+         *
+         * @since S60 3.2
+         * @param aRule, presence rule name
+         * @param aUri, entity url 
+         * @return none
+         */ 
+        void RemoveOneFromRuleL(
+            const TDesC& aRule,
+            const TDesC&  aUri );
+        
+        /**
+         * Add one to rule list
+         *
+         * @since S60 3.2
+         * @param aRule, presence rule name
+         * @param aUri, entity url 
+         * @return none
+         */ 
+        void DoOneAddUserL(
+            const TDesC& aList,
+            const TDesC&  aUri );
+          
+        /**
+         * Update presence document from server
+         *
+         * @since S60 3.2
+         * @param none
+         * @return TInt, error code
+         */
+        TInt UpdateFromServerL( MPresRulesAsyncHandler* const aHandler );
+  
+    private:
+        
+        /**
+         * Standard C++ constructor
+         * @param aXmdId, XDM settings id
+         */  
+        CPresencePluginXdmPresRules( const TInt aXmdId );
+
+        /**
+         * Performs the 2nd phase of construction.
+         *
+         * @param aXmdId, xdm settings id
+         * @param aLocalMode, clinet localmode state
+         */   
+        void ConstructL( const TInt aXmdId, TBool aLocalMode );
+    
+    private: // own functions
+    
+        /**
+         * GetRulesL
+         *
+         * @since S60 3.2
+         * @param aRuleArray, rule array
+         * @return TBool, rules found
+         */        
+        CXdmDocumentNode* GetRulesL( const TDesC& aRule,
+            RPointerArray<CXdmDocumentNode>& aRuleArray );
+    
+        /**
+         * Remove rule group from pres-rules document
+         *
+         * @since S60 3.2
+         * @param aRule, presence rule name
+         * @return none
+         */
+        void RemoveRuleGroupL( const TDesC& aRule );
+        
+        /**
+         * Search list under parent
+         *
+         * @since S60 3.2        
+         * @param aParent. document node
+         * @param aName, name of search
+         * @return none
+         */        
+        CXdmDocumentNode* SearchListUnderParentL(
+            CXdmDocumentNode* aParent,
+            const TDesC& aName );
+    
+        /**
+         * Create root if need
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void CreateRootIfNeededL();
+       
+        static void ResetAndDestroy1( TAny* aPointerArray );
+        static void ResetAndDestroy2( TAny* aPointerArray );
+        
+        /**
+         * Find rule from presrules xml
+         *
+         * @since S60 3.2
+         * @param aRule, rule name
+         * @return TBool
+         */
+        TBool FindRuleL( const TDesC& aRule, TBool aCreateRule );
+               
+        /**
+         * Check if one already exist
+         *
+         * @since S60 3.2
+         * @param aList, listname
+         * @param aUri, entity url
+         * @return TBool
+         */
+        TBool CheckIfOneExistL(
+            const TDesC& aRule,
+            const TDesC& aUri );
+        
+        /**
+         * Compare uri to attribute without prefix. Returns ETrue if match.
+         *
+         * @since S60 5.0
+         * @param aUri, entity url
+         * @parram aAttribute url attribute
+         * @return TBool
+         */
+        TBool CompareUriWithoutPrefixL( 
+            const TDesC& aUri, const TDesC& aAttribute );
+                
+    protected: // from base class CActive
+
+        /**
+         * Defined in a base class
+         */
+        void RunL();
+
+        /**
+         * Defined in a base class
+         */
+        TInt RunError( TInt aError );
+
+        /**
+         * Defined in a base class
+         */
+        void DoCancel();
+
+    private: // Data
+        
+        /**
+         * XDM Engine
+         * Own.
+         */
+        CXdmEngine* iXdmEngine;
+        
+        /**
+         * XDM Settings id
+         * Own.        
+         */
+        TInt iSettingsId;
+        
+        /**
+         * Presence rules document
+         * Own
+         */
+        CXdmDocument* iPresRulesDoc;
+        
+        /**
+         * Current state
+         * Own.
+         */
+        TPluginPresRulesXdmState iXdmState;
+        
+        /**
+         * TPluginPresRulesUpdateState
+         * Own.
+         */
+        TPluginPresRulesUpdateState iRulesUpdateState;
+         
+        /**
+         * client statutus.
+         * Not own.
+         */
+        TRequestStatus* iClientStatus;
+        
+        /**
+         * Whether Presence XDM is up-to-date
+         * Own.
+         */
+        TBool iPresXdmOk;
+       
+        /**
+         * Entity uri
+         * own
+         */
+        HBufC*  iEntityUri;
+        
+        /**
+         * Async request
+         * Own. 
+         */
+        TPluginPresRulesXdmOperation iAsyncReq;
+        
+        /**
+         * Async handler
+         * Own.
+         */
+        MPresRulesAsyncHandler* iAsyncHandler;
+        
+        SIMPLE_UNIT_TEST( T_CPresencePluginXdmPresRules )
+    };
+
+#endif // CPRESENCEPLUGINXDMPRESRULES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/inc/presencepluginxdmutils.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,655 @@
+/*
+* Copyright (c) 2006-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#ifndef CPRESENCEPLUGINXDMUTILS_H
+#define CPRESENCEPLUGINXDMUTILS_H
+
+#include <e32base.h>
+#include <ximpbase.h>
+#include <protocolpresenceauthorization.h>
+#include "presenceplugincommon.h"
+#include "mpresrulesasynchandler.h"
+#include "presencelogger.h"
+#include "presenceplugincontactsobs.h"
+
+class CPresencePluginXdmPresRules;
+class TXIMPRequestId;
+class MXIMPIdentity;
+class MXIMPObjectCollection;
+class CXdmEngine;
+class CXdmDocument;
+class CXdmDocumentNode;
+class TRequestStatus;
+class MPresencePluginConnectionObs;
+
+/**
+ * CPresencePluginXdmUtils
+ *
+ * Simple Engine Connection
+ *
+ * @lib presenceplugin.dll
+ * @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CPresencePluginXdmUtils ) : public CActive,
+    public MPresRulesAsyncHandler,
+    public MPresencePluginContactsObs
+    {
+    public: // Constructor and destructor
+
+        /**
+         * Active object asynch states
+         */
+        enum TPluginXdmState
+            {
+            EStateIdle,
+            /** Get XDM lists 1*/
+            EGetXdmLists,
+            /** Create XDM lists */
+            ECreateXdmLists,
+            /** Get XDM lists only, no rules later */
+            EGetXdmListsOnly,
+            /** Create XDM lists only, no rules later */
+            ECreateXdmListsOnly,        
+            /** Get RLS service */
+            EGetRlsServices,
+            /** Create RLS service */
+            ECreateRlsServices,
+            /** Update RLS service */
+            EUpdateRlsServices,
+            /** Get rules from server for GrantPresenceForPresentity */
+            EGetXdmRules,
+            /** Update rules to server for GrantPresenceForPresentity */
+            EUpdateXdmRules,
+            /** Update XDM List */
+            EUpdateXdmList,
+            /** Cancel XDM document operation */
+            ECancelDocument,
+            /** Get Block list */
+            EGetXdmBlockList,
+            /** Create presence rules */
+            ECreateXdmRules,
+            /** Subscripe block list */
+            ESubsBlockList,
+            EGetResourceListFromServer,
+            EUpdateBlockedContactPresenceCache
+            };
+
+        /**
+         * Current operation
+         */
+        enum TPluginXdmOperation
+            {
+            ENoOperation,
+            EXdmInit,   
+            EXdmDeleteAll,
+            EXdmCancel,
+            EXdmAddUserToGroup,
+            EXdmAddGroupToGroup,
+            EXdmRemoveUserFromGroup,
+            EXdmRemoveGroupFromGroup,
+            EXdmGrantForAll,
+            EXdmWithdrawFromAll,
+            EXdmGetBlockedList,
+            EXdmCreateGroup,
+            EXdmDeleteGroup,
+            EXdmRlsFetch,
+            EXdmRlsAdd,
+            EXdmRlsRemove,
+            EXdmCommitXdm,
+            EXdmCommitRls,
+            EXdmGetBuddyList,
+            EXdmAddUserToRules,
+            EXdmRemoveUserFromRules
+            };
+
+        /**
+         * Operation state for rules update
+         */
+        enum TPluginPresRulesState
+            {
+            EStateNoOperation,
+            EStateAddToWhiteList,
+            EStateAddToBlockList,
+            EStateRemoveFromWhiteList,
+            EStateRemoveFromBlackList,
+            EStateInitializeRules
+            };
+            
+        /**
+         * NewL
+         * @param aObs callback for complete requests
+         * @param aXdmId XDm settings id
+         */
+        static CPresencePluginXdmUtils* NewL(
+            MPresencePluginConnectionObs& aObs,
+            TInt aXmdId,
+            TBool aLocalMode );
+
+        virtual ~CPresencePluginXdmUtils();
+
+        /**
+         * Initialize XDMS and Presence XDM structures in network
+         *
+         * @since S60 3.2
+         * @param aStatus Request status of the caller
+         */
+        void InitializeXdmL( TRequestStatus& aStatus );
+        
+        /**
+         * Initialize XDMS in network
+         *
+         * @since S60 3.2
+         * @param aStatus Request status of the caller
+         */
+        void InitializeXdmsOnlyL( TRequestStatus& aStatus );    
+
+        /**
+         * Initialize Presence rules document only
+         *
+         * @since S60 3.2        
+         * @param aStatus Request status of the caller
+         */
+        void InitializePresRulesL( );
+
+        /**
+         * Add entity to granted list
+         *
+         * @since S60 3.2        
+         * @param aUri, entity URL
+         * @param aStatus, request status
+         * @return none
+         */
+        void AddEntityToGrantedL( 
+            const TDesC&  aUri,
+            TRequestStatus& aStatus );
+         
+        /**
+         * Remove entity from granted list
+         *
+         * @since S60 3.2        
+         * @param aUri, entity URL
+         * @param aStatus, request status
+         * @return none
+         */
+        void RemoveEntityFromGrantedL( 
+            const TDesC&  aUri,
+            TRequestStatus& aStatus );
+
+        /**
+         * Remove entity from blocked list
+         *
+         * @since S60 3.2        
+         * @param aName, entity URL
+         * @param aStatus, request status
+         * @return none
+         */
+        void RemoveEntityFromBlockedL( 
+            const TDesC&  aName,
+            TRequestStatus& aStatus );
+        
+        /**
+         * Add entity to blocked list
+         *
+         * @since S60 3.2        
+         * @param aUri, entity URL
+         * @param aStatus, request status
+         * @return none
+         */
+        void AddEntityToBlockedL( 
+            const TDesC&  aUri,
+            TRequestStatus& aStatus );
+    
+        /**
+         * Get (subscribe) Block List
+         *
+         * @since S60 3.2        
+         * @param aMembers, member list array
+         * @return none
+         */
+        void SubscribeBlockListL( RPointerArray<MXIMPIdentity>& aMembers );
+
+        /**
+         * Get (subscribe) Buddy List
+         *
+         * @since S60 3.2        
+         * @param aMembers, member list array
+         * @return none
+         */
+        void SubscribeBuddyListL( RPointerArray<MXIMPIdentity>& aMembers );
+        
+        /**
+         * GetUserListsL
+         *
+         * @since S60 3.2
+         * @param aList, List name
+         * @param aColl, XIMP object collection        
+         */
+        void GetEntitiesInListL(
+            const TDesC&  aList, MXIMPObjectCollection& aColl );
+        
+        /**
+         * Add identity to virtual list
+         *
+         * @since S60 3.2
+         * @param aList, List name
+         */
+        void AddIdentityToVirtualListL(
+            const TDesC&  aList );
+        
+       /**
+        * CheckXdmDoc
+        *
+        * @since S60 3.2
+        * @param none
+        * @return TBool, state of xdm documents        
+        */    
+       TBool CheckXdmDoc();
+    
+    public: //From assync
+        
+        /**
+         * Defined in a base class
+         */
+        void HandlePresUpdateDocumentL( TInt aErrorCode );
+        
+        /**
+         * Defined in a base class
+         */
+        void HandlePresUpdateCancelL( TInt aErrorCode );
+   
+    private:
+    
+        /**
+         * Standard C++ constructor
+         *
+         * @param aObs, plugin connection observer
+         * @param aXmdId, XDM settings id 
+         */ 
+        CPresencePluginXdmUtils( 
+        		MPresencePluginConnectionObs& aObs,
+        		TInt aXmdId,
+        		TBool aLocalmode );
+
+        /**
+         * Performs the 2nd phase of construction.
+         */ 
+        void ConstructL( );
+
+    protected:// from base class CActive
+
+        /**
+         * Defined in a base class
+         */
+        void RunL();
+
+        /**
+         * Defined in a base class
+         */
+        TInt RunError( TInt aError );
+
+        /**
+         * Defined in a base class
+         */
+        void DoCancel();
+
+    protected: // from MPresencePluginContactsObs
+
+        /**
+         * Defined in a base class
+         */
+        void RequestComplete( TAny* aResult,
+            TPresenceContactsOperation aOperation, TInt aError );
+
+    private:
+    
+        /**
+         * DoUpdateXdmLists
+         *
+         * @since S60 3.2
+         * @param aMyStatus, RunL status
+         * @return aOrigState, xdm state
+         */    
+        void DoUpdateXdmListsL( TInt aMyStatus,
+            TPluginXdmState aOrigState );
+                
+        /**
+         * DoGetXdmLists
+         *
+         * @since S60 3.2
+         * @param aMyStatus, RunL status
+         * @return aOrigState, xdm state
+         */    
+        void DoGetXdmListsL( TInt aMyStatus,
+            TPluginXdmState aOrigState );
+
+        /**
+         * DoCreateXdmLists
+         *
+         * @since S60 3.2
+         * @param aMyStatus, RunL status
+         * @return aOrigState, xdm state
+         */    
+        void DoCreateXdmListsL( TInt aMyStatus,
+            TPluginXdmState aOrigState,
+            TBool aOnlyResourceList );
+               
+        /**
+         * Search list under parent
+         *
+         * @since S60 3.2        
+         * @param none
+         * @return none
+         */
+        CXdmDocumentNode* SearchListUnderParentL(
+            CXdmDocumentNode* aParent,
+            const TDesC& aName );
+
+        /**
+         * Complete client request
+         *
+         * @since S60 3.2
+         * @param aStatus, client status
+         * @return none
+         */    
+        void CompleteClientReq( TInt aStatus );
+
+        /**
+         * Get XDM lists
+         *
+         * @since S60 3.2
+         * @param aCreateRules, create new rule document
+         * @param aLocalMode, use localmode
+         * @return none
+         */
+        void GetXdmListsL( TBool aCreateRules, TBool aLocalMode );
+
+        /**
+         * Create XDM list document model
+         *
+         * @since S60 3.2
+         * @param aCreateRules, create new rule document
+         * @return none
+         */
+        void CreateXdmListsL( TBool aCreateRules );
+
+        /**
+         * Update document to server
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void UpdateXdmToServerL();
+          
+        /**
+         * Updates XDMS reource lists into server
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */  
+        void UpdateXdmsL();
+        
+        /**
+         * Updates XDM rules
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */        
+        void UpdateXdmRulesL();
+        
+        /**
+         * Get XDM rules
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */         
+        void GetXdmRulesL();
+                 
+        /**
+         * Handle presence document 
+         *
+         * @since S60 3.2        
+         * @param aList, list name
+         * @param aUser, entity name
+         * @return none
+         */
+        void DoHandlePresUpdateDocumentL( TInt aErrorCode );
+
+        /**
+         * Add User to resource list
+         *
+         * @since S60 3.2
+         * @param aList, list name
+         * @param aName, url         
+         */
+        void DoAddUserToListL(
+            const TDesC& aList,
+            const TDesC&  aName );
+        
+        /**
+         * Remove user from list
+         *
+         * @since S60 3.2
+         * @param aList, list name
+         * @param aUser, entity name
+         * @return none
+         */
+        void DoRemoveUserFromListL(
+            const TDesC& aList,
+            const TDesC&  aName );
+
+        /**
+         * Get member list
+         *
+         * @since S60 3.2
+         * @param aList, list name
+         * @param aMembers, member array
+         * @return none
+         */
+        void DoGetListMembersL(
+            const TDesC& aList,
+            RPointerArray<MXIMPIdentity>& aMembers  );
+
+        /**
+         * Get buddy list
+         *
+         * @since S60 3.2
+         * @param aList, list name
+         * @return XDM document
+         */
+        CXdmDocumentNode* DoGetBuddyListL( const TDesC& aParent);
+
+        /**
+         * Get buddy list
+         *
+         * @since S60 3.2
+         * @param aList, list name
+         * @parma aBuddyList, xdm document node
+         * @return XDM document
+         */
+        CXdmDocumentNode* DoGetUserListL(
+            const TDesC& aList,
+            CXdmDocumentNode* aBuddyList );
+        
+        /**
+         * Check XDM errors
+         *
+         * @since S60 3.2
+         * @param aMyStatus, XDM error code
+         * @return errorcode
+         */    
+        TInt CheckIfErrorL( TInt aMyStatus );
+
+        /**
+         * Check if entity already exist
+         *
+         * @since S60 3.2
+         * @param aList, listname
+         * @param aUri, entity url
+         * @return TBool
+         */
+        TBool CheckIfEnityExistL( const TDesC& aList, const TDesC&  aUri );
+        
+        /**
+         * Update document from server
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void UpdateFromServerL();
+        
+        /**
+         * Compare uri to attribute without prefix. Returns ETrue if match.
+         *
+         * @since S60 5.0
+         * @param aUri, entity url
+         * @parram aAttribute url attribute
+         * @return TBool
+         */
+        TBool CompareUriWithoutPrefixL( 
+            const TDesC& aUri, const TDesC& aAttribute );
+        
+        /**
+         * Update blocked contact status to Presence Cache
+         *
+         * @since S60 5.0
+         * @param aMyStatus, error status
+         */
+        void DoUpdateBlockedContactPresenceCacheL(
+            TInt aMyStatus );
+
+    private: // Data
+
+        /**
+         * ximp Plugin connection observer
+         * Own.
+         */
+        MPresencePluginConnectionObs& iConnObs;
+
+        /**
+         * XDM Settings id
+         * Own.
+         */
+        TInt iSettingsId;
+
+        /**
+         * ximp request id
+         * Own.         
+         */
+        TXIMPRequestId iximpId;
+
+        /**
+         * ximp request id for own requests
+         * Own.         
+         */
+        TXIMPRequestId iximpIdOwn;
+
+        /**
+         * Simple Engine request id
+         * Own.         
+         */
+        TInt iSimpleId;
+
+        /**
+         * XDM Engine
+         * Own.
+         */
+        CXdmEngine* iXdmEngine;
+
+        /**
+         * XDM document for resource-lists
+         * Own.
+         */
+        CXdmDocument* iXdmDoc;
+       
+        /**
+         * Current state
+         * Own.         
+         */
+        TPluginXdmState iXdmState;
+         
+        /**
+         * Current operation
+         * Own.         
+         */
+        TPluginXdmOperation iOperation;
+
+        /**
+         * Whether Presence XDM is up-to-date
+         * Own.         
+         */
+        TBool iPresXdmOk;
+
+        /**
+         * Whether XDM is up-to-date
+         * Own.         
+         */
+        TBool iXdmOk;
+
+        /**
+         * client statutus.
+         * Not own.
+         */
+        TRequestStatus* iClientStatus;
+           
+        /**
+         * XDM presence rules handling
+         * own.
+         */
+        CPresencePluginXdmPresRules*  iXdmPresRules;
+        
+        /**
+         * Entity uri
+         * Own.         
+         */
+        HBufC* iEntityUri;
+        
+        /**
+         * TPluginPresRulesUpdateState
+         * Own.         
+         */
+        TPluginPresRulesState iRulesUpdateState;
+        
+        /**
+         * XDM localmode
+         * Own.         
+         */
+        TBool iLocalMode;
+        
+        /**
+         * Request results.
+         * Is contact blocked request
+         */
+        TBool iPresenceContactsAsyncReqResult;
+
+        /*
+         * Initial blocked contact list
+         */
+        RPointerArray<HBufC> iBlockedContacts;
+
+        SIMPLE_UNIT_TEST( T_CPresencePluginGroups )
+        SIMPLE_UNIT_TEST( T_CPresencePluginWatcher )
+        SIMPLE_UNIT_TEST( T_CPresencePluginAuthorization )
+        SIMPLE_UNIT_TEST( T_CPresencePluginXdmUtils )
+    };
+
+#endif // CPRESENCEPLUGINXDMUTILS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/install/sis/create_sis.bat	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,17 @@
+rem
+rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+rem All rights reserved.
+rem This component and the accompanying materials are made available
+rem under the terms of "Eclipse Public License v1.0"
+rem which accompanies this distribution, and is available
+rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
+rem
+rem Initial Contributors:
+rem Nokia Corporation - initial contribution.
+rem
+rem Contributors:
+rem
+rem Description:
+rem
+
+createsis create -key H:\RD_RootCA\rd-key.pem -cert H:\RD_RootCA\rd.cer simpledatamodeladapter.pkg
\ No newline at end of file
Binary file simpledatamodeladapter/install/sis/simpledatamodeladapter.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/install/sis/simpledatamodeladapter.pkg	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,61 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description: 
+;
+&EN
+
+;Header 
+#{"Presence adapter"},(0x10207FE0),1,22,1, TYPE=SA
+
+
+;Series 60 v3.0
+[0x101f7961], 0, 0, 0, {"Series60ProductID"}
+
+;Localised Vendor name
+%{"Nokia"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+;Files to install 
+
+
+;ECOM PLUGINS:
+
+; SIMPLE DATAMODEL ADAPTER:
+"\epoc32\release\armv5\udeb\presenceplugin.dll"				-"!:\sys\bin\presenceplugin.dll"
+"\epoc32\data\Z\Resource\Plugins\presenceplugin.RSC"	-"C:\Resource\Plugins\presenceplugin.RSC"
+
+;test app
+;"\epoc32\release\armv5\urel\HelloWorld.exe"				-"!:\sys\bin\HelloWorld.exe"
+;"\epoc32\data\Z\Resource\Apps\HelloWorld.RSC"	-"C:\Resource\HelloWorld.RSC"
+
+;UI stuff
+;"\epoc32\release\armv5\udeb\sipvoipcontactsextension.dll"					-"C:\sys\bin\sipvoipcontactsextension.dll"                                
+;"\epoc32\data\Z\Resource\sipvoipcontactsextensionres.Rsc"		        	-"C:\Resource\sipvoipcontactsextensionres.Rsc"
+;"\epoc32\data\Z\Resource\Plugins\sipvoipcontactsextension.RSC"		        	    -"C:\Resource\Plugins\sipvoipcontactsextension.RSC"
+;"\epoc32\data\Z\Resource\apps\sipvoipcontactsextensiondefaulticons.mif"		-"C:\Resource\Apps\sipvoipcontactsextensiondefaulticons.mif"
+;"\epoc32\data\Z\Resource\apps\svcedefaulticons.mif"		-"C:\Resource\Apps\svcedefaulticons.mif"
+
+;Extension manager stuff
+;"\epoc32\release\armv5\udeb\ExtensionManager.dll"		-"!:\sys\bin\ExtensionManager.dll"
+;"\epoc32\data\Z\Resource\ExtensionManagerRes.rsc"		-"C:\Resource\Plugins\ExtensionManagerRes.rsc"
+
+; sipconnectionprovider
+;"\epoc32\release\armv5\udeb\sipconnectionprovider.dll"-"!:\sys\bin\sipconnectionprovider.dll"
+;"\epoc32\data\Z\resource\plugins\sipconnectionprovider.rsc"-"!:\resource\plugins\sipconnectionprovider.rsc"
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/rom/simpledatamodeladapter.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ROM definition file.
+*
+*/
+
+
+#ifndef SIMPLEDATAMODELADAPTER_IBY
+#define SIMPLEDATAMODELADAPTER_IBY
+
+#ifdef RD_VOIP_REL_2_2
+
+ECOM_PLUGIN(presenceplugin.dll,	10275464.RSC)
+
+#endif // RD_VOIP_REL_2_2
+
+#endif // SIMPLEDATAMODELADAPTER_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/data/20022d58.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  Resource definitions for project Simple IM Plugin
+*
+*/
+
+#include <registryinfov2.rh>
+#include <immanagementifids.hrh>
+#include "simpleimpluginuids.hrh"
+
+// ---------------------------------------------------------------------------
+// REGISTRY_INFO
+// ecom plugin resource info
+// ---------------------------------------------------------------------------
+//
+RESOURCE REGISTRY_INFO theInfo
+    {
+    resource_format_version = RESOURCE_FORMAT_VERSION_2;
+
+    dll_uid = KDllUidSimpleImPlugin;
+
+    // Declare array of interface info
+    interfaces = 
+        {
+        INTERFACE_INFO
+            {
+            // UID of interface that is implemented
+            interface_uid = IM_IF_ID_PROTOCOL_IM_FEATURES;
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = KImplUidSimpleImPlugin;
+                    version_no = 1;
+                    display_name = "simple im plugin";
+                    default_data = 2219;
+                    opaque_data = "";
+                    rom_only = 0;
+                    }
+                };
+            }
+        };
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  Build information file for project simpleimplugin.
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../rom/simpleimplugin.iby CORE_MW_LAYER_IBY_EXPORT_PATH(simpleimplugin.iby)
+
+PRJ_MMPFILES
+simpleimplugin.mmp
+
+PRJ_TESTMMPFILES
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/group/simpleimplugin.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  Project definition file for project simpleimplugin.
+*
+*/
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  simpleimplugin.dll
+TARGETTYPE              PLUGIN
+UID                     0x10009D8D 0x20022D58
+
+CAPABILITY              CAP_ECOM_PLUGIN
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  simpleimconversation.cpp
+SOURCE                  simpleimfeatures.cpp
+SOURCE                  simpleimpluginimplementationproxy.cpp
+
+SOURCEPATH              ../data
+START RESOURCE          20022d58.rss
+TARGET                  simpleimplugin.rsc
+END // RESOURCE
+
+USERINCLUDE             ../inc
+USERINCLUDE             ../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE           /epoc32/include/ecom
+
+LIBRARY                 cch.lib
+LIBRARY                 euser.lib
+LIBRARY                 ecom.lib
+LIBRARY                 esock.lib
+LIBRARY                 insock.lib
+LIBRARY                 charconv.lib
+LIBRARY                 simpleengine.lib
+LIBRARY                 serviceprovidersettings.lib
+LIBRARY                 imcacheclient.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/inc/simpleimconversation.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,290 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Provides IM sending and receiving services.
+*
+*/
+
+
+#ifndef C_CSIMPLEIMCONVERSATION_H
+#define C_CSIMPLEIMCONVERSATION_H
+
+#include <e32base.h>
+#include <ximpbase.h>
+#include <ximpcontextobserver.h>
+#include <ximprequestcompleteevent.h>
+#include <protocolimconversation.h>
+#include <simpleinstantmsgobserver.h>
+#include <simpleinstantmessage.h>
+
+class CIMCacheFactory;
+class MIMCacheUpdater;
+class MPresencePluginConnectionObs;
+class MSimpleConnection;
+class MProtocolImDataHost;
+class MXIMPIdentity;
+
+/**
+ *  This class is used for sending and receiving instant messages.
+ *  A client sends the message and waits for notification of send process 
+ *  success. Client is notified with 
+ *  MPresencePluginConnectionObs::CompleteReq().
+ *  
+ *  There can be only one message in the sending que at the time.
+ *  Otherwise DoSendMessageL() method leaves with KErrInUse.
+ *  
+ *  Messages received from the other end are handled in this class and
+ *  delivered to the client. Client gets messages through
+ *  MProtocolImConversationDataHost::HandleNewTextMessageL().
+ *
+ *  @lib simpleimplugin.dll
+ *  @since S60 v5.1
+ */
+NONSHARABLE_CLASS( CSimpleImConversation ) : public CBase,
+                                             public MProtocolImConversation,
+                                             public MSimpleInstantMsgObserver
+    {
+
+public:
+    
+    /**
+     * Two-phased constructor.
+     * 
+     * @param   aObs    Callback for complete requests.
+     * @param   aConn   Simple engine connection.
+     */
+    static CSimpleImConversation* NewL(
+        MPresencePluginConnectionObs& aObs, MSimpleConnection& aConn,
+        TUint aServiceId );
+
+    /**
+     * Destructor.
+     */ 
+    virtual ~CSimpleImConversation();
+
+public:
+    
+    /**
+     * Sets current IM data host.
+     * 
+     * @since   S60 v5.1
+     * @param   aHost   IM data host.
+     */
+    void SetHost( MProtocolImDataHost& aHost );
+    
+public:  //from MXIMPBase
+
+    /**
+     * From MXIMPBase.
+     * @see MXIMPBase.
+     */
+    TAny* GetInterface( 
+        TInt32 aInterfaceId,
+        TIfGetOps  aOptions );
+    
+    /**
+     * From MXIMPBase.
+     * @see MXIMPBase.
+     */
+    const TAny* GetInterface( 
+        TInt32 aInterfaceId,
+        TIfGetOps aOptions ) const;
+    
+    /**
+     * From MXIMPBase.
+     * @see MXIMPBase.
+     */
+    TInt32 GetInterfaceId() const;
+
+public: // From MProtocolImConversation
+    
+    /**
+     * From MProtocolImConversation.
+     * @see MProtocolImConversation.
+     */
+    void DoSendMessageL( 
+        const MImConversationInfo& aImMessage,
+        TXIMPRequestId aReqId );
+    
+    /**
+     * From MProtocolImConversation.
+     * @see MProtocolImConversation.
+     */
+    void DoForwardMessageL(
+        const MImConversationInfo& aImMessage,
+        TXIMPRequestId aReqId);
+    
+    /**
+     * From MProtocolImConversation.
+     * @see MProtocolImConversation.
+     */
+    void DoSendMessageToGroupL( 
+        const MImConversationInfo& aImMessage,
+        const TDesC* aGroupId,TXIMPRequestId aReqId );
+    
+    /**
+     * From MProtocolImConversation.
+     * @see MProtocolImConversation.
+     */
+    TXIMPRequestId DoBlockUsersL(
+        const MDesCArray* aUserIds,
+        TXIMPRequestId aReqId);
+    
+    /**
+     * From MProtocolImConversation.
+     * @see MProtocolImConversation.
+     */
+    TXIMPRequestId DoUnBlockUsersL(
+        const MDesCArray* aUserIds,
+        TXIMPRequestId aReqId );
+    
+    /**
+     * From MProtocolImConversation.
+     * @see MProtocolImConversation.
+     */
+    void DoGetBlockedListRequestL( 
+        const MXIMPIdentity& aImMessageId,
+        TXIMPRequestId aReqId );            
+    
+    /**
+     * From MProtocolImConversation.
+     * @see MProtocolImConversation.
+     */
+    void DoGetMessageListL( 
+        const MXIMPIdentity& aImMessageId,
+        const TDesC* aGroupId,
+        const TInt aMessageCount,
+        TBool aDeliveryReportWanted,
+        TXIMPRequestId aReqId);
+    
+    /**
+     * From MProtocolImConversation.
+     * @see MProtocolImConversation.
+     */
+    void DoRejectMessageL( 
+        const MXIMPIdentity& aImMessageId,
+        const TDesC& aMessageID,
+        TXIMPRequestId aReqId );
+    
+public: // From MSimpleInstantMsgObserver
+    
+    /**
+     * From MSimpleInstantMsgObserver.
+     * @see MSimpleInstantMsgObserver.
+     */
+    void SendInstantMsgReqComplete( TInt aOpid, TInt aStatus );
+    
+    /**
+     * From MSimpleInstantMsgObserver.
+     * @see MSimpleInstantMsgObserver.
+     */
+    void HandleReceiveTextMessage( TPtrC8 aFrom, TPtrC8 aContent );
+
+private: // constructor and the Symbian second-phase constructor
+
+    CSimpleImConversation( MPresencePluginConnectionObs& aObs, 
+                           MSimpleConnection& aConn,
+                           TUint aServiceId );
+    
+    void ConstructL( );
+
+private:
+
+    /**
+     * Calls MXIMPProtocolConnectionHost callback.
+     *
+     * @since   S60 v5.1
+     * @param   aStatus     Error status.
+     */
+    void CompleteXimpReq( TInt aStatus );
+    
+    /**
+     * Leaveable version of HandleReceiveTextMessage.
+     * 
+     * @see MSimpleInstantMsgObserver 
+     */
+    void DoHandleReceiveTextMessageL( TPtrC8 aFrom, TPtrC8 aContent );
+    
+    /**
+     * Resolves username to be used.
+     * 
+     * @since   S60 v5.1
+     * @param   aServiceId     Service identifier.
+     * @param   aUserName      On return contains resolved user name.
+     */
+    void ResolveUsernameL( TUint aServiceId, RBuf& aUserName ) const;
+    
+    /**
+     * Creates IM cache updater if not yet created.
+     * 
+     * @since   S60 v5.1
+     */
+    void CreateImCacheUpdaterIfNeededL();
+    
+private:  // Data
+    
+    /**
+     * XIMP Plugin connection observer.
+     * Not own.
+     */
+    MPresencePluginConnectionObs* iConnectionObs;
+    
+    /**
+     * SIMPLE engine connection.
+     * Not Own.
+     */
+    MSimpleConnection* iConnection;
+    
+    /**
+     * Instant message handler instance.
+     * Own.
+     */
+    MSimpleInstantMessage* iImHandler;
+    
+    /**
+     * Request identifier.
+     */
+    TXIMPRequestId iXimpId;
+
+    /**
+     * Current request status; completed or not.
+     */
+    TBool iCompleted;
+    
+    /**
+     * Protocol IM data host.
+     * Not own.
+     */
+    MProtocolImDataHost* iHost;
+    
+    /**
+     * IM cache factory.
+     * Own.
+     */
+    CIMCacheFactory* iImCacheFactory;
+
+    /**
+     * IM cache updater.
+     * Owned by factory.
+     */
+    MIMCacheUpdater* iImCacheUpdater;
+    
+    /**
+     * ServiceId of current 
+     * service
+     */
+    TUint iServiceId;
+    
+    };
+
+#endif // C_CSIMPLEIMCONVERSATION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/inc/simpleimfeatures.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,173 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef C_CSIMPLEIMFEATURES_H
+#define C_CSIMPLEIMFEATURES_H
+
+#include <e32base.h>
+#include <cprotocolimfeatures.h>
+
+class CSimpleImConversation;
+class MPresencePluginConnectionObs;
+class MSimpleConnection;
+
+/**
+ * Main class of XIMP FW plugin providing SIP IM feature.
+ *
+ * @lib simpleimplugin.dll
+ * @since S60 v5.1
+ */
+NONSHARABLE_CLASS( CSimpleImFeatures ) : public CProtocolImFeatures
+{
+public:
+    
+    /**
+     * This class encapsulates SIP IM plugin initialization parameters.
+     *
+     * @lib simpleimplugin.dll
+     * @since S60 v5.1
+     */
+    class TSimpleImPluginInitParams
+        {
+        public:
+
+            /**
+             * Constructor.
+             * @param   aObs    Presence plugin connection observer.
+             * @param   aConn   Simple engine connection.
+             */
+            TSimpleImPluginInitParams( MPresencePluginConnectionObs& aObs,
+                MSimpleConnection& aConn, TUint aServiceId ) : iObserver( aObs ),
+                iConnection( aConn ), iServiceId( aServiceId ) {};
+
+        public:
+        
+            /**
+             * Presence plugin connnection observer.
+             * Not own.
+             */    
+            MPresencePluginConnectionObs& iObserver;
+        
+            /**
+             * Simple engine connection.
+             * Not own.
+             */
+            MSimpleConnection& iConnection;
+            
+            /**
+             * Service identifier.
+             */
+            TUint iServiceId;
+        };
+
+    /**
+     * Constructor.
+     * @param   aInitParams   Plugin initialization parameters.
+     */
+    static CSimpleImFeatures* NewL( TAny* aInitParams );
+
+    /**
+     * Standard C++ destructor.
+     */ 
+    virtual ~CSimpleImFeatures();
+
+private:
+
+    CSimpleImFeatures();
+
+    void ConstructL( TAny* aInitParams );
+
+public: // From MXIMPBase
+
+    /**
+     * From MXIMPBase.
+     * @see MXIMPBase.
+     */
+    TAny* GetInterface( 
+        TInt32 aInterfaceId, 
+        TIfGetOps aOptions );
+
+    /**
+     * From MXIMPBase.
+     * @see MXIMPBase.
+     */
+    const TAny* GetInterface( 
+        TInt32 aInterfaceId, 
+        TIfGetOps aOptions ) const;
+
+    /**
+     * From MXIMPBase.
+     * @see MXIMPBase.
+     */
+    TInt32 GetInterfaceId() const;
+
+public : // From CProtocolImFeatures
+
+    /**
+     * From CProtocolImFeatures.
+     * @see CProtocolImFeatures.
+     */
+    MProtocolImGroup& ImGroup();
+    
+    /**
+     * From CProtocolImFeatures.
+     * @see CProtocolImFeatures.
+     */
+    MProtocolImConversation& ImConversation();
+    
+    /**
+     * From CProtocolImFeatures.
+     * @see CProtocolImFeatures.
+     */
+    MProtocolImInvitation& ImInvitation();
+    
+    /**
+     * From CProtocolImFeatures.
+     * @see CProtocolImFeatures.
+     */
+    MProtocolImSearch& ImSearch();
+    
+    /**
+     * From CProtocolImFeatures.
+     * @see CProtocolImFeatures.
+     */
+    void SetHost( MProtocolImDataHost& aHost );
+    
+    /**
+     * From CProtocolImFeatures.
+     * @see CProtocolImFeatures.
+     */
+    TInt SupportedSubInterfaces() const;
+
+private : // data members
+        
+    /**
+     * IM conversation.
+     * Own.
+     */
+    CSimpleImConversation* iImConversation;
+
+    /**
+     * Protocol IM data host.
+     * Not own.
+     */
+    MProtocolImDataHost* iHost;
+
+    };
+
+#endif // C_CSIMPLEIMFEATURES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/inc/simpleimlogger.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef SIMPLEIMLOGGER_H
+#define SIMPLEIMLOGGER_H
+
+#ifdef _DEBUG
+    #include <e32svr.h>
+    #define _DEBUG_SIMPLE_IM_PLUGIN
+#endif
+
+#ifdef _DEBUG_SIMPLE_IM_PLUGIN
+    #define DP_IMP( a ) \
+        { _LIT( KFormatString, a ); RDebug::Print( KFormatString ); }
+    #define DP_IMP2( a, b ) \
+        { _LIT( KFormatString, a ); RDebug::Print( KFormatString, b ); }
+    #define DP_IMP3( a, b, c ) \
+        { _LIT( KFormatString, a ); RDebug::Print( KFormatString, b, c ); }
+#else
+    #define DP_IMP( a );
+    #define DP_IMP2( a, b );
+    #define DP_IMP3( a, b, c );
+#endif
+
+#endif // SIMPLEIMLOGGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/inc/simpleimplugindefs.h	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  Common definitions for SIP IM plugin.
+*
+*/
+
+
+#ifndef SIMPLEIMPLUGINDEFS_H
+#define SIMPLEIMPLUGINDEFS_H
+
+#include <e32std.h>
+
+_LIT( KSimpleImPluginName, "SimpleImPlugin" );
+
+#endif // SIMPLEIMPLUGINDEFS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/inc/simpleimpluginuids.hrh	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource headers for project simpleimplugin.
+*
+*/
+
+#ifndef SIMPLEIMPLUGINUIDS_HRH
+#define SIMPLEIMPLUGINUIDS_HRH
+
+/**
+ * Plugin DLL UID
+ */
+#define KDllUidSimpleImPlugin       0x20022D58
+
+/**
+ * Interface Implementation UIDs
+ */
+#define KImplUidSimpleImPlugin      0x20022D59
+
+#endif // SIMPLEIMPLUGINUIDS_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/rom/simpleimplugin.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  ROM definition file.
+*
+*/
+
+#ifndef SIMPLEIMPLUGIN_IBY
+#define SIMPLEIMPLUGIN_IBY
+
+#ifdef RD_VOIP_REL_2_2
+
+ECOM_PLUGIN(simpleimplugin.dll,	20022D58.RSC)
+
+#endif // RD_VOIP_REL_2_2
+
+#endif // SIMPLEIMPLUGIN_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/src/simpleimconversation.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,487 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <ximpobjectfactory.h>
+#include <imobjectfactory.h>
+#include <simplefactory.h>
+#include <imconversationinfo.h>
+#include <utf.h>
+#include <ximpprotocolconnectionhost.h>
+#include <protocolimdatahost.h>
+#include <protocolimconversationdatahost.h>
+#include <spsettings.h>
+#include <cch.h>
+#include <cimcachefactory.h>
+#include <mimcacheupdater.h>
+
+#include "simpleimconversation.h"
+#include "presenceplugincommon.h"
+#include "mpresencepluginconnectionobs.h"
+#include "simpleimplugindefs.h"
+#include "simpleimlogger.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::CPresencePluginGroups
+// ---------------------------------------------------------------------------
+//
+CSimpleImConversation::CSimpleImConversation( 
+    MPresencePluginConnectionObs& aObs, MSimpleConnection& aConn,
+    TUint aServiceId ):
+  	iConnectionObs( &aObs ),
+  	iConnection( &aConn ),
+  	iServiceId( aServiceId )  	
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImConversation::NewL
+// ---------------------------------------------------------------------------
+//
+CSimpleImConversation* CSimpleImConversation::NewL(
+    MPresencePluginConnectionObs& aObs,
+    MSimpleConnection& aConn, TUint aServiceId)
+    { 
+    CSimpleImConversation* self = 
+        new( ELeave ) CSimpleImConversation ( aObs, aConn, aServiceId );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImConversation::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::ConstructL()
+    {
+    DP_IMP("CSimpleImConversation::ConstructL")
+    
+    iImHandler = TSimpleFactory::NewInstantMessageL( 
+        *iConnection, *this );
+    
+    iImCacheFactory = CIMCacheFactory::InstanceL();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImConversation::~CSimpleImConversation
+// ---------------------------------------------------------------------------
+//
+CSimpleImConversation::~CSimpleImConversation()
+    {
+    DP_IMP("CSimpleImConversation::~CSimpleImConversation")
+    
+    if ( iImHandler )
+        {
+        DP_IMP("Close the msg handler")
+        iImHandler->Close();
+        }
+    
+    // Release the imcache, all the conversation will lost here
+    if ( iImCacheFactory )
+        {
+        DP_IMP("Release IM Cache")
+        CIMCacheFactory::Release();
+        iImCacheFactory = NULL;
+        }
+
+    iImCacheUpdater = NULL;
+    iHost = NULL;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImConversation::SetHost
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::SetHost( MProtocolImDataHost& aHost )
+    {
+    DP_IMP("CSimpleImConversation::SetHost")
+    
+    iHost = &aHost;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImConversation::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CSimpleImConversation::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions )
+    {
+    DP_IMP("CSimpleImConversation::GetInterface")
+    
+    if ( MProtocolImConversation::KInterfaceId == aInterfaceId )
+        {
+        return this;
+        }
+    
+    if ( MXIMPBase::EPanicIfUnknown == aOptions )
+        {
+        User::Panic( KSimpleImPluginName, KErrExtensionNotSupported );
+        }
+    
+    return NULL;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImConversation::GetInterface() const
+// ---------------------------------------------------------------------------
+//
+const TAny* CSimpleImConversation::GetInterface(
+        TInt32 aInterfaceId, TIfGetOps aOptions ) const
+    {
+    DP_IMP("CSimpleImConversation::GetInterface")
+    
+    if ( MProtocolImConversation::KInterfaceId == aInterfaceId )
+        {
+        // caller wants this interface
+        return const_cast<CSimpleImConversation*>( this );
+        }
+    
+    if ( MXIMPBase::EPanicIfUnknown == aOptions )
+        {
+        User::Panic( KSimpleImPluginName, KErrExtensionNotSupported );
+        }
+    
+    return NULL;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImConversation::GetInterfaceId() const
+// ---------------------------------------------------------------------------
+//
+TInt32 CSimpleImConversation::GetInterfaceId() const
+    {
+    DP_IMP("CSimpleImConversation::GetInterfaceId")
+    
+    return MProtocolImConversation::KInterfaceId;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MProtocolImConversation.
+// CSimpleImConversation::DoSendMessageL()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::DoSendMessageL(
+    const MImConversationInfo& aImMessage,
+    TXIMPRequestId aReqId )
+    {
+    DP_IMP( "CSimpleImConversation::DoSendMessageL" )
+    
+    iCompleted = EFalse;    
+    
+    TPtrC16 msgText16 = aImMessage.TextMessage();
+    DP_IMP2( "CSimpleImConversation::DoSendMessageL, CONTENT: %S",
+        &msgText16 )
+    HBufC8* contentData = CnvUtfConverter::ConvertFromUnicodeToUtf8L(
+        msgText16 );
+    CleanupStack::PushL( contentData );
+    
+    const MDesCArray& recipients = aImMessage.RecipientL();
+    for ( TInt i = 0; i < recipients.MdcaCount(); i++ )
+        {
+        TPtrC16 recipientsPtr16 = recipients.MdcaPoint( i );
+        HBufC8* recipientsData = CnvUtfConverter::ConvertFromUnicodeToUtf8L(
+                    recipientsPtr16 );
+        CleanupStack::PushL( recipientsData );
+        DP_IMP2( "CSimpleImConversation::DoSendMessageL, RECIPIENT: %S",
+            &recipientsPtr16 )
+        
+        TInt result = iImHandler->SendInstantMessage( *contentData,
+            *recipientsData );
+        CleanupStack::PopAndDestroy( recipientsData );
+        
+        if ( KErrInUse == result )
+            {
+            User::Leave( KErrInUse );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( contentData );
+    iXimpId = aReqId;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MProtocolImConversation.
+// CSimpleImConversation::DoForwardMessageL()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::DoForwardMessageL(
+    const MImConversationInfo& /*aImMessage*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_IMP( "CSimpleImConversation::DoForwardMessageL, NOT SUPPORTED" )
+    
+    User::Leave( KErrNotSupported );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MProtocolImConversation.
+// CSimpleImConversation::DoSendMessageToGroupL()
+// ---------------------------------------------------------------------------
+//
+void  CSimpleImConversation::DoSendMessageToGroupL(
+    const MImConversationInfo& /*aImMessage*/,
+    const TDesC* /*aGroupId*/, TXIMPRequestId /*aReqId*/ )
+    {
+    DP_IMP( "CSimpleImConversation::DoSendMessageToGroupL, NOT SUPPORTED" )
+    
+    User::Leave( KErrNotSupported );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MProtocolImConversation.
+// CSimpleImConversation::DoBlockUsersL()
+// ---------------------------------------------------------------------------
+//
+TXIMPRequestId CSimpleImConversation::DoBlockUsersL(
+    const MDesCArray* /*aUserIds*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_IMP( "CSimpleImConversation::DoBlockUsersL, NOT SUPPORTED" )
+    
+    User::Leave( KErrNotSupported );
+    return TXIMPRequestId();
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MProtocolImConversation.
+// CSimpleImConversation::DoUnBlockUsersL()
+// ---------------------------------------------------------------------------
+//
+TXIMPRequestId CSimpleImConversation::DoUnBlockUsersL(
+    const MDesCArray* /*aUserIds*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_IMP( "CSimpleImConversation::DoUnBlockUsersL, NOT SUPPORTED" )
+    
+    User::Leave( KErrNotSupported );
+    return TXIMPRequestId();
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MProtocolImConversation.
+// CSimpleImConversation::DoGetBlockedListRequestL()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::DoGetBlockedListRequestL(
+    const MXIMPIdentity& /*aImMessageId*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_IMP( "CSimpleImConversation::DoGetBlockedListRequestL, NOT SUPPORTED" )
+    
+    User::Leave( KErrNotSupported );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MProtocolImConversation.
+// CSimpleImConversation::DoGetMessageListL()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::DoGetMessageListL(
+    const MXIMPIdentity& /*aImMessageId*/,
+    const TDesC* /*aGroupId*/,
+    const TInt /*aMessageCount*/,
+    TBool /*aDeliveryReportWanted*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_IMP( "CSimpleImConversation::DoGetMessageListL, NOT SUPPORTED" )
+    
+    User::Leave( KErrNotSupported );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MProtocolImConversation.
+// CSimpleImConversation::DoRejectMessageL()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::DoRejectMessageL(
+    const MXIMPIdentity& /*aImMessageId*/,
+    const TDesC& /*aMessageID*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_IMP( "CSimpleImConversation::DoRejectMessageL, NOT SUPPORTED" )
+    
+    User::Leave( KErrNotSupported );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MSimpleInstantMsgObserver.
+// CSimpleImConversation::SendInstantMsgReqComplete()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::SendInstantMsgReqComplete( 
+    TInt /*aOpid*/, TInt aStatus)
+    {
+    DP_IMP("CSimpleImConversation::SendInstantMsgReqComplete")
+    
+    CompleteXimpReq( aStatus );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MSimpleInstantMsgObserver.
+// CSimpleImConversation::HandleReceiveTextMessage()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::HandleReceiveTextMessage( 
+    TPtrC8 aFrom, TPtrC8 aContent )
+    {
+    DP_IMP( "CSimpleImConversation::HandleReceiveTextMessage" )
+    
+    TRAPD( err, DoHandleReceiveTextMessageL( aFrom, aContent ) )
+    
+    if ( KErrNone != err )
+        {
+        // Do nothing
+        DP_IMP2( "CSimpleImConversation::HandleReceiveTextMessage, ERROR: %i",
+            err )
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImConversation::CompleteXimpReq()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::CompleteXimpReq( TInt aStatus )
+    {
+    DP_IMP( "CSimpleImConversation::CompleteXimpReq" )
+    
+    if ( iCompleted )
+        {
+        DP_IMP("CSimpleImConversation::CompleteXimpReq return")
+        return;
+        }
+    
+    iCompleted = ETrue;
+    iConnectionObs->CompleteReq( iXimpId, aStatus );
+    iXimpId = TXIMPRequestId();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImConversation::DoHandleReceiveTextMessageL()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::DoHandleReceiveTextMessageL( TPtrC8 aFrom,
+    TPtrC8 aContent )
+    {
+    DP_IMP( "CSimpleImConversation::DoHandleReceiveTextMessageL" )
+    
+    CreateImCacheUpdaterIfNeededL();
+    
+    if ( iHost )
+        {
+        MXIMPObjectFactory& objFact = iConnectionObs->Host()->ObjectFactory();
+        MImObjectFactory& imObjFact = iHost->ImObjectFactory();
+        
+        MXIMPIdentity* identity = objFact.NewIdentityLC(); // CS:1
+        MImConversationInfo* convinfo = imObjFact.
+            NewImConversationInfoLC(); // CS:2
+        
+        HBufC16* sendername = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+            aFrom );
+        CleanupStack::PushL( sendername ); // CS:3
+        identity->SetIdentityL( *sendername );
+        CleanupStack::PopAndDestroy( sendername ); // CS:2
+        convinfo->SetMessageIdL( identity );
+        
+        HBufC16* messagecontent = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+            aContent );
+        CleanupStack::PushL( messagecontent ); // CS:3
+        convinfo->SetTextMessageL( *messagecontent );
+        CleanupStack::PopAndDestroy( messagecontent ); // CS:2
+        
+        iHost->ConversationDataHost().HandleNewTextMessageL( convinfo );
+        TRAP_IGNORE( iImCacheUpdater->AppendReceiveMessageL(
+            identity->Identity(), convinfo->TextMessage() ) );
+        
+        CleanupStack::Pop(); // CS:1
+        CleanupStack::Pop(); // CS:0
+        }
+    else
+        {
+        DP_IMP( " --> PROTOCOL IM DATA HOST IS NULL!" )
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CSimpleImConversation::ResolveUsernameL
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::ResolveUsernameL( 
+        TUint aServiceId, RBuf& aUserName ) const
+    {
+    DP_IMP( "CSimpleImConversation::ResolveUsernameL" )
+    
+    CCch* cchApi = CCch::NewLC();
+    CCchService* service = cchApi->GetService( aServiceId );
+
+    User::LeaveIfError( service->GetConnectionParameter( 
+        ECCHUnknown, ECchUsername, aUserName ) );
+    
+    DP_IMP2( "CSimpleImConversation::ResolveUsernameL, USERNAME: %S",
+        &aUserName )
+    
+    CleanupStack::PopAndDestroy( cchApi );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImConversation::CreateImCacheUpdaterIfNeededL()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImConversation::CreateImCacheUpdaterIfNeededL()
+    {
+    if ( !iImCacheUpdater )
+        {
+        DP_IMP( "CSimpleImConversation::CreateImCacheUpdaterIfNeededL," )
+        DP_IMP( "CREATING UPDATER" )
+        
+        RBuf username;
+        CleanupClosePushL( username );
+        const TInt KMaxUserNameLength = 255;
+        username.CreateL( KMaxUserNameLength );
+        ResolveUsernameL( iServiceId, username );
+        
+        iImCacheUpdater =
+            iImCacheFactory->CreateUpdaterL( iServiceId, username, EFalse );
+        CleanupStack::PopAndDestroy( &username );
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/src/simpleimfeatures.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,223 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include "simpleimfeatures.h"
+#include "simpleimconversation.h"
+#include "mpresencepluginconnectionobs.h"
+#include "simpleimplugindefs.h"
+#include "simpleimlogger.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CSimpleImFeatures::CSimpleImFeatures()
+// ---------------------------------------------------------------------------
+//
+CSimpleImFeatures::CSimpleImFeatures() : CProtocolImFeatures()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImFeatures::NewL()
+// ---------------------------------------------------------------------------
+//
+CSimpleImFeatures* CSimpleImFeatures::NewL( TAny* aInitParams )
+    {
+    DP_IMP( "CSimpleImFeatures::NewL()" )
+    
+    CSimpleImFeatures* self = new( ELeave ) CSimpleImFeatures();
+    CleanupStack::PushL( self );
+    self->ConstructL( aInitParams );
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImFeatures::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CSimpleImFeatures::ConstructL( TAny* aInitParams )
+    {    
+    DP_IMP( "CSimpleImFeatures::ConstructL()" )
+    __ASSERT_ALWAYS( aInitParams, User::Leave( KErrArgument ) );
+    
+    TSimpleImPluginInitParams* initParams =
+        static_cast<TSimpleImPluginInitParams*>( aInitParams );
+    
+    iImConversation = CSimpleImConversation::NewL( initParams->iObserver,
+        initParams->iConnection, initParams->iServiceId );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CSimpleImFeatures::~CSimpleImFeatures
+// ---------------------------------------------------------------------------
+//
+CSimpleImFeatures::~CSimpleImFeatures()
+    {
+    DP_IMP( "CSimpleImFeatures::~CSimpleImFeatures()" )
+    
+    delete iImConversation;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MXIMPBase.
+// CSimpleImFeatures::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CSimpleImFeatures::GetInterface( TInt32 aInterfaceId,
+        TIfGetOps aOptions )
+    {
+    DP_IMP( "CSimpleImFeatures::GetInterface()" )
+    
+    if ( CProtocolImFeatures::KInterfaceId == aInterfaceId )
+        {
+        DP_IMP( "CSimpleImFeatures::GetInterface() - Found" )
+        CProtocolImFeatures* self = this;
+        return self;
+        }
+    
+    if ( MXIMPBase::EPanicIfUnknown == aOptions )
+        {
+        User::Panic( KSimpleImPluginName, KErrExtensionNotSupported );
+        }
+    
+    return NULL;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MXIMPBase.
+// CSimpleImFeatures::GetInterface() const
+// ---------------------------------------------------------------------------
+//
+const TAny* CSimpleImFeatures::GetInterface( TInt32 aInterfaceId,
+        TIfGetOps aOptions ) const
+    {
+	DP_IMP( "CSimpleImFeatures::GetInterface() const" )
+	
+    if ( CProtocolImFeatures::KInterfaceId == aInterfaceId )
+        {
+        DP_IMP( "CSimpleImFeatures::GetInterface() const - Found" )
+        const CProtocolImFeatures* self = this;
+        return self;
+        }
+
+    if ( MXIMPBase::EPanicIfUnknown == aOptions )
+        {
+        User::Panic( KSimpleImPluginName, KErrExtensionNotSupported );
+        }
+    
+    return NULL;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MXIMPBase.
+// CSimpleImFeatures::GetInterfaceId() const
+// ---------------------------------------------------------------------------
+//
+TInt32 CSimpleImFeatures::GetInterfaceId() const
+    {
+    return CProtocolImFeatures::KInterfaceId;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From CProtocolImFeatures.
+// CSimpleImFeatures::ImGroup()
+// ---------------------------------------------------------------------------
+//
+MProtocolImGroup& CSimpleImFeatures::ImGroup()
+    {
+    DP_IMP( "CSimpleImFeatures::ImGroup(), NOT SUPPORTED" )
+    
+    MProtocolImGroup* dummyGroup = NULL;
+    return *dummyGroup;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From CProtocolImFeatures.
+// CSimpleImFeatures::ImConversation()
+// ---------------------------------------------------------------------------
+//
+MProtocolImConversation& CSimpleImFeatures::ImConversation()
+    {
+    DP_IMP( "CSimpleImFeatures::ImConversation()" )
+    
+    return *iImConversation;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From CProtocolImFeatures.
+// CSimpleImFeatures::ImInvitation()
+// ---------------------------------------------------------------------------
+//
+MProtocolImInvitation& CSimpleImFeatures::ImInvitation()
+    {
+    DP_IMP( "CSimpleImFeatures::ImInvitation(), NOT SUPPORTED" )
+    
+    MProtocolImInvitation* dummyInvitation = NULL;
+    return *dummyInvitation;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From CProtocolImFeatures.
+// CSimpleImFeatures::ImSearch()
+// ---------------------------------------------------------------------------
+//
+MProtocolImSearch& CSimpleImFeatures::ImSearch()
+    {
+    DP_IMP( "CSimpleImFeatures::ImSearch(), NOT SUPPORTED" )
+    
+    MProtocolImSearch* dummySearch = NULL;
+    return *dummySearch;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From CProtocolImFeatures.
+// CSimpleImFeatures::SetHost()
+// ---------------------------------------------------------------------------
+//
+void CSimpleImFeatures::SetHost( MProtocolImDataHost& aHost )
+    {
+    DP_IMP( "CSimpleImFeatures::SetHost()" )
+    
+    iHost = &aHost ;
+    iImConversation->SetHost( *iHost );
+    }
+
+// ---------------------------------------------------------------------------
+// From CProtocolImFeatures.
+// CSimpleImFeatures::SupportedSubInterfaces()
+// ---------------------------------------------------------------------------
+//
+TInt CSimpleImFeatures::SupportedSubInterfaces() const
+    {
+    return EProtocolImConversation;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/simpleimplugin/src/simpleimpluginimplementationproxy.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECom implementation proxy.
+*
+*/
+
+
+#include <e32std.h>
+#include <implementationproxy.h>
+
+#include "simpleimfeatures.h"
+
+// LOCAL CONSTANTS AND MACROS
+const TImplementationProxy ImplementationTable[] = 
+    {
+    IMPLEMENTATION_PROXY_ENTRY( 0x20022D59, CSimpleImFeatures::NewL )
+    };
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Function to return the implementation proxy table
+// -----------------------------------------------------------------------------
+//
+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/simpledatamodeladapter/src/presenceconnectioninfo.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,192 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+#include <e32math.h> 
+#include <ximpprotocolconnection.h>
+
+#include "presencepluginconnection.h"
+#include "presenceconnectioninfo.h"
+#include "presenceplugincommon.h"
+#include "presencelogger.h"
+
+ 
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::CPresenceConnectionInfo()
+// ---------------------------------------------------------------------------
+//
+CPresenceConnectionInfo::CPresenceConnectionInfo( 
+        MXIMPProtocolConnection* aConnection ):
+	iConnection( aConnection ),	
+    iConnectStatus( CPresencePluginConnection::ENotActive )
+    {
+    iClientCount = 0;
+    iClientId = GenerateClientId();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresenceConnectionInfo* CPresenceConnectionInfo::NewL( 
+		MXIMPProtocolConnection* aConnection )
+    {
+    DP_SDA("CPresenceConnectionInfo::NewL");
+    CPresenceConnectionInfo* self =
+    	new( ELeave ) CPresenceConnectionInfo( aConnection );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::~CPresenceConnectionInfo()
+// ---------------------------------------------------------------------------
+//
+CPresenceConnectionInfo::~CPresenceConnectionInfo()
+    {
+    DP_SDA("CPresenceConnectionInfo::~CPresenceConnectionInfo");
+    DP_SDA2("CPresenceConnectionInfo:: clientID %d", iClientId);
+    
+    delete iETag;
+    iETag = NULL;
+    
+    DP_SDA("CPresenceConnectionInfo::~CPresenceConnectionInfo done");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::SetConnectionStatus()
+// ---------------------------------------------------------------------------
+//
+void CPresenceConnectionInfo::SetConnectionStatus( 
+		CPresencePluginConnection::TConnectionStatus aStatus )
+    {
+    DP_SDA2("CPresenceConnectionInfo::SetConnectionStatus %d", aStatus);
+    DP_SDA2("CPresenceConnectionInfo:: clientID %d", iClientId);
+    iConnectStatus = aStatus;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::SetConnectionETag()
+// ---------------------------------------------------------------------------
+//
+void CPresenceConnectionInfo::SetConnectionETag( const TDesC8& aETag )
+    {
+    DP_SDA("CPresenceConnectionInfo::SetConnectionETag");
+    DP_SDA2("CPresenceConnectionInfo:: clientID %d", iClientId);
+    delete iETag;
+    iETag = NULL;
+    TRAP_IGNORE( ( iETag = aETag.AllocL() ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::GetConnectionStatus()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginConnection::TConnectionStatus 
+	CPresenceConnectionInfo::GetConnectionStatus()
+    {
+    DP_SDA("CPresenceConnectionInfo::GetConnectionStatus");
+    DP_SDA2("CPresenceConnectionInfo:: clientID %d", iClientId);
+    DP_SDA2("CPresenceConnectionInfo:: connection status %d", iConnectStatus);
+    return iConnectStatus;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::GetConnectionEtag()
+// ---------------------------------------------------------------------------
+//
+TDesC8* CPresenceConnectionInfo::GetConnectionEtag()
+    {
+    DP_SDA("CPresenceConnectionInfo::GetConnectionEtag");
+    DP_SDA2("CPresenceConnectionInfo:: clientID %d", iClientId);
+    return iETag;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::GetConnection()
+// ---------------------------------------------------------------------------
+//
+MXIMPProtocolConnection* CPresenceConnectionInfo::GetConnection()
+    {
+    DP_SDA("CPresenceConnectionInfo::GetConnection");
+    DP_SDA2("CPresenceConnectionInfo:: clientID %d", iClientId);
+    return iConnection;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::IncreaseClientCount()
+// ---------------------------------------------------------------------------
+//
+void CPresenceConnectionInfo::IncreaseClientCount()
+    {
+    iClientCount++;
+    DP_SDA2("CPresenceConnectionInfo::IncreaseClientCount %d", iClientCount );
+    DP_SDA2("CPresenceConnectionInfo:: clientID %d", iClientId);
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::DecreaseClientCount()
+// ---------------------------------------------------------------------------
+//
+void CPresenceConnectionInfo::DecreaseClientCount()
+    {
+    iClientCount--;
+    DP_SDA2("CPresenceConnectionArray::DecreaseClientCount %d", iClientCount );
+    DP_SDA2("CPresenceConnectionArray:: clientID %d", iClientId);
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::ClientCount()
+// ---------------------------------------------------------------------------
+//
+TInt CPresenceConnectionInfo::ClientCount()
+    {
+    DP_SDA2("CPresenceConnectionInfo::ClientCount %d", iClientCount );
+    DP_SDA2("CPresenceConnectionInfo:: clientID %d", iClientId);
+    return iClientCount;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::GetClientId()
+// ---------------------------------------------------------------------------
+//
+TInt CPresenceConnectionInfo::GetClientId()
+    {
+    DP_SDA2("CPresenceConnectionInfo::ClientCount %d", iClientCount );
+    DP_SDA2("CPresenceConnectionInfo:: clientID %d", iClientId);
+    return iClientId;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresenceConnectionInfo::GenerateClientId()
+// ---------------------------------------------------------------------------
+//
+TInt CPresenceConnectionInfo::GenerateClientId()
+    {
+    // Generate unique session client id
+    DP_SDA("CPresenceConnectionInfo::GenerateClientIdstart");
+    const TInt KMaxRand = 9999;
+    TInt64 seed;
+    TTime time;
+    time.HomeTime();
+    seed = time.Int64();
+    TInt random = Math::Rand( seed ) % KMaxRand;
+    DP_SDA("CPresenceConnectionInfo::GenerateClientId 1");
+    return random; 
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presenceplugin.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,378 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <badesca.h>
+#include <ecom/implementationproxy.h>
+#include <ximpserviceinfo.h>
+#include <ximpbase.h>
+#include <ximpidentity.h>
+#include <presenceinfo.h>
+#include <ximpprotocolconnectionhost.h>
+#include <ximpprotocolconnection.h>
+#include <ximpserviceinfo.h>
+#include <ximpcontextclientinfo.h>
+
+#include "presenceplugin.h"
+#include "presenceplugindef.h"
+#include "presencepluginconnection.h"
+#include "presenceplugincommon.h"
+#include "presenceplugin_resource.hrh"
+#include "presenceconnectioninfo.h"
+ 
+#include <spsettings.h>
+#include <spentry.h>
+#include <spproperty.h>
+#include <spdefinitions.h>
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Key value pair table to identify correct constructor
+// function for the requested interface.
+// ---------------------------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] =
+    {
+    //Warning in Lint 611
+    IMPLEMENTATION_PROXY_ENTRY( PRESENCEPLUGIN_1_IMPLEMENTATION_UID,
+        CPresencePlugin::NewL )
+    };
+
+// ---------------------------------------------------------------------------
+// Exported function to return the implementation proxy table
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( 
+    TInt& aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) /
+        sizeof( TImplementationProxy );
+    return ImplementationTable;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePlugin::CPresencePlugin()
+// ---------------------------------------------------------------------------
+//
+CPresencePlugin::CPresencePlugin()
+    {
+    //empty
+    }
+   
+// ---------------------------------------------------------------------------
+// CPresencePlugin::NewLC()
+// ---------------------------------------------------------------------------
+//
+CPresencePlugin* CPresencePlugin::NewLC()
+    {
+    CPresencePlugin* self = new( ELeave ) CPresencePlugin();
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePlugin::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresencePlugin* CPresencePlugin::NewL()
+    {
+    CPresencePlugin* self = CPresencePlugin::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePlugin::~CPresencePlugin()
+// ---------------------------------------------------------------------------
+//
+CPresencePlugin::~CPresencePlugin()
+    {
+    DP_SDA("CPresencePlugin::~CPresencePlugin");
+    iConnections.ResetAndDestroy();
+    iConnectionArray.ResetAndDestroy();
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePlugin::~CPresencePlugin()
+// ---------------------------------------------------------------------------
+//   
+void CPresencePlugin::PrimeHost( MXIMPProtocolPluginHost& aHost ) 
+    {
+    DP_SDA("CPresencePlugin::PrimeHost");
+    iHost = &aHost;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePlugin::AcquireConnectionL()
+// ---------------------------------------------------------------------------
+//
+MXIMPProtocolConnection& CPresencePlugin::AcquireConnectionL(
+    const MXIMPServiceInfo& aServiceInfo,
+    const MXIMPContextClientInfo& aContextClient )
+    {
+    DP_SDA("CPresencePlugin::AcquireConnectionL");
+    MXIMPProtocolConnection* tmp = NULL;
+    CPresenceConnectionInfo* connectionArray = NULL;
+    TBool connected = EFalse;
+    
+    //Check if presence is allready connected to id
+    //!!!! IN this adapter that IapID is service id ID!!!!
+    
+    DP_SDA2("CPresencePlugin::AcquireConnectionL - service id: %d", 
+        aServiceInfo.IapId() );
+    
+    TInt presenceId = KErrNotFound;
+    CSPSettings* spSettings = CSPSettings::NewL();
+    CleanupStack::PushL( spSettings );
+    
+    CSPProperty* property = CSPProperty::NewLC();
+    spSettings->FindPropertyL( aServiceInfo.IapId(),
+                                ESubPropertyPresenceSettingsId,
+                                *property );    
+    if ( property )
+        {
+        property->GetValue( presenceId );
+        }
+    CleanupStack::PopAndDestroy( property );        
+    CleanupStack::PopAndDestroy( spSettings );
+
+    DP_SDA2(" -> presence settings id: %d",presenceId );
+    __ASSERT_ALWAYS( presenceId > 0, User::Leave( KErrArgument ) );
+    
+    TInt connectionsCount = iConnections.Count();
+    DP_SDA2("AcquireConnectionL : connectionsCount =%d ", connectionsCount );
+    
+    for( TInt i( connectionsCount - 1 ); i >= 0; i-- )
+    	{
+		DP_SDA2("AcquireConnectionL connection count %d", connectionsCount);
+        if( iConnections[i]->GetPresenceSetId() == presenceId )
+            {
+            DP_SDA2("AcquireConnectionL RETURN OLD CONNECTION : i = %d " , i );
+            //Check connection status
+			tmp = iConnections[i];
+			connectionArray = iConnections[i]->GetConnectionArray();
+			
+			//Check connection status from connectionArray
+			CPresencePluginConnection::TConnectionStatus status =
+				connectionArray->GetConnectionStatus();
+			
+			if( CPresencePluginConnection::ENotActive == status )
+			    {
+			    DP_SDA("AcquireConnectionL ENotActive ");
+                DP_SDA("AcquireConnectionL Del old inactive connection");
+                //Call session CLOSE here!!!!!
+                //Ensure there is no any client to bind this connect
+                //Release this failed connection
+                DeleteConnection(i);
+			    }
+			else if ( CPresencePluginConnection::ETerminated == status )
+                {
+                DP_SDA("AcquireConnectionL ETerminated CREATE NEW CONNECTION ");
+                //Roamning try use lates ETag
+                //Delete old terminaded connection and create new with old ETag                             
+                CPresencePluginConnection* connection =
+                	CPresencePluginConnection::NewL(
+                        aServiceInfo, aContextClient,
+                        *iConnectionArray[i]->GetConnectionEtag() );
+                CleanupStack::PushL( connection );
+                
+                DeleteConnection( i );
+                
+                //Add this new connection to connectionArray
+                CPresenceConnectionInfo* connectionInfo =
+                	CPresenceConnectionInfo::NewL( connection );
+                CleanupStack::PushL( connectionInfo );
+                iConnectionArray.AppendL( connectionInfo );
+                CleanupStack::Pop();
+                connection->SetConnectionArray( connectionInfo );
+                iConnections.AppendL( connection );
+                CleanupStack::Pop( connection ); 
+                tmp = connection;
+                connected = ETrue;
+                
+                iConnectionArray[i]->IncreaseClientCount();
+                }
+			else if ( CPresencePluginConnection::EActive == status )
+			    {
+			    DP_SDA("AcquireConnectionL EActive");
+                // NOTE: Incase there is no reply from XIMP before client is
+                // shutdown , then closeconnection wouldnt be called, reopening 
+                // client will increase clientCount which is wrong. ClientCount 
+                // should be checked for validity before increasing? 
+                // If already connected
+                iConnectionArray[i]->IncreaseClientCount();
+                connected = ETrue;
+                tmp = iConnections[i];
+                DP_SDA("AcquireConnectionL RETURN OLD CONNECTION done");
+			    }
+			break;
+            }
+        }   
+    if( !connected )
+        {
+        DP_SDA("CPresencePlugin::AcquireConnectionL CREATE NEW CONNECTION");
+        // If not already connected 
+        CPresencePluginConnection* connection = CPresencePluginConnection::NewL(
+        	aServiceInfo, aContextClient );
+        CleanupStack::PushL( connection );
+        
+        //Add this new connection to connectionArray
+        CPresenceConnectionInfo* connectionInfo =
+        	CPresenceConnectionInfo::NewL( connection );
+        CleanupStack::PushL( connectionInfo );
+        iConnectionArray.AppendL( connectionInfo );
+        CleanupStack::Pop();
+        connection->SetConnectionArray( connectionInfo );
+        //Add on binded client
+        connectionInfo->IncreaseClientCount();
+        
+        iConnections.AppendL( connection );
+        CleanupStack::Pop( connection ); 
+    	tmp = connection;
+    	DP_SDA("AcquireConnectionL CREATE NEW CONNECTION DONE"); 
+        }
+    DP_SDA("CPresencePlugin::AcquireConnectionL ret");    
+	return *tmp;				
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePlugin::ReleaseConnection()
+// ---------------------------------------------------------------------------
+//
+void CPresencePlugin::ReleaseConnection( MXIMPProtocolConnection& aConnection )
+    {
+    DP_SDA("CPresencePlugin::ReleaseConnection");   
+	TInt connectionsCount = iConnections.Count();
+    
+    DP_SDA2("ReleaseConnection : connectionsCount =%d ", connectionsCount );    
+        
+    for ( TInt i=0; i < connectionsCount; i++ )          
+        {
+        DP_SDA("CPresencePlugin::ReleaseConnection for start");
+        if ( iConnectionArray[i]->GetConnection() == &aConnection )
+            {
+            //Check how many client is using this connection
+            TInt clientCount = iConnectionArray[i]->ClientCount();
+            
+            DP_SDA2("ReleaseConnection :  clientCount = %d ", clientCount );    
+            DP_SDA2("CPresencePlugin::ReleaseConnection :  i = %d", i );    
+                
+            if ( connectionsCount == 1 && clientCount <= 0 )
+                {
+                DP_SDA("CPresencePlugin::ReleaseConnection Lets start to check");
+                DP_SDA2("CPresencePlugin::ReleaseConnection connect status %d,", iConnections[i]->GetSessionStatus());
+                //Check this connection status
+                if( !(CPresencePluginConnection::ENotActive ==
+                	iConnectionArray[i]->GetConnectionStatus() ))
+                   {
+                   DP_SDA("CPresencePlugin::ReleaseConnection not have clients");
+                   DeleteConnection(i);
+                   break;
+                   }
+                DP_SDA("connectionsCount == 1 && i == 0 && clientCount == 0 ");    
+                DP_SDA("ReleaseConnection : Don't delete this connection ");    
+                break; //don't delete first connection
+                } 
+            DP_SDA("CPresencePlugin::ReleaseConnection for end");  
+            }
+        }     
+    DP_SDA("CPresencePlugin::ReleaseConnection end");     
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePlugin::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CPresencePlugin::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions )
+    {       
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface 
+        return this;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }  
+    return NULL;    
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePlugin::GetInterface()
+// ---------------------------------------------------------------------------
+//
+const TAny* CPresencePlugin::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    DP_SDA("CPresencePlugin::GetInterface");
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        return const_cast<CPresencePlugin*>(this);
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }       
+    return NULL; 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePlugin::GetInterfaceId()
+// ---------------------------------------------------------------------------
+//
+TInt32 CPresencePlugin::GetInterfaceId() const
+    {
+    return MXIMPProtocolPlugin::KInterfaceId;
+    }    
+
+// ---------------------------------------------------------------------------
+// CPresencePlugin::DeleteConnection()
+// ---------------------------------------------------------------------------
+//
+void CPresencePlugin::DeleteConnection( TInt aIndex )
+    {
+    //First delete connectionArray where connection is same at connection
+    DP_SDA("CPresencePlugin::DeleteConnection"); 
+    
+    TInt connectionArrayCount = iConnectionArray.Count();
+    
+    for ( TInt i=0; i < connectionArrayCount; i++ )
+        {
+        DP_SDA2("CPresencePlugin::DeleteConnection FINDING, con status %d", iConnectionArray[i]->GetConnectionStatus() ); 
+        if( (iConnections[aIndex] == iConnectionArray[i]->GetConnection()) &&
+            !(CPresencePluginConnection::EActive ==
+            iConnectionArray[i]->GetConnectionStatus() )    )
+            {
+            DP_SDA("CPresencePlugin::DeleteConnection connection Match"); 
+            delete iConnectionArray[i];
+            iConnectionArray.Remove( i );
+            iConnectionArray.Compress();
+            break; 
+            }
+        }
+    delete iConnections[aIndex];
+    iConnections.Remove( aIndex );
+    iConnections.Compress();
+    DP_SDA("CPresencePlugin::DeleteConnection end"); 
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginauthorization.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,1350 @@
+/*
+* Copyright (c) 2006-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+#include <e32std.h>
+#include <s32strm.h>
+#include <utf.h>
+#include <ximpdatasubscriptionstate.h>
+#include <protocolpresenceauthorizationdatahost.h>
+#include <ximpobjectfactory.h>
+#include <presenceobjectfactory.h>
+#include <ximpstatus.h>
+#include <ximpidentity.h>
+#include <presencegrantrequestinfo.h>
+#include <ximpobjectcollection.h>
+#include <presenceblockinfo.h>
+#include <presenceinfofilter.h>
+#include <msimplewinfo.h>
+#include <msimpleelement.h>
+
+#include <presenceinfo.h>
+#include <presenceinfofieldcollection.h>
+#include <personpresenceinfo.h>
+#include <presenceinfofield.h>
+#include <presenceinfofieldvalueenum.h>
+#include <avabilitytext.h>
+
+#include "presencepluginauthorization.h"
+#include "presencepluginwinfo.h"
+#include "presenceplugincommon.h"
+#include "presencepluginxdmutils.h"
+#include "presencepluginwatcher.h"
+#include "presenceplugindata.h"
+#include "presencepluginutility.h"
+#include "presenceplugingroup.h"
+#include "presencepluginvirtualgroup.h"
+#include "presenceplugincontacts.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::CPresencePluginAuthorization()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginAuthorization::CPresencePluginAuthorization(
+    MPresencePluginConnectionObs& aObs,
+    CPresencePluginData* aPresenceData )
+    : CActive( CActive::EPriorityStandard ),
+    iConnObs(aObs), iSubscribed( EFalse ),
+    iOperation( ENoOperation ), iXdmOk( EFalse ),
+    iComplete( EFalse ), iPresenceData( aPresenceData ),
+    iContactIsStored( ETrue )
+    {
+    CActiveScheduler::Add(this);
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginAuthorization* CPresencePluginAuthorization::NewL(
+    MPresencePluginConnectionObs& aObs,
+    CPresencePluginData* aPresenceData )
+    {
+    DP_SDA("CPresencePluginAuthorization::NewL ");
+    CPresencePluginAuthorization* self =
+        new( ELeave ) CPresencePluginAuthorization( aObs, aPresenceData );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::ConstructL()
+    {
+    HBufC* serviceName =
+        iPresenceData->ServiceNameLC( iPresenceData->ServiceId() );
+    iContacts = CPresencePluginContacts::NewL(
+        iPresenceData->ServiceId(), *serviceName, *this );
+    CleanupStack::PopAndDestroy( serviceName );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::~CPresencePluginAuthorization()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginAuthorization::~CPresencePluginAuthorization()
+    {
+    delete iPresIdentity;
+    delete iContacts;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::SetDataHost()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::SetDataHost( 
+    MProtocolPresenceAuthorizationDataHost& aDataHost )
+    {
+    DP_SDA("CPresencePluginAuthorization::SetDataHost ");
+    iDataHost = &aDataHost;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::WinfoTerminatedL()
+// ---------------------------------------------------------------------------
+// 
+void CPresencePluginAuthorization::WinfoTerminatedL( TInt aReason )
+    {
+    DP_SDA("CPresencePluginAuthorization::WinfoTerminatedL ");
+    
+    if ( iSubscribed )
+        {
+        MXIMPDataSubscriptionState* myState =
+            iConnObs.ObjectFactory().NewDataSubscriptionStateLC();
+        MXIMPStatus* myStatus = iConnObs.ObjectFactory().NewStatusLC();
+        myStatus->SetResultCode( aReason ? aReason : KErrCompletion );
+        myState->SetSubscriptionStateL( 
+            MXIMPDataSubscriptionState::ESubscriptionInactive );
+        
+        // parameters' OWNERSHIP is taken   
+        iDataHost->SetPresenceGrantRequestDataSubscriptionStateL( 
+            myState,  
+            myStatus );
+        
+        CleanupStack::Pop( /*myStatus*/ );
+        CleanupStack::Pop( /*myState*/ );
+        }
+    
+    DP_SDA("CPresencePluginAuthorization::WinfoTerminatedL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoSubscribePresenceGrantRequestListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoSubscribePresenceGrantRequestListL(
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("DoSubscribePresenceGrantRequestListL ");
+    iConnObs.WinfoHandlerL()->SubscribeWinfoListL( aReqId );
+    iSubscribed = ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoUnsubscribePresenceGrantRequestListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoUnsubscribePresenceGrantRequestListL(
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("DoUnsubscribePresenceGrantRequestListL ");
+    iConnObs.WinfoHandlerL()->UnsubscribeWinfoListL( aReqId );
+    iSubscribed = EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoGrantPresenceForPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoGrantPresenceForPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    const MPresenceInfoFilter& /*aPif*/,  // notice: pif support
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginAuthorization::DoGrantPresenceForPresentityL ");
+    
+    // Workaround for clients that can only grant when accepting buddy request.
+    // SIMPLE also requires grant + subscribe so do both here even though
+    // it is agains ximp api definitions.
+    
+    _LIT( KDefaultBuddyList, "buddylist" );
+    
+    iAuthState = EStateAcceptBuddyRequest;
+    MXIMPIdentity* buddyList = iConnObs.ObjectFactory().NewIdentityLC(); 
+    buddyList->SetIdentityL( KDefaultBuddyList() ); 
+    
+    iConnObs.GroupsL().DoAddPresentityGroupMemberL( *buddyList, aPresentityId,
+        KNullDesC(), aReqId );
+    CleanupStack::PopAndDestroy( 1 ); // buddyList 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoPerformGrantPresenceForPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoPerformGrantPresenceForPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    TRequestStatus& aClientStatus )
+    {
+    DP_SDA("CPresencePluginAuthorization::DoPerformGrantPresenceForPresentityL");
+    StartXdmOperationL( aPresentityId, 
+        EGrantPresenceForPresentity, aClientStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoUpdatePresenceGrantPifForPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoUpdatePresenceGrantPifForPresentityL(
+    const MXIMPIdentity& /*aPresentityId*/,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    // Notice: later
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoWithdrawPresenceGrantFromPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoWithdrawPresenceGrantFromPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginAuth::DoWithdrawPresenceGrantFromPresentityL ");
+    StartXdmOperationL( aPresentityId, aReqId, EWithdrawFromPresentity );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoPerformWithdrawPresGrantFromPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoPerformWithdrawPresGrantFromPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    TRequestStatus& aClientStatus )
+    {
+    DP_SDA("CPresencePluginAuthorization");
+    DP_SDA(" -> DoPerformWithdrawPresGrantFromPresentityL");
+    StartXdmOperationL( aPresentityId,
+        EWithdrawFromPresentity, aClientStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoGrantPresenceForPresentityGroupMembersL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoGrantPresenceForPresentityGroupMembersL(
+    const MXIMPIdentity& /*aGroupId*/,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_SDA("CPresencePluginAuthorization::DoGrantPresenceForPresentityGroupMembersL -not supported");
+    
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::
+// DoUpdatePresenceGrantPifForPresentityGroupMembersL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::
+    DoUpdatePresenceGrantPifForPresentityGroupMembersL(
+    const MXIMPIdentity& /*aGroupId*/,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_SDA("CPresencePluginAuthorization::DoUpdatePresenceGrantPifForPresentityGroupMembersL -not supported");
+    
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::
+// DoWithdrawPresenceGrantFromPresentityGroupMembersL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::
+    DoWithdrawPresenceGrantFromPresentityGroupMembersL(
+    const MXIMPIdentity& /*aGroupId*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_SDA("CPresencePluginAuthorization::DoWithdrawPresenceGrantFromPresentityGroupMembersL -not supported");
+    
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoGrantPresenceForEveryoneL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoGrantPresenceForEveryoneL(
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_SDA("CPresencePluginAuthorization::DoGrantPresenceForEveryoneL -not supported");
+    
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoUpdatePresenceGrantPifForEveryoneL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoUpdatePresenceGrantPifForEveryoneL(
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_SDA("CPresencePluginAuthorization::DoUpdatePresenceGrantPifForEveryoneL -not supported");
+    
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoWithdrawPresenceGrantFromEveryoneL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoWithdrawPresenceGrantFromEveryoneL(
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_SDA("CPresencePluginAuthorization::DoWithdrawPresenceGrantFromEveryoneL -not supported");
+    
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoSubscribePresenceBlockListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoSubscribePresenceBlockListL(
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginAuthorization::DoSubscribePresenceBlockListL ");
+    MXIMPIdentity* nobody = iConnObs.ObjectFactory().NewIdentityLC(); 
+    StartXdmOperationL( *nobody, aReqId, ESubscribeBlockList );
+    // Cannot PopAndDestroy by name
+    CleanupStack::PopAndDestroy( );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoUnsubscribePresenceBlockListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoUnsubscribePresenceBlockListL(
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginAuthorization::DoUnsubscribePresenceBlockListL ");
+    MXIMPIdentity* nobody = iConnObs.ObjectFactory().NewIdentityLC();
+    StartXdmOperationL( *nobody, aReqId, EUnsubscribeBlockList );
+    // Cannot PopAndDestroy by name
+    CleanupStack::PopAndDestroy();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoBlockPresenceForPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoBlockPresenceForPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginAuthorization::DoBlockPresenceForPresentityL ");
+    StartXdmOperationL( aPresentityId, aReqId, EBlockPresentity );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoPerformBlockPresenceForPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoPerformBlockPresenceForPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    TRequestStatus& aClientStatus )
+    {
+    DP_SDA(
+        "CPresencePluginAuthorization::DoPerformBlockPresenceForPresentityL");
+    StartXdmOperationL( aPresentityId, EBlockPresentity, aClientStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoCancelPresenceBlockFromPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoCancelPresenceBlockFromPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA(" DoCancelPresenceBlockFromPresentityL ");
+    StartXdmOperationL( aPresentityId, aReqId, EUnblockPresentity );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoPerformCancelPresenceBlockFromPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoPerformCancelPresenceBlockFromPresentityL(
+    const MXIMPIdentity& aPresentityId,
+    TRequestStatus& aClientStatus )
+    {
+    DP_SDA(" DoPerformCancelPresenceBlockFromPresentityL (list)");
+    StartXdmOperationL( aPresentityId, EUnblockPresentity, aClientStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::DoCancel(  )
+    {
+    iXdmUtils->Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::RunL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::RunL(  )
+    {
+    TInt myStatus = iStatus.Int();
+    
+    DP_SDA2( "CPresencePluginAuthorization::RunL mystatus %d ", myStatus );
+    DP_SDA2( "CPresencePluginAuthorization::RunL state %d ",iOperation );
+    
+    if ( !iXdmOk && !myStatus )
+        {
+        DP_SDA( "CPresencePluginAuthorization::RunL !iXdmOk && !myStatus" );
+        iXdmOk = ETrue;
+        CallActualXdmOperationL();
+        }
+    else if ( iClientStatus )
+        {
+        DP_SDA( "CPresencePluginAuthorization::RunL - complete client" );
+        TRequestStatus* s = iClientStatus;
+        User::RequestComplete( s, myStatus );
+        iClientStatus = NULL;
+        DP_SDA( "CPresencePluginAuthorization::RunL - complete client ok" );
+        }
+    else if ( !myStatus )
+        {
+        switch ( iAuthState )
+            {
+            case EStateDoBlock:
+                {
+                DP_SDA( "CPresencePluginAuthorization::RunL - Block presentity" );
+                BlockPresentityL();
+                iAuthState = EStateRemovePresentityFromGranted;
+                }
+                break;
+                
+            case EStateRemovePresentityFromGranted:
+                {
+                DP_SDA( "CPresencePluginAuthorization::RunL - Remove presentity from granted" );
+                WithdrawFromPresentityL();
+                iAuthState = EStateBlocked;
+                }
+                break;
+            
+            case EStateBlocked:
+                {
+                DP_SDA( "CPresencePluginAuthorization::RunL - Blocked" );
+                SetPresentityBlockedToXIMPL();
+                iAuthState = EStateIdle;
+                CompleteXIMPReq( myStatus );
+                }
+                break;
+
+            case EStateIsContactBlockedBuddyRequest:
+                {
+                DP_SDA( "CPresencePluginAuthorization::RunL - Resolve contact type" );
+                // resolve is contact blocked friend request
+                HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *iPresIdentity );
+                IsBlockedContactFriendRequestL( *withoutPrefix, *this, iStatus );
+                CleanupStack::PopAndDestroy( withoutPrefix );
+                SetActive();
+                iAuthState = EStateDoUnBlock;
+                }
+                break;
+                
+            case EStateDoUnBlock:
+                {
+                if ( iContactIsStored )
+                    {
+                    DP_SDA( "CPresencePluginAuthorization::RunL - Grant presence for presentity" );
+                    GrantPresenceForPresentityL();
+                    iAuthState = EStatePresenceGranted;
+                    }
+                else
+                    {
+                    DP_SDA( "CPresencePluginAuthorization::RunL - Complete unblock" );
+                    iAuthState = EStateIdle;
+                    CompleteXIMPReq( myStatus );
+                    }
+                }
+                break;
+            
+            case EStatePresenceGranted:
+                {
+                DP_SDA( "CPresencePluginAuthorization::RunL -Subscribe presentity presence" );  
+                MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC();
+                identity->SetIdentityL( iPresIdentity->Des() ); 
+                iConnObs.WatcherHandlerL()->DoPerformSubscribePresentityPresenceL( *identity, iStatus );
+                CleanupStack::PopAndDestroy( ); //identity 
+                iAuthState = EStateSubscribe;
+                SetActive();
+                }
+                break;
+                
+            case EStateSubscribe:
+                {
+                DP_SDA( "CPresencePluginAuthorization::RunL -UnBlock completed" ); 
+                HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *iPresIdentity );
+                iPresenceData->WriteStatusToCacheL( *withoutPrefix, 
+                    MPresenceBuddyInfo2::ENotAvailable,
+                    KInvisibleState(),
+                    KNullDesC() );
+                CleanupStack::PopAndDestroy( withoutPrefix );
+                iAuthState = EStateIdle;
+                CompleteXIMPReq( myStatus );
+                }
+                break;
+                
+            default:
+                {
+                DP_SDA( "CPresencePluginAuthorization::RunL - default case" );
+                CompleteXIMPReq( myStatus );
+                }
+                break;
+            }
+        }
+    else if ( KErrNotFound == myStatus && EStateDoBlock == iAuthState )
+        {
+        // When blocking friend request, watcher was not found but request
+        // has to be blocked anyways.
+        DP_SDA( "CPresencePluginAuthorization::RunL - Block presentity" );
+        BlockPresentityL();
+        iAuthState = EStateBlocked;
+        }
+    else
+        {
+        DP_SDA( "CPresencePluginAuthorization::RunL -error" );
+        CompleteXIMPReq( myStatus );
+        }
+        
+    if ( EStateAcceptBuddyRequest == iAuthState && EGrantPresenceForPresentity == iOperation )
+        {
+        iAuthState = EStateIdle;
+        HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *iPresIdentity );
+        CallHandlePresenceGrantRequestObsoletedL( *withoutPrefix );
+        iConnObs.SubscribedContacts()->HandlePresentityGroupMemberAddedL( *withoutPrefix );
+        CleanupStack::PopAndDestroy( withoutPrefix );
+        }
+    
+    DP_SDA( "CPresencePluginAuthorization::RunL - exit" );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::CallActualXdmOperationL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::CallActualXdmOperationL()
+    {
+    DP_SDA("CPresencePluginAuthorization::CallActualXdmOperationL ");
+    DP_SDA2("CallActualXdmOperationL operation %d", iOperation );
+    iComplete = EFalse;
+    switch ( iOperation )
+        {
+        case EGrantPresenceForPresentity:
+            {
+            DP_SDA("CallActualXdmOperationL EGrantPresenceForPresentity");
+            GrantPresenceForPresentityL();
+            }
+            break;
+            
+        case EWithdrawFromPresentity:
+            {
+            DP_SDA("CallActualXdmOperationL EWithdrawFromPresentity");
+            WithdrawFromPresentityL();
+            }
+            break;
+            
+        case ESubscribeBlockList:
+            {
+            SubscribeBlockListL( );
+            }
+            break;
+            
+        case EUnsubscribeBlockList:
+            {
+            UnSubscribeBlockListL();
+            }
+            break;
+            
+        case EBlockPresentity:
+            {
+            DP_SDA( "CallActualXdmOperationL EBlockPresentity" );
+            
+            TRAPD( error, UnsubscribePresentityPresenceL() );
+            
+            if( error )
+                {
+                DP_SDA2( "Unsubscribe presentity FAIL, error = %d" , error );
+                
+                if ( KErrNotFound != error  )
+                    {
+                    User::Leave( error );
+                    }
+                BlockPresentityL();
+                iAuthState = EStateBlocked;
+                }
+            else
+                {
+                iAuthState = EStateDoBlock;
+                }
+            }
+            break;
+            
+        case EUnblockPresentity:
+            {
+            DP_SDA("CallActualXdmOperationL EUnblockPresentity"); 
+            UnblockPresentityL();
+            }
+            break;
+            
+        default:
+            User::Leave( KErrNotSupported );
+            break;
+        }
+    DP_SDA("CPresencePluginAuthorization::CallActualXdmOperationL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::RunError()
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginAuthorization::RunError( TInt aError )
+    {
+    // complete the open request
+    CompleteXIMPReq( aError );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CPresencePluginAuthorization::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions )
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        return this;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }  
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::GetInterface() const
+// ---------------------------------------------------------------------------
+//
+const TAny* CPresencePluginAuthorization::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        return const_cast<CPresencePluginAuthorization*>(this);
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }  
+    return NULL;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::GetInterfaceId()
+// ---------------------------------------------------------------------------
+//
+TInt32 CPresencePluginAuthorization::GetInterfaceId() const
+    {
+    return MProtocolPresenceAuthorization::KInterfaceId;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::SetPresIdentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::SetPresIdentityL(
+    const MXIMPIdentity& aPresentityId,
+    TBool aFormatUri )
+    {  
+    DP_SDA2("CPresencePluginAuthorization::SetPresIdentityL: %S",
+        &aPresentityId.Identity() );
+    
+    delete iPresIdentity;
+    iPresIdentity = NULL;
+    
+    if ( aFormatUri )
+        {
+        DP_SDA("CPresencePluginAuthorization::SetPresIdentityL, add prefix");
+        
+        HBufC8* identityCopy = HBufC8::NewLC( KBufSize255 );
+        TPtr8 identityCopyPtr( identityCopy->Des() );
+        identityCopyPtr.Copy( aPresentityId.Identity() );
+        
+        HBufC8* prefixUri = iPresenceData->CreatePresenceUri8LC( 
+            identityCopyPtr );
+        
+        HBufC* prefixUri16 = HBufC::NewLC( KBufSize255 );
+        TPtr prefixUri16Ptr( prefixUri16->Des() );
+        prefixUri16Ptr.Copy( *prefixUri );
+        
+        iPresIdentity = prefixUri16;
+        CleanupStack::Pop( prefixUri16 );
+        CleanupStack::PopAndDestroy( prefixUri );
+        CleanupStack::PopAndDestroy( identityCopy );
+        }
+    else
+        {
+        DP_SDA(" SetPresIdentityL, use as it is");
+        iPresIdentity = aPresentityId.Identity().AllocL();
+        }
+    DP_SDA( "CPresencePluginAuthorization::SetPresIdentityL -exit" );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::WinfoNotificationL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::WinfoNotificationL(
+    MSimpleWinfo& aWinfo )
+    {
+    DP_SDA("CPresencePluginAuthorization::WinfoNotificationL");
+    // Ignore notification if not subscribed
+    using namespace NPresencePlugin::NPresence;
+    
+    RPointerArray<MSimpleElement> elems;
+    CleanupClosePushL( elems );
+    TInt err = aWinfo.SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    TInt count = elems.Count();
+    
+    DP_SDA2("CPresencePluginAuthorization::WinfoNotificationL count %d",
+        count);
+    
+    if ( !count ) 
+        { 
+        // stop parsing empty notification 
+        DP_SDA("CPresencePluginAuthorization::WinfoNotificationL LEAVE");
+        User::Leave( KErrArgument ); 
+        } 
+    
+    const TDesC8* stateVal = aWinfo.AttrValue( KPresenceState8 ); 
+    if ( stateVal && !stateVal->CompareF( KPresenceFull8 )) 
+        { 
+        // Call full list method
+        DP_SDA("CPresencePluginAuthorization::WinfoNotificationL FULL winfo");
+        HandleFullWinfoNotificationL( aWinfo ); 
+        } 
+    else 
+        { 
+        // Indicate changes in WINFO list one by one.
+        DP_SDA("CPresencePluginAuthorization::WinfoNotificationLPARTIAL winfo");
+        HandlePartialWinfoNotificationL( aWinfo );
+        } 
+    CleanupStack::PopAndDestroy( &elems );
+    DP_SDA("CPresencePluginAuthorization::WinfoNotificationL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::StartXdmOperationL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::StartXdmOperationL(
+    const MXIMPIdentity& aId,
+    TXIMPRequestId aReqId,
+    TPluginAuthOperation aOperation )
+    {
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrNotReady ) );
+    DP_SDA("CPresencePluginAuthorization::StartXdmOperationL 2");
+    SetPresIdentityL( aId, ETrue );
+    
+    iXIMPId = aReqId;
+    iOperation = aOperation;
+    if ( !iXdmUtils )
+        {
+        DP_SDA("StartXdmOperationL !iXdmUtils");
+        iXdmUtils = iConnObs.XdmUtilsL();
+        }
+    if ( iXdmUtils->CheckXdmDoc() )
+        {
+        DP_SDA("StartXdmOperationL iXdmOk");
+        iXdmOk = ETrue;
+        CallActualXdmOperationL();
+        }
+    else
+        {
+        DP_SDA("StartXdmOperationL else");
+        iXdmUtils->InitializeXdmL( iStatus );
+        SetActive();
+        }
+    DP_SDA("CPresencePluginAuthorization::StartXdmOperationL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::StartXdmOperationL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::StartXdmOperationL(
+    const MXIMPIdentity& aId,
+    TPluginAuthOperation aOperation,
+    TRequestStatus& aClientStatus )
+    {
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrNotReady ) );
+    DP_SDA("CPresencePluginAuthorization::StartXdmOperationL 3 (list)");
+    
+    SetPresIdentityL( aId, EFalse );
+    
+    iClientStatus = &aClientStatus;
+    *iClientStatus = KRequestPending;
+    
+    iOperation = aOperation;
+    
+    if ( !iXdmUtils )
+        {
+        DP_SDA("StartXdmOperationL !iXdmUtils");
+        iXdmUtils = iConnObs.XdmUtilsL();
+        }
+    if ( iXdmUtils->CheckXdmDoc() )
+        {
+        DP_SDA("StartXdmOperationL iXdmOk");
+        iXdmOk = ETrue;
+        CallActualXdmOperationL();
+        }
+    else
+        {
+        DP_SDA("StartXdmOperationL else");
+        iXdmUtils->InitializeXdmL( iStatus );
+        SetActive();
+        }
+    DP_SDA("CPresencePluginAuthorization::StartXdmOperationL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::CompleteXIMPReq()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::CompleteXIMPReq( TInt aStatus )
+    {
+    DP_SDA("CPresencePluginAuthorization::CompleteXIMPReq");
+    iOperation = ENoOperation;
+    iConnObs.CompleteReq( iXIMPId, aStatus );
+    iXIMPId = TXIMPRequestId();
+    DP_SDA("CPresencePluginAuthorization::CompleteXIMPReq end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::SubscribeBlockListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::SubscribeBlockListL()
+    {
+    DP_SDA("CPresencePluginAuthorization::SubscribeBlockList");
+    
+    RPointerArray<MXIMPIdentity> blocked;
+    CleanupStack::PushL( TCleanupItem(
+        TPresencePluginUtility::ResetAndDestroyIdentities,
+        &blocked ) );
+    
+    iXdmUtils->SubscribeBlockListL( blocked );
+    MXIMPObjectCollection* coll =
+        iConnObs.ObjectFactory().NewObjectCollectionLC(); // << coll
+    
+    TInt count = blocked.Count();
+    for ( TInt i = 0; i < count; i++ )
+        {
+        MXIMPIdentity* currId = blocked[i];
+        HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( currId->Identity() );
+        currId->SetIdentityL( *withoutPrefix );
+        CleanupStack::PopAndDestroy( withoutPrefix );
+        MPresenceBlockInfo* bInfo =
+            iConnObs.PresenceObjectFactoryOwn().NewPresenceBlockInfoLC();
+        bInfo->SetBlockedEntityIdL( currId ); // ownership is taken
+        blocked.Remove( i ); // remove currId from blocked
+        blocked.InsertL( NULL, i );
+        bInfo->SetBlockedEntityDisplayNameL( currId->Identity() );
+        coll->AddObjectL( bInfo );// ownership is taken
+        CleanupStack::Pop();// >> bInfo
+        }
+    
+    DP_SDA("SubscribeBlockList complete request");
+    CompleteXIMPReq( KErrNone );
+    
+    MXIMPDataSubscriptionState* myState =
+       iConnObs.ObjectFactory().NewDataSubscriptionStateLC();
+    
+    MXIMPStatus* myStatus = iConnObs.ObjectFactory().NewStatusLC();
+    
+    // Notice: consider XIMP error codes
+    myStatus->SetResultCode( KErrNone );
+    myState->SetSubscriptionStateL(
+        MXIMPDataSubscriptionState::ESubscriptionInactive );
+    
+    iDataHost->SetPresenceBlockDataSubscriptionStateL(
+        myState, myStatus );
+    
+    iDataHost->HandlePresenceBlockListL( coll );
+    //Callback for subscription result
+    CleanupStack::Pop( 3 ); // >> myState, myStatus, coll
+    CleanupStack::PopAndDestroy( &blocked );
+    DP_SDA("CPresencePluginAuthorization::SubscribeBlockList end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::UnSubscribeBlockListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::UnSubscribeBlockListL()
+    {
+    DP_SDA("CPresencePluginAuthorization::UnSubscribeBlockListL");
+    
+    MXIMPObjectCollection* coll =
+        iConnObs.ObjectFactory().NewObjectCollectionLC();
+    
+    MXIMPDataSubscriptionState* myState =
+        iConnObs.ObjectFactory().NewDataSubscriptionStateLC();
+    
+    MXIMPStatus* myStatus = iConnObs.ObjectFactory().NewStatusLC();
+    
+    myStatus->SetResultCode( KErrNone );
+    myState->SetSubscriptionStateL(
+        MXIMPDataSubscriptionState::ESubscriptionInactive );
+    
+    iDataHost->SetPresenceBlockDataSubscriptionStateL(
+        myState, myStatus );
+    
+    iDataHost->HandlePresenceBlockListL( coll );
+    
+    CleanupStack::Pop( 3 );
+    
+    CompleteXIMPReq( KErrNone );
+    
+    DP_SDA("CPresencePluginAuthorization::UnSubscribeBlockListL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::ReturnListSubsState()
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginAuthorization::ReturnListSubsState()
+    {
+    return iSubscribed;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::PluginData()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginData& CPresencePluginAuthorization::PluginData()
+    {
+    return *iPresenceData;
+    }
+
+// --------------------------------------------------------------------------- 
+// CPresencePluginAuthorization::HandleFullWinfoNotificationL 
+// --------------------------------------------------------------------------- 
+// 
+void CPresencePluginAuthorization::HandleFullWinfoNotificationL( 
+    MSimpleWinfo& aWinfo )
+    {
+    using namespace NPresencePlugin::NPresence;
+    
+    RPointerArray<MSimpleElement> elems;
+    CleanupClosePushL( elems );
+    TInt err = aWinfo.SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    TInt count = elems.Count();
+    
+    MSimpleElement* elem = elems[0];
+    TPtrC8 p8 = elem->LocalName();
+    err = p8.CompareF( KPresenceWatcherList8 ); //watcher-list
+    DP_SDA2("HandleFullWinfoNotificationL leave if watcherlist error %d", err);
+    User::LeaveIfError( err );
+    
+    err = elem->SimpleElementsL( elems );
+    DP_SDA2("HandleFullWinfoNotificationL error %d", err);
+    User::LeaveIfError( err );
+    
+    count = elems.Count();
+    DP_SDA("HandleFullWinfoNotificationL watcher list is valid");
+    
+    // Search watchers who are pending (status = pending)
+    HBufC* nodeContent = NULL;
+    MXIMPObjectCollection *pendings =
+        iConnObs.ObjectFactory().NewObjectCollectionLC();
+    
+    TBool pendingFound(EFalse);
+    
+    for ( TInt i = 0; i < count; i++ )
+        {
+        elem = elems[i];
+        p8.Set( elem->LocalName());
+        if (!( p8.CompareF( KPresenceWatcher8 )))
+            {
+            const TDesC8* pp8 = elem->AttrValue( KPresenceStatus8 );
+            if ( pp8 && !pp8->CompareF( KPresencePending8 ))
+                {
+                DP_SDA("HandleFullWinfoNotificationL least one pending");
+                // Build collection of grant requests
+                // Find the child node containing the SIP entity
+                nodeContent = elem->ContentUnicodeL();
+                CleanupStack::PushL( nodeContent );
+                // create the collection entry here 
+                MPresenceGrantRequestInfo* grInfo =
+                   iConnObs.PresenceObjectFactoryOwn().
+                       NewPresenceGrantRequestInfoLC();
+                MXIMPIdentity* identity =
+                    iConnObs.ObjectFactory().NewIdentityLC();
+                
+                // Remove prefix to keep client side protocol agnostic
+                HBufC16* withoutPrefix = iPresenceData->RemovePrefixLC( 
+                    *nodeContent );
+                identity->SetIdentityL( *withoutPrefix );
+                CleanupStack::PopAndDestroy( withoutPrefix );
+                
+                grInfo->SetRequestorIdL( identity ); // ownership is taken
+                
+                pendings->AddObjectL( grInfo ); // ownership is taken
+                pendingFound = ETrue;
+                CleanupStack::Pop( 2 ); //grInfo, identity
+                CleanupStack::PopAndDestroy( nodeContent );
+                }
+            }
+        }
+    
+    if ( pendingFound )
+        {
+        DP_SDA("HandleFullWinfoNotificationL send pending");
+        iXIMPIdOwn = iDataHost->HandlePresenceGrantRequestListL( pendings );
+        CleanupStack::Pop();    // >> pendings
+        }
+    else
+        {
+        DP_SDA("HandleFullWinfoNotificationL pop pending");
+        CleanupStack::PopAndDestroy( ); // >> pendings
+        }
+    
+    CleanupStack::PopAndDestroy( &elems );
+    DP_SDA("CPresencePluginAuthorization::HandleFullWinfoNotificationL END");
+    } 
+ 
+// --------------------------------------------------------------------------- 
+// CPresencePluginAuthorization::HandlePartialWinfoNotificationL 
+// --------------------------------------------------------------------------- 
+// 
+void CPresencePluginAuthorization::HandlePartialWinfoNotificationL( 
+    MSimpleWinfo& aWinfo )
+    {
+    DP_SDA("CPresencePluginAuthorization::HandlePartialWinfoNotificationL");
+    using namespace NPresencePlugin::NPresence;
+    
+    RPointerArray<MSimpleElement> elems;
+    CleanupClosePushL( elems );
+    TInt err = aWinfo.SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    TInt count = elems.Count();
+    
+    MSimpleElement* elem = elems[0];
+    TPtrC8 p8 = elem->LocalName();
+    err = p8.CompareF( KPresenceWatcherList8 );
+    User::LeaveIfError( err );
+    
+    err = elem->SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    count = elems.Count();
+    
+    HBufC* nodeContent = NULL;
+    
+    for ( TInt i = 0; i < count; i++ )
+        {
+        elem = elems[i]; 
+        p8.Set( elem->LocalName());
+        if (!( p8.CompareF( KPresenceWatcher8 )))
+            { 
+            const TDesC8* pp8 = elem->AttrValue( KPresenceStatus8 );
+            if ( pp8 && !pp8->CompareF( KPresencePending8 ))
+                {
+                nodeContent = elem->ContentUnicodeL();
+                CleanupStack::PushL( nodeContent );
+                
+                // Remove prefix to keep client side protocol agnostic
+                HBufC16* withoutPrefix = iPresenceData->RemovePrefixLC( 
+                    *nodeContent );
+                CallHandlePresenceGrantRequestReceivedL( *withoutPrefix ); 
+                CleanupStack::PopAndDestroy( withoutPrefix );
+                CleanupStack::PopAndDestroy( nodeContent ); 
+                } 
+            else if ( pp8 && !pp8->CompareF( KPresenceTerminated8 )) 
+                {
+                nodeContent = elem->ContentUnicodeL(); 
+                CleanupStack::PushL( nodeContent ); 
+
+                // Remove prefix to keep client side protocol agnostic
+                HBufC16* withoutPrefix = iPresenceData->RemovePrefixLC( 
+                    *nodeContent );
+                CallHandlePresenceGrantRequestObsoletedL( *withoutPrefix ); 
+                CleanupStack::PopAndDestroy( withoutPrefix );
+                CleanupStack::PopAndDestroy( nodeContent ); 
+                }
+            else if ( pp8 && !pp8->CompareF( KPresenceActive8 ))
+                {
+                DP_SDA( "CPresencePluginAuthorization::HandlePartialWinfoNotificationL presence active" );
+                
+                nodeContent = elem->ContentUnicodeL();
+                CleanupStack::PushL( nodeContent );
+                TInt pos( 0 );
+                if ( iConnObs.SubscribedContacts()->
+                    GetVirtualIdentityArray()->Find( *nodeContent, pos ) == 0  )
+                    {
+                    HBufC8* buffer = HBufC8::NewLC( nodeContent->Length() );
+                    buffer->Des().Copy( *nodeContent );
+                    if ( !iConnObs.WatcherHandlerL()->MatchWatcherId( *buffer ) )
+                        {
+                        DP_SDA( "CPresencePluginAuthorization::HandlePartialWinfoNotificationL -subscribe presence" );
+                        iConnObs.WatcherHandlerL()->SubscribeL( *nodeContent );
+                        }
+                    CleanupStack::PopAndDestroy( buffer );
+                    }
+                CleanupStack::PopAndDestroy( nodeContent );
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy( &elems );
+    DP_SDA("CPresencePluginAuthorization::HandlePartialWinfoNotificationL END");
+    } 
+
+// --------------------------------------------------------------------------- 
+// CPresencePluginAuthorization::CallHandlePresenceGrantRequestReceivedL 
+// --------------------------------------------------------------------------- 
+// 
+void CPresencePluginAuthorization::CallHandlePresenceGrantRequestReceivedL(
+    const TDesC& aUserId ) 
+    {
+    DP_SDA("PluginAuthorization::CallHandlePresenceGrantRequestReceivedL");
+    // create the collection entry here 
+    MPresenceGrantRequestInfo* grInfo = 
+        iConnObs.PresenceObjectFactoryOwn().NewPresenceGrantRequestInfoLC();
+    MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC();
+    identity->SetIdentityL( aUserId ); 
+    grInfo->SetRequestorIdL( identity ); // ownership is taken
+    CleanupStack::Pop( ); // -identity 
+    
+    iDataHost->HandlePresenceGrantRequestReceivedL( grInfo );//ownership taken 
+    CleanupStack::Pop( );           // -grInfo
+    DP_SDA("PluginAuthorization::CallHandlePresenceGrantRequestReceivedL END");
+    } 
+
+// --------------------------------------------------------------------------- 
+// CPresencePluginAuthorization::CallHandlePresenceGrantRequestObsoletedL 
+// --------------------------------------------------------------------------- 
+// 
+void CPresencePluginAuthorization::CallHandlePresenceGrantRequestObsoletedL(
+    const TDesC& aUserId )
+    {
+    DP_SDA("PluginAuthorization::CallHandlePresenceGrantRequestObsoletedL");
+    MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC(); 
+    identity->SetIdentityL( aUserId ); 
+    iDataHost->HandlePresenceGrantRequestObsoletedL( identity );//taken 
+    CleanupStack::Pop( );// >> identity
+    DP_SDA("PluginAuthorization::CallHandlePresenceGrantRequestObsoletedL END");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::GrantPresenceForPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::GrantPresenceForPresentityL()
+    {
+    iXdmUtils->AddEntityToGrantedL( 
+        iPresIdentity->Des(), iStatus );
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::WithdrawFromPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::WithdrawFromPresentityL()
+    {
+    iXdmUtils->RemoveEntityFromGrantedL( 
+        iPresIdentity->Des(),iStatus );
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::UnsubscribePresentityPresenceL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::UnsubscribePresentityPresenceL()
+    {
+    DP_SDA( "CPresencePluginAuthorization::UnsubscribePresentityPresence" );
+    
+    MXIMPIdentity* identity =
+        iConnObs.ObjectFactory().NewIdentityLC();
+    identity->SetIdentityL( iPresIdentity->Des() );
+    iConnObs.WatcherHandlerL()->
+        DoPerformUnsubscribePresentityPresenceL( *identity, iStatus );
+    CleanupStack::PopAndDestroy(); // identity
+    SetActive();
+    
+    DP_SDA( "CPresencePluginAuthorization::UnsubscribePresentityPresence -Exit" );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::BlockPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::BlockPresentityL()
+    {
+    DP_SDA( "CPresencePluginAuthorization::BlockPresentityL" );
+    // add entity to block list
+    iXdmUtils->AddEntityToBlockedL( 
+        iPresIdentity->Des(), iStatus );
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::BlockPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::SetPresentityBlockedToXIMPL()
+    {
+    DP_SDA( "CPresencePluginAuthorization::SetPresentityBlockedToXIMPL" );
+    
+    MPresenceBlockInfo* bInfo =
+        iConnObs.PresenceObjectFactoryOwn().NewPresenceBlockInfoLC();
+    MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC();
+    HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *iPresIdentity );
+    identity->SetIdentityL( *withoutPrefix ); 
+    bInfo->SetBlockedEntityIdL( identity ); // ownership is taken
+    // Write blocked state into the presence cache
+    TBuf<20> buf;
+    buf.Copy( KBlockedExtensionValue );
+    iPresenceData->WriteStatusToCacheL(
+        *withoutPrefix, 
+        MPresenceBuddyInfo2::EUnknownAvailability,
+        buf,
+        KNullDesC() );
+    CleanupStack::PopAndDestroy( withoutPrefix );
+    iDataHost->HandlePresenceBlockedL( bInfo );
+    CleanupStack::Pop();// >> identity
+    CleanupStack::Pop();// >> bInfo
+    
+    DP_SDA( "CPresencePluginAuthorization::SetPresentityBlockedToXIMPL -Exit" );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::UnblockPresentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::UnblockPresentityL()
+    {
+    DP_SDA( "CPresencePluginAuthorization::UnblockPresentityL" );
+     
+    //remove entity from blocked list 
+    iXdmUtils->RemoveEntityFromBlockedL( 
+        iPresIdentity->Des(), iStatus );
+    //remove enity from ximp blocked too
+    MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC();
+    HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *iPresIdentity );
+    identity->SetIdentityL( *withoutPrefix );
+    CleanupStack::PopAndDestroy( withoutPrefix );
+    iDataHost->HandlePresenceBlockCanceledL( identity );
+    CleanupStack::Pop();// >> identity
+    iAuthState = EStateIsContactBlockedBuddyRequest;
+    SetActive();
+    
+    DP_SDA( "CPresencePluginAuthorization::UnblockPresentityL -Exit" );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginAuthorization::IsBlockedContactFriendRequest()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::IsBlockedContactFriendRequestL(
+    const TDesC& aPresenceId,
+    MPresencePluginContactsObs& aObserver,
+    TRequestStatus& aStatus )
+    {
+    DP_SDA( "CPresencePluginAuthorization::IsBlockedContactFriendRequest" );
+
+    delete iContacts;
+    iContacts = NULL;
+
+    HBufC* serviceName =
+        iPresenceData->ServiceNameLC( iPresenceData->ServiceId() );
+
+    iContacts = CPresencePluginContacts::NewL(
+        iPresenceData->ServiceId(), *serviceName, aObserver );
+
+    CleanupStack::PopAndDestroy( serviceName );
+
+    iContacts->IsPresenceIdStoredL( aPresenceId, aStatus );
+
+    DP_SDA( "CPresencePluginAuthorization::IsBlockedContactFriendRequest -exit" );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From base class MPresencePluginContactsObs
+// CPresencePluginAuthorization::RequestComplete()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginAuthorization::RequestComplete( TAny* aResult,
+    TPresenceContactsOperation aOperation, TInt aError )
+    {
+    DP_SDA( "CPresencePluginAuthorization::RequestComplete" );
+    
+    switch( aOperation )
+        {
+        case EOperationIsPresenceStoredToContacts:
+            if ( aResult != NULL && KErrNone == aError  )
+                {
+                iContactIsStored = *static_cast<TBool*>( aResult );
+                }
+            break;
+        default:
+            break;
+        }
+    DP_SDA2( "CPresencePluginAuthorization::RequestComplete - iContactIsStored = %d", iContactIsStored );
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginconnection.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,981 @@
+/*
+* Copyright (c) 2006-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <badesca.h>
+#include <ximpbase.h>
+#include <ximpserviceinfo.h>
+#include <protocolpresencefeatures.h>
+#include <cprotocolimfeatures.h>
+#include <protocolpresencedatahost.h>
+#include <presenceobjectfactory.h>  
+
+#include <ximpcontextclientinfo.h>		
+#include <protocolpresenceauthorization.h>  
+#include <ximpprotocolconnectionhost.h>			   
+#include <ximpfeatureinfo.h> //for etc. KPublish
+#include <msimpleconnection.h> //Part of Registration API from SIMPLE engine
+#include <msimpleconnectionobserver.h>//Connection callback methods
+#include <presenceinfo.h>
+
+#include "presencepluginconnection.h"
+#include "presencepluginsession.h" 
+#include "mpresencepluginconnectionobs.h"   
+#include "presencepluginwatcher.h"
+#include "presencepluginauthorization.h"
+#include "presencepluginwinfo.h"
+#include "presencepluginpublisher.h"
+#include "presenceplugingroup.h"
+#include "presencepluginxdmutils.h"
+#include "presencepluginvirtualgroup.h"
+#include "presenceconnectioninfo.h"
+#include "presenceplugindata.h"
+
+#include "simpleimpluginuids.hrh" //KImplUidSimpleImPlugin
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::CPresencePluginConnection()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginConnection::CPresencePluginConnection( ): 
+	CActive( CActive::EPriorityHigh ), iSipPresentity(NULL),
+    iStopPublishState( EFalse ), iGrantListSubs( EFalse ), iStopPublishCall( EFalse ),
+    iTerminatedCall( EFalse )
+    {
+    DP_SDA("CPresencePluginConnection::CPresencePluginConnection");
+    CActiveScheduler::Add(this);
+    iOwnTupleId = 0;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginConnection* CPresencePluginConnection::NewL(
+    const MXIMPServiceInfo& aServiceInfo,
+    const MXIMPContextClientInfo& aClientCtxInfo )
+    {
+    DP_SDA("CPresencePluginConnection::NewL");
+    CPresencePluginConnection* self = 
+        new( ELeave ) CPresencePluginConnection( );
+    CleanupStack::PushL( self );
+    self->ConstructL( aServiceInfo, aClientCtxInfo );
+    CleanupStack::Pop( self );    
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::NewL() loaded
+// ---------------------------------------------------------------------------
+//
+CPresencePluginConnection* CPresencePluginConnection::NewL(
+    const MXIMPServiceInfo& aServiceInfo,
+    const MXIMPContextClientInfo& aClientCtxInfo,
+    const TDesC8& aETag )
+    {
+    DP_SDA("CPresencePluginConnection::NewL loaded");
+    CPresencePluginConnection* self = 
+        new( ELeave ) CPresencePluginConnection( );
+    CleanupStack::PushL( self );
+    self->ConstructL( aServiceInfo, aClientCtxInfo, aETag );
+    CleanupStack::Pop( self );    
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::ConstructL() loaded
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginConnection::ConstructL(
+    const MXIMPServiceInfo& aServiceInfo,
+    const MXIMPContextClientInfo& /*aClientCtxInfo*/,
+    const TDesC8& aETag )
+    {
+    DP_SDA("CPresencePluginConnection::ConstructL loaded");
+    
+    iETag = aETag.AllocL();                  
+    
+    iSession = CPresencePluginSession::NewL( aServiceInfo, *this );
+            
+    // create instance from data class
+    iPresenceData = CPresencePluginData::NewL( *this,
+        aServiceInfo.IapId() ); 
+    
+    DP_SDA("ConstructL create subscribed buddy list loaded ");  
+    // create another virtual group for all subscribed buddyes
+    iSubscribedBuddys =
+        CPresencePluginVirtualGroup::NewL( *this, 
+        KPresenceBuddyList(),
+        iPresenceData );
+
+    iAuth = CPresencePluginAuthorization::NewL( *this, iPresenceData );
+    
+    iPublisher = CPresencePluginPublisher::NewL(
+               *this,        
+               *iSession->SimpleConnection(),
+               iPresenceData );
+    
+    iWatcher = CPresencePluginWatcher::NewL(
+               *this,
+               *iSession->SimpleConnection(),
+               iPresenceData ); 
+    
+    iGroups = CPresencePluginGroups::NewL( 
+        *this, iSubscribedBuddys, iPresenceData );
+    
+    iPluginWinfo = CPresencePluginWinfo::NewL( 
+                 *this, *(iSession->SimpleConnection() ));
+    
+    }    
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginConnection::ConstructL(
+    const MXIMPServiceInfo& aServiceInfo,
+    const MXIMPContextClientInfo& /*aClientCtxInfo*/ )
+    {
+    DP_SDA("CPresencePluginConnection::ConstructL");
+     
+    iETag = KNullDesC8().AllocL();                  
+    
+    iSession = CPresencePluginSession::NewL( aServiceInfo, *this );
+            
+    // create instance from data class
+    iPresenceData = CPresencePluginData::NewL( *this, 
+        aServiceInfo.IapId() ); 
+
+    DP_SDA("ConstructL create subscribed buddy list");	
+    // create another virtual group for all subscribed buddyes
+    iSubscribedBuddys =
+    	CPresencePluginVirtualGroup::NewL( 
+    	    *this, KPresenceBuddyList(), iPresenceData );
+
+    iAuth = CPresencePluginAuthorization::NewL( *this, iPresenceData );
+    
+    iPublisher = CPresencePluginPublisher::NewL(
+               *this,        
+               *iSession->SimpleConnection(),
+               iPresenceData );
+    
+    iWatcher = CPresencePluginWatcher::NewL(
+               *this,
+               *iSession->SimpleConnection(),
+               iPresenceData ); 
+      
+    iGroups = CPresencePluginGroups::NewL( 
+        *this, iSubscribedBuddys, iPresenceData );
+    
+    iPluginWinfo = CPresencePluginWinfo::NewL( 
+                 *this, *(iSession->SimpleConnection() ));   
+                                      
+    }    
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::~CPresencePluginConnection()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginConnection::~CPresencePluginConnection()
+    {
+    DP_SDA("CPresencePluginConnection::~CPresencePluginConnection");
+    
+    Cancel();
+    
+    delete iSipPresentity;
+    iSipPresentity = NULL;
+    
+    delete iPluginWinfo;
+    iPluginWinfo = NULL;
+    
+    delete iWatcher;
+    iWatcher = NULL;
+    
+    delete iPublisher;
+    iPublisher = NULL;
+    
+    delete iAuth;
+    iAuth = NULL;
+    
+    delete iGroups;
+    iGroups = NULL;
+    
+    delete iSession;
+    iSession = NULL;
+    
+    delete iImFeatures;
+    
+    REComSession::FinalClose();
+    
+    delete iSubscribedBuddys;
+    delete iPresenceData;
+    
+    delete iETag;
+    iETag = NULL;
+    DP_SDA("CPresencePluginConnection::~CPresencePluginConnection end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::PrimeHost
+// ---------------------------------------------------------------------------
+//  
+void CPresencePluginConnection::PrimeHost( 
+    MXIMPProtocolConnectionHost& aHost )
+    {
+    DP_SDA("CPresencePluginConnection::PrimeHost");
+    iConnectionHost = &aHost;
+    iAuth->SetDataHost( 
+        iConnectionHost->ProtocolPresenceDataHost().AuthorizationDataHost() );  
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GetOnlineBuddyGroup()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginVirtualGroup* CPresencePluginConnection::SubscribedContacts( )
+    {
+    return iSubscribedBuddys;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GetSessionStatus()
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginConnection::GetSessionStatus( )
+    {
+    return iSession->ConnectionStatus();
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::TupleIdGet()
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginConnection::GetTupleId() const
+    {
+    DP_SDA("CPresencePluginConnection::TupleIdGet");
+    return iOwnTupleId;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GetEtag()
+// ---------------------------------------------------------------------------
+//    
+const TDesC8& CPresencePluginConnection::GetETag() const
+    {
+    DP_SDA("CPresencePluginConnection::GetETag");
+    
+    if( !iETag )
+        {
+        DP_SDA2("CPresencePluginConnection::GetETag empty ??? %S", iConnectionArray->GetConnectionEtag() );
+        return  KNullDesC8();
+        }
+
+    return *iETag;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::SetETag()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginConnection::SetETag( const TDesC8& aETag )
+    {
+    DP_SDA("CPresencePluginConnection::SetETag");
+    delete iETag;
+    iETag = NULL;
+        
+    TRAP_IGNORE( ( iETag = aETag.AllocL() ) );
+    //Add etag also in connectionArray
+    iConnectionArray->SetConnectionETag( *iETag );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::SetConnectionArray()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginConnection::SetConnectionArray( 
+		CPresenceConnectionInfo* aArray )
+    {
+    DP_SDA("CPresencePluginConnection::SetConnectionArray");
+    iConnectionArray = aArray;
+    iConnectionArray->SetConnectionStatus( EActive );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GetConnectionArray()
+// ---------------------------------------------------------------------------
+//    
+CPresenceConnectionInfo* CPresencePluginConnection::GetConnectionArray( )
+    {
+    DP_SDA("CPresencePluginConnection::GetConnectionArray");
+    return iConnectionArray;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::TupleIdGet()
+// ---------------------------------------------------------------------------
+//
+TInt32 CPresencePluginConnection::GetPresenceSetId() const
+    {
+    DP_SDA("CPresencePluginConnection::GetPresenceSetId");
+    return iSession->GetPresenceSetId();
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::TupleIdGet()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginConnection::SetTupleId( const TInt aTupleId )
+    {
+    DP_SDA("CPresencePluginConnection::TupleIdSet");
+    iOwnTupleId = aTupleId;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GetStopPublishState()
+// ---------------------------------------------------------------------------
+//    
+TBool CPresencePluginConnection::GetStopPublishState()
+    {
+    DP_SDA2("::GetStopPublishState = %d", (TInt)iStopPublishState );
+    return iStopPublishState;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::SetStopPublishState()
+// ---------------------------------------------------------------------------
+// 
+void CPresencePluginConnection::SetStopPublishState( TBool aState )
+    {
+    DP_SDA2("SetStopPublishState : aState = %d ",  (TInt)aState );
+    iStopPublishState = aState;
+    }
+            
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::PresenceWatching
+// ---------------------------------------------------------------------------
+//    
+MProtocolPresenceDataHost& CPresencePluginConnection::ProtocolPresenceHost()
+    {
+    DP_SDA("CPresencePluginConnection::ProtocolPresenceHost");
+    return iConnectionHost->ProtocolPresenceDataHost();
+    }
+     
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::PresenceWatching
+// ---------------------------------------------------------------------------
+//    
+MProtocolPresenceWatching& CPresencePluginConnection::PresenceWatching()
+    {
+    DP_SDA("CPresencePluginConnection::PresenceWatching");
+    return *iWatcher;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::PresencePublishing
+// ---------------------------------------------------------------------------
+//   
+ MProtocolPresencePublishing& CPresencePluginConnection::PresencePublishing()
+    {
+    return *iPublisher;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::PresentityGroups
+// ---------------------------------------------------------------------------
+//   
+MProtocolPresentityGroups& CPresencePluginConnection::PresentityGroups()
+    {
+    return *iGroups;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::PresenceAuthorization
+// ---------------------------------------------------------------------------
+//   
+MProtocolPresenceAuthorization& 
+    CPresencePluginConnection::PresenceAuthorization()
+    {
+    DP_SDA2("CPresencePluginConnection::PresenceAuthorization %x", iAuth);
+    return *iAuth;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::InternalPresenceAuthorization
+// ---------------------------------------------------------------------------
+//       
+CPresencePluginAuthorization& 
+    CPresencePluginConnection::InternalPresenceAuthorization()
+    {
+    DP_SDA2("CPresencePluginConnection::InternalPresenceAuthorization %x", iAuth);
+    return *iAuth;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::OpenSessionL
+// ---------------------------------------------------------------------------
+//     
+void CPresencePluginConnection::OpenSessionL( 
+    const MXIMPContextClientInfo& /*aClientCtxInfo*/,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginConnection::OpenSessionL");
+    iGrantListSubs = ETrue; 
+    iTerminatedCall = EFalse;
+    iXIMPId = aReqId;
+    iSession->OpenSessionL();         
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::OpenSessionL
+// ---------------------------------------------------------------------------
+// 
+void CPresencePluginConnection::OpenSessionL( const TInt& /*aSettingsId*/,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginConnection::OpenSessionL 2 ");
+    iXIMPId = aReqId;
+    iGrantListSubs = ETrue; 
+    iTerminatedCall = EFalse;
+    iSession->OpenSessionL( ); 
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::CloseSession
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginConnection::CloseSession( 
+    const MXIMPContextClientInfo& /*aContextClient*/,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginConnection::CloseSession begin");
+    
+    TBool completeXimpRequestNow( EFalse );
+    iConnectionArray->DecreaseClientCount();
+    iXIMPId = aReqId;
+        
+    // Client count can´t be negative. Increase if goes negative.
+    // This happens for example in network lost case.
+    // This method is called then because connection is terminated and
+    // for all clients which have done unbind. But here we cannot tell
+    // if this method is called by clients unbind or connection termination
+    // therefore this workaround needed.
+    if ( iConnectionArray->ClientCount() < 0 )
+        {        
+        completeXimpRequestNow = ETrue;
+        iConnectionArray->IncreaseClientCount();
+        }
+    
+    // In case there is no more clients we cannot complete Ximp request
+    // right away. We have to stop publish first, Ximp request completion is
+    // handled in RunL after that is done.
+    if( KErrNone == iConnectionArray->ClientCount() && 
+        (EActive == iConnectionArray->GetConnectionStatus()) )
+        {       
+        completeXimpRequestNow = EFalse; // request is completed later in RunL
+        iGrantListSubs = EFalse;
+        
+        //Start stopPublish request
+        DeRegister();
+        }
+        
+    if ( !iStopPublishCall )
+       {
+       completeXimpRequestNow = ETrue;
+       }
+    
+    if ( completeXimpRequestNow )
+        {
+        CompleteReq( iXIMPId, KErrNone );
+        }
+
+    DP_SDA("CPresencePluginConnection::CloseSession end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GetSupportedFeaturesL
+// ---------------------------------------------------------------------------
+//     
+void CPresencePluginConnection::GetSupportedFeaturesL( 
+    CDesC8Array& aFeatures ) const
+    {
+    DP_SDA("CPresencePluginConnection::GetSupportedFeaturesL");
+    // first empty the whole array
+    aFeatures.Reset();   
+    using namespace NXIMPFeature::Presence;    
+    aFeatures.AppendL( KPublish );
+    aFeatures.AppendL( KSubscribe );    
+    aFeatures.AppendL( KUnsubscribe );  
+    aFeatures.AppendL( KAddContact );
+    aFeatures.AppendL( KDeleteContact );
+    aFeatures.AppendL( KFetch );
+    aFeatures.AppendL( KBlock );
+    aFeatures.AppendL( KUnBlock );
+    
+    if( iImFeatures )
+        {
+        using namespace NXIMPFeature::InstantMessage;
+        aFeatures.AppendL( KInstantMessage );
+        }
+    }
+
+//*****************************************************************************
+//*  FROM MPresencePluginConnectionObs
+//*****************************************************************************  
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::CompleteReq()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginConnection::CompleteReq( TReqType aType, TInt aStatus )
+    {
+    DP_SDA("CPresencePluginConnection::CompleteReq");
+    // Return immediately if PrimeHost() is not called.
+    if ( !iConnectionHost )
+        {
+        DP_SDA("CPresencePluginConnection::CompleteReq !iConnectionHost");
+        iXIMPId = TXIMPRequestId(); 
+        return;
+        }
+                      
+    switch ( aType )
+        {
+        case EOpenSess:
+            {
+            DP_SDA("CPresencePluginConnection::CompleteReq EOpenSess");          
+            iConnectionHost->HandleRequestCompleted( iXIMPId, aStatus );
+            iXIMPId = TXIMPRequestId();
+            //Set connection status to connection Array
+            iConnectionArray->SetConnectionStatus( EActive );
+            }
+            break;
+        case ECloseSess:
+            {
+            DP_SDA("CPresencePluginConnection::CompleteReq ECloseSess"); 
+            iConnectionArray->DecreaseClientCount();
+            CompleteReq( iXIMPId, aStatus );
+            iConnectionArray->SetConnectionStatus( ENotActive );
+            }
+            break;
+        default:
+            DP_SDA("CPresencePluginConnection::CompleteReq DEFAULT");  
+            break;   
+        };
+    DP_SDA("CPresencePluginConnection::CompleteReq end"); 
+    }
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::CompleteReq()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginConnection::CompleteReq( 
+    TXIMPRequestId aReqId,
+    TInt aStatus )
+    { 
+    DP_SDA2("CPresencePluginConnection::CompleteReq status %d", aStatus); 
+    // Return immediately if PrimeHost() is not called.
+    if ( !iConnectionHost )
+        {
+        DP_SDA("CPresencePluginConnection::CompleteReq return"); 
+        return;
+        }               
+    DP_SDA("CPresencePluginConnection::CompleteReq complete");               
+    iConnectionHost->HandleRequestCompleted( aReqId, aStatus );
+    } 
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::ObjectFactory()
+// ---------------------------------------------------------------------------
+// 
+MXIMPObjectFactory& CPresencePluginConnection::ObjectFactory()
+    {
+    DP_SDA("CPresencePluginConnection::ObjectFactory");
+    return iConnectionHost->ObjectFactory();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::Host
+// ---------------------------------------------------------------------------
+//     
+MXIMPProtocolConnectionHost* CPresencePluginConnection::Host()
+    {
+    DP_SDA("CPresencePluginConnection::Host");
+    return iConnectionHost;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection:CurrentDomain
+// ---------------------------------------------------------------------------
+//     
+TPtrC16 CPresencePluginConnection::CurrentDomain()
+    {
+    return iSession->CurrentDomain();    
+    } 
+     
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::CurrentSipPresentit8()
+// ---------------------------------------------------------------------------
+// 
+TPtrC8 CPresencePluginConnection::CurrentSipPresentity8()
+    {
+    return iSession->CurrentSipPresentity();
+    } 
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection:XdmUtilsL
+// ---------------------------------------------------------------------------
+//
+CPresencePluginXdmUtils* CPresencePluginConnection::XdmUtilsL()
+    {
+    DP_SDA("CPresencePluginConnection::XdmUtilsL");
+    return iSession->XdmUtilsL();
+    } 
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::WinfoHandlerL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginWinfo* CPresencePluginConnection::WinfoHandlerL()
+    {
+    DP_SDA("CPresencePluginConnection::WinfoHandlerL");
+    if ( !iPluginWinfo )
+        {
+        iPluginWinfo = CPresencePluginWinfo::NewL( 
+            *this, *(iSession->SimpleConnection() ));
+        }
+    
+    iPluginWinfo->SetHost( iConnectionHost );
+    return iPluginWinfo;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::WatcherHandlerL()
+// ---------------------------------------------------------------------------
+//    
+ CPresencePluginWatcher* CPresencePluginConnection::WatcherHandlerL()
+    {
+    DP_SDA("CPresencePluginConnection::WatcherHandlerL");  
+    if ( !iWatcher )
+        {
+        DP_SDA("CPresencePluginConnection::WatcherHandlerL: if ( !iWatcher )");  
+        iWatcher = CPresencePluginWatcher::NewL(
+            *this,
+            *iSession->SimpleConnection(),
+            iPresenceData );
+        }
+    return iWatcher;
+    }
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::WinfoTerminatedL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginConnection::WinfoTerminatedL( TInt aReason )
+    {
+    DP_SDA("CPresencePluginConnection::WinfoTerminatedL");  
+    // Pass the information to iAuth and iPublisher,
+    // so that they can call XIMP Plugin Data Host callbacks.
+    iAuth->WinfoTerminatedL( aReason );
+    iPublisher->WinfoTerminatedL( aReason );
+    }  
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::WinfoNotification()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginConnection::WinfoNotification( MSimpleWinfo& aWinfo )
+    {
+    DP_SDA("CPresencePluginConnection::WinfoNotification");  
+    TRAP_IGNORE( iPublisher->WinfoNotificationL( aWinfo  ));
+    TRAP_IGNORE( iAuth->WinfoNotificationL( aWinfo ));
+    }      
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CPresencePluginConnection::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions )
+    { 
+    DP_SDA("CPresencePluginConnection::GetInterface()");  
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        DP_SDA("CPresencePluginConnection::GetInterface()if ");
+        // caller wants this interface 
+        return this;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        DP_SDA("CPresencePluginConnection::GetInterface() panic");  
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }  
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GetInterface()
+// ---------------------------------------------------------------------------
+//
+const TAny* CPresencePluginConnection::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    DP_SDA("CPresencePluginConnection::GetInterface() const ");  
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        DP_SDA("CPresencePluginConnection::GetInterface()2 ");  
+        // caller wants this interface
+        return const_cast<CPresencePluginConnection*>(this);
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        DP_SDA("CPresencePluginConnection::GetInterface()panic 2");  
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }  
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GetInterfaceId()
+// ---------------------------------------------------------------------------
+//
+TInt32 CPresencePluginConnection::GetInterfaceId() const
+    {
+    DP_SDA("CPresencePluginConnection::GetInterfaceId() const ");  
+    return MXIMPProtocolConnection::KInterfaceId;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::ProtocolPresenceFeatures()
+// ---------------------------------------------------------------------------
+//    
+MProtocolPresenceFeatures& CPresencePluginConnection::
+    ProtocolPresenceFeatures()           
+    {
+    DP_SDA("CPresencePluginConnection::ProtocolPresenceFeatures() ");  
+    return *this;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::PresenceObjectFactory()
+// ---------------------------------------------------------------------------
+// 
+MPresenceObjectFactory& CPresencePluginConnection::PresenceObjectFactoryOwn()
+    {
+    DP_SDA("CPresencePluginConnection::PresenceObjectFactoryOwn() ");  
+    return iConnectionHost->
+        ProtocolPresenceDataHost().PresenceObjectFactory();    
+    }  
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GrandListState()
+// ---------------------------------------------------------------------------
+// 
+TBool CPresencePluginConnection::GrandListState( )
+    {
+    DP_SDA2("GrandListState : iGrantListSubs = %d", (TInt)iGrantListSubs );
+    return iGrantListSubs;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::IsStopPublishCalled()
+// ---------------------------------------------------------------------------
+// 
+TBool CPresencePluginConnection::IsStopPublishCalled( )
+    {
+    DP_SDA("CPresencePluginConnection::IsStopPublishCalled");
+    return iStopPublishCall;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::TerminateConnectionL()
+// ---------------------------------------------------------------------------
+// 
+void CPresencePluginConnection::TerminateConnectionL( )
+    {
+    DP_SDA("CPresencePluginConnection::TerminateConnectionL");
+    iConnectionHost->HandleConnectionTerminated( NULL );
+    iConnectionArray->SetConnectionStatus( ETerminated );
+    DP_SDA("CPresencePluginConnection::TerminateConnectionL Done");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::DeRegister()
+// ---------------------------------------------------------------------------
+// 
+void CPresencePluginConnection::DeRegister( )
+    {
+    DP_SDA("CPresencePluginConnection::Deregister");
+    
+    DP_SDA(" -> CloseSession, delete permanent pres data");
+    TRAP_IGNORE( iPresenceData->DeletePresenceVariablesL( ServiceId() ) );
+    
+    // Try to stop publish only if we have successfully published
+    if ( iPublisher->Published() )
+        {
+        DP_SDA("CloseSession call stopPublish");
+        TRAP_IGNORE( iPublisher->StopPublishL( iStatus ) );
+        iStopPublishCall = ETrue;
+        SetActive();
+        }
+    
+    DP_SDA("CPresencePluginConnection::Deregister Done");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::CreateImFeaturesPlugin()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginConnection::CreateImFeaturesPluginL( )
+    {
+    if ( !iImFeatures )
+        {
+        DP_SDA("Creating SimpleImPlugin");
+        
+        CSimpleImFeatures::TSimpleImPluginInitParams imPluginInitParams( 
+            *this,
+            *iSession->SimpleConnection(),
+            iSession->ServiceId() );
+        
+        iImFeatures = static_cast<CSimpleImFeatures*> ( 
+            CProtocolImFeatures::NewL( TUid::Uid(KImplUidSimpleImPlugin),
+            &imPluginInitParams ) );
+        
+        DP_SDA("Creating SimpleImPlugin done");
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::DeleteImFeaturesPlugin()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginConnection::DeleteImFeaturesPlugin( )
+    {
+    if ( iImFeatures )
+        {
+        DP_SDA("Deleting SimpleImPlugin");
+        
+        delete iImFeatures;
+        iImFeatures = NULL;      
+        REComSession::FinalClose();
+        
+        DP_SDA("Deleting SimpleImPlugin done");
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginConnection::DoCancel(  )
+    {
+    DP_SDA("CPresencePluginConnection::DoCancel CANCEL");
+    iPublisher->Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::RunL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginConnection::RunL(  )
+    {
+    DP_SDA("CPresencePluginConnection::RunL");
+    TInt status = iStatus.Int();
+    DP_SDA2("CPresencePluginConnection::RunL status %d", status );
+    
+    if ( iStopPublishCall )
+        {
+        DP_SDA("CPresencePluginConnection::RunL complete");     
+        
+        iStopPublishCall = EFalse;
+        CompleteReq( iXIMPId, status );      
+        
+        DP_SDA("CPresencePluginConnection::RunL --> REMOVE CACHE");
+        iPresenceData->RemoveCacheL();
+        
+        DP_SDA("CPresencePluginConnection::RunL --> Delete im plugin");
+        DeleteImFeaturesPlugin();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginConnection::RunError( TInt /*aError*/ )
+    {
+    DP_SDA("CPresencePluginConnection::RunError"); 
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GroupsL()
+// ---------------------------------------------------------------------------
+// 
+CPresencePluginGroups& CPresencePluginConnection::GroupsL()
+	{
+	User::LeaveIfNull( iGroups );
+	return *iGroups;
+	}
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::ServiceId()
+// ---------------------------------------------------------------------------
+// 	
+TInt& CPresencePluginConnection::ServiceId()
+    {
+    return iSession->ServiceId();
+    }
+	
+// ---------------------------------------------------------------------------
+// CPresencePluginConnection::GetProtocolInterface()
+// ---------------------------------------------------------------------------
+// 
+TAny* CPresencePluginConnection::GetProtocolInterface( TInt aInterfaceId )
+	{
+	DP_SDA("CPresencePluginConnection::GetProtocolInterface");
+	
+	if( aInterfaceId == CProtocolImFeatures::KInterfaceId )
+        {
+        TInt err( KErrNone );
+        
+        if ( !iImFeatures )
+            {
+            DP_SDA("    --> Create im features plugin");           
+            TRAP( err, CreateImFeaturesPluginL() );
+            }
+        
+        if ( !err )
+            {
+            DP_SDA("    --> get interface");
+            
+            return iImFeatures->GetInterface( 
+                aInterfaceId, MXIMPBase::EPanicIfUnknown );
+            }
+        else
+            {
+            DP_SDA("    --> Creating im features plugin failed");
+            return NULL;
+            }
+        }
+	else
+        {
+	    return NULL;
+        }
+	}
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presenceplugincontacts.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,507 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <VPbkContactStoreUris.h>
+#include <spsettings.h>
+#include <spproperty.h>
+#include <CVPbkContactManager.h>
+#include <CVPbkContactStoreUriArray.h>
+#include <TVPbkContactStoreUriPtr.h>
+#include <MVPbkContactOperationBase.h>
+#include <MVPbkContactStoreList.h>
+#include <MVPbkContactLinkArray.h>
+#include <MVPbkContactLink.h>
+#include <MVPbkStoreContact.h>
+#include <MVPbkContactFieldData.h>
+#include <MVPbkContactFieldTextData.h>
+#include <MVPbkContactFieldUriData.h>
+#include <CVPbkContactIdConverter.h>
+#include <MVPbkStoreContactFieldCollection.h>
+#include <CVPbkFieldTypeRefsList.h>
+#include <VPbkEng.rsg>
+
+#include "presenceplugincontacts.h" 
+#include "presencelogger.h"
+#include "presenceplugincontactsobs.h"
+#include "presenceplugincontactstatehandler.h"
+#include "presencepluginlocalstore.h"
+// States
+#include "presenceplugincontactstate.h"
+#include "presenceplugincontactstateopen.h"
+#include "presenceplugincontactstateresolve.h"
+#include "presenceplugincontactstatesearch.h"
+#include "presenceplugincontactstateend.h"
+
+const TInt KSDMASPSMaxPropertyLength = 512;
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContacts::CPresencePluginContacts()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContacts::CPresencePluginContacts( TInt aServiceId,
+    MPresencePluginContactsObs& aObserver )
+    : CActive( CActive::EPriorityStandard ),
+    iServiceId( aServiceId ),
+    iObserver( &aObserver )
+    {
+    CActiveScheduler::Add(this);
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContacts::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::ConstructL( const TDesC& aServiceName )
+    {
+    DP_SDA( "CPresencePluginContacts::ConstructL()" );
+    
+    iServiceName = aServiceName.AllocL();
+    CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewLC();
+    HBufC* storeName = ContactStoreNameL();
+
+    if ( NULL != storeName )
+        {
+        DP_SDA2( "CPresencePluginContacts::ConstructL() %S", storeName );
+        CleanupStack::PushL( storeName );
+        uriArray->AppendL( TVPbkContactStoreUriPtr( *storeName ) );
+        CleanupStack::PopAndDestroy( storeName );
+        }
+    else
+        {
+        DP_SDA( "CPresencePluginContacts::ConstructL() Use default contact store uri" );
+        uriArray->AppendL( TVPbkContactStoreUriPtr(
+            VPbkContactStoreUris::DefaultCntDbUri() ) );
+        }
+    iContactManager = CVPbkContactManager::NewL( *uriArray );
+    CleanupStack::PopAndDestroy( uriArray );
+    
+    DP_SDA( "CPresencePluginContacts::ConstructL() -exit" );
+    }
+    
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginContacts::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContacts* CPresencePluginContacts::NewL( TInt aServiceId,
+    const TDesC& aServiceName, MPresencePluginContactsObs& aObserver )
+    {
+    CPresencePluginContacts* self =
+        CPresencePluginContacts::NewLC( aServiceId, aServiceName, aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginContacts::NewLC()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContacts* CPresencePluginContacts::NewLC( TInt aServiceId,
+        const TDesC& aServiceName, MPresencePluginContactsObs& aObserver )
+    {
+    CPresencePluginContacts* self =
+        new( ELeave ) CPresencePluginContacts( aServiceId, aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL( aServiceName );
+    return self;
+    }
+    
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginContacts::~CPresencePluginContacts()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContacts::~CPresencePluginContacts()
+    {
+    DP_SDA("CPresencePluginContacts::~CPresencePluginContacts");
+    
+    delete iServiceName;
+    delete iSearchText;
+    delete iContactOperation;
+    iStoreContactArray.ResetAndDestroy();
+    delete iStateHandler;
+    delete iFieldTypeRefList;
+    delete iContactLinkArray;
+    if( iContactManager )
+        {
+        TRAP_IGNORE( iContactManager->ContactStoresL().CloseAll( *this ) );
+        }
+    delete iContactManager;
+    iClientStatus = NULL;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContacts::PresenceIdStoredL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::IsPresenceIdStoredL(
+    const TDesC16& aPresenceId, TRequestStatus& aStatus )
+    {
+    DP_SDA( "CPresencePluginContacts::IsPresenceIdStoredL -Enter" );
+    
+    iOperation = EOperationIsPresenceStoredToContacts;
+    
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    
+    iSearchText = HBufC::NewL(
+        iServiceName->Length() + aPresenceId.Length() + 1 );
+    TPtr searchTextPtr = iSearchText->Des();
+    searchTextPtr.Copy( *iServiceName );
+    searchTextPtr.Append( ':' );
+    searchTextPtr.Append( aPresenceId );
+    
+    iFieldTypeRefList = CVPbkFieldTypeRefsList::NewL();
+    iFieldTypeRefList->AppendL(
+        *iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_IMPP  ) );
+    
+    iStateHandler = CPresencePluginContactStateHandler::NewL();
+    
+    iStateHandler->AddStateL( new( ELeave ) CPresencePluginContactStateOpen(
+        *this, *iStateHandler ) );
+    iStateHandler->AddStateL( new( ELeave ) CPresencePluginContactStateSearch(
+        *this, *iStateHandler ) );
+    iStateHandler->AddStateL( new( ELeave ) CPresencePluginContactStateResolve(
+        *this, *iStateHandler ) );
+    iStateHandler->AddStateL( new( ELeave ) CPresencePluginContactStateEnd(
+        *this, *iStateHandler ) );
+    
+    iStateHandler->Start( &iStatus );
+    SetActive();
+    
+    DP_SDA( "CPresencePluginContacts::IsPresenceIdStoredL - exit" );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContacts::ContactStoreNameL
+// ---------------------------------------------------------------------------
+//
+HBufC* CPresencePluginContacts::ContactStoreNameL()
+    {
+    DP_SDA( "CPresencePluginContacts::ContactStoreNameL()" );
+    
+    HBufC* storeName = NULL;
+    CSPSettings* spSettings = CSPSettings::NewLC();
+    CSPProperty* property = CSPProperty::NewLC();
+    
+    TInt err = spSettings->FindPropertyL( iServiceId,
+                                EPropertyContactStoreId,      
+                                *property );
+    
+    if ( KErrNone == err )
+        {
+        storeName = HBufC::NewL( KSDMASPSMaxPropertyLength );
+        TPtr16 storeNamePtr = storeName->Des();
+        err = property->GetValue( storeNamePtr );
+        }
+    
+    CleanupStack::PopAndDestroy( property );
+    CleanupStack::PopAndDestroy( spSettings );
+    
+    return storeName;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MPresenceContactsContextBase. 
+// CPresencePluginContacts::Open
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::OpenL()
+    {
+    DP_SDA( "CPresencePluginContacts::Open()" );
+    iContactManager->ContactStoresL().OpenAllL( *this );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MPresenceContactsContextBase.
+// CPresencePluginContacts::Search
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::SearchL()
+    {
+    DP_SDA( "CPresencePluginContacts::Search()" );
+    iContactOperation = iContactManager->FindL(
+        *iSearchText, *iFieldTypeRefList, *this );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MPresenceContactsContextBase. 
+// CPresencePluginContacts::ContactLinkArray
+// ---------------------------------------------------------------------------
+//
+const MVPbkContactLinkArray& CPresencePluginContacts::ContactLinkArrayL()
+    {
+    if ( NULL == iContactLinkArray )
+        {
+        User::Leave( KErrNotReady );
+        }
+    return *iContactLinkArray;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MPresenceContactsContextBase.
+//CPresencePluginContacts::RetrieveContactL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::RetrieveContactL(
+    const MVPbkContactLink& aContactLink )
+    {
+    DP_SDA( "CPresencePluginContacts::RetrieveContactL()" );
+    iContactOperation =
+        iContactManager->RetrieveContactL( aContactLink, *this );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MVPbkContactStoreListObserver.
+// CPresencePluginContacts::OpenComplete
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::OpenComplete()
+    {
+    DP_SDA( "CPresencePluginContacts::OpenComplete()" );
+    iStateHandler->State()->Complete();
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MVPbkContactStoreObserver.
+// CPresencePluginContacts::StoreReady
+// ---------------------------------------------------------------------------
+// 
+void CPresencePluginContacts::StoreReady(
+    MVPbkContactStore& /*aContactStore*/ )
+     {
+     DP_SDA( "CPresencePluginContacts::StoreReady()" );
+     }
+
+
+// ---------------------------------------------------------------------------
+// From class MVPbkContactStoreObserver.
+// CPresencePluginContacts::StoreUnavailable
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::StoreUnavailable(
+    MVPbkContactStore& /*aContactStore*/, TInt /*aReason*/ )
+    {
+    DP_SDA( "CPresencePluginContacts::StoreUnavailable()" );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MVPbkContactStoreObserver.
+// CPresencePluginContacts::HandleStoreEventL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::HandleStoreEventL(
+         MVPbkContactStore& /*aContactStore*/, 
+         TVPbkContactStoreEvent /*aStoreEvent*/ )
+    {
+    DP_SDA( "CPresencePluginContacts::HandleStoreEventL()" );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MVPbkContactFindObserver.
+// CPresencePluginContacts::FindCompleteL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::FindCompleteL( MVPbkContactLinkArray* aResults )
+    {
+    DP_SDA( "CPresencePluginContacts::FindCompleteL()" );
+    
+    delete iContactLinkArray;
+    iContactLinkArray = NULL;
+    iContactLinkArray = aResults;
+    
+    delete iContactOperation;
+    iContactOperation = NULL;
+
+    iStateHandler->State()->Complete();
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MVPbkContactFindObserver.
+// CPresencePluginContacts::FindFailed
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::FindFailed( TInt aError )
+    {
+    DP_SDA( "CPresencePluginContacts::FindFailed()" );
+    
+    delete iContactOperation;
+    iContactOperation = NULL;
+    
+    iStateHandler->State()->Error( aError );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MVPbkSingleContactOperationObserver.
+// CPresencePluginContacts::VPbkSingleContactOperationComplete
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::VPbkSingleContactOperationComplete(
+        MVPbkContactOperationBase& aOperation,
+        MVPbkStoreContact* aContact )
+    {
+    DP_SDA( "CPresencePluginContacts::VPbkSingleContactOperationComplete()" );
+    
+    if ( iContactOperation == &aOperation )
+        {
+        delete iContactOperation;
+        iContactOperation = NULL;
+        }
+    
+    TInt error = iStoreContactArray.Append( aContact );
+    if ( KErrNone != error )
+        {
+        delete aContact;
+        aContact = NULL;
+        iStateHandler->State()->Error( error );
+        }
+    else
+        {
+        iStateHandler->State()->Complete();
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MVPbkSingleContactOperationObserver.
+// CPresencePluginContacts::VPbkSingleContactOperationFailed
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::VPbkSingleContactOperationFailed(
+        MVPbkContactOperationBase& aOperation, 
+        TInt aError )
+    {
+    DP_SDA( "CPresencePluginContacts::VPbkSingleContactOperationFailed()" );
+    
+    if ( iContactOperation == &aOperation )
+        {
+        delete iContactOperation;
+        iContactOperation = NULL;
+        }
+    
+    iStateHandler->State()->Error( aError);
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// CPresencePluginContacts::RunL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::RunL()
+    {
+    DP_SDA2( "CPresencePluginContacts::RunL - status %d", iStatus.Int() );
+    
+    TBool result( EFalse );
+    TBool found( EFalse );
+    CPresencePluginLocalstore* localStore = NULL;
+    TInt error = iStatus.Int();
+    
+    switch( iOperation )
+        {
+        case EOperationIsPresenceStoredToContacts:
+            DP_SDA( "CPresencePluginContacts::RunL -EOperationIsPresenceStoredToContacts" );
+            
+            if ( KErrNone == error )
+                {
+                localStore = CPresencePluginLocalstore::NewLC( *iServiceName );
+                
+                for ( TInt i( 0 ); ( i < iStoreContactArray.Count() ) && !found; i++ )
+                    {
+                    MVPbkContactLink* link = iStoreContactArray[ i ]->CreateLinkLC();
+                    CVPbkContactIdConverter* converter =
+                        CVPbkContactIdConverter::NewL( link->ContactStore() );
+                    CleanupStack::PushL( converter );
+    
+                    TInt32 id = converter->LinkToIdentifier( *link );
+                    if ( localStore->SeekRowAtContactColL( id ) )
+                        {
+                        found = ETrue;
+                        result = ETrue;
+                        }
+                    CleanupStack::PopAndDestroy( converter );
+                    CleanupStack::PopAndDestroy(); // link
+                    }
+                 
+                CleanupStack::PopAndDestroy( localStore );
+                }
+            if ( KErrNotFound == error )
+                {
+                error = KErrNone;
+                }
+            iObserver->RequestComplete( &result, iOperation, error );
+            break;
+        default:
+            break;
+        }
+    // Operation completed.
+    // State handler not needet anymore
+    delete iStateHandler;
+    iStateHandler = NULL;
+    // Close contact stores
+    iContactManager->ContactStoresL().CloseAll( *this );
+    
+    User::RequestComplete( iClientStatus, error );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// CPresencePluginContacts::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContacts::DoCancel()
+    {
+    if ( iClientStatus && *iClientStatus == KRequestPending )
+        {
+        User::RequestComplete( iClientStatus, KErrCancel );
+        }
+    iStateHandler->Complete( KErrCancel );
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class CActive.
+// CPresencePluginContacts::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginContacts::RunError( TInt aError )
+    {
+    DP_SDA2( "CPresencePluginContacts::RunError - status %d", aError );
+    User::RequestComplete( iClientStatus, aError );
+    return KErrNone;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presenceplugincontactstate.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include "presenceplugincontactstate.h"
+#include "presenceplugincontactstatehandler.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencepluginContactState::CPresencepluginContactState
+// ---------------------------------------------------------------------------
+//
+CPresencepluginContactState::CPresencepluginContactState(
+    MPresenceContactsContextBase& aContext,
+    CPresencePluginContactStateHandler& aStateHandler )
+    : iContext( &aContext ), iStateHandler( &aStateHandler )
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencepluginContactState::~CPresencepluginContactState
+// ---------------------------------------------------------------------------
+//
+CPresencepluginContactState::~CPresencepluginContactState()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencepluginContactState::Complete
+// ---------------------------------------------------------------------------
+//
+void CPresencepluginContactState::Complete()
+    {
+    iStateHandler->ProgressToNextState();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencepluginContactState::Complete
+// ---------------------------------------------------------------------------
+//
+void CPresencepluginContactState::Error( TInt aError )
+    {
+    iStateHandler->Complete( aError );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presenceplugincontactstateend.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include "presenceplugincontactstateend.h"
+#include "presenceplugincontactstatehandler.h"
+#include "presencecontactscontextbase.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateEnd::CPresencePluginContactStateEnd
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContactStateEnd::CPresencePluginContactStateEnd(
+    MPresenceContactsContextBase& aContext,
+    CPresencePluginContactStateHandler& aStateHandler )
+    : CPresencepluginContactState( aContext, aStateHandler )
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateEnd::~CPresencePluginContactStateEnd
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContactStateEnd::~CPresencePluginContactStateEnd()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateEnd::HandleL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContactStateEnd::HandleL()
+    {
+    iStateHandler->Complete( KErrNone );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presenceplugincontactstatehandler.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,129 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include "presenceplugincontactstatehandler.h"
+#include "presenceplugincontactstate.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateHandler::CPresencePluginContactStateHandler
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContactStateHandler::CPresencePluginContactStateHandler()
+    : iCurrentStateIndex( 0 )
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateHandler::~CPresencePluginContactStateHandler
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContactStateHandler::~CPresencePluginContactStateHandler()
+    {
+    iStateArray.ResetAndDestroy();
+    iClientStatus = NULL;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateHandler::NewL
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContactStateHandler* CPresencePluginContactStateHandler::NewL()
+    {
+    CPresencePluginContactStateHandler* self =
+            new (ELeave) CPresencePluginContactStateHandler();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateHandler::Start
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContactStateHandler::Start( TRequestStatus* aStatus )
+    {
+    iClientStatus = aStatus;
+    *iClientStatus = KRequestPending;
+    iCurrentStateIndex = 0;
+    HandleNextState();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateHandler::Complete
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContactStateHandler::Complete( TInt aError )
+    {
+    if( iClientStatus && *iClientStatus == KRequestPending )
+        {
+        User::RequestComplete( iClientStatus, aError );
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateHandler::ProgressToNextState
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContactStateHandler::ProgressToNextState()
+    {
+    iCurrentStateIndex++;
+    HandleNextState();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateHandler::HandleNextState
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContactStateHandler::HandleNextState()
+    {
+    TRAPD( error, State()->HandleL() );
+    if ( KErrNone != error )
+        {
+        Complete( error );
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateHandler::AddStateL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContactStateHandler::AddStateL(
+    CPresencepluginContactState* aState )
+    {
+    CleanupStack::PushL( aState );
+    iStateArray.AppendL( aState );
+    CleanupStack::Pop( aState );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateHandler::State
+// ---------------------------------------------------------------------------
+//
+CPresencepluginContactState* CPresencePluginContactStateHandler::State()
+    {
+    return iStateArray[ iCurrentStateIndex ];
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presenceplugincontactstateopen.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,54 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include "presenceplugincontactstateopen.h"
+#include "presencecontactscontextbase.h"
+#include "presenceplugincontactstatehandler.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateOpen::CPresencePluginContactStateOpen
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContactStateOpen::CPresencePluginContactStateOpen(
+    MPresenceContactsContextBase& aContext,
+    CPresencePluginContactStateHandler& aStateHandler )
+    : CPresencepluginContactState( aContext, aStateHandler )
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateOpen::~CPresencePluginContactStateOpen
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContactStateOpen::~CPresencePluginContactStateOpen()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateOpen::HandleL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContactStateOpen::HandleL()
+    {
+    iContext->OpenL();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presenceplugincontactstateresolve.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <MVPbkContactLinkArray.h>
+#include <MVPbkContactLink.h>
+#include "presenceplugincontactstateresolve.h"
+#include "presencecontactscontextbase.h"
+#include "presenceplugincontactstatehandler.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateResolve::PresencePluginContactStateResolve
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContactStateResolve::CPresencePluginContactStateResolve(
+    MPresenceContactsContextBase& aContext,
+    CPresencePluginContactStateHandler& aStateHandler )
+    : CPresencepluginContactState( aContext, aStateHandler ),
+      iContactLinkIndex( NULL ),
+    iContactLinkCount( NULL )
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateResolve::~CPresencePluginContactStateResolve
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContactStateResolve::~CPresencePluginContactStateResolve()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateResolve::HandleL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContactStateResolve::HandleL()
+    {
+    iContactLinkCount = iContext->ContactLinkArrayL().Count();
+    if ( NULL == iContactLinkCount )
+        {
+        Error( KErrNotFound );
+        }
+    else
+        {
+        iContext->RetrieveContactL(
+            iContext->ContactLinkArrayL().At( iContactLinkIndex ) );
+        iContactLinkIndex++;
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateResolve::Complete
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContactStateResolve::Complete()
+    {
+    if ( iContactLinkIndex < iContactLinkCount )
+        {
+        TRAPD( error, HandleL() );
+        if ( KErrNone != error )
+            {
+            Error( error );
+            }
+        }
+    else
+        {
+        iStateHandler->ProgressToNextState();
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presenceplugincontactstatesearch.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include "presenceplugincontactstatesearch.h"
+#include "presencecontactscontextbase.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateSearch::CPresencePluginContactStateSearch
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContactStateSearch::CPresencePluginContactStateSearch(
+    MPresenceContactsContextBase& aContext,
+    CPresencePluginContactStateHandler& aStateHandler )
+    : CPresencepluginContactState( aContext, aStateHandler )
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateSearch::~CPresencePluginContactStateSearch
+// ---------------------------------------------------------------------------
+//
+CPresencePluginContactStateSearch::~CPresencePluginContactStateSearch()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginContactStateSearch::HandleL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginContactStateSearch::HandleL()
+    {
+    iContext->SearchL();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presenceplugindata.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,1839 @@
+/*
+* Copyright (c) 2007-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <e32std.h>
+#include <e32base.h>
+#include <s32strm.h>
+#include <e32def.h>
+#include <e32svr.h>
+#include <e32math.h> 
+#include <utf.h>
+#include <ximpbase.h>
+#include <ximpobjectfactory.h>
+#include <ximpobjectcollection.h>
+#include <presenceobjectfactory.h>
+#include <presenceinfo.h>
+#include <personpresenceinfo.h>
+#include <presenceinfofieldcollection.h>
+#include <presenceinfofield.h>
+#include <presenceinfofieldvaluetext.h>
+#include <presenceinfofieldvalueenum.h>
+#include <ximpidentity.h>
+#include <msimpledocument.h>
+#include <msimpleelement.h>
+#include <msimplepresencelist.h>
+#include <msimplemeta.h>
+#include <simpleutils.h>
+#include <presencecachewriter2.h>
+#include <presencecachereader2.h>
+#include <presencebuddyinfo.h>
+#include <spsettings.h>
+#include <spentry.h>
+#include <spproperty.h>
+#include <spdefinitions.h>
+#include <avabilitytext.h>
+#include <cvimpstsettingsstore.h>
+#include <escapeutils.h>
+
+#include "presenceplugindata.h"
+#include "presenceplugincommon.h"
+#include "presencepluginvirtualgroup.h"
+#include "presencepluginlanguagecodes.h"
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::CPresencePluginData
+// ---------------------------------------------------------------------------
+//
+CPresencePluginData::CPresencePluginData( 
+	MPresencePluginConnectionObs& aObs,
+	TInt aServiceId ):
+	iConnObs( aObs ), 
+	iServiceId( aServiceId ),
+	iPresenceCacheWriter( NULL ),
+	iPresenceCacheReader( NULL )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::~CPresencePluginData
+// ---------------------------------------------------------------------------
+//
+CPresencePluginData::~CPresencePluginData()
+    {
+    DP_SDA("CPresencePluginData::~CPresencePluginData");
+    delete iPresenceCacheWriter;
+    delete iPresenceCacheReader;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::NewL
+// ---------------------------------------------------------------------------
+//
+CPresencePluginData* CPresencePluginData::NewL( 
+	MPresencePluginConnectionObs& aObs, TInt aServiceId )
+    {
+    CPresencePluginData* self = CPresencePluginData::NewLC( 
+		aObs,
+		aServiceId );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginData::ConstructL()
+    {
+    DP_SDA("CPresencePluginData::ConstructL");
+    iPresenceCacheWriter =  MPresenceCacheWriter2::CreateWriterL();
+    iPresenceCacheReader = MPresenceCacheReader2::CreateReaderL();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::NewLC
+// ---------------------------------------------------------------------------
+//
+CPresencePluginData* CPresencePluginData::NewLC(
+    MPresencePluginConnectionObs& aObs, TInt aServiceId )
+    {
+    CPresencePluginData* self =
+    	new( ELeave ) CPresencePluginData( aObs, aServiceId );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::NotifyToBlockedToXIMPL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginData::NotifyToBlockedToXIMPL(
+    MPresenceObjectFactory& aPresenceFactory,
+    MPresenceInfo& aPrInfo,
+    const TDesC& aUnicodeNoteContent )
+    {
+    DP_SDA("CPresencePluginData::NotifyToBlockedToXIMPL");
+    MPersonPresenceInfo* persInfo =
+        aPresenceFactory.NewPersonPresenceInfoLC();
+    MPresenceInfoFieldCollection& coll = persInfo->Fields();
+    
+    //Set pending
+    using namespace NPresenceInfo::NFieldType;
+    using namespace NPresencePlugin::NPresenceStates;
+    
+    MPresenceInfoField* field = aPresenceFactory.NewInfoFieldLC();
+    field->SetFieldTypeL( KAvailabilityEnum );
+        
+    // use mapped enums to pass status    
+    MPresenceInfoFieldValueEnum* enumField = 
+        aPresenceFactory.NewEnumInfoFieldLC();
+    
+    // HOX: BLOCKED ENUM NEEDED TO XIMP
+    enumField->SetValueL( NPresenceInfo::ENotAvailable ); 
+    field->SetFieldValue( enumField );
+        
+    coll.AddOrReplaceFieldL( field );
+    CleanupStack::Pop( 2 );            // >> field, enumField      
+    
+    // Add status msg field
+    MPresenceInfoField* noteField = aPresenceFactory.NewInfoFieldLC();
+    noteField->SetFieldTypeL( KStatusMessage );
+        
+    MPresenceInfoFieldValueText* textField = 
+        aPresenceFactory.NewTextInfoFieldLC();
+    textField->SetTextValueL( aUnicodeNoteContent );
+    
+    noteField->SetFieldValue( textField );
+        
+    coll.AddOrReplaceFieldL( noteField );
+    CleanupStack::Pop( 2 );            // >> noteField, enumField      
+    
+    aPrInfo.SetPersonPresenceL( persInfo );
+    CleanupStack::Pop();   // >> persInfo
+    DP_SDA("CPresencePluginData::NotifyToBlockedToXIMPL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::NotifyToPendingToXIMPL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginData::NotifyToPendingToXIMPL(
+    MPresenceObjectFactory& aPresenceFactory,
+    MPresenceInfo& aPrInfo,
+    const TDesC& aUnicodeNoteContent )
+    {
+    DP_SDA("CPresencePluginData::NotifyToPendingToXIMP");
+    MPersonPresenceInfo* persInfo =
+        aPresenceFactory.NewPersonPresenceInfoLC();
+    MPresenceInfoFieldCollection& coll = persInfo->Fields();
+    
+    //Set pending
+    using namespace NPresenceInfo::NFieldType;
+    using namespace NPresencePlugin::NPresenceStates;
+    
+    MPresenceInfoField* field = aPresenceFactory.NewInfoFieldLC();
+    field->SetFieldTypeL( KAvailabilityEnum );
+        
+    // use mapped enums to pass status    
+    MPresenceInfoFieldValueEnum* enumField = 
+        aPresenceFactory.NewEnumInfoFieldLC();
+    enumField->SetValueL( NPresenceInfo::ERemotePending );
+    field->SetFieldValue( enumField );
+        
+    coll.AddOrReplaceFieldL( field );
+    CleanupStack::Pop( 2 );            // >> field, enumField      
+    
+    // Add status msg field
+    MPresenceInfoField* noteField = aPresenceFactory.NewInfoFieldLC();
+    noteField->SetFieldTypeL( KStatusMessage );
+        
+    MPresenceInfoFieldValueText* textField = 
+        aPresenceFactory.NewTextInfoFieldLC();
+    textField->SetTextValueL( aUnicodeNoteContent );
+    
+    noteField->SetFieldValue( textField );
+        
+    coll.AddOrReplaceFieldL( noteField );
+    CleanupStack::Pop( 2 );            // >> noteField, enumField      
+    
+    aPrInfo.SetPersonPresenceL( persInfo );
+    CleanupStack::Pop();   // >> persInfo
+    DP_SDA("CPresencePluginData::NotifyToPendingToXIMP end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::NotifyActiveToPrInfoL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginData::NotifyToActiveToXIMPL(
+    MPresenceObjectFactory& aPresenceFactory,
+    MPresenceInfo& aPrInfo,
+    const TDesC& aUnicodeNoteContent,
+    NPresenceInfo::TAvailabilityValues aAvailability )
+    {
+    DP_SDA("CPresencePluginData::NotifyToActiveToXIMPL");
+    MPersonPresenceInfo* persInfo =
+        aPresenceFactory.NewPersonPresenceInfoLC();
+    MPresenceInfoFieldCollection& coll = persInfo->Fields();
+    
+    //Set pending
+    using namespace NPresenceInfo::NFieldType;
+    using namespace NPresencePlugin::NPresenceStates;
+    
+    MPresenceInfoField* field = aPresenceFactory.NewInfoFieldLC();
+    field->SetFieldTypeL( KAvailabilityEnum );
+        
+    // use mapped enums to pass status    
+    MPresenceInfoFieldValueEnum* enumField = 
+        aPresenceFactory.NewEnumInfoFieldLC();
+    enumField->SetValueL( aAvailability );
+    field->SetFieldValue( enumField );
+        
+    coll.AddOrReplaceFieldL( field );
+    CleanupStack::Pop( 2 );            // >> field, enumField      
+    
+    // Add status msg field
+    MPresenceInfoField* noteField = aPresenceFactory.NewInfoFieldLC();
+    noteField->SetFieldTypeL( KStatusMessage );
+        
+    MPresenceInfoFieldValueText* textField = 
+        aPresenceFactory.NewTextInfoFieldLC();
+    textField->SetTextValueL( aUnicodeNoteContent );
+    
+    noteField->SetFieldValue( textField );
+        
+    coll.AddOrReplaceFieldL( noteField );
+    CleanupStack::Pop( 2 );            // >> noteField, enumField      
+    
+    aPrInfo.SetPersonPresenceL( persInfo );
+    CleanupStack::Pop();   // >> persInfo
+    DP_SDA("CPresencePluginData::NotifyToActiveToXIMPL end");
+    }
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginData::NotifyTerminatedToPrInfoL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginData::NotifyTerminatedToXIMPL(
+    MPresenceObjectFactory& aPresenceFactory,
+    MPresenceInfo& aPrInfo,
+    const TDesC& aUnicodeNoteContent )
+    {
+    DP_SDA("CPresencePluginData::NotifyTerminatedToXIMPL");
+    MPersonPresenceInfo* persInfo =
+        aPresenceFactory.NewPersonPresenceInfoLC();
+    MPresenceInfoFieldCollection& coll = persInfo->Fields();
+    
+    //Set pending
+    using namespace NPresenceInfo::NFieldType;
+    using namespace NPresencePlugin::NPresenceStates;
+    
+    MPresenceInfoField* field = aPresenceFactory.NewInfoFieldLC();
+    field->SetFieldTypeL( KAvailabilityEnum );
+        
+    // use mapped enums to pass status    
+    MPresenceInfoFieldValueEnum* enumField = 
+        aPresenceFactory.NewEnumInfoFieldLC();
+    enumField->SetValueL( NPresenceInfo::EOffline );
+    field->SetFieldValue( enumField );
+        
+    coll.AddOrReplaceFieldL( field );
+    CleanupStack::Pop( 2 );            // >> field, enumField      
+    
+    // Add status msg field
+    MPresenceInfoField* noteField = aPresenceFactory.NewInfoFieldLC();
+    noteField->SetFieldTypeL( KStatusMessage );
+        
+    MPresenceInfoFieldValueText* textField = 
+        aPresenceFactory.NewTextInfoFieldLC();
+    textField->SetTextValueL( aUnicodeNoteContent );
+    
+    noteField->SetFieldValue( textField );
+        
+    coll.AddOrReplaceFieldL( noteField );
+    CleanupStack::Pop( 2 );            // >> noteField, enumField      
+    
+    aPrInfo.SetPersonPresenceL( persInfo );
+    CleanupStack::Pop();   // >> persInfo
+    DP_SDA("CPresencePluginData::NotifyTerminatedToXIMPL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::NotifyToPrInfoL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginData::NotifyToPrInfoL(
+    MXIMPObjectFactory& /*aFactory*/,
+    MPresenceObjectFactory& aPresenceFactory,
+    MSimpleDocument& aDocument,
+    MPresenceInfo& aPrInfo )
+    {
+    DP_SDA("CPresencePluginData::NotifyToPrInfoL");
+    MPersonPresenceInfo* persInfo =
+        aPresenceFactory.NewPersonPresenceInfoLC();
+    DP_SDA("CPresencePluginData::NotifyToPrInfoL persInfo");
+
+    if( !aDocument.EntityURI() )
+    	{
+    	DP_SDA("CPresencePluginData::NotifyToPrInfoL entity URL not valid");
+    	User::Leave( KErrCancel );
+    	}
+ 
+    MPresenceInfoFieldCollection& coll = persInfo->Fields();
+    
+    DP_SDA("CPresencePluginData::NotifyToPrInfoL collection");
+    // Search own person info. Notice: Extend supported attributes later
+    TBool basicElementFound = EFalse;
+    TBool activitiesElementFound = EFalse;
+    TBool noteElemFound = EFalse;
+        
+    DP_SDA("CPresencePluginData::NotifyToPrInfoL RPointerArray");
+    RPointerArray<MSimpleElement> elems;
+    DP_SDA("CPresencePluginData::NotifyToPrInfoL Push elems");
+    CleanupClosePushL( elems );
+    DP_SDA("CPresencePluginData::NotifyToPrInfoL aDocument");
+    TInt err = aDocument.SimpleElementsL( elems );
+    
+    DP_SDA2("CPresencePluginData::NotifyToPrInfoL err %d", err);
+    
+    RPointerArray<MSimpleElement> basicElems;
+	CleanupClosePushL( basicElems );
+	MSimpleElement* basicSimpleElem(NULL);
+	
+	RPointerArray<MSimpleElement> activitiesElems;
+	CleanupClosePushL( activitiesElems );
+	MSimpleElement* activitiesSimpleElem(NULL);
+	MSimpleElement* noteSimpleElem(NULL);
+		
+    if ( !err )
+        {
+        DP_SDA("CPresencePluginData::NotifyToPrInfoL, elements ok");       
+        TInt count = elems.Count();
+        DP_SDA2("CPresencePluginData::NotifyToPrInfoL, element count: %d", count );       
+        
+        using namespace NPresencePlugin::NPresence;
+
+        MSimpleElement* elem = NULL;
+        TPtrC8 p8;
+
+        for ( TInt i = 0; i < count; i++ )
+            {
+            DP_SDA2("CPresencePluginData::NotifyToPrInfoL, handling elem[%d]", i );
+            
+            elem = elems[i];
+            p8.Set( elem->LocalName());
+            if (!( p8.CompareF( KPresencePerson8 )) ||
+                !( p8.CompareF( KPresenceTuple8 )) )
+                {
+                // person element found
+                RPointerArray<MSimpleElement> elems2;
+                CleanupClosePushL( elems2 );
+                elem->SimpleElementsL( elems2 );
+                TInt count2 = elems2.Count();
+                DP_SDA2("CPresencePluginData::NotifyToPrInfoL count2 %d", count2);
+                for ( TInt j = 0; j < count2; j++ )
+                    {
+                    DP_SDA("CPresencePluginData::NotifyToPrInfoL 4");
+                    //
+                    MSimpleElement* elem2 = elems2[j];
+                    
+                    //FIND BASIC/ACTIVITIES ELEMENT
+                    if ( !elem2->LocalName().CompareF( KPresenceStatus8 ) &&
+                        !basicElementFound )
+             	        {
+             	        DP_SDA("NotifyToPrInfoL PresenceStatus");
+             	        //Get elem2 childs
+			            elem2->SimpleElementsL( basicElems );
+			            TInt count3 = basicElems.Count();  //Child count
+			            for ( TInt k = 0; k < count3; k++ )
+			                {
+			                MSimpleElement* tempElem = basicElems[k];
+			                if ( !tempElem->LocalName().CompareF( 
+			                		KPresenceBasic8 ))
+			                    {
+			                    DP_SDA("NotifyToPrInfoL basic elem true");
+			                    basicSimpleElem = basicElems[k];
+			                    basicElementFound = ETrue;
+			                    }
+			                else if( !tempElem->LocalName().CompareF( 
+			                		KPresenceActivities8 ))
+			                    {
+			                    DP_SDA("NotifyToPrInfoL activities under basic");
+			                    activitiesSimpleElem = basicElems[k];
+			                    activitiesElementFound = ETrue;
+			                    }
+			                } 
+             	        }
+             	    
+                    //FIND ACTIVITIES ELEMENT
+             	    if ( basicElementFound && !activitiesElementFound &&
+             	        !elem2->LocalName().CompareF( KPresenceActivities8 ) )
+             	        {
+             	        DP_SDA("NotifyToPrInfoL activities found outside basic");
+			            elem2->SimpleElementsL( activitiesElems );
+			            TInt count4 = activitiesElems.Count();
+			            for ( TInt l = 0; l < count4; l++ )
+			                {
+			                activitiesSimpleElem = activitiesElems[l];
+			                activitiesElementFound = ETrue;
+			                DP_SDA("CPresencePluginData::NotifyToPrInfoL 6");
+			                }
+             	        }
+                    }
+                
+                if ( basicElementFound && !noteSimpleElem )
+                    {
+                    noteSimpleElem = ResolveNoteElementL( elems2 );
+                    }
+                
+                DP_SDA("NotifyToPrInfoL ALL DONE"); 
+                CleanupStack::PopAndDestroy( &elems2 );
+                
+                if ( basicElementFound && activitiesElementFound && noteElemFound )
+                    {
+                    DP_SDA("NotifyToPrInfoL ALL DONE break out"); 
+                    //Just handle first status information from document
+                    // In future server should support <timestamp>
+                    //Also client should be can handle timestaps if there are present
+                    break;
+                    }
+                }
+     	    // Check note field    
+     	    else if ( basicElementFound && !( p8.CompareF( KPresenceNote8 )) &&
+     	         !noteSimpleElem )
+     	        {
+     	        DP_SDA("NotifyToPrInfoL note field found outside tuple");
+	            noteSimpleElem = elem;
+     	        }             	    
+            }                
+        }
+    
+    if ( basicElementFound )
+    	{
+    	DP_SDA("NotifyToPrInfoL basic proceed to handling");
+    	SingleUserStatusToXIMPL( 
+            aPresenceFactory, basicSimpleElem, 
+    		activitiesSimpleElem, noteSimpleElem, coll );  
+    	}
+    CleanupStack::PopAndDestroy( &activitiesElems );
+    CleanupStack::PopAndDestroy( &basicElems );
+    CleanupStack::PopAndDestroy( &elems );
+
+    aPrInfo.SetPersonPresenceL( persInfo );
+    CleanupStack::Pop();   // >> persInfo
+    
+    // TODO2: Notice: the following crashes in old PrFW version
+    /*
+    aPrInfo.AddDevicePresenceL ( NULL );
+    aPrInfo.AddServicePresenceL( NULL );
+    */
+    DP_SDA("CPresencePluginData::NotifyToPrInfoL end");        
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::CacheEntriesFromPrInfo
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginData::CacheEntriesFromPrInfo(
+    MPresenceInfo& aPrInfo,
+    MPresenceBuddyInfo2::TAvailabilityValues& aAvailability,
+    TPtr& aExtendedAvailability,
+    TPtr& aStatusMessage )
+    {
+    DP_SDA("CPresencePluginData::CacheEntriesFromPrInfoL");
+    
+    DP_SDA(" -> CacheEntriesFromPrInfoL, fetch status enum field");
+    MPresenceInfoField* statusEnumInfoField = NULL;
+    MPersonPresenceInfo* presInfo = aPrInfo.PersonPresence();
+    if ( presInfo )
+        {
+        DP_SDA(" -> CacheEntriesFromPrInfoL, has person presence, get field");
+        presInfo->Fields().LookupFieldByFieldType( 
+            statusEnumInfoField, 
+            NPresenceInfo::NFieldType::KAvailabilityEnum );
+        DP_SDA(" -> CacheEntriesFromPrInfoL, fetch status enum field done, check item");
+        if ( statusEnumInfoField )
+            {
+            DP_SDA(" -> status enum field found");
+            const MPresenceInfoFieldValueEnum* availability = 
+            TXIMPGetInterface< const MPresenceInfoFieldValueEnum >::From( 
+                statusEnumInfoField->FieldValue(), MXIMPBase::EPanicIfUnknown );
+             switch( availability->Value() )
+                {
+                case NPresenceInfo::EAvailable:
+                    {
+                    DP_SDA(" -> status enum field => available");
+                    aAvailability = MPresenceBuddyInfo2::EAvailable;
+                    aExtendedAvailability.Copy( KDefaultAvailableStatus() );
+                    }
+                    break;
+                    
+                case NPresenceInfo::EBusy:
+                    {
+                    DP_SDA(" -> status enum field => busy");
+                    aAvailability = MPresenceBuddyInfo2::EBusy;
+                    aExtendedAvailability.Copy( KDndState() );
+                    }
+                    break;
+                    
+                case NPresenceInfo::EOnPhone:
+                    {
+                    DP_SDA(" -> status enum field => on phone");
+                    aAvailability = MPresenceBuddyInfo2::EBusy;
+                    aExtendedAvailability.Copy( KOnPhoneState() );
+                    }
+                    break;
+                    
+                case NPresenceInfo::EAway:
+                    {
+                    DP_SDA(" -> status enum field => away");
+                    aAvailability = MPresenceBuddyInfo2::EBusy;
+                    aExtendedAvailability.Copy( KAwayState() );
+                    }
+                    break;
+                
+                case NPresenceInfo::EDoNotDisturb:
+                    {
+                    DP_SDA(" -> status enum field => dnd");
+                    aAvailability = MPresenceBuddyInfo2::EBusy;
+                    aExtendedAvailability.Copy( KDndState() );
+                    }
+                    break;
+                
+                case NPresenceInfo::EOffline:
+                case NPresenceInfo::ENotAvailable:
+                default:
+                    {
+                    DP_SDA(" -> status enum field => offline/not available/default");
+                    aAvailability = MPresenceBuddyInfo2::ENotAvailable;
+                    aExtendedAvailability.Copy( KInvisibleState() );
+                    }
+                    break;
+                }        
+            }
+        else
+            {
+            DP_SDA(" -> status enum not found => set unknown");
+            aAvailability = MPresenceBuddyInfo2::EUnknownAvailability;
+            aExtendedAvailability.Copy( KNullDesC() );
+            }
+        DP_SDA(" -> fetch status message field");    
+        MPresenceInfoField* statusMsgInfoField = NULL;
+        presInfo->Fields().LookupFieldByFieldType( 
+            statusMsgInfoField, 
+            NPresenceInfo::NFieldType::KStatusMessage );
+        DP_SDA(" -> CacheEntriesFromPrInfoL, fetch status message field done, check item");    
+        if ( statusMsgInfoField )
+            {
+            DP_SDA(" -> status msg field found");
+            const MPresenceInfoFieldValueText* statusMsg = 
+            TXIMPGetInterface< const MPresenceInfoFieldValueText >::From( 
+                statusMsgInfoField->FieldValue(), MXIMPBase::EPanicIfUnknown );
+            if ( statusMsg && statusMsg->TextValue().Length() )
+                {
+                DP_SDA(" -> status msg field found, copy content");
+                aStatusMessage.Copy( statusMsg->TextValue() );
+                }
+            }
+        else
+            {
+            DP_SDA(" -> status msg field not found, set empty");
+            aStatusMessage.Copy( KNullDesC() );
+            }
+        }
+        
+    DP_SDA("CPresencePluginData::CacheEntriesFromPrInfoL out");    
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::SingleUserStatusToXIMPL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginData::SingleUserStatusToXIMPL(
+    MPresenceObjectFactory& aPresenceFactory,
+    MSimpleElement* aBasicElement,
+    MSimpleElement* aActivitiesElement,
+    MSimpleElement* aNoteElement,
+    MPresenceInfoFieldCollection& aCollection )
+    {
+    DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL");
+
+    using namespace NPresenceInfo::NFieldType;
+    using namespace NPresencePlugin::NPresenceStates;
+    
+    //Get aBasicElem content 
+    HBufC* nodeContent = aBasicElement->ContentUnicodeL();
+    CleanupStack::PushL( nodeContent );
+    
+    TBuf<KBufSize100> basicContentBuf; 
+    basicContentBuf.Copy( *nodeContent );
+    DP_SDA2("SingleUserStatusToXIMPL basicContent %S", &basicContentBuf);
+    
+    TBuf<KBufSize100> activitiesContentBuf;
+    
+    if ( !aActivitiesElement )
+        {
+        activitiesContentBuf.Copy( KPresenceUnknow );
+        DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL activities NULL");
+        }
+    else
+        {
+        activitiesContentBuf.Copy( aActivitiesElement->LocalName() );
+        DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL else");
+        }
+        
+    if ( nodeContent )
+        {
+        using namespace NPresenceInfo::NFieldType;
+        MPresenceInfoField* field = aPresenceFactory.NewInfoFieldLC();
+        field->SetFieldTypeL( KAvailabilityEnum );
+        
+        // use mapped enums to pass status    
+        MPresenceInfoFieldValueEnum* enumField = 
+            aPresenceFactory.NewEnumInfoFieldLC();
+
+        // Busy case
+        if ( !nodeContent->Des().CompareF( KPresenceOpen ) &&
+            !activitiesContentBuf.CompareF ( KPresenceBusy ) )
+            {
+            DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL open/busy");
+            enumField->SetValueL( NPresenceInfo::EBusy );
+            }
+        // On-The-Phone case
+        else if ( !nodeContent->Des().CompareF( KPresenceOpen ) &&
+            !activitiesContentBuf.CompareF ( KPresenceOnThePhone ) )
+            {
+            DP_SDA("CPresencePluginData::SingleUserStatusToXIMPL open/on-the-phone");
+            enumField->SetValueL( NPresenceInfo::EOnPhone );
+            }
+        //Away case  
+        else if ( !nodeContent->Des().CompareF( KPresenceOpen ) &&
+            !activitiesContentBuf.CompareF ( KPresenceAway ) )
+            {
+            DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL open/away");
+            enumField->SetValueL( NPresenceInfo::EAway );
+            }
+        //Dnd case  
+        else if ( !nodeContent->Des().CompareF( KPresenceOpen ) &&
+            !activitiesContentBuf.CompareF ( KPresenceDoNotDisturb ) )
+            {
+            DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL open/dnd");
+            enumField->SetValueL( NPresenceInfo::EDoNotDisturb );
+            }            
+        // Unknown open
+        else if ( !nodeContent->Des().CompareF( KPresenceOpen ) &&
+            !activitiesContentBuf.CompareF ( KPresenceUnknow ) )
+            {
+            DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL open/unknown");
+            enumField->SetValueL( NPresenceInfo::EAvailable );
+            }
+        // availale open
+        else if ( !nodeContent->Des().CompareF( KPresenceOpen ) &&
+            !activitiesContentBuf.CompareF ( KPresenceAvailable ) )
+            {
+            DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL open/available");
+            enumField->SetValueL( NPresenceInfo::EAvailable );
+            }            
+        //Unknown closed
+        else if ( !nodeContent->Des().CompareF( KPresenceClosed ) &&
+            !activitiesContentBuf.CompareF ( KPresenceUnknow ) )
+            {
+            DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL closed/unknown");
+            enumField->SetValueL( NPresenceInfo::EOffline );
+            }
+        //Else set status according to basic status
+        else
+            {
+            if ( !nodeContent->Des().CompareF( KPresenceOpen ) )
+                {
+                DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL else open");
+                enumField->SetValueL( NPresenceInfo::EAvailable );
+                }
+            else
+                {
+                DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL else closed");
+                enumField->SetValueL( NPresenceInfo::ENotAvailable );
+                }
+            }
+        
+        field->SetFieldValue( enumField );
+        aCollection.AddOrReplaceFieldL( field );
+        
+        CleanupStack::Pop( 2 );            // >> field, enumField
+        
+        DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL check for note");
+        
+        // Handle note field if found and buddy is "available".
+        if ( aNoteElement && 
+             NPresenceInfo::EOffline != enumField->Value() &&
+             NPresenceInfo::ENotAvailable != enumField->Value() )
+            {
+            DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL note elems found");
+            // consider mapping note text to enum value if value not mapped
+            UserNoteToXIMPL( aPresenceFactory, aNoteElement, aCollection );
+            }
+        }
+    CleanupStack::PopAndDestroy( nodeContent );
+    DP_SDA(" CPresencePluginData::SingleUserStatusToXIMPL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::UserNoteToXIMPL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginData::UserNoteToXIMPL(
+    MPresenceObjectFactory& aPresenceFactory,
+    MSimpleElement* aElement,
+    MPresenceInfoFieldCollection& aCollection )
+    {
+    DP_SDA(" CPresencePluginData::UserNoteToXIMPL IN");
+    HBufC* nodeContent = aElement->ContentUnicodeL();
+    CleanupStack::PushL( nodeContent );
+    if ( nodeContent )
+        {
+        DP_SDA(" CPresencePluginData::UserNoteToXIMPL - content found");
+        // Save note, convert from unicode
+        // notice: consider xml::lang-attribute
+        // note <-> KStatusMessage
+        // notice: no need to consider namespaces in XML?
+        using namespace NPresenceInfo::NFieldType;
+        
+        DP_SDA(" CPresencePluginData::UserNoteToXIMPL - create fields");
+        MPresenceInfoField* field = aPresenceFactory.NewInfoFieldLC();
+        field->SetFieldTypeL( KStatusMessage );
+        MPresenceInfoFieldValueText* text =
+        	aPresenceFactory.NewTextInfoFieldLC();
+        text->SetTextValueL( nodeContent->Des() );
+        field->SetFieldValue( text );
+        CleanupStack::Pop();            // >> text
+        aCollection.AddOrReplaceFieldL( field );
+        CleanupStack::Pop();            // >> field     
+        DP_SDA("  -> fields added to collection");
+        }
+    CleanupStack::PopAndDestroy( nodeContent );
+    DP_SDA(" CPresencePluginData::UserNoteToXIMPL OUT");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::NotifyListToPrInfoL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginData::NotifyListToPrInfoL(
+    MXIMPObjectFactory& aFactory,
+    MPresenceObjectFactory& aPresenceFactory,
+    MSimplePresenceList& aList,
+    RPointerArray<MPresenceInfo>& aEntities,
+    RPointerArray<MXIMPIdentity>& aActives,
+    RPointerArray<MXIMPIdentity>& aTerminated )
+    {
+    DP_SDA(" CPresencePluginData::NotifyListToPrInfoL");
+    // Split array into individual prInfos
+
+    aEntities.Reset();
+    RPointerArray<MSimpleDocument> docs;
+    CleanupClosePushL( docs );
+    // get documents, ownership is not transferred.
+    aList.GetDocuments( docs );
+
+    TInt count = docs.Count();
+
+    // active presentities
+    for ( TInt i = 0; i < count; i++ )
+        {
+        MPresenceInfo* info =
+            aPresenceFactory.NewPresenceInfoLC();//<< info
+        aEntities.AppendL( info );
+        // aEntities may contain entries even this method leaves
+        CleanupStack::Pop();// >> info
+
+        NotifyToPrInfoL( aFactory, aPresenceFactory, *docs[i], *info );
+        // Add SIp identity to active users list
+        MXIMPIdentity* active = aFactory.NewIdentityLC();// << active
+        aActives.AppendL( active );
+        CleanupStack::Pop();// >> active
+
+        // Convert SIP entity URI from UTF to Unicode.
+        const TDesC8* pUri8 = (docs[i])->EntityURI();
+        HBufC16* uri16 = NULL;
+        uri16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *pUri8 );
+        CleanupStack::PushL( uri16 );  // << uri16
+        active->SetIdentityL( uri16->Des() );
+        CleanupStack::PopAndDestroy( uri16 );// >> uri16
+        }
+
+    using namespace NPresencePlugin::NPresence;
+
+    // Search "terminated" presentities
+    MSimpleMeta* meta = aList.MetaData();
+    // ownership in not transferred
+    if ( meta && !meta->LocalName().CompareF( KPresenceList8 ))
+        {
+        // list element found
+        RPointerArray<MSimpleElement> elems2;
+        CleanupClosePushL( elems2 );
+        meta->SimpleElementsL( elems2);
+        TInt count2 = elems2.Count();
+
+        for ( TInt i = 0; i < count2; i++ )
+            {
+            MSimpleElement* elem2 = elems2[i];
+            if ( !elem2->LocalName().CompareF( KPresenceResource8 ))
+                {
+                // resource element
+                RPointerArray<MSimpleElement> elems3;
+                CleanupClosePushL( elems3 );
+                meta->SimpleElementsL( elems3 );
+                TInt count3 = elems3.Count();
+
+                for ( TInt j=0; j < count3; j++ )
+                    {
+                    MSimpleElement* elem3 = elems3[i];
+
+                    if ( !elem3->LocalName().CompareF( KPresenceInstance8 ))
+                        {
+                        // instance element
+                        const TDesC8* stateVal =
+                            elem3->AttrValue( KPresenceState8 );
+                        if ( stateVal && stateVal->
+                            CompareF( KPresenceTerminated8 ))
+                            {
+                            // get next entity if this is not state="terminated"
+                            break;
+                            }
+                        // Save resource element URI into list of
+                        // "terminated" users.
+                        const TDesC8* uri8 = elem2->AttrValue( KPresenceUri8 );
+                        MXIMPIdentity* terminated =
+                            aFactory.NewIdentityLC();// << terminated
+                        aTerminated.AppendL( terminated );
+                        CleanupStack::Pop();                   // >> terminated
+
+                        // Convert SIP entity URI from UTF to Unicode.
+                        HBufC16* uri16 = NULL;
+                        uri16 =
+                            CnvUtfConverter::ConvertToUnicodeFromUtf8L( *uri8 );
+                        CleanupStack::PushL( uri16 );  // << uri16
+                        terminated->SetIdentityL( uri16->Des() );
+                        CleanupStack::PopAndDestroy( uri16 );  // >> uri16
+                        }
+                    }
+                CleanupStack::PopAndDestroy( &elems3 );
+                } // resource element
+            }// for (i); list element subelement
+        CleanupStack::PopAndDestroy( &elems2 );
+        }
+
+    CleanupStack::PopAndDestroy( &docs );
+    DP_SDA(" CPresencePluginData::NotifyListToPrInfoL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::AddPrPersToSimpleDocumentL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginData::AddPrPersToSimpleDocumentL(
+    const MPersonPresenceInfo* aInfo,
+    MSimpleDocument& aDocument,
+    const TDesC8& aSipId, TInt aTupleId )
+    {
+    DP_SDA("CPresencePluginData::AddPrPersToSimpleDocumentL start");
+    iNumBuf = aTupleId;
+    // notice: later: generate random id.
+
+    using namespace NPresencePlugin::NPresence;
+    using namespace NPresenceInfo::NFieldType;
+
+    const MPresenceInfoFieldCollection& coll = aInfo->Fields();
+
+    const MPresenceInfoField* statusEmumField = NULL;
+    const MPresenceInfoField* messageField = NULL;
+
+    TInt myCount = coll.FieldCount();
+    for ( TInt i = 0; i < myCount; i++ )
+        {
+        DP_SDA("CPresencePluginData::AddPrPersToSimpleDocumentL 1");
+        
+        const MPresenceInfoField& field =  coll.FieldAt( i );
+        const TDesC8& fieldType = field.FieldType();
+        TBuf<KBufSize100> printBuf;
+        printBuf.Copy( fieldType );
+   
+        if ( !fieldType.Compare( KAvatar ) )
+           {
+           // Do nothing in sawfis, maybe later?
+           }
+        else if ( !fieldType.Compare( KAvailabilityEnum ) )
+            {
+            DP_SDA("AddPrPersToSimpleDocumentL Avaibility");
+            statusEmumField = &field;
+            DP_SDA("AddPrPersToSimpleDocumentL Avaibility done");
+            }          
+        else if ( !fieldType.Compare( KStatusMessage ) )
+            {
+            DP_SDA("AddPrPersToSimpleDocumentL statusmessage");
+            messageField = &field;
+            }
+        }
+    if ( statusEmumField )
+        {
+        DoCreateDocumentL( aDocument, aSipId, 
+            statusEmumField, messageField );            
+        }
+    
+        
+    DP_SDA("CPresencePluginData::AddPrPersToSimpleDocumentL end");
+    }
+    
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginData::CreatePresenceUri8LC
+// ---------------------------------------------------------------------------
+//
+HBufC8* CPresencePluginData::CreatePresenceUri8LC( 
+    const TDesC8& aPresentityUri )
+    {
+    DP_SDA("CPresencePluginData::CreatePresenceUri8LC ");
+    const TInt KMyLenSipPrefix = 4;
+    const TInt KMyLenSipsPrefix = 5;
+    _LIT8( KMySip8, "sip:" );
+    _LIT8( KMySips8, "sips:" ); 
+    TInt uriLen = aPresentityUri.Length();
+    DP_SDA2( "CPresencePluginData::CreatePresenceUri8LC - param length: %d ", uriLen );
+    
+    //For debugging purposes
+    //TBuf<256> tmpPresentityUri; 
+    //tmpPresentityUri.Copy( aPresentityUri );
+    //DP_SDA2( "CPresencePluginData::CreatePresenceUri8LC - URI: %S ", &tmpPresentityUri );
+    
+    HBufC8* buf = HBufC8::NewLC( uriLen );
+    TPtr8 pBuf( buf->Des() );
+    
+    //SIP uri check
+    if ( !aPresentityUri.Left( KMyLenSipPrefix ).CompareF( KMySip8 ) )
+        {
+        DP_SDA("CPresencePluginData::CreatePresenceUri8LC (sip:) prefix in SIP URI ");
+        pBuf.Append( aPresentityUri );
+        }
+    else if ( !aPresentityUri.Left( KMyLenSipsPrefix ).CompareF( KMySips8 ) )
+        {
+        DP_SDA( "CPresencePluginData::CreatePresenceUri8LC (sips:) prefix in SIP URI " );
+        pBuf.Append( aPresentityUri );
+        }
+    else // No prefix, strange ...
+        {
+        DP_SDA( "CPresencePluginData::CreatePresenceUri8LC NO prefix in SIP URI, adding... " );
+        // Maybe should check which prefix to use,
+        // but assume that no secure is used if prefix missing
+        TInt len = aPresentityUri.Length() + KMyLenSipPrefix;
+        buf = buf->ReAllocL( len );
+        //update pointer after realloc
+        CleanupStack::Pop( 1 );
+        CleanupStack::PushL( buf );
+        // Since realloc may have changed the location in memory
+        // we must also reset ptr
+        pBuf.Set( buf->Des() );
+        pBuf.Append( KMySip8 );
+        pBuf.Append( aPresentityUri );
+        }   
+    return buf; 
+    } 
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginData::RemovePrefixLC
+// ---------------------------------------------------------------------------
+//
+HBufC16* CPresencePluginData::RemovePrefixLC( 
+    const TDesC& aPresentityUri )
+    {
+    DP_SDA2("CPresencePluginData::RemovePrefixLC, uri: %S", &aPresentityUri );
+
+    HBufC* withouPrefix = HBufC::NewLC( KBufSize255 );
+    TPtr withouPrefixPtr( withouPrefix->Des() );
+    
+    TInt prefixLocation = aPresentityUri.Locate( ':' );
+    DP_SDA2("CPresencePluginData::RemovePrefixLC, prefix pos: %d", prefixLocation );
+    if ( KErrNotFound != prefixLocation )
+        {
+        DP_SDA("CPresencePluginData::RemovePrefixLC - has prefix");        
+        withouPrefixPtr.Copy( aPresentityUri.Mid( prefixLocation+1 ) );
+        DP_SDA("CPresencePluginData::RemovePrefixLC - copy ok");        
+        }
+    else
+        {
+        DP_SDA("CPresencePluginData::RemovePrefixLC - has no prefix");        
+        withouPrefixPtr.Copy( aPresentityUri );
+        }    
+        
+    //DP_SDA2("CPresencePluginData::RemovePrefixLC - returns %S", *withouPrefix );            
+    return withouPrefix;
+    }     
+       
+// ---------------------------------------------------------------------------
+// CPresencePluginData::DoCreateDocumentL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginData::DoCreateDocumentL( 
+    MSimpleDocument& aDocument,
+    const TDesC8& aSipId,
+    const MPresenceInfoField* aStatusField,
+    const MPresenceInfoField* aMessageField )
+    {    
+    DP_SDA("CPresencePluginData::DoCreateDocumentL ");
+    const TInt KNumBuf = 20;
+    const TInt KTupleBuf = 10;
+    
+    using namespace NPresencePlugin::NPresence;
+    using namespace NPresencePlugin::NPresenceStates;
+    using namespace NPresenceInfo::NFieldType;
+
+    TBuf<KNumBuf> numBuf;
+    TBuf<KTupleBuf> tupleBuf;
+
+    tupleBuf.Copy( KIndent );
+    numBuf.Num( iNumBuf );
+    tupleBuf.Append( numBuf );
+    DP_SDA2("CPresencePluginData::DoCreateDocumentL id %d", iNumBuf);
+	DP_SDA("CPresencePluginData::DoCreateDocumentL 2");
+    
+	//Add tuple id to document
+    MSimpleElement* tuple = aDocument.AddSimpleElementL( KPresenceTuple8 );
+    CleanupClosePushL( *tuple );
+    tuple->AddAttrL( KPresenceId8, tupleBuf);
+    
+    //Presence status field
+    MSimpleElement* status = tuple->AddSimpleElementL( KPresenceStatus8 );
+    CleanupClosePushL( *status );
+    
+    //basic field
+    MSimpleElement* basic = status->AddSimpleElementL( KPresenceBasic8 );
+    CleanupClosePushL( *basic );
+    
+    basic->SetContentUnicodeL( DoCheckBasicStatusValueL( *aStatusField ) );
+    
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Basic ok, check msg"); 
+    
+    if ( aMessageField )
+        {
+        DP_SDA("CPresencePluginData::DoCreateDocumentL message field"); 
+        //Creating note 
+        MSimpleElement* note =
+            aDocument.AddSimpleElementL( KPresenceNote8 );
+        CleanupClosePushL( *note );        
+        
+        // Get status msg field from info field
+        const MPresenceInfoFieldValueText* textField = 
+            TXIMPGetInterface< 
+                const MPresenceInfoFieldValueText >::From(
+                aMessageField->FieldValue(), 
+                    MXIMPBase::EPanicIfUnknown );
+        note->SetContentUnicodeL( textField->TextValue() );
+        CleanupStack::PopAndDestroy( note );
+        }
+
+    /* Basic model example
+    <tuple id="c8dqui">
+          <status>
+            <basic>open</basic>
+          </status>
+             <ts:basic>closed</ts:basic>
+          </ts:timed-status>
+          <contact>sip:someone@example.com</contact>
+        </tuple>
+    <note>sleeping</note>    
+    </presence>
+    */
+    
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Rich presence person");
+    //Creatin person presence field
+    MSimpleElement* pers =
+    	aDocument.AddSimpleElementL( KSimpleNsPDM, KPresencePerson8 );
+    CleanupClosePushL( *pers );
+    TBuf<KBufSize10> buf;
+    TBuf<KBufSize20> personId;
+    personId.Copy( KPersonId );
+    buf.Num( iNumBuf );
+    personId.Append( buf );
+    pers->AddAttrL( KPresenceId8, personId );
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Rich presence person ok");
+    
+    HBufC8* urlBuf = CreatePresenceUri8LC( aSipId );
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Push urlBuf"); 
+      
+    aDocument.SetEntityURIL( urlBuf->Des() );
+    DP_SDA("CPresencePluginData::DoCreateDocumentL 2");
+
+    DP_SDA("CPresencePluginData::DoCreateDocumentLC Rich presence activities");
+    MSimpleElement* activ = pers->AddSimpleElementL( 
+        KSimpleNsRPID, KPresenceActivities8 );
+    CleanupClosePushL( *activ );
+    
+    //unknown used if person presence is just open or closed
+    MSimpleElement* unknown = activ->AddSimpleElementL( 
+        KSimpleNsRPID, DoCheckActivitiesValueL( *aStatusField ) );
+    DP_SDA("CPresencePluginData::DoCreateDocumentL, unknown/status element created");  
+    CleanupClosePushL( *unknown );
+   
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Destroy unknown");  
+    CleanupStack::PopAndDestroy( unknown );
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Destroy activ");  
+    CleanupStack::PopAndDestroy( activ ); 
+    
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Destroy urlBuf");
+    CleanupStack::PopAndDestroy( urlBuf );
+
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Destroy pers");  
+    CleanupStack::PopAndDestroy( pers );    
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Rich presence activities ok");
+
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Destroy basic");
+    CleanupStack::PopAndDestroy( basic );
+    
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Destroy status");
+    CleanupStack::PopAndDestroy( status );
+    
+    DP_SDA("CPresencePluginData::DoCreateDocumentL Destroy tuple");
+    CleanupStack::PopAndDestroy( tuple );   
+    DP_SDA("CPresencePluginData::DoCreateDocumentL end");    
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::DoCheckBasicStatusValueL()
+// ---------------------------------------------------------------------------
+//
+TPtrC CPresencePluginData::DoCheckBasicStatusValueL(
+	const MPresenceInfoField& aField )
+	{
+    using namespace NPresencePlugin::NPresence;
+    using namespace NPresencePlugin::NPresenceStates;
+    using namespace NPresenceInfo::NFieldType;
+    
+	TPtrC basicStatus( KPresenceOpen ); //default status open
+	//First check what is person status value
+	const MXIMPBase& storage = aField.FieldValue();
+    const MPresenceInfoFieldValueEnum* enumObject =
+          TXIMPGetInterface< const MPresenceInfoFieldValueEnum >::
+          From( storage,MXIMPBase::EReturnNullIfUnknown );
+    
+    __ASSERT_ALWAYS( NULL != enumObject, User::Leave( KErrArgument ) );
+
+    DP_SDA2(" DoCheckBasicStatusValueL - enumValue: %d", enumObject->Value() );
+    switch ( enumObject->Value() )
+        {
+        case NPresenceInfo::EAvailable:
+            {
+			DP_SDA("DoCheckBasicStatusValueL stopPublish false status open");
+			iConnObs.SetStopPublishState( EFalse );
+			basicStatus.Set( KPresenceOpen );
+            }
+            break;
+            
+        case NPresenceInfo::EOffline:
+        case NPresenceInfo::EHidden:
+        case NPresenceInfo::ENotAvailable:
+            {
+			//If state is closed we can stop publish
+			//if client is going to offline
+			DP_SDA("DoCheckBasicStatusValueL stopPublish true status Closed");
+			iConnObs.SetStopPublishState( ETrue );
+			basicStatus.Set( KPresenceClosed );                
+            }
+            break;                
+            
+        default:
+            {
+			DP_SDA("DoCheckBasicStatusValueL stopPublish false else open");
+			iConnObs.SetStopPublishState( EFalse );
+			basicStatus.Set( KPresenceOpen );                
+            }
+            break;    
+        }
+    return basicStatus;
+	}
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::DoCheckActivitiesValueL()
+// ---------------------------------------------------------------------------
+//
+TPtrC8 CPresencePluginData::DoCheckActivitiesValueL(
+	const MPresenceInfoField& aField )
+	{
+	using namespace NPresencePlugin::NPresence;
+    using namespace NPresencePlugin::NPresenceStates;
+    using namespace NPresenceInfo::NFieldType;
+    
+	TPtrC8 activities( KPresenceUnknow8 ); //default activities unknown
+	
+	const MXIMPBase& storage = aField.FieldValue();
+    const MPresenceInfoFieldValueEnum* enumObject =
+          TXIMPGetInterface< const MPresenceInfoFieldValueEnum >::
+          From( storage,MXIMPBase::EReturnNullIfUnknown );
+    
+    __ASSERT_ALWAYS( NULL != enumObject, User::Leave( KErrArgument ) );
+
+    DP_SDA2(" DoCheckActivitiesValueL - enumValue: %d", enumObject->Value() );
+    switch ( enumObject->Value() )
+        {
+        case NPresenceInfo::EAvailable:
+            {
+            DP_SDA("DoCheckActivitiesValueL - available, set publish");
+    		iConnObs.SetStopPublishState( EFalse );
+    		DP_SDA("DoCheckActivitiesValueL - available, set value");
+    		activities.Set( KPresenceUnknow8 );
+    		DP_SDA("DoCheckActivitiesValueL - available, ok");
+            }
+            break;
+            
+        case NPresenceInfo::EOffline:
+        case NPresenceInfo::ENotAvailable:
+            {
+            DP_SDA("DoCheckActivitiesValueL - offline/not available");
+    		iConnObs.SetStopPublishState( ETrue );
+    		activities.Set( KPresenceUnknow8 );
+            }
+            break;                
+            
+        case NPresenceInfo::EBusy:
+            {
+            DP_SDA("DoCheckActivitiesValueL - busy");
+    		iConnObs.SetStopPublishState( EFalse );
+    		activities.Set( KPresenceBusy8 );
+            }
+            break;
+            
+        case NPresenceInfo::EExtAway:
+        case NPresenceInfo::EAway:
+            {
+            DP_SDA("DoCheckActivitiesValueL - away");
+    		iConnObs.SetStopPublishState( EFalse );
+    		activities.Set( KPresenceAway8 );
+            }
+            break;
+            
+        case NPresenceInfo::EOnPhone:
+            {
+            DP_SDA("DoCheckActivitiesValueL - on phone");
+    		iConnObs.SetStopPublishState( EFalse );
+    		activities.Set( KPresenceOnThePhone8 );
+            }
+            break;
+
+        
+        case NPresenceInfo::EDoNotDisturb:
+            {
+            DP_SDA("DoCheckActivitiesValueL - dnd");
+    		iConnObs.SetStopPublishState( EFalse );
+    		activities.Set( KPresenceDoNotDisturb8 );
+            }
+            break;
+            
+        default:
+            {
+			DP_SDA("DoCheckActivitiesValueL default => unknown");
+    		iConnObs.SetStopPublishState( EFalse );
+    		activities.Set( KPresenceUnknow8  );
+            }
+            break;    
+        }
+    DP_SDA("DoCheckActivitiesValueL - done and return");        
+    return activities;
+	}
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::DoCheckNoteValueL()
+// ---------------------------------------------------------------------------
+//
+TPtrC CPresencePluginData::DoCheckNoteValueL(
+    const MPresenceInfoField& aField )
+    {
+    using namespace NPresencePlugin::NPresence;
+    using namespace NPresencePlugin::NPresenceStates;
+    using namespace NPresenceInfo::NFieldType;
+    
+    TPtrC note( KPresenceUnknow ); //default activities unknown
+    //First check what is person status value
+    const MXIMPBase& storage = aField.FieldValue();
+    const MPresenceInfoFieldValueText* text =
+          TXIMPGetInterface< const MPresenceInfoFieldValueText >::
+          From( storage,MXIMPBase::EReturnNullIfUnknown );
+    
+    __ASSERT_ALWAYS( NULL != text, User::Leave( KErrArgument ) );
+
+    TBuf<KBufSize200> buffer;
+    buffer.Copy( text->TextValue() );
+
+    //Check if status is closed
+    if( !buffer.CompareF( KPresenceClosed ) )
+        {
+        //If state is closed we can stop publish 
+        //if client is going to offline
+        DP_SDA("DoCheckNoteValueL stopPublish true closed");
+        iConnObs.SetStopPublishState( ETrue );
+        note.Set( KPresenceOffline );       
+        }
+    else if( !buffer.CompareF( KPresenceOpen ) )
+        {
+        DP_SDA("DoCheckNoteValueL stopPublish false open");
+        iConnObs.SetStopPublishState( EFalse );
+        note.Set( KPresenceAvailable );
+        }
+    else if( !buffer.CompareF( KPresenceBusy ) )
+        {
+        DP_SDA("DoCheckNoteValueL activities BUSY");
+        iConnObs.SetStopPublishState( EFalse );
+        note.Set( KPresenceBusy );
+        }
+    else if( !buffer.CompareF( KPresenceOnThePhone ) )
+        {
+        DP_SDA("DoCheckNoteValueL activities OnThePhone");
+        iConnObs.SetStopPublishState( EFalse );
+        note.Set( KPresenceOnThePhone );
+        }
+    else if( !buffer.CompareF( KPresenceAway ) )
+        {
+        DP_SDA("DoCheckNoteValueL activities OnThePhone");
+        iConnObs.SetStopPublishState( EFalse );
+        note.Set( KPresenceAway );
+        }
+    else
+        {
+        DP_SDA("DoCheckNoteValueL stopPublish false");
+        iConnObs.SetStopPublishState( EFalse );
+        note.Set( KPresenceUnknow  );
+        }
+    return note;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::GenerateTupleId()
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginData::GenerateTupleId()
+    {
+    // Generate unique session tuple id
+    DP_SDA("CPresencePluginData::GenerateTupleId start");
+    const TInt KMaxRand = KMaxNumber;
+    TInt64 seed;
+    TTime time;
+    time.HomeTime();
+    seed = time.Int64();
+    TInt random = Math::Rand( seed ) % KMaxRand;
+    DP_SDA("CPresencePluginData::GenerateTupleId 1");
+    return random; 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::ServiceId()
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginData::ServiceId()
+    {
+    return iServiceId;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::ServiceNameLC()
+// ---------------------------------------------------------------------------
+//
+HBufC* CPresencePluginData::ServiceNameLC( TInt aServiceId ) const
+    {
+    CSPSettings* spSettings = CSPSettings::NewLC();
+    CSPEntry* entry = CSPEntry::NewLC();
+    HBufC* serviceName = NULL;
+    
+    User::LeaveIfError( spSettings->FindEntryL( aServiceId, *entry ) );
+    
+    serviceName = entry->GetServiceName().AllocL();
+    
+    CleanupStack::PopAndDestroy( entry );
+    CleanupStack::PopAndDestroy( spSettings );
+    CleanupStack::PushL( serviceName );
+    return serviceName;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::ResolveCacheXspIdentifierL()
+// ---------------------------------------------------------------------------
+//
+HBufC* CPresencePluginData::ResolveCacheXspIdentifierL(
+    const TDesC& aIdentity ) const
+    {
+    DP_SDA( "CPresencePluginData::ResolveCacheXspIdentifierL" ); 
+    
+    CSPSettings* spSettings = CSPSettings::NewLC();
+    CSPEntry* entry = CSPEntry::NewLC();
+    
+    User::LeaveIfError( spSettings->FindEntryL( iServiceId, *entry ) );
+
+    TInt cacheUriLength = ( entry->GetServiceName().Length() + 
+            aIdentity.Length() + 1 );
+    
+    HBufC* cacheUri = HBufC::NewL( cacheUriLength );
+    TPtr cacheUriPtr( cacheUri->Des() );
+    
+    cacheUriPtr.Append( entry->GetServiceName() );
+    cacheUriPtr.Append( ':' );
+    cacheUriPtr.Append( aIdentity );
+    
+    CleanupStack::PopAndDestroy( entry );
+    CleanupStack::PopAndDestroy( spSettings );
+    
+    DP_SDA2( "CPresencePluginData::ResolveCacheXspIdentifierL returns: %S", cacheUri );
+    return cacheUri;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::WriteBlockItemsToCacheL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginData::WriteStatusToCacheL(
+    const TDesC& aPresentityId, 
+    MPresenceBuddyInfo2::TAvailabilityValues aAvailability,
+    const TDesC& aAvailabilityText,
+    const TDesC& aStatusMessage )
+    {
+    DP_SDA( "CPresencePluginData::WriteStatusToCacheL start" );
+    DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, aStatus: %d", 
+        aAvailability );
+    DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, availabilityText: %S", 
+        &aAvailabilityText );
+    DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, statusMessage: %S", 
+        &aStatusMessage );
+
+    TBool updateCache( ETrue );
+    
+    // Decode encoded username (spaces to %20).
+    HBufC* decodedUsername = EscapeUtils::EscapeDecodeL( aPresentityId );
+    CleanupStack::PushL( decodedUsername );
+    
+    // convert to 8 bit version
+    HBufC8* tmp = HBufC8::NewLC( decodedUsername->Length() );
+    tmp->Des().Copy( *decodedUsername );
+    
+    // convert to unicode
+    HBufC* userName16 =
+            EscapeUtils::ConvertToUnicodeFromUtf8L( tmp->Des() );
+    
+    HBufC* cacheUri = ResolveCacheXspIdentifierL( userName16->Des() );
+    CleanupStack::PopAndDestroy( tmp );
+    CleanupStack::PopAndDestroy( decodedUsername );
+    delete userName16;
+    CleanupStack::PushL( cacheUri );
+    
+    DP_SDA(" -> WriteStatusToCacheL - read previous values from cache"); 
+    
+    // Read previous values from cache
+    MPresenceBuddyInfo2* previousPresInfo = 
+        iPresenceCacheReader->PresenceInfoLC( *cacheUri );
+    
+    if ( previousPresInfo )
+        {
+        DP_SDA(" -> WriteStatusToCacheL - get availability value"); 
+        
+        MPresenceBuddyInfo2::TAvailabilityValues availability = 
+            previousPresInfo->Availability();
+        
+        DP_SDA(" -> WriteStatusToCacheL - get availability text"); 
+        
+        TPtrC availabilityText = previousPresInfo->AvailabilityText();
+        
+        DP_SDA(" -> WriteStatusToCacheL - get status message"); 
+        
+        TPtrC statusMessage = previousPresInfo->StatusMessage();
+        CleanupStack::PopAndDestroy(); //previousPresInfo 
+        
+        DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, OLD STATUS: %d", 
+                availability );
+        DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, OLD AVAILABILITY TEXT: %S", 
+            &availabilityText );
+        DP_SDA2( "CPresencePluginData::WriteStatusToCacheL, OLD STATUS MESSAGE: %S", 
+            &statusMessage );
+        
+        if ( ( aAvailability == availability ) && 
+            ( aAvailabilityText.Compare( availabilityText ) == 0 ) &&
+            ( aStatusMessage.Compare( statusMessage ) == 0 ))
+            {
+            DP_SDA(" -> WriteStatusToCacheL - no need to update cache");    
+            updateCache = EFalse;
+            } 
+        }
+        
+    if ( updateCache )
+        {
+        MPresenceBuddyInfo2* newPresInfo = MPresenceBuddyInfo2::NewLC();
+        newPresInfo->SetIdentityL( *cacheUri );
+        
+        DP_SDA(" -> WriteStatusToCacheL - update cache");
+        
+        TBuf<KBufSize20> buf;
+        TBool handled = EFalse;
+           
+        buf.Copy( KBlockedExtensionValue );
+          
+        if( aAvailabilityText.Compare( buf ) == 0 )
+            {
+            DP_SDA( " -> WriteStatusToCacheL - set Blocked" );
+            newPresInfo->SetAnyFieldL( KExtensionKey, KBlockedExtensionValue );
+            handled = ETrue;
+            }
+           
+        buf.Copy( KPendingRequestExtensionValue );
+           
+        if ( aAvailabilityText.Compare( buf ) == 0 )
+            {
+            DP_SDA( " -> WriteStatusToCacheL - set Pending request" );
+            newPresInfo->SetAnyFieldL( KExtensionKey, KPendingRequestExtensionValue );
+            handled = ETrue;
+            }
+           
+        if ( !handled )
+            {
+            DP_SDA2( " -> WriteStatusToCacheL - set availability text: %S", &aAvailabilityText );
+            newPresInfo->SetAvailabilityL( aAvailability, aAvailabilityText );
+            }
+           
+        if ( aStatusMessage.Length() )
+            {
+            DP_SDA2( " -> WriteStatusToCacheL - set status message: %S", &aStatusMessage ); 
+            newPresInfo->SetStatusMessageL( aStatusMessage );
+            }
+
+        DP_SDA( " -> WriteStatusToCacheL - write presence to cache" );    
+        TInt cacheError = iPresenceCacheWriter->WritePresenceL( newPresInfo );
+        DP_SDA2( "CPresencePluginEntityWatcher::WriteStatusToCacheL error: %d", 
+            cacheError );
+           
+        DP_SDA( " -> destroy buddy info" );    
+        CleanupStack::PopAndDestroy(); // newPresInfo            
+        }
+    
+    DP_SDA(" -> destroy uri");    
+    CleanupStack::PopAndDestroy( cacheUri );
+
+    DP_SDA("CPresencePluginData::WriteStatusToCacheL end");
+    }     
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginData::RemoveCacheL()
+// ---------------------------------------------------------------------------
+//      
+void CPresencePluginData::RemoveCacheL()
+    {
+    DP_SDA("CPresencePluginData::RemoveCacheL");
+    
+    // Resolve service name (cache xsp identifier)
+    CSPSettings* spSettings = CSPSettings::NewL();
+    CleanupStack::PushL( spSettings );
+    
+    CSPEntry* entry = CSPEntry::NewLC();
+    DP_SDA2(" -> RemoveCacheL look for service: %d", ServiceId() );
+    spSettings->FindEntryL( ServiceId(), *entry );
+
+    DP_SDA(" -> RemoveCacheL cache xsp identifier found");
+    TInt cacheUriLength = entry->GetServiceName().Length();
+    DP_SDA2(" -> cache uri length: %d", cacheUriLength );    
+    
+    HBufC* cacheUri = HBufC::NewLC( cacheUriLength );
+    TPtr cacheUriPtr( cacheUri->Des() );
+    
+    DP_SDA(" -> RemoveCacheL - form cache entry");
+    cacheUriPtr.Append( entry->GetServiceName() );
+    
+    DP_SDA(" -> RemoveCacheL - delete cache entries");
+    TInt error = iPresenceCacheWriter->DeleteService( cacheUriPtr );
+    DP_SDA2(" -> RemoveCacheL - delete error: %d", error );
+    CleanupStack::PopAndDestroy( cacheUri );
+
+    DP_SDA(" -> destroy sp entry");        
+    CleanupStack::PopAndDestroy( entry );        
+    DP_SDA(" -> destroy sp");        
+    CleanupStack::PopAndDestroy( spSettings );
+    DP_SDA("CPresencePluginData::RemoveCacheL out");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginData::DeletePresenceL()
+// ---------------------------------------------------------------------------
+//      
+void CPresencePluginData::DeletePresenceL( const TDesC& aIdentity )
+    {
+    DP_SDA("CPresencePluginData::DeletePresenceL");
+    
+    // Resolve service name (cache xsp identifier)
+    CSPSettings* spSettings = CSPSettings::NewL();
+    CleanupStack::PushL( spSettings );
+    CSPEntry* entry = CSPEntry::NewLC();
+    DP_SDA2(" -> DeletePresenceL look for service: %d", ServiceId() );
+    spSettings->FindEntryL( ServiceId(), *entry );
+
+    DP_SDA(" -> DeletePresenceL cache xsp identifier found");
+    TInt cacheUriLength = ( entry->GetServiceName().Length() + 
+        aIdentity.Length() + 1 );
+    DP_SDA2(" -> cache uri length: %d", cacheUriLength );    
+    
+    HBufC* cacheUri = HBufC::NewLC( cacheUriLength );
+    TPtr cacheUriPtr( cacheUri->Des() );
+    
+    DP_SDA(" -> DeletePresenceL - form cache entry");
+    cacheUriPtr.Append( entry->GetServiceName() );
+    cacheUriPtr.Append( ':' );
+    cacheUriPtr.Append( aIdentity );
+
+    iPresenceCacheWriter->DeletePresenceL( cacheUriPtr );
+    
+    CleanupStack::PopAndDestroy( cacheUri ); 
+    CleanupStack::PopAndDestroy( entry ); 
+    DP_SDA(" -> destroy sp");        
+    CleanupStack::PopAndDestroy( spSettings );
+    DP_SDA("CPresencePluginData::DeletePresenceL out");
+    }    
+
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginData::StorePresenceOwnPresenceL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginData::StorePresenceOwnPresenceL(
+    const TUint aServiceId, 
+    NPresenceInfo::TAvailabilityValues aAvailability,
+    const TDesC& aStatusMessage )
+    {  
+    DP_SDA("CPresencePluginData::StorePresenceOwnPresenceL IN");
+    DP_SDA2(" -> aServiceId: %d", aServiceId );
+        
+    DP_SDA2(" -> SAVE AVAILABILITY VALUE: %d", aAvailability );
+    DP_SDA2(" -> SAVE STATUS MESSAGE: %S", &aStatusMessage );
+        
+    MVIMPSTSettingsStore* settings = CVIMPSTSettingsStore::NewLC();
+    
+    DP_SDA("CPresencePluginData::StorePresenceOwnPresenceL 1");
+    
+    // Store availability value to uiservicetabsettings
+    TInt availabilityInt = ( ( TInt ) aAvailability );
+    User::LeaveIfError( settings->SetL( 
+        aServiceId, EServicePresenceAvailablilityValue, availabilityInt ) );
+    
+    DP_SDA("CPresencePluginData::StorePresenceOwnPresenceL 2");
+    
+    // Store custom status message to uiservicetabsettings
+    User::LeaveIfError( settings->SetL( 
+        aServiceId, EServiceCustomStatusMessage, aStatusMessage ) );
+    
+    CleanupStack::PopAndDestroy(); //settings
+    
+    DP_SDA("CPresencePluginData::StorePresenceOwnPresenceL OUT");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginData::ReadDocumentIdL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginData::ReadDocumentIdL(
+    const TInt aServiceId, 
+    TDes8& aDocumentId )
+    {  
+    DP_SDA("CPresencePluginData::ReadDocumentIdL IN");
+        
+    DP_SDA2(" -> aServiceId: %d", aServiceId );
+    
+    MVIMPSTSettingsStore* settings = CVIMPSTSettingsStore::NewLC();
+    
+    RBuf8 documentId;
+    CleanupClosePushL( documentId );
+    documentId.CreateL( KBufSize255 );
+    
+    TInt error = settings->GetL( 
+        aServiceId, EServicePresenceSessionIdentifier, documentId );
+    
+    DP_SDA2(" -> ERROR: %d", error );
+    DP_SDA2(" -> DOCUMENT ID LENGTH: %d", documentId.Length() );
+        
+    if ( !error && documentId.Length() )
+        {
+        aDocumentId.Copy( documentId );
+        
+        TBuf<KBufSize255> printDocumentId;
+        printDocumentId.Copy( aDocumentId );
+        DP_SDA("CPresencePluginData::ReadDocumentIdL - 1");
+        DP_SDA2(" -> READ DOCUMENT ID: %S", &printDocumentId );
+        }
+    else if ( KErrNotFound == error || !documentId.Length() )
+        {
+        DP_SDA("CPresencePluginData::ReadDocumentIdL - 2");
+        // If document id lenght is zero (KNullDesC8) or error
+        // is KErrNotFound leave with KErrNotFound
+        User::Leave( KErrNotFound );
+        }
+    else
+        {
+        User::Leave( error );
+        }
+    
+    CleanupStack::PopAndDestroy( &documentId );
+    CleanupStack::PopAndDestroy(); //settings
+    
+    DP_SDA("CPresencePluginData::ReadDocumentIdL OUT");
+    }   
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginData::DeletePresenceVariablesL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginData::DeletePresenceVariablesL( const TInt aServiceId )
+    {  
+    DP_SDA("CPresencePluginData::DeletePresenceVariablesL IN");
+    DP_SDA2(" -> aServiceId: %d", aServiceId );
+        
+    MVIMPSTSettingsStore* settings = CVIMPSTSettingsStore::NewLC();
+    
+    // Reset availability value in uiservicetabsettings
+    User::LeaveIfError( settings->SetL( 
+        aServiceId, EServicePresenceAvailablilityValue, KErrNotFound ) );
+       
+    // Reset status message in uiservicetabsettings
+    User::LeaveIfError( settings->SetL( 
+        aServiceId, EServiceCustomStatusMessage, KNullDesC ) );
+    
+    // Reset document id value in uiservicetabsettings
+    User::LeaveIfError( settings->SetL( 
+        aServiceId, EServicePresenceSessionIdentifier, KNullDesC8 ) );
+    
+    CleanupStack::PopAndDestroy(); // settings
+    
+    DP_SDA("CPresencePluginData::DeletePresenceVariablesL OUT");
+    }   
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::ResolveNoteElementL
+// Returns <note> element corresponding current locale or first <note> 
+// element if better match is not found.
+// ---------------------------------------------------------------------------
+//
+MSimpleElement* CPresencePluginData::ResolveNoteElementL( 
+        const RPointerArray<MSimpleElement>& aElements ) const
+    {
+    DP_SDA("CPresencePluginData::ResolveNoteElementL" )
+    
+    MSimpleElement* bestMatch = NULL;
+    MSimpleElement* secondBestMatch = NULL;
+    
+    for ( TInt i = aElements.Count() - 1; i >= 0 && NULL == bestMatch; i-- )
+        {
+        MSimpleElement* element = aElements[i];
+        
+        using namespace NPresencePlugin::NPresence;
+        if ( 0 == element->LocalName().CompareF( KPresenceNote8 ) )
+            {
+            if ( IsElementLanguageValidForCurrentLocaleL( *element ) )
+                {
+                DP_SDA("CPresencePluginData::ResolveNoteElementL, BEST MATCH.")
+                bestMatch = element;
+                }
+            else
+                {
+                secondBestMatch = element;
+                }
+            }
+        }
+    
+    return ( bestMatch ? bestMatch : secondBestMatch );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginData::IsElementLanguageValidForCurrentLocaleL
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginData::IsElementLanguageValidForCurrentLocaleL( 
+        MSimpleElement& aElement ) const
+    {
+    DP_SDA( "CPresencePluginData::IsElementLanguageValidForCurrentLocaleL" )
+    
+    TBool isLanguageResolved = EFalse;
+    _LIT8( KLanguageAttribute, "xml:lang" );
+    
+    TLanguage language = User::Language();
+    RPointerArray<MSimpleAttribute> attributes;
+    CleanupClosePushL( attributes );
+    aElement.SimpleAttributesL( attributes );
+    for ( TInt i = attributes.Count() - 1; i >= 0 && !isLanguageResolved; i-- )
+        {
+        if ( 0 == KLanguageAttribute().CompareF( attributes[i]->Name() ) )
+            {
+            const TDesC8& attributeValue = attributes[i]->Value();
+            for ( TInt index = 0; index < KLanguageCodeMappingsCount; index++ )
+                {
+                if ( language == KLanguageCodeMappings[index].SymbianLanguageCode() &&
+                     0 == attributeValue.CompareF( 
+                         KLanguageCodeMappings[index].IsoLanguageCode() ) )
+                    {
+                    isLanguageResolved = ETrue;
+                    }
+                }
+            }
+        }
+    CleanupStack::Pop( &attributes );
+    
+    return isLanguageResolved;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginentitywatcher.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,689 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+#include <e32std.h>
+#include <e32svr.h>
+#include <utf.h>
+#include <ximpdatasubscriptionstate.h>
+#include <protocolpresencewatchingdatahost.h>
+#include <ximpobjectfactory.h>
+#include <presenceinfo.h>
+#include <ximpprotocolconnectionhost.h>
+#include <protocolpresencedatahost.h>
+#include <presenceobjectfactory.h>
+#include <ximpstatus.h>
+#include <ximpidentity.h>
+#include <simplefactory.h>
+#include <msimplewatcher.h>
+#include <msimpledocument.h>
+#include <msimpleconnection.h>
+#include <simpleerrors.h>
+#include <avabilitytext.h>
+
+#include "presencepluginentitywatcher.h"
+#include "presenceplugindata.h"
+#include "presencepluginwatcher.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::CPresencePluginEntityWatcher()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginEntityWatcher::CPresencePluginEntityWatcher(
+    MPresencePluginConnectionObs& aObs,
+    MSimpleConnection& aConn,
+    CPresencePluginWatcher& aWatcher )
+    :iConnObs(aObs), iConnection(aConn),
+    iPluginWatcher(aWatcher), iOperation( EPluginIdle )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::ConstructL( 
+    CPresencePluginData* aPresenceData )
+    { 
+    DP_SDA("CPresencePluginEntityWatcher::ConstructL - begin");
+    iWatcher = TSimpleFactory::NewWatcherL( iConnection, *this );
+    iPresenceData = aPresenceData; 
+    DP_SDA("CPresencePluginEntityWatcher::ConstructL - end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginEntityWatcher* CPresencePluginEntityWatcher::NewL(
+    MPresencePluginConnectionObs& aObs,
+    MSimpleConnection& aConn,
+    CPresencePluginWatcher& aWatcher,
+    CPresencePluginData* aPresenceData )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::NewL");
+    CPresencePluginEntityWatcher* self =
+        new( ELeave ) CPresencePluginEntityWatcher( aObs, aConn, aWatcher );
+    CleanupStack::PushL( self );
+    self->ConstructL( aPresenceData );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::~CPresencePluginEntityWatcher()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginEntityWatcher::~CPresencePluginEntityWatcher()
+    {
+    DP_SDA("CPresencePluginEntityWatcher::~CPresencePluginEntityWatcher");
+    if ( iWatcher )
+        {
+        iWatcher->Close();
+        }
+    delete iEntityId;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::StartSubscribeL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::StartSubscribeL(
+    const TDesC8& aPresentityId )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL");
+    delete iEntityId; 
+    iEntityId = NULL; 
+    DP_SDA(" StartSubscribeL - entity id deleted");
+    
+    TRAPD( error, iSimpleId = iWatcher->SubscribeL( 
+        aPresentityId, NULL, ETrue, EFalse ););
+    DP_SDA2("StartSubscribeL subscribe error %d",error);
+    
+    if( KErrNone != error )
+        {
+        DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL ERROR");
+        if( KErrInUse == error )
+            {
+            DP_SDA(" iWatcher is in use try to close and restart");
+            iWatcher->Close();
+            iWatcher = TSimpleFactory::NewWatcherL( iConnection, *this );
+            DP_SDA("StartSubscribeL Second try after creating iWatcher again");
+            error = KErrNone;
+            TRAP( error, iSimpleId = iWatcher->GetPresenceL( 
+                aPresentityId, NULL, EFalse ););
+            DP_SDA2("iWatcher->GetPresenceL error2 = %d",error );
+            }
+        }
+    
+    // Save entity id after successful call 
+    DP_SDA("StartSubscribeL - allocate entity id");
+    iEntityId = aPresentityId.AllocL();
+    DP_SDA("StartSubscribeL - new entity id stored");
+    
+    iOperation = EPluginStart;
+    
+    DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL End");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::StartSubscribeL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::StartSubscribeL(
+    const TDesC8& aPresentityId, TRequestStatus& aClientRequst )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL 2");
+    delete iEntityId; 
+    iEntityId = NULL; 
+    DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL - entity id deleted");
+    
+    iClientStatus = &aClientRequst;
+    *iClientStatus = KRequestPending; // wait for watcher complete
+    iOperation = EPluginStartNotifyClient; 
+    
+    TRAPD( error, iSimpleId = iWatcher->SubscribeL( 
+        aPresentityId, NULL, ETrue, EFalse ););
+    DP_SDA2("StartSubscribeL subscribe error %d",error);
+    
+    if( KErrInUse == error )
+        {
+        DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL ERROR");	
+        DP_SDA("StartSubscribeL iWatcher is in use try to close and restart");
+        iWatcher->Close();
+        iWatcher = TSimpleFactory::NewWatcherL( iConnection, *this );
+        DP_SDA("StartSubscribeL Second try after creating iWatcher again");
+        error = KErrNone;
+        TRAP( error, iSimpleId = iWatcher->GetPresenceL( 
+            aPresentityId, NULL, EFalse ););
+        DP_SDA2("iWatcher->GetPresenceL error2 = %d",error );
+        }
+    User::LeaveIfError( error );
+    
+    // Save entity id after successful call 
+    DP_SDA("StartSubscribeL - allocate entity id");
+    iEntityId = aPresentityId.AllocL(); 
+    DP_SDA("StartSubscribeL - new entity id stored");
+    
+    DP_SDA("CPresencePluginEntityWatcher::StartSubscribeL End"); 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::StopSubscribeL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::StopSubscribeL( 
+    TRequestStatus& aClientRequst )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::StopSubscribeL 2 (list)");
+    iClientStatus = &aClientRequst;
+    *iClientStatus = KRequestPending; // wait for watcher complete    
+    
+    iSimpleId = iWatcher->UnsubscribeL();
+    iOperation = EPluginStop;
+    DP_SDA("CPresencePluginEntityWatcher::StopSubscribeL 2 end"); 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::StopSubscribeL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::StopSubscribeL( )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::StopSubscribeL");
+    iSimpleId = iWatcher->UnsubscribeL();
+    iOperation = EPluginStop;
+    DP_SDA("CPresencePluginEntityWatcher::StopSubscribeL end"); 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::WatcherReqCompleteL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::WatcherReqCompleteL( 
+    TInt /*aOpId*/, TInt aStatus )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::WatcherReqCompleteL");
+    DP_SDA2("WatcherReqCompleteL status %d",aStatus );
+    TPluginEntityWatcherOperation orig = iOperation;
+    DP_SDA2("WatcherReqCompleteL orig %d",orig );
+    iOperation = EPluginIdle;
+    
+    if( !aStatus )
+        {
+        iPluginWatcher.AcceptL( this );
+        }
+    
+    if ( EPluginStartNotifyClient == orig )
+        {
+        orig = EPluginStart;
+        DP_SDA(" WatcherReqCompleteL complete client");
+        CompleteClientReq( aStatus );
+        }
+    else if ( iClientStatus )
+        {
+        DP_SDA(" WatcherReqCompleteL complete client 2");
+        CompleteClientReq( aStatus );
+        }
+    
+    MSimpleWatcher::TSimpleSipSubscriptionState subscribeStatus =
+        iWatcher->SipSubscriptionState();
+    DP_SDA2("WatcherReqCompleteL subscribe status %d",subscribeStatus );
+     	
+    if ( aStatus && ( orig == EPluginStop || orig == EPluginStart &&
+        MSimpleWatcher::ESimpleStateTerminated != subscribeStatus ) )
+        {
+        DP_SDA("CPresencePluginEntityWatcher::WatcherReqCompleteL if");
+        // Delete this entity as useless
+        DP_SDA("WatcherReqCompleteL DELETE WATCHER");
+        iPluginWatcher.DeleteWatcher( iEntityId->Des() ); 
+        //Do not call anything, 
+        //since the method call above deletes this instance.
+        }
+    else if( !aStatus && ( MSimpleWatcher::ESimpleStateActive ==
+        subscribeStatus  &&
+        orig == EPluginStop ) )
+        {
+        DP_SDA(" WatcherReqCompleteL state STOP");	
+        // Delete this entity as useless
+        DP_SDA("WatcherReqCompleteL DELETE WATCHER 2");
+        iPluginWatcher.DeleteWatcher( iEntityId->Des() );
+        }
+    else if ( MSimpleWatcher::ESimpleStatePending == subscribeStatus )
+        {
+        SetPendingToXIMPL();
+        }
+    DP_SDA("CPresencePluginEntityWatcher::WatcherReqCompleteL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::SetPendingToXIMPL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::SetPendingToXIMPL()
+    {
+    DP_SDA("CPresencePluginEntityWatcher::SetPendingToXIMPL");
+    //check what is grand request list subscribe state
+    if( iConnObs.GrandListState() )
+        {
+        DP_SDA("CPresencePluginEntityWatcher::SetPendingToXIMPL True");
+        MProtocolPresenceWatchingDataHost& watcherHost =    
+        iConnObs.ProtocolPresenceHost().WatchingDataHost();
+        MPresenceInfo* prInfo = 
+            iConnObs.PresenceObjectFactoryOwn().NewPresenceInfoLC();
+        
+        //Call set to pending
+        iPresenceData->NotifyToPendingToXIMPL( 
+            iConnObs.PresenceObjectFactoryOwn(),
+            *prInfo );
+            
+        MXIMPIdentity* identity2 = iConnObs.ObjectFactory().NewIdentityLC();    
+        HBufC* uniBuffer = 
+            CnvUtfConverter::ConvertToUnicodeFromUtf8L( iEntityId->Des() );
+        CleanupStack::PushL( uniBuffer );
+        
+        HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *uniBuffer );
+        identity2->SetIdentityL( *withoutPrefix );    
+        
+        //Call presence cache writer too
+        TBuf<20> buf;
+        buf.Copy( KPendingRequestExtensionValue );
+        
+        iPresenceData->WriteStatusToCacheL( *withoutPrefix, 
+            MPresenceBuddyInfo2::ENotAvailable,
+            buf,
+            KNullDesC() ); 
+        
+        // XIMP Host API callback 
+        watcherHost.HandleSubscribedPresentityPresenceL( identity2, prInfo );
+        
+        CleanupStack::PopAndDestroy( withoutPrefix );
+        CleanupStack::PopAndDestroy( uniBuffer );
+        CleanupStack::Pop();        // >> identity2
+        CleanupStack::Pop();        // >> prInfo
+        }
+    DP_SDA("CPresencePluginEntityWatcher::SipSubscriptionState end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::SetActiveToXIMPL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::SetActiveToXIMPL( const TDesC& aIdentity )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL, identity");
+    //check what is grand request list subscribe state
+    if( iConnObs.GrandListState() )
+        {
+        DP_SDA("CPresencePluginEntityWatcher::SetPendingToXIMPL True");
+        MProtocolPresenceWatchingDataHost& watcherHost =    
+        iConnObs.ProtocolPresenceHost().WatchingDataHost();
+        MPresenceInfo* prInfo = 
+            iConnObs.PresenceObjectFactoryOwn().NewPresenceInfoLC();
+        
+        //Call set to pending
+        DP_SDA(" SetPendingToXIMPL, notify active");
+        iPresenceData->NotifyToActiveToXIMPL( 
+            iConnObs.PresenceObjectFactoryOwn(),
+            *prInfo );
+
+        DP_SDA(" SetActiveToXIMPL, create new identity");
+        MXIMPIdentity* identity2 = iConnObs.ObjectFactory().NewIdentityLC();    
+
+        DP_SDA(" SetActiveToXIMPL, strip prefix");
+        HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( aIdentity );
+        identity2->SetIdentityL( *withoutPrefix );    
+
+        DP_SDA(" SetActiveToXIMPL, write to cache");
+        //Call presence cache writer too
+        iPresenceData->WriteStatusToCacheL( *withoutPrefix, 
+            MPresenceBuddyInfo2::ENotAvailable,
+            KDefaultAvailableStatus(),
+            KNullDesC() );    
+
+        DP_SDA(" SetActiveToXIMPL, ximp api callback");
+        // XIMP Host API callback 
+        watcherHost.HandleSubscribedPresentityPresenceL( identity2, prInfo );
+        
+        DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL, cleanup");
+        CleanupStack::PopAndDestroy( withoutPrefix );
+        CleanupStack::Pop();        // >> identity2
+        CleanupStack::Pop();        // >> prInfo
+        }   
+    DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::SetTerminatedToXIMPL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::SetTerminatedToXIMPL( 
+	const TDesC& aIdentity )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL");
+    DP_SDA2("CPresencePluginEntityWatcher::SetTerminatedToXIMPL, uri: %S", 
+        &aIdentity );    
+    //check what is grand request list subscribe state
+    if( iConnObs.GrandListState() )
+        {
+        DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL True");
+        MProtocolPresenceWatchingDataHost& watcherHost =    
+        iConnObs.ProtocolPresenceHost().WatchingDataHost();
+        MPresenceInfo* prInfo = 
+            iConnObs.PresenceObjectFactoryOwn().NewPresenceInfoLC();
+        
+        //Call set to pending
+        iPresenceData->NotifyTerminatedToXIMPL( 
+            iConnObs.PresenceObjectFactoryOwn(),
+            *prInfo );
+
+        MXIMPIdentity* identity2 = iConnObs.ObjectFactory().NewIdentityLC();    
+        
+        HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( aIdentity );
+        identity2->SetIdentityL( *withoutPrefix );
+        
+        DP_SDA("SetTerminatedToXIMPL, write offline status to cache");
+        iPresenceData->WriteStatusToCacheL( *withoutPrefix,
+            MPresenceBuddyInfo2::ENotAvailable,
+            KNullDesC(),
+            KNullDesC() );
+        
+        // XIMP Host API callback 
+        watcherHost.HandleSubscribedPresentityPresenceL( identity2, prInfo );
+
+        CleanupStack::PopAndDestroy( withoutPrefix );
+        CleanupStack::Pop();        // >> identity2
+        CleanupStack::Pop( );        // >> prInfo
+        }   
+    DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::SetActiveToXIMPL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::SetActiveToXIMPL( 
+	MSimpleDocument& aDocument )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL, aDocument");
+    // No need to check the expiration here since WatcherTerminatedL
+    // is called then too.
+    MProtocolPresenceWatchingDataHost& watcherHost =    
+        iConnObs.ProtocolPresenceHost().WatchingDataHost();
+    MPresenceInfo* prInfo = 
+        iConnObs.PresenceObjectFactoryOwn().NewPresenceInfoLC();
+
+    DP_SDA(" SetActiveToXIMPL, call NotifyToPrInfoL");
+    
+    iPresenceData->NotifyToPrInfoL( 
+        iConnObs.ObjectFactory(),
+        iConnObs.PresenceObjectFactoryOwn(),
+        aDocument, *prInfo );
+    DP_SDA(" SetActiveToXIMPL, NotifyToPrInfoL ok");
+    
+    // Get variables from presence info object for cache entry
+    MPresenceBuddyInfo2::TAvailabilityValues availability = 
+        MPresenceBuddyInfo2::ENotAvailable;
+    
+    HBufC* extendedAvailability = HBufC::NewLC( KBufSize255 );
+    TPtr extendedAvailabilityPtr( extendedAvailability->Des() );
+    
+    HBufC* statusMessage = HBufC::NewLC( KBufSize255 );
+    TPtr statusMessagePtr( statusMessage->Des() );
+    
+    DP_SDA(" SetActiveToXIMPL, NotifyToPrInfoL ok, get cache entries");
+    iPresenceData->CacheEntriesFromPrInfo( *prInfo,
+        availability, extendedAvailabilityPtr, statusMessagePtr );
+    
+    DP_SDA(" SetActiveToXIMPL, create identity");
+    MXIMPIdentity* identity2 = iConnObs.ObjectFactory().NewIdentityLC();    
+    HBufC* uniBuffer = 
+        CnvUtfConverter::ConvertToUnicodeFromUtf8L( 
+            *aDocument.EntityURI() );
+    CleanupStack::PushL( uniBuffer );
+    DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL, identity ok");
+    
+    DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL, strip prefix");
+    HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *uniBuffer );
+    identity2->SetIdentityL( *withoutPrefix );   
+
+    //Call presence cache writer too
+    iPresenceData->WriteStatusToCacheL( *withoutPrefix, availability,
+         extendedAvailabilityPtr, statusMessagePtr );
+    
+    // XIMP Host API callback 
+    watcherHost.HandleSubscribedPresentityPresenceL( identity2, prInfo );
+
+    CleanupStack::PopAndDestroy( withoutPrefix );
+    CleanupStack::PopAndDestroy( uniBuffer );
+    CleanupStack::Pop();        // >> identity2
+    
+    CleanupStack::PopAndDestroy( statusMessage );
+    CleanupStack::PopAndDestroy( extendedAvailability );
+    
+    CleanupStack::Pop();        // >> prInfo
+    DP_SDA("CPresencePluginEntityWatcher::SetActiveToXIMPL end");   
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::SetTerminatedToXIMPL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::SetTerminatedToXIMPL( )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL");
+    DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL True");
+    
+    MProtocolPresenceWatchingDataHost& watcherHost = 
+        iConnObs.ProtocolPresenceHost().WatchingDataHost();
+    MPresenceInfo* prInfo = 
+        iConnObs.PresenceObjectFactoryOwn().NewPresenceInfoLC();
+    
+    //Call set to pending
+    iPresenceData->NotifyTerminatedToXIMPL( 
+        iConnObs.PresenceObjectFactoryOwn(),
+        *prInfo );
+    
+    MXIMPIdentity* identity2 = iConnObs.ObjectFactory().NewIdentityLC();
+    HBufC* uniBuffer = 
+       CnvUtfConverter::ConvertToUnicodeFromUtf8L( iEntityId->Des() );
+    
+    CleanupStack::PushL( uniBuffer );
+    HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *uniBuffer );
+    identity2->SetIdentityL( *withoutPrefix ); 
+    
+    //Call presence cache writer too
+    iPresenceData->WriteStatusToCacheL( *withoutPrefix, 
+        MPresenceBuddyInfo2::ENotAvailable,
+        KInvisibleState(),
+        KNullDesC() );
+    
+    // XIMP Host API callback 
+    watcherHost.HandleSubscribedPresentityPresenceL( identity2, prInfo );
+    
+    DP_SDA2("SetTerminatedToXIMPL2: ident %S", &identity2->Identity() );
+    CleanupStack::PopAndDestroy( withoutPrefix );
+    CleanupStack::PopAndDestroy( uniBuffer );
+    CleanupStack::Pop(); // >> identity21
+    CleanupStack::Pop(); // >> prInfo
+    
+    DP_SDA("CPresencePluginEntityWatcher::SetTerminatedToXIMPL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::WatcherNotificationL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::WatcherNotificationL( 
+    MSimpleDocument& aDocument )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::WatcherNotificationL");
+    
+    MSimpleWatcher::TSimpleSipSubscriptionState subscribeStatus =
+        iWatcher->SipSubscriptionState();
+    DP_SDA2("WatcherNotificationL subscribe status %d",subscribeStatus );
+    
+    //If subscribeStatus = pending
+    if( MSimpleWatcher::ESimpleStatePending == subscribeStatus )
+        {
+        // Pending
+        DP_SDA("CPresencePluginEntityWatcher::WatcherNotificationL PENDING");
+        SetPendingToXIMPL();
+        }
+    else if( MSimpleWatcher::ESimpleStateTerminated == subscribeStatus )
+        {
+        DP_SDA("CPresencePluginEntityWatcher::WatcherNotificationL TERMINATED");
+        SetTerminatedToXIMPL( );
+        }
+    else
+        {
+        //Active
+        DP_SDA("WatcherNotificationL normal Case");
+        SetActiveToXIMPL( aDocument );
+        }
+   	DP_SDA("CPresencePluginEntityWatcher::WatcherNotificationL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::WatcherListNotificationL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::WatcherListNotificationL(
+    MSimplePresenceList& aList )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::WatcherListNotificationL");
+    // call all the necessary callbacks, for new data + teminated ones.
+    
+    MProtocolPresenceWatchingDataHost& watcherHost = 
+         iConnObs.Host()->ProtocolPresenceDataHost().WatchingDataHost();
+    
+    RPointerArray<MPresenceInfo> entities;
+    RPointerArray<MXIMPIdentity> terminated;
+    RPointerArray<MXIMPIdentity> actives;
+    
+    TRAPD( err, iPresenceData->NotifyListToPrInfoL(
+         iConnObs.ObjectFactory(),iConnObs.PresenceObjectFactoryOwn(),
+          aList, entities, actives, terminated ));
+    if ( err )
+        {
+        entities.ResetAndDestroy();
+        terminated.ResetAndDestroy();
+        actives.ResetAndDestroy();
+        entities.Close();
+        terminated.Close();
+        actives.Close();
+        return;
+        }
+    
+    // Start to collect data for HandleSubscribedPresentityPresenceL
+    TInt counter = entities.Count();
+    for ( TInt i = counter-1 ; i>=0; i-- )
+        {
+        HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( 
+            actives[i]->Identity() );
+        actives[i]->SetIdentityL( *withoutPrefix );    
+        
+        watcherHost.HandleSubscribedPresentityPresenceL(
+            actives[i], entities[i] );
+        // Owenership is transferred
+        actives.Remove(i);
+        entities.Remove(i);
+        CleanupStack::PopAndDestroy( withoutPrefix );
+        }
+    
+    entities.ResetAndDestroy();
+    terminated.ResetAndDestroy();
+    actives.ResetAndDestroy();
+    
+    entities.Close();
+    terminated.Close();
+    actives.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::WatcherTerminatedL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::WatcherTerminatedL(
+    TInt /*aOpId*/, TInt aReason )
+    {
+    DP_SDA2("CPresencePluginEntityWatcher::WatcherTerminatedL -reason: %d", aReason );
+    
+    MProtocolPresenceWatchingDataHost& watcherHost = 
+        iConnObs.Host()->ProtocolPresenceDataHost().WatchingDataHost();
+    
+    MXIMPDataSubscriptionState *state =
+        iConnObs.ObjectFactory().NewDataSubscriptionStateLC();
+    MXIMPStatus* status = iConnObs.ObjectFactory().NewStatusLC();
+    state->SetSubscriptionStateL( 
+        MXIMPDataSubscriptionState::ESubscriptionInactive );
+    status->SetResultCode( aReason );
+    MXIMPIdentity* identity = iConnObs.ObjectFactory().NewIdentityLC();
+    
+    HBufC16* buf16 = HBufC16::NewLC( PresentityId().Length());
+    buf16->Des().Copy( PresentityId() );
+    identity->SetIdentityL( buf16->Des() );
+    
+    //Visualize closed state OpenSer
+    SetTerminatedToXIMPL( buf16->Des() );
+    
+    CleanupStack::PopAndDestroy( buf16 );
+    watcherHost.SetPresentityPresenceDataSubscriptionStateL( 
+        identity, state, status );
+    DP_SDA("CPresencePluginEntityWatcher::WatcherTerminatedL pop");
+    CleanupStack::Pop( 3 );
+    
+    iPluginWatcher.DeleteWatcher( iEntityId->Des() ); 
+    
+    DP_SDA("CPresencePluginEntityWatcher::WatcherTerminatedL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::CompleteClientReq()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginEntityWatcher::CompleteClientReq( TInt aStatus )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::CompleteClientReq"); 
+    iOperation = EPluginIdle;    
+    TRequestStatus* s = iClientStatus;
+    User::RequestComplete( s, aStatus );
+    iClientStatus = NULL;
+    DP_SDA("CPresencePluginEntityWatcher::CompleteClientReq out"); 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::PresentityId
+// ---------------------------------------------------------------------------
+//
+TPtrC8 CPresencePluginEntityWatcher::PresentityId( )
+    {
+    DP_SDA("CPresencePluginEntityWatcher::PresentityId");
+    return iEntityId ? iEntityId->Des() : TPtrC8();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginEntityWatcher::XIMPRequestId
+// ---------------------------------------------------------------------------
+//
+TXIMPRequestId CPresencePluginEntityWatcher::XIMPRequestId( )
+    {
+    return iXIMPId;  
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presenceplugingroup.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,925 @@
+/*
+* Copyright (c) 2006-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <e32std.h>
+#include <ximpdatasubscriptionstate.h>
+#include <protocolpresentitygroupsdatahost.h>
+#include <protocolpresencedatahost.h>
+#include <ximpobjectfactory.h>
+#include <presenceobjectfactory.h>
+#include <ximpstatus.h>
+#include <ximpidentity.h>
+#include <ximpobjectcollection.h>
+#include <XdmErrors.h>
+#include <presentitygroupinfo.h>
+#include <presentitygroupmemberinfo.h>
+#include <utf.h>
+#include <avabilitytext.h>
+
+#include "mpresencepluginconnectionobs.h"
+#include "presenceplugingroup.h"
+#include "presencepluginxdmutils.h"
+#include "presenceplugincommon.h"
+#include "presencepluginvirtualgroup.h"
+#include "presenceplugindata.h"
+#include "presencepluginwatcher.h"
+#include "presencepluginauthorization.h"
+#include "presencepluginutility.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::CPresencePluginGroups
+// ---------------------------------------------------------------------------
+//
+CPresencePluginGroups::CPresencePluginGroups(
+    MPresencePluginConnectionObs& aObs,
+    CPresencePluginVirtualGroup* aSubscribedBuddies,
+    CPresencePluginData* aPresenceData ):
+  	CActive( CActive::EPriorityStandard ),
+  	iConnObs(aObs),
+  	iOperation( ENoOperation),
+  	iState( EPluginIdle ), iCompleted( ETrue ),
+  	iSubscribedBuddies( aSubscribedBuddies ),
+  	iPresenceData( aPresenceData )
+    {
+    CActiveScheduler::Add( this );
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::NewL
+// ---------------------------------------------------------------------------
+//
+CPresencePluginGroups* CPresencePluginGroups::NewL(
+    MPresencePluginConnectionObs& aObs,
+    CPresencePluginVirtualGroup* aSubscribedBuddies,
+    CPresencePluginData* aPresenceData )
+    {
+    CPresencePluginGroups* self =
+        CPresencePluginGroups::NewLC( 
+             aObs,
+             aSubscribedBuddies,
+             aPresenceData );    
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::NewLC
+// ---------------------------------------------------------------------------
+//
+CPresencePluginGroups* CPresencePluginGroups::NewLC(
+    MPresencePluginConnectionObs& aObs,
+    CPresencePluginVirtualGroup* aSubscribedBuddies,
+    CPresencePluginData* aPresenceData )
+    {
+    CPresencePluginGroups* self =
+        new( ELeave ) CPresencePluginGroups( 
+             aObs,
+             aSubscribedBuddies,
+             aPresenceData );
+    CleanupStack::PushL( self );
+    return self;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::~CPresencePluginGroups
+// ---------------------------------------------------------------------------
+//
+CPresencePluginGroups::~CPresencePluginGroups()
+    {
+    DP_SDA("CPresencePluginGroups::~CPresencePluginGroups");
+    Cancel();
+    delete iPresIdentity;
+    delete iDisplayName;
+    DP_SDA("CPresencePluginGroups::~CPresencePluginGroups end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoSubscribePresentityGroupListL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoSubscribePresentityGroupListL(
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginGroups::DoSubscribePresentityGroupListL");
+    iCompleted = EFalse;
+    // List of lists under buddylist
+    StartXdmOperationL( aReqId, EGetListOfLists );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoUnsubscribePresentityGroupListL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoUnsubscribePresentityGroupListL(
+    TXIMPRequestId /*aReqId*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoCreatePresentityGroupL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoCreatePresentityGroupL(
+    const MXIMPIdentity& /*aGroupId*/,
+    const TDesC16& /*aDisplayName*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoDeletePresentityGroupL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoDeletePresentityGroupL(
+    const MXIMPIdentity& /*aGroupId*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoUpdatePresentityGroupDisplayNameL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoUpdatePresentityGroupDisplayNameL(
+    const MXIMPIdentity& /*aGroupId*/,
+    const TDesC16& /*aDisplayName*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    // Notice: later
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoSubscribePresentityGroupContentL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoSubscribePresentityGroupContentL(
+    const MXIMPIdentity& aGroupId,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginGroups::DoSubscribePresentityGroupContentL");
+    iCompleted = EFalse;
+    // List of lists under buddylist
+    StartXdmOperationL( aGroupId, aReqId, EGetListContent );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoUnsubscribePresentityGroupContentL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoUnsubscribePresentityGroupContentL(
+    const MXIMPIdentity& /*aGroupId*/,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginGroups::DoUnsubscribePresentityGroupContentL");
+    
+    iXIMPId = aReqId;
+    iConnObs.WatcherHandlerL()->UnSubscribeAllL();    
+    iCompleted = EFalse;
+    CompleteXIMPReq( KErrNone );
+    DP_SDA("CPresencePluginGroups::DoUnsubscribePresentityGroupContentL out");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoAddPresentityGroupMemberL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoAddPresentityGroupMemberL(
+    const MXIMPIdentity& aGroupId,
+    const MXIMPIdentity& aMemberId,
+    const TDesC16& /*aMemberDisplayName*/,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL");
+    __ASSERT_ALWAYS( !IsActive(), User::Leave( KErrNotReady ) );
+    
+    SetPresIdentityL( aMemberId, ETrue );
+    
+    iCompleted = EFalse;
+    iXIMPId = aReqId;
+        
+    if( !aGroupId.Identity().Compare( KPresenceBuddyList ) )
+        {
+        DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL - buddylist");
+        TBool contactIsBlocked = EFalse;
+        RPointerArray<MXIMPIdentity> blockedList;
+        CleanupStack::PushL( TCleanupItem(
+            TPresencePluginUtility::ResetAndDestroyIdentities,
+            &blockedList ) );
+        iXdmUtils->SubscribeBlockListL( blockedList );
+        DP_SDA2( "CPresencePluginGroups::DoAddPresentityGroupMemberL - blockedList.Count = %d",
+            blockedList.Count() );
+        
+        for ( TInt i( 0 ); i < blockedList.Count() && !contactIsBlocked; i++ ) 
+            {
+            if ( 0 == blockedList[i]->Identity().Compare( aMemberId.Identity() ) )
+                {
+                // contact found from blocked list
+                contactIsBlocked = ETrue;
+                }
+            }
+        CleanupStack::PopAndDestroy( &blockedList );
+        
+        if ( contactIsBlocked )
+            {
+            DP_SDA( "CPresencePluginGroups::DoAddPresentityGroupMemberL - contact is Blocked" );
+            iOperation = EUnblockInAddPresentityGroupMember;
+            iConnObs.InternalPresenceAuthorization().
+                DoPerformCancelPresenceBlockFromPresentityL(
+                    aMemberId, iStatus  );
+            SetActive();
+            }
+        else
+            {
+            DP_SDA( "CPresencePluginGroups::DoAddPresentityGroupMemberL - contact is not Blocked" );
+            iOperation = EAddPresentityGroupMember;
+            // write pending to presence cache
+            TBuf<20> buf;
+            buf.Copy( KPendingRequestExtensionValue );
+            iPresenceData->WriteStatusToCacheL( aMemberId.Identity(), 
+                MPresenceBuddyInfo2::ENotAvailable,
+                buf,
+                KNullDesC() );
+            iConnObs.WatcherHandlerL()->DoPerformSubscribePresentityPresenceL( 
+                aMemberId, iStatus );
+            SetActive();
+            }
+        }
+    else if ( !aGroupId.Identity().Compare( KPresenceBlockedList ) )
+        {
+        DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL - blockedlist");
+        iOperation = EBlockPresentityGroupMember;
+        iConnObs.InternalPresenceAuthorization().
+            DoPerformBlockPresenceForPresentityL( aMemberId, iStatus );
+        SetActive();
+        }
+    else
+        {
+        DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL - unknown, leave");
+        User::Leave( KErrNotSupported );
+        }
+    
+    DP_SDA("CPresencePluginGroups::DoAddPresentityGroupMemberL out");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoRemovePresentityGroupMemberL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoRemovePresentityGroupMemberL(
+    const MXIMPIdentity& aGroupId,
+    const MXIMPIdentity& aMemberId,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginGroups::DoRemovePresentityGroupMemberL");
+    __ASSERT_ALWAYS( !IsActive(), User::Leave( KErrNotReady ) );
+
+    SetPresIdentityL( aMemberId, ETrue );
+    
+    iCompleted = EFalse;
+    iXIMPId = aReqId;
+    iOperation = ERemovePresentityGroupMember;
+    
+    if( !aGroupId.Identity().Compare( KPresenceBuddyList ) )
+        {
+        DP_SDA( "DoRemovePresentityGroupMemberL - buddylist" );
+        iConnObs.WatcherHandlerL()->DoPerformUnsubscribePresentityPresenceL( 
+            aMemberId, iStatus );
+        SetActive();
+        }
+    else if ( !aGroupId.Identity().Compare( KPresenceBlockedList ) )
+        {
+        DP_SDA( "DoRemovePresentityGroupMemberL - blockedlist" );
+        // Contact blocking is not cancelled when blocked contact is removed
+        // user can remove blocking from blocked list later
+        DeletePersonCacheL();
+        CompleteXIMPReq( KErrNone );
+        }
+    else
+        {
+        DP_SDA("DoRemovePresentityGroupMemberL - unknown, leave");
+        User::Leave( KErrNotSupported );
+        }
+        
+    DP_SDA("CPresencePluginGroups::DoRemovePresentityGroupMemberL out");    
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoUpdatePresentityGroupMemberDisplayNameL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoUpdatePresentityGroupMemberDisplayNameL(
+    const MXIMPIdentity& /*aGroupId*/,
+    const MXIMPIdentity& /*aMemberId*/,
+    const TDesC16& /*aMemberDisplayName*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    DP_SDA("CPresencePluginGroups::DoUpdatePresentityGroupMemberDisplayNameL");
+    // Notice: Later
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoCancel(  )
+    {
+    if ( iOperation != ENoOperation )
+        {
+        iXdmUtils->Cancel();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::RunL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::RunL()
+    {
+    DP_SDA("CPresencePluginGroups::RunL");
+    TInt myStatus = iStatus.Int();
+    DP_SDA2("CPresencePluginGroups::RunL myStatus %d", myStatus );
+    
+    if ( !myStatus && !iCompleted )
+        {
+        DP_SDA("CPresencePluginGroups::RunL !myStatus");
+        // OK response
+        CallActualXdmOperationL( myStatus );
+        }
+    else if ( KErrNotFound == myStatus && !iCompleted )
+        {
+        DP_SDA("CPresencePluginGroups::RunL KErrNotFound == myStatus");
+        
+        // DoPerformUnsubscribePresentityPresenceL didn't find watcher
+        // so it did not execute StopSubscribeL from the watcher. Still
+        // presentity group member has to be removed.
+        CallActualXdmOperationL( KErrNone );
+        }
+    else if ( !myStatus && iCompleted )
+        {
+        DP_SDA("CPresencePluginGroups::RunL SEND COMPLETE");
+        CompleteXIMPReq( myStatus );
+        }
+    else
+        {
+        if ( iOperation == EDeletePresentityGroup && iState ==
+        	EPluginCommitRls )
+            {
+            DP_SDA("CPresencePluginGroups::RunL CallActualXdmOperation");
+            CallActualXdmOperationL( myStatus );
+            }
+        else
+            {
+            DP_SDA("CPresencePluginGroups::RunL SEND COMPLETE 2");
+            // Other errors terminated the show
+            CompleteXIMPReq( myStatus );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::CallActualXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::CallActualXdmOperationL( TInt aCompleteStatus )
+    {
+    DP_SDA("CPresencePluginGroups::CallActualXdmOperationL");
+        
+    DP_SDA2("CallActualXdmOperationL iOperation %d", iOperation);
+    switch ( iOperation )
+        {
+        case EGetListOfLists:
+            {
+            DP_SDA("PluginGroups::CallActualXdmOperationL EGetListOfLists");
+            iOperation = EGetListOfLists;
+            GetListOfListsL();
+            }
+            break;
+        
+        case EGetListContent:
+            {
+            DP_SDA("PluginGroups::CallActualXdmOperationL EGetListContent");
+            iOperation = EGetListContent;
+            GetListContentL();
+            }
+            break;
+            
+        case EAddPresentityGroupMember:
+            {
+            DP_SDA(" CallActualXdmOperationL EAddPresentityGroupMember");
+            
+            iOperation = EGrantPresentityGroupMember;
+            MXIMPIdentity* newIdentity = 
+                iConnObs.ObjectFactory().NewIdentityLC();
+            newIdentity->SetIdentityL( *iPresIdentity );
+            
+            iConnObs.InternalPresenceAuthorization().
+                DoPerformGrantPresenceForPresentityL( *newIdentity, iStatus );
+            CleanupStack::PopAndDestroy(); // >> newIdentity
+            SetActive();
+            }
+            break;
+            
+        case ERemovePresentityGroupMember:
+            {
+            DP_SDA(" CallActualXdmOperationL ERemovePresentityGroupMember");
+            iOperation = EWithdrawGrantFromMember;
+            MXIMPIdentity* newIdentity = iConnObs.ObjectFactory().NewIdentityLC();
+            newIdentity->SetIdentityL( *iPresIdentity );
+            iConnObs.InternalPresenceAuthorization().
+                DoPerformWithdrawPresGrantFromPresentityL( 
+                    *newIdentity, iStatus );
+            CleanupStack::PopAndDestroy(); // >> newIdentity
+            SetActive();
+            }
+            break;
+            
+        case EGrantPresentityGroupMember:
+            {
+            DP_SDA(" CallActualXdmOperationL EGrantPresentityGroupMember");
+            CompleteXIMPReq( aCompleteStatus );
+            }
+            break;
+            
+        case EWithdrawGrantFromMember:
+            {
+            DP_SDA(" CallActualXdmOperationL EWithdrawGrantFromMember");
+            if ( !aCompleteStatus )
+                {
+                DP_SDA(" -> succesfully unblocked, store to cache");
+                DeletePersonCacheL();                
+                DP_SDA(" -> store info to cache done");                
+                }            
+            CompleteXIMPReq( aCompleteStatus );
+            }
+            break;
+            
+        case EBlockPresentityGroupMember:
+            {
+            DP_SDA(" CallActualXdmOperationL EBlockPresentityGroupMember");
+            if ( !aCompleteStatus )
+                {
+                DP_SDA(" -> succesfully blocked, store to cache");
+
+                DP_SDA(" -> strip prefix from uri");
+                HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( 
+                    *iPresIdentity );
+                DP_SDA(" -> store info to cache");
+                
+                TBuf<20> buf;
+                buf.Copy( KBlockedExtensionValue );
+                                
+                iPresenceData->WriteStatusToCacheL( *withoutPrefix, 
+                    MPresenceBuddyInfo2::EUnknownAvailability,
+                    buf,
+                    KNullDesC() );
+                
+                CleanupStack::PopAndDestroy( withoutPrefix );
+                DP_SDA(" -> store info to cache done");
+                }
+            CompleteXIMPReq( aCompleteStatus );
+            }
+            break;
+            
+        case EUnblockPresentityGroupMember:
+            {
+            DP_SDA(" CallActualXdmOperationL EUnblockPresentityGroupMember");
+            if ( !aCompleteStatus )
+                {
+                DP_SDA(" -> succesfully unblocked, store to cache");
+                DeletePersonCacheL();                
+                DP_SDA(" -> store info to cache done");                
+                }            
+            CompleteXIMPReq( aCompleteStatus );
+            }
+            break;
+            
+        case EUnblockInAddPresentityGroupMember:
+            {
+            DP_SDA(" CallActualXdmOperationL EUnblockInAddPresentityGroupMember");
+            iOperation = EAddPresentityGroupMember;
+            MXIMPIdentity* newIdentity = iConnObs.ObjectFactory().NewIdentityLC();
+            newIdentity->SetIdentityL( *iPresIdentity );
+            
+            TBuf<20> buf;
+            buf.Copy( KPendingRequestExtensionValue );
+            iPresenceData->WriteStatusToCacheL( *iPresIdentity,
+                MPresenceBuddyInfo2::ENotAvailable,
+                buf, KNullDesC() );
+            
+            iConnObs.WatcherHandlerL()->DoPerformSubscribePresentityPresenceL( 
+                *newIdentity, iStatus );
+            CleanupStack::PopAndDestroy(); // >> newIdentity
+            SetActive();
+            }
+            break;
+            
+        default:
+            User::Leave( KErrNotSupported );
+            break;
+        }
+    DP_SDA("CPresencePluginGroups::CallActualXdmOperationL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginGroups::RunError( TInt aError )
+    {
+    DP_SDA("CPresencePluginGroups::RunError SEND COMPLETE");
+    // complete the open request
+    CompleteXIMPReq( aError );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CPresencePluginGroups::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions )
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        MProtocolPresentityGroups* myIf = this;
+        return myIf;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::GetInterface()
+// ---------------------------------------------------------------------------
+//
+const TAny* CPresencePluginGroups::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        const MProtocolPresentityGroups* myIf = this;
+        return myIf;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::GetInterfaceId()
+// ---------------------------------------------------------------------------
+//
+TInt32 CPresencePluginGroups::GetInterfaceId() const
+    {
+    return MProtocolPresentityGroups::KInterfaceId;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::SetPresIdentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::SetPresIdentityL(
+     const MXIMPIdentity& aPresentityId,
+     TBool aFormatUri )
+    {
+    DP_SDA2("CPresencePluginGroups::SetPresIdentityL: %S", 
+        &aPresentityId.Identity() ); 
+     
+    delete iPresIdentity;
+    iPresIdentity = NULL;
+     
+    if ( aFormatUri )
+        {
+        DP_SDA("CPresencePluginGroups::SetPresIdentityL, format uri");
+
+        HBufC8* identityCopy = HBufC8::NewLC( KBufSize255 );
+        TPtr8 identityCopyPtr( identityCopy->Des() );
+        identityCopyPtr.Copy( aPresentityId.Identity() );
+    
+        HBufC8* prefixUri = iPresenceData->CreatePresenceUri8LC( 
+            identityCopyPtr );
+    
+        HBufC* prefixUri16 = HBufC::NewLC( KBufSize255 );
+        TPtr prefixUri16Ptr( prefixUri16->Des() );
+        prefixUri16Ptr.Copy( *prefixUri );
+    
+        iPresIdentity = prefixUri16;
+        CleanupStack::Pop( prefixUri16 );
+        CleanupStack::PopAndDestroy( prefixUri );
+        CleanupStack::PopAndDestroy( identityCopy );
+        }
+    else
+        {
+        DP_SDA("CPresencePluginGroups::SetPresIdentityL, use as it is");
+        iPresIdentity = aPresentityId.Identity().AllocL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::StartXdmOperationL(
+    TXIMPRequestId aReqId,
+    TPluginGroupsOperation aOperation )
+    {
+    DP_SDA("StartXdmOperationL StartXdmOperationL two param");
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) );
+    iXIMPId = aReqId;
+    iOperation = aOperation;
+    StartXdmOperationL();
+    DP_SDA("StartXdmOperationL StartXdmOperationL two param end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::StartXdmOperationL(
+    const MXIMPIdentity& aId,
+    TXIMPRequestId aReqId,
+    TPluginGroupsOperation aOperation )
+    {
+    DP_SDA("StartXdmOperationL StartXdmOperationL three param");
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) );
+    SetPresIdentityL( aId, EFalse );
+    iXIMPId = aReqId;
+    iOperation = aOperation;
+    StartXdmOperationL();
+    }
+  
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::StartXdmOperationL()
+    {
+    if ( !iXdmUtils )
+        {
+        DP_SDA("CPresencePluginGroups::StartXdmOperationL Get xdmUtils");
+        iXdmUtils = iConnObs.XdmUtilsL();
+        }
+    DP_SDA("CPresencePluginGroups::StartXdmOperationL StartXdmOperationL");
+    
+    iXdmUtils->InitializeXdmL( iStatus );
+    iState = EPluginInitXdm;
+    DP_SDA("CPresencePluginGroups::StartXdmOperationL SetActive");
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::GetListOfListsL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::GetListOfListsL()
+    {
+    DP_SDA("CPresencePluginGroups::GetListOfListsL");
+
+    RPointerArray<MXIMPIdentity> subscribed;
+    CleanupClosePushL( subscribed );
+
+    iXdmUtils->SubscribeBuddyListL( subscribed );
+	DP_SDA("CPresencePluginGroups::GetListOfListsL SubscribeBudyList Ready");
+	
+    MXIMPObjectCollection* coll =
+        iConnObs.ObjectFactory().NewObjectCollectionLC();    // << coll
+        
+    TInt count = subscribed.Count();
+    DP_SDA2("CPresencePluginGroups::GetListOfListsL soul count %d", count);
+    
+    for ( TInt i = 0; i < count; i++ )
+        {
+        MXIMPIdentity* currId = subscribed[i];
+        MPresentityGroupInfo* sInfo =
+            iConnObs.PresenceObjectFactoryOwn().NewPresentityGroupInfoLC();
+        sInfo->SetGroupIdL( currId ); // ownership is taken
+        sInfo->SetGroupDisplayNameL( currId->Identity() );
+        
+        coll->AddObjectL( sInfo );      // ownership is taken
+        CleanupStack::Pop();                                // >> bInfo
+        }
+    DP_SDA("SubscribeBudyList For ready SEND COMPLETE continue");    
+     
+    CompleteXIMPReq( KErrNone );
+    
+     // Callback for subscription state (terminated).
+    MXIMPDataSubscriptionState* myState =
+        iConnObs.ObjectFactory().NewDataSubscriptionStateLC();
+        
+    MXIMPStatus* myStatus = iConnObs.ObjectFactory().NewStatusLC();
+    
+    // Notice: consider XIMP error codes
+    myStatus->SetResultCode( KErrNone );
+    myState->SetSubscriptionStateL(
+        MXIMPDataSubscriptionState::ESubscriptionInactive );
+        
+    MProtocolPresentityGroupsDataHost& dataHost =
+         iConnObs.ProtocolPresenceHost().GroupsDataHost();
+    
+    dataHost.SetPresentityGroupListDataSubscriptionStateL(
+        myState, myStatus );
+        
+    dataHost.HandlePresentityGroupListL( coll );    
+
+    CleanupStack::Pop( 3 ); // >> myState, myStatus, coll
+   	CleanupStack::Pop( &subscribed );
+   	DP_SDA("CPresencePluginGroups::GetListOfListsL end"); 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::GetListContentL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::GetListContentL()
+    {
+    DP_SDA("CPresencePluginGroups::GetListContentL");
+    
+    if( !iPresIdentity->Compare( KPresenceBuddyList ) )
+        {
+        DP_SDA("CPresencePluginGroups::GetListContentL - get buddies");
+        DoGetSubscribedBuddyListL();
+        
+        // Consider waiting complete for each subscribe before completing
+        CompleteXIMPReq( KErrNone ); 
+        }
+    else if( !iPresIdentity->Compare( KPresenceSubcribedBuddys ) )
+    	{
+    	//Subscribe subscribed buddyes virtual group
+    	DP_SDA("GetListContentL KPresenceSubcribedBuddys");
+    	DoGetSubscribedBuddyListL();
+    	}
+    else
+    	{
+    	DP_SDA("CPresencePluginGroups::GetListContentL Wrong list name");	
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoGetBuddyListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoGetBuddyListL()
+    {
+    DP_SDA("CPresencePluginGroups::DoGetBuddyListL KPresenceBuddyList");
+    MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();
+    MProtocolPresentityGroupsDataHost& dataHost =
+        iConnObs.ProtocolPresenceHost().GroupsDataHost();
+    
+    MXIMPObjectCollection* entities =
+    	myFactory.NewObjectCollectionLC();          // << entities
+    iXdmUtils->GetEntitiesInListL( iPresIdentity->Des(), *entities );
+    DP_SDA("DoGetBuddyListL entities get ready SEND COMPLETE");
+    
+    // callback for data
+    DP_SDA("CPresencePluginGroups::DoGetBuddyListL callback data");
+    MXIMPIdentity* id = myFactory.NewIdentityLC();  // << id
+    id->SetIdentityL( iPresIdentity->Des() );
+    dataHost.HandlePresentityGroupContentL( id, entities );
+    CleanupStack::Pop();// >> id
+    CleanupStack::Pop();// >> entities
+    DP_SDA("CPresencePluginGroups::DoGetBuddyListL callback ready");
+
+    // Callback for subscription state (terminated).
+    DP_SDA("CPresencePluginGroups::DoGetBuddyListL terminated ");
+    id = myFactory.NewIdentityLC();  // << id
+    id->SetIdentityL( iPresIdentity->Des() );
+    MXIMPDataSubscriptionState* myState =
+    myFactory.NewDataSubscriptionStateLC();
+    MXIMPStatus* myStatus = myFactory.NewStatusLC();
+    // Notice: consider XIMP error codes
+    myStatus->SetResultCode( KErrNone );
+    myState->SetSubscriptionStateL(
+    		MXIMPDataSubscriptionState::ESubscriptionInactive );
+    
+    dataHost.SetPresentityGroupContentDataSubscriptionStateL(
+    	id, myState, myStatus );
+  
+    DP_SDA("CPresencePluginGroups::DoGetBuddyListL Pop");
+	CleanupStack::Pop( 3 );
+	
+    DP_SDA("CPresencePluginGroups::DoGetBuddyListL end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DoGetSubscribedBuddyListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DoGetSubscribedBuddyListL()
+    {
+    DP_SDA("CPresencePluginGroups::DoGetSubscribedBuddyListL");
+    MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();
+    MProtocolPresentityGroupsDataHost& dataHost =
+        iConnObs.ProtocolPresenceHost().GroupsDataHost();
+    
+    // Get internal list content
+    MXIMPObjectCollection* entities =
+    	myFactory.NewObjectCollectionLC();          // << entities
+    iXdmUtils->GetEntitiesInListL( iPresIdentity->Des(), *entities );
+    DP_SDA("DoGetBuddyListL entities get ready SEND COMPLETE");
+    CleanupStack::PopAndDestroy();	// entities
+    
+    // start getting virtualEntities
+    MXIMPObjectCollection* virtualEntities =
+        myFactory.NewObjectCollectionLC();// << virtualEntities
+
+    iSubscribedBuddies->GetVirtualEntitiesL( *virtualEntities );
+    
+    DP_SDA("CPresencePluginGroups::DoGetSubscribedBuddyListL - subscribe all");
+    iConnObs.WatcherHandlerL()->SubscribeAllL();
+    DP_SDA("CPresencePluginGroups::DoGetSubscribedBuddyListL - subscribe all ok");
+
+    // callback for data
+    DP_SDA("DoGetSubscribedBuddyListL callback data");
+    MXIMPIdentity* id = myFactory.NewIdentityLC();  // << id
+    id->SetIdentityL( iPresIdentity->Des() );
+    dataHost.HandlePresentityGroupContentL( id, virtualEntities );
+    CleanupStack::Pop();                            // >> id
+    CleanupStack::Pop();                            // >> entities
+    DP_SDA("DoGetSubscribedBuddyListL callback ready");
+
+    // Callback for subscription state (terminated).
+    DP_SDA("CPresencePluginGroups::DoGetSubscribedBuddyListL terminated");
+    id = myFactory.NewIdentityLC();  // << id
+    id->SetIdentityL( iPresIdentity->Des() );
+    MXIMPDataSubscriptionState* myState =
+    	myFactory.NewDataSubscriptionStateLC();
+    MXIMPStatus* myStatus = myFactory.NewStatusLC();
+    // Notice: consider XIMP error codes
+    myStatus->SetResultCode( KErrNone );
+    myState->SetSubscriptionStateL(
+    		MXIMPDataSubscriptionState::ESubscriptionActive );
+    dataHost.SetPresentityGroupContentDataSubscriptionStateL(
+    	id, myState, myStatus );
+    
+	CleanupStack::Pop( 3 );
+	
+    DP_SDA("DoGetSubscribedBuddyListL - KPresenceOnlineBuddy case end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::CompleteXIMPReq
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::CompleteXIMPReq( TInt aStatus )
+    {
+    DP_SDA("CPresencePluginGroups::CompleteXIMPReq");
+    if ( iCompleted  )
+        {
+        DP_SDA("CPresencePluginGroups::CompleteXIMPReq return");
+        return;
+        }
+
+    iCompleted = ETrue;
+    iOperation = ENoOperation;
+    iConnObs.CompleteReq( iXIMPId, aStatus );
+    iXIMPId = TXIMPRequestId();
+    DP_SDA("CPresencePluginGroups::CompleteXIMPReq end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginGroups::DeletePersonCacheL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginGroups::DeletePersonCacheL()
+    {
+    DP_SDA("CPresencePluginGroups::DeletePersonCacheL");
+    DP_SDA(" -> strip prefix from uri");
+    HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( *iPresIdentity );
+    iPresenceData->DeletePresenceL( *withoutPrefix );
+    CleanupStack::PopAndDestroy( withoutPrefix );
+    DP_SDA("CPresencePluginGroups::DeletePersonCacheL out");
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginpublisher.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,1440 @@
+/*
+* Copyright (c) 2006-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <e32std.h>
+#include <utf.h>
+#include <ximpdatasubscriptionstate.h>	  
+#include <protocolpresencepublishingdatahost.h>
+#include <protocolpresencedatahost.h>
+#include <ximpobjectfactory.h>
+#include <presenceobjectfactory.h>
+#include <presenceinfo.h>
+#include <personpresenceinfo.h>
+#include <ximpprotocolconnectionhost.h>
+#include <ximpstatus.h>
+#include <ximperrors.hrh>
+#include <ximpidentity.h>
+#include <ximpobjectcollection.h>
+#include <presencewatcherinfo.h>
+#include <simpleutils.h>   // For KSimplePDM
+#include <simplefactory.h>
+#include <msimpledocument.h>
+#include <msimplepublisher.h>
+#include <msimplewatcher.h>
+#include <msimplewinfo.h>
+#include <msimpleelement.h>
+#include <msimpleconnection.h>
+#include <simpleerrors.h>
+#include <avabilitytext.h>
+
+#include "presenceplugincommon.h"
+#include "presencepluginpublisher.h"
+#include "presencepluginwinfo.h"
+#include "presenceplugindata.h"
+#include "presencepluginxdmutils.h"
+#include "presencepluginwatcherinfo.h"
+#include "presenceplugincommon.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::CPresencePluginPublisher()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginPublisher::CPresencePluginPublisher(
+    MPresencePluginConnectionObs& aObs,
+    MSimpleConnection& aConn )
+    : CActive( CActive::EPriorityStandard ),
+    iConnObs(aObs), iConnection(aConn),
+    iPublisher( NULL ), iWatcher( NULL ),
+    iSubscribed(EFalse), iSubscribedOwn(EFalse), 
+    iPublished(EFalse), iRePublish(EFalse),
+    iWatcherList( CPresencePluginWatcherInfo::LinkOffset() ) 
+    {
+    DP_SDA("CPresencePluginPublisher::CPresencePluginPublisher ");
+    CActiveScheduler::Add(this);        
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::ConstructL( CPresencePluginData* aPresenceData )
+    {
+    DP_SDA("CPresencePluginPublisher::ConstructL ");
+    iWatcher = TSimpleFactory::NewWatcherL( iConnection, *this );
+    iPublisher = TSimpleFactory::NewPublisherL( iConnection, *this );       
+    iPresenceData = aPresenceData;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginPublisher* CPresencePluginPublisher::NewL(
+    MPresencePluginConnectionObs& aObs,
+    MSimpleConnection& aConn,
+    CPresencePluginData* aPresenceData )
+    {
+    CPresencePluginPublisher* self =
+        new( ELeave ) CPresencePluginPublisher( aObs, aConn );
+    CleanupStack::PushL( self );
+    self->ConstructL( aPresenceData );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::~CPresencePluginPublisher()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginPublisher::~CPresencePluginPublisher()
+    {
+    DP_SDA("CPresencePluginPublisher::~CPresencePluginPublisher");
+    
+    if ( iDocument )
+        {
+        iDocument->Close();
+        }
+
+    if ( iPublisher )
+        {
+        iPublisher->Close();
+        }
+        
+    if ( iWatcher )
+        {
+        iWatcher->Close();
+        }
+         
+    DeleteWatchers();
+    iClientStatus = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::DeleteWatchers
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::DeleteWatchers()
+    {
+    DP_SDA("CPresencePluginPublisher::DeleteWatchers");
+    // Delete all buffered transaction requests
+    TDblQueIter<CPresencePluginWatcherInfo> rIter( iWatcherList );
+    rIter.SetToFirst();
+
+    while ( rIter )
+        {
+        DP_SDA("CPresencePluginPublisher::DeleteWatchers while"); 
+        CPresencePluginWatcherInfo* w = rIter;
+        rIter++;
+        // delete wathcer info
+        w->Destroy();
+        } 
+    DP_SDA("CPresencePluginPublisher::DeleteWatchers end"); 
+    } 
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::AddWatcherIfNotExistsL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::AddWatcherIfNotExistsL( 
+    const TDesC8& aId,
+    const TDesC& aSipId )
+    {
+    DP_SDA("CPresencePluginPublisher::AddWatcherIfNotExistsL");
+    // Delete all buffered transaction requests
+    TDblQueIter<CPresencePluginWatcherInfo> rIter( iWatcherList );
+    rIter.SetToFirst();
+    
+    TBool found(EFalse);
+
+    while ( rIter )
+        {
+        CPresencePluginWatcherInfo* w = rIter;
+        rIter++;
+        found = w->Match( aId, aSipId );
+        if ( found )
+            {
+            DP_SDA("CPresencePluginPublisher::AddWatcherIfNotExistsL found");
+            break;
+            }
+        }
+    if ( !found )
+        {
+        DP_SDA("CPresencePluginPublisher::AddWatcherIfNotExistsL !found");       
+        CPresencePluginWatcherInfo* w =
+            CPresencePluginWatcherInfo::NewL( aId, aSipId );
+        iWatcherList.AddLast( *w );
+        } 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::RemoveWatcherIfExistsL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::RemoveWatcherIfExists( 
+    const TDesC8& aId, const TDesC& aSipId )
+    {
+    DP_SDA("CPresencePluginPublisher::RemoveWatcherIfExistsL");
+    // Delete all buffered transaction requests
+    TDblQueIter<CPresencePluginWatcherInfo> rIter( iWatcherList );
+    rIter.SetToFirst();
+    
+    TBool found(EFalse);
+
+    while ( rIter )
+        {
+        CPresencePluginWatcherInfo* w = rIter;
+        rIter++;
+        // delete wathcer info
+        found = w->Match( aId, aSipId );
+        if ( found )
+            {         
+            w->Destroy();
+            break;
+            }
+        }    
+    }  
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::DoPublishOwnPresenceL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::DoPublishOwnPresenceL(
+    const MPresenceInfo& aOwnPresence,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginPublisher::DoPublishOwnPresenceL");
+    const MPersonPresenceInfo* persInfo = aOwnPresence.PersonPresence();
+    if ( !persInfo )
+        {
+        // Notice: error codes
+        CompleteXIMPReq( KErrArgument );
+        return;
+        }
+    InitializeSimpleDocumentL( );    
+    AddSimpleDocumentPersL( persInfo ); 
+    
+    StartXdmOperationL( aReqId );
+    iOperation = EPublishOwn;                 
+    DP_SDA("CPresencePluginPublisher::DoPublishOwnPresenceL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::DoSubscribeOwnPresenceL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::DoSubscribeOwnPresenceL(
+    const MPresenceInfoFilter& /*aPif*/,   // notice: later
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginPublisher::DoSubscribeOwnPresenceL");         
+    StartXdmOperationL( aReqId );    
+    iOperation = ESubscribeOwn; 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::DoUpdateOwnPresenceSubscriptionPifL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::DoUpdateOwnPresenceSubscriptionPifL(
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    // Notice: later
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::DoUnsubscribeOwnPresenceL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::DoUnsubscribeOwnPresenceL(
+    TXIMPRequestId aReqId )
+    {     
+    DP_SDA("CPresencePluginPublisher::DoUnsubscribeOwnPresenceL");
+    iSubscribedOwn = EFalse;
+    iSimpleId = iWatcher->UnsubscribeL();
+    iXIMPId = aReqId;
+    iOperation = EUnsubscribeOwn;    
+    }    
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::DoSubscribePresenceWatcherListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::DoSubscribePresenceWatcherListL(
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginPublisher::DoSubscribePresenceWatcherListL");
+    if ( !iSubscribed )
+        {    
+        DP_SDA("DoSubscribePresenceWatcherListL !Subscribed");    
+        iConnObs.WinfoHandlerL()->SubscribeWinfoListL( aReqId );
+        iSubscribed = ETrue;
+        iXIMPId = aReqId;
+        iOperation = ESubscribeWinfo;
+        }
+    else
+        {
+        DP_SDA("DoSubscribePresenceWatcherListL else");
+        iXIMPId = aReqId;         
+        iOperation = ESubscribeWinfo;        
+        CompleteXIMPReq( KErrNone );
+        } 
+    DP_SDA("CPresencePluginPublisher::DoSubscribePresenceWatcherListL end"); 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::DoUnsubscribePresenceWatcherListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::DoUnsubscribePresenceWatcherListL(
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginPublisher::DoUnsubscribePresenceWatcherListL");
+    if ( iSubscribed )
+        {
+        DP_SDA("DoUnsubscribePresenceWatcherListL: if ( iSubscribed ) - begin");
+        iConnObs.WinfoHandlerL()->UnsubscribeWinfoListL( aReqId );
+        iSubscribed = EFalse;
+        iXIMPId = aReqId;
+        iOperation = EUnsubscribeWinfo;        
+        DP_SDA("DoUnsubscribePresenceWatcherListL:  if ( iSubscribed ) - end");
+        
+        }
+    else
+        {
+        DP_SDA("DoUnsubscribePresenceWatcherListL: iSubscribed ) is false");        
+        iXIMPId = aReqId;
+        iOperation = EUnsubscribeWinfo; //hameed
+        CompleteXIMPReq( KErrNone );
+        }
+    }
+  
+      
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::PublishReqCompleteL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::PublishReqCompleteL( 
+    TInt /*aOpid*/,
+    TInt aStatus )
+    {
+    DP_SDA("CPresencePluginPublisher::PublishReqCompleteL");
+    // Notice: make 415 error code conversion here and other 
+    //SIP code -> XIMP conversions
+    DP_SDA2("PublishReqCompleteL STATUS %d",aStatus );
+    
+    if( iConnObs.GetSessionStatus() )
+        {
+        DP_SDA2("PublishReqComp stopState %d",iConnObs.GetStopPublishState());
+        if ( !aStatus && !iConnObs.GetStopPublishState() )
+            {
+            DP_SDA("CPresencePluginPublisher::PublishReqCompleteL ETrue");
+            iPublished = ETrue;
+            iConnObs.SetStopPublishState( ETrue );
+            }
+        // Save E-Tag
+        if( !aStatus )
+            {
+            DP_SDA("CPresencePluginPublisher::PublishReqCompleteL Save ETAG");
+            TBuf8<KBufSize255> buf;
+            buf.Copy( iPublisher->SIPETag() );
+            iConnObs.SetETag( buf );
+            }
+    	//Do not complete if error republish is true. XIMPFW is not knowing we 
+    	//are sending republish.
+        if( EFalse == iRePublish && !aStatus )
+            {
+            //Complete Publish request
+            DP_SDA("CPresencePluginPublisher::PublishReqCompleteL complete");
+            if( !(iConnObs.IsStopPublishCalled()) )
+                {
+                DP_SDA("CPresencePluginPublisher::PublishReqCompleteL complete normal");
+                // successfull Online / others: store status to cache
+                StoreOwnStatusToCacheL( );
+                CompleteXIMPReq( aStatus );
+                }
+            //Complete stopPublish and close session if stopPublish is called
+            if( iConnObs.IsStopPublishCalled() )
+                {
+                DP_SDA("PublishReqCompleteL complete closeSession"); 
+                iPresenceData->DeletePresenceVariablesL( iConnObs.ServiceId() );
+                // successfull Online / others: store status to cache
+                StoreOwnStatusToCacheL( );
+                //Complete close session
+                CompleteClientReq( aStatus );
+                }
+            }
+        if( EFalse == iRePublish && ( KSimpleErrTemporary == aStatus  ) )
+           {
+           DP_SDA("PublishReqCompleteL KSimpleErrTemporary"); 
+           // Make new publish request without ETag
+           CreatePublisherL();        
+           iSimpleId = iPublisher->StartPublishL( *iDocument, ETrue );
+           }
+        else if( EFalse == iRePublish && ( KErrTimedOut == aStatus  ) )
+            {
+            DP_SDA("PublishReqCompleteL KErrTimedOut"); 
+            iPublisher->StopPublishL();
+            CompleteXIMPReq( KXIMPErrServicRequestTimeouted );
+            }
+        else if( KErrCommsBreak == aStatus )
+            {
+            DP_SDA("PublishReqCompleteL KErrCommsBreak");
+            CompleteXIMPReq( KErrCommsBreak );
+            }
+        else
+        	{
+        	//Set rePublish flag back to false.
+        	iRePublish = EFalse;
+        	}
+        }
+    else
+        {
+        //Run this case if connection is not good any more
+        DP_SDA("PublishReqCompleteL No connect CANCEL");
+        Cancel();
+        }
+    DP_SDA("CPresencePluginPublisher::PublishReqCompleteL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::PublishTerminatedL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::PublishTerminatedL( TInt aOpid )
+    {
+    DP_SDA("CPresencePluginPublisher::PublishTerminatedL");
+    DP_SDA2("CPresencePluginPublisher::PublishTerminatedL opID %d",aOpid );
+    DP_SDA2("PublishTerminatedL iSimpleId %d",iSimpleId );
+    DP_SDA2("PublishTerminatedL iStatus %d",iStatus.Int() );
+    
+    if ( iSimpleId == aOpid && iConnObs.GetSessionStatus() )
+        {
+        DP_SDA("CPresencePluginPublisher::PublishTerminatedL NewPublish");
+        CreatePublisherL();       
+        TRAPD( error , iSimpleId = iPublisher->StartPublishL( 
+        		*iDocument, ETrue ) );
+        if ( KErrNone == error )
+            {
+            DP_SDA("PublishTerminatedL NewPublish KErrNone");
+            iRePublish = ETrue;
+            iConnObs.SetStopPublishState( EFalse );
+            }        
+        }
+    else
+        {
+        DP_SDA("CPresencePluginPublisher::PublishTerminatedL else");
+        iPublished = EFalse;
+        if( iPublisher )
+            {
+            iPublisher->Close();
+            iPublisher = NULL; 
+            }    
+        }  
+    }   
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::WatcherReqCompleteL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::WatcherReqCompleteL( TInt /*aOpid*/,
+    TInt aStatus )
+    {
+    DP_SDA("CPresencePluginPublisher::WatcherReqCompleteL");
+    if ( !aStatus )
+        {      
+        iSubscribedOwn = ETrue;   
+        }
+    
+    CompleteXIMPReq( aStatus );       
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::WatcherNotificationL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::WatcherNotificationL( 
+    MSimpleDocument& aDocument )
+    {       
+    // Notice: Do not need to check the expiration here since
+    // WatcherTerminatedL is called then too.
+    DP_SDA("CPresencePluginPublisher::WatcherNotificationL");
+    
+    MProtocolPresencePublishingDataHost& publishHost =
+        iConnObs.ProtocolPresenceHost().PublishingDataHost();
+            
+    MPresenceInfo* prInfo =
+        iConnObs.PresenceObjectFactoryOwn().NewPresenceInfoLC();// << prInfo
+        
+    iPresenceData->NotifyToPrInfoL(  
+        iConnObs.ObjectFactory(),
+        iConnObs.PresenceObjectFactoryOwn(), 
+        aDocument,
+        *prInfo );
+
+    // XIMP Host API callbacks
+  
+    publishHost.HandleSubscribedOwnPresenceL( prInfo );
+    CleanupStack::Pop();  // >> prInfo            
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::WatcherListNotificationL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::WatcherListNotificationL( 
+    MSimplePresenceList& /*aList*/ )
+    {
+    //Do nothing now
+    DP_SDA("CPresencePluginPublisher::WatcherListNotificationL EMPTY");     
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::WatcherTerminatedL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::WatcherTerminatedL(
+    TInt /*aOpId*/, TInt aReason )
+    {
+    DP_SDA("CPresencePluginPublisher::WatcherTerminatedL");
+    
+    iSubscribedOwn = EFalse;    
+
+    MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();    
+    MProtocolPresencePublishingDataHost& publishHost =
+        iConnObs.ProtocolPresenceHost().PublishingDataHost();
+        
+    MXIMPDataSubscriptionState *state =
+        myFactory.NewDataSubscriptionStateLC();
+    MXIMPStatus* status = myFactory.NewStatusLC();
+    state->SetSubscriptionStateL( 
+        MXIMPDataSubscriptionState::ESubscriptionInactive );
+        
+    status->SetResultCode( aReason );
+    publishHost.SetOwnPresenceDataSubscriptionStateL( state, status );
+    CleanupStack::Pop( 2 ); // status, state    
+    
+    DP_SDA("CPresencePluginPublisher::WatcherTerminatedL - end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::CompleteXIMPReq()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::CompleteXIMPReq( TInt aStatus )
+    {
+    DP_SDA("CPresencePluginPublisher::CompleteXIMPReq");
+    DP_SDA2("CompleteXIMPReq:  iOperation = %d",(TInt) iOperation );
+    // Notice: should this yield active scheduler???
+    if ( iOperation != ENoOperation )
+        {
+        DP_SDA("CPresencePluginPublisher::CompleteXIMPReq complete");                
+        iOperation = ENoOperation;
+        iConnObs.CompleteReq( iXIMPId, aStatus );
+        iXIMPId = TXIMPRequestId();
+        }
+    DP_SDA("CPresencePluginPublisher::CompleteXIMPReq end"); 
+    }  
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::CompleteClientReq()
+// ---------------------------------------------------------------------------
+//               
+void CPresencePluginPublisher::CompleteClientReq( TInt aStatus )
+    {
+    DP_SDA2("CPresencePluginPublisher::CompleteClientReq status %d ", aStatus);
+    iOperation = ENoOperation;
+    TRequestStatus* s = iClientStatus;
+    User::RequestComplete( s, aStatus );
+    DP_SDA("CPresencePluginPublisher::CompleteClientReq end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::DoCancel(  )
+    {
+    DP_SDA("CPresencePluginPublisher::DoCancel CANCEL");
+    iXdmUtils->Cancel();
+    iPublisher->Close();
+    iPublisher = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::RunL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::RunL(  )
+    {
+    DP_SDA("CPresencePluginPublisher::RunL");
+    TInt status = iStatus.Int();
+    DP_SDA2("CPresencePluginPublisher::RunL status %d", status );
+    if ( !status )
+        {
+        
+        if ( iOperation == ESubscribeOwn )
+            {
+            DP_SDA("CPresencePluginPublisher::RunL Subscribe Own");
+            iSimpleId = iWatcher->SubscribeL(
+                iConnObs.CurrentSipPresentity8(),
+                NULL,  // aFilter <-> aPif
+                ETrue, EFalse );          
+            }
+        else if( iOperation == EPublishOwn )
+            {
+            DP_SDA("CPresencePluginPublisher::RunL MakePublishReqL");
+            MakePublishReqL();
+            }
+        }
+    else
+        {
+        DP_SDA("CPresencePluginPublisher::RunL complete");
+        CompleteXIMPReq( status );
+        }           
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginPublisher::RunError( TInt aError )
+    {
+    DP_SDA2("CPresencePluginPublisher::RunError %d",aError );
+    
+    CompleteXIMPReq( aError );  
+    return KErrNone;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CPresencePluginPublisher::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions )
+    {
+    DP_SDA("CPresencePluginPublisher::GetInterface");
+    
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        MProtocolPresencePublishing* myIf = this;
+        return myIf;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }  
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::GetInterface()
+// ---------------------------------------------------------------------------
+//
+const TAny* CPresencePluginPublisher::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    DP_SDA("CPresencePluginPublisher::GetInterface 2 ");
+    
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        // caller wants this interface
+        const MProtocolPresencePublishing* myIf = this;
+        return myIf;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }  
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::GetInterfaceId()
+// ---------------------------------------------------------------------------
+//
+TInt32 CPresencePluginPublisher::GetInterfaceId() const
+    {
+    DP_SDA("CPresencePluginPublisher::GetInterfaceId");
+    
+    return MProtocolPresencePublishing::KInterfaceId;
+    }
+       
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::InitializeSimpleDocumentL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::InitializeSimpleDocumentL( )
+    {
+    _LIT8 ( KCipidNS, "urn:ietf:params:xml:ns:pidf:cipid" );
+    _LIT8 ( KCipidCP, "c" );
+    if ( iDocument )
+        {
+        DP_SDA("CPresencePluginPublisher:: deletedocument");
+        iDocument->Close();
+        iDocument = NULL;
+        iDocument = TSimpleFactory::NewDocumentL();
+        }
+    else
+        {
+        DP_SDA("CPresencePluginPublisher:: create document");
+        iDocument = TSimpleFactory::NewDocumentL();
+        }
+    iDocument->AddNamespaceL( KSimplePDM, KSimpleNsPDM );
+    iDocument->AddNamespaceL( KSimpleRPID, KSimpleNsRPID );
+    iDocument->AddNamespaceL( KCipidCP, KCipidNS );
+    }      
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::AddSimpleDocumentPersL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::AddSimpleDocumentPersL(
+    const MPersonPresenceInfo* aInfo )
+    {
+    TInt tupleId = iConnObs.GetTupleId();
+    
+    DP_SDA2("AddSimpleDocumentPersL tuple id get: %d", tupleId);
+    if ( tupleId == 0 )
+        {
+        DP_SDA("AddSimpleDocumentPersL tuple generate");
+        tupleId = iPresenceData->GenerateTupleId();
+        iConnObs.SetTupleId(tupleId);
+        }
+   
+    iPresenceData->AddPrPersToSimpleDocumentL(
+        aInfo, *iDocument, iConnObs.CurrentSipPresentity8(), tupleId ); 
+    }
+          
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::StopPublishL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::StopPublishL( TRequestStatus& aStatus )
+    {
+    DP_SDA2("StopPublish - begin : iPublished= %d ",(TInt) iPublished);
+    
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    
+    TInt err1( 0 );
+    TInt err2( 0 );
+    
+    // get stored document id if available
+    HBufC8* oldDocumentId = HBufC8::NewLC( KBufSize255 );
+    TPtr8 oldDocumentIdPtr( oldDocumentId->Des() );
+    TRAP( err1, iPresenceData->ReadDocumentIdL( 
+            iConnObs.ServiceId(), oldDocumentIdPtr ) );
+    
+    if ( iConnObs.GetStopPublishState() && iPublished )
+        {
+        DP_SDA("CPresencePluginPublisher::StopPublish really Stop");
+        if ( !err1 )
+            {
+            TRAP( err2, iPublisher->StopPublishL( oldDocumentIdPtr ) );
+            }
+        else 
+            {
+            // if stored document id is not available try with this
+            TRAP( err2, iPublisher->StopPublishL( iConnObs.GetETag() ) );
+            }
+        DP_SDA2("StopPublish iPublisher->StopPublishL : error = %d ", err2 );
+        if ( KErrNone != err2 )
+            {            
+            if( iPublisher )
+                {
+                DP_SDA("StopPublish delete and recreate publisher");
+                iPublisher->Close();
+                iPublisher = NULL;
+                DP_SDA("StopPublish really Stop try again 1 ");
+                iPublisher =
+                	TSimpleFactory::NewPublisherL( iConnection, *this ); 
+                DP_SDA("StopPublish really Stop try again 2 ");
+                err2 = KErrGeneral;
+                TRAP( err2, iPublisher->StopPublishL( iConnObs.GetETag() ););
+                DP_SDA2("StopPublishL 2nd try : error = %d ", err2 );
+                if ( KErrNone != err2 )
+                    {
+                    DP_SDA("StopPublish TWO TIME Error, last try without tag ");
+                    TRAP( err2, iPublisher->StopPublishL(); );
+                    DP_SDA2("StopPublishL 3rd try : error = %d ", err2 );
+                    }
+                }
+            }
+        iConnObs.SetStopPublishState( ETrue );
+        iPublished = EFalse;
+        }
+    CleanupStack::PopAndDestroy( oldDocumentId );
+    
+    DP_SDA("CPresencePluginPublisher::StopPublish- end");        
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::Published()
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginPublisher::Published()
+    {
+    return iPublished;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::MakePublishReqL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::MakePublishReqL( )
+    {
+    DP_SDA("CPresencePluginPublisher::MakePublishReqL");
+    
+        DP_SDA(" -> MakePublishReqL, check for old doc id");       
+        HBufC8* oldDocumentId = HBufC8::NewLC( KBufSize255 );
+        TPtr8 oldDocumentIdPtr( oldDocumentId->Des() );
+        TRAPD( error, iPresenceData->ReadDocumentIdL( 
+            iConnObs.ServiceId(), oldDocumentIdPtr ) );
+    if ( !iPublished )
+        {
+        DP_SDA("CPresencePluginPublisher::MakePublishReqL 1");       
+        CreatePublisherL();
+        
+        DP_SDA2(" -> MakePublishReqL, doc id error: %d", error );
+        if ( !error )
+            {
+            DP_SDA(" -> MakePublishReqL, publish with old id");       
+            iSimpleId = iPublisher->ContinuePublishL( 
+                *iDocument, ETrue, oldDocumentIdPtr );
+            }
+        else
+            {
+            DP_SDA(" -> MakePublishReqL, publish with new id");       
+            iSimpleId = iPublisher->StartPublishL( *iDocument, ETrue );    
+            }
+        }
+    else
+        {
+        DP_SDA("CPresencePluginPublisher::MakePublishReqL 2");
+        CreatePublisherL();
+        DP_SDA("CPresencePluginPublisher::MakePublishReqL Continue Publish");
+        if ( !error )
+            {
+            DP_SDA(" -> MakePublishReqL, publish with stored id");
+            iSimpleId = iPublisher->ContinuePublishL( 
+                *iDocument ,ETrue, oldDocumentIdPtr );
+            }
+        else
+            {
+            DP_SDA(" -> MakePublishReqL, stored id not found" );
+            DP_SDA(", publish with old id");
+            iSimpleId = iPublisher->ContinuePublishL( 
+                            *iDocument ,ETrue, iConnObs.GetETag() );
+            }
+		DP_SDA("CPresencePluginPublisher::MakePublishReqL modifyed");
+        }
+    CleanupStack::PopAndDestroy( oldDocumentId );
+    DP_SDA("CPresencePluginPublisher::MakePublishReqL end");     
+    } 
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::StartXdmOperationL(
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginPublisher::StartXdmOperationL");
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrNotReady ) );
+    iXIMPId = aReqId;
+    if ( !iXdmUtils )
+        {
+        DP_SDA("StartXdmOperationL Initialize XDMUtils");
+        iXdmUtils = iConnObs.XdmUtilsL();
+        }
+
+    // Allways check those XDM files are ok / 
+    //publish seems to be jam if xdm not initialized ? 
+    iXdmUtils->InitializeXdmL( iStatus ); 
+    SetActive();
+    DP_SDA("CPresencePluginPublisher::StartXdmOperationL end");     
+    }
+                 
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::WinfoNotificationL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::WinfoNotificationL(
+    MSimpleWinfo& aWinfo )
+    {
+    DP_SDA("CPresencePluginPublisher::WinfoNotificationL");
+   
+    RPointerArray<MSimpleElement> elems;
+    CleanupClosePushL( elems );         // << elems
+    TInt err = aWinfo.SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    TInt count = elems.Count();
+    
+    DP_SDA2("WinfoNotificationL elems count%d", count);
+
+    __ASSERT_ALWAYS( count == 1, User::Leave( KErrCorrupt ) );
+
+    using namespace NPresencePlugin::NPresence;
+
+    const TDesC8* stateVal = aWinfo.AttrValue( KPresenceState8 );
+    
+    if ( stateVal && !stateVal->CompareF( KPresenceFull8 )) //state full
+        {
+        // full winfo-list is received  (New empty list )
+        DP_SDA("CPresencePluginPublisher::WinfoNotificationL full list found");
+        DeleteWatchers();
+        }
+	else
+        {
+		DP_SDA("PluginPublisher: state != full");
+		// Test if state is partitial
+		if ( stateVal && !stateVal->CompareF( KPresencePartial8 ))
+			{
+			DP_SDA("PluginPublisher: state = partitial");	
+			}
+		}
+
+    MSimpleElement* elem = elems[0];
+    TPtrC8 p8 = elem->LocalName();
+    err = p8.CompareF( KPresenceWatcherList8 );
+    DP_SDA2("WinfoNotificationL KPresenceWatcherList8 err %d", err);
+    User::LeaveIfError( err );
+    DP_SDA("WinfoNotificationL KPresenceWatcherList8 continue");
+    
+    //Get elemets from document
+    err = elem->SimpleElementsL( elems );
+    User::LeaveIfError( err );
+    DP_SDA2("WinfoNotificationL get elems err %d", err);
+    //Make collect from active watchers
+    CollectWatchersL( elems );
+    
+    CDesCArrayFlat* watchers = MakeCurrentWatcherListLC();// << watchers
+    MXIMPObjectCollection *actives =
+        iConnObs.ObjectFactory().NewObjectCollectionLC();// << actives       
+
+    // Create MXIMPPresenceWatcherInfo entities for
+    // all active watchers and add to actives.
+    TInt wCount = watchers->MdcaCount();
+    DP_SDA2("CPresencePluginPublisher::WinfoNotificationL wCount %d", wCount);
+    for ( TInt j = 0; j < wCount; j++ )
+        {       
+        // create MXIMPPresenceWatcherInfo object
+        MPresenceWatcherInfo* wInfo =
+            iConnObs.PresenceObjectFactoryOwn().
+                NewPresenceWatcherInfoLC();// << wInfo
+
+        MXIMPIdentity* identity =
+        	iConnObs.ObjectFactory().NewIdentityLC();// << identity
+         
+        identity->SetIdentityL( watchers->MdcaPoint( j ) );                
+        wInfo->SetWatcherIdL( identity );
+        CleanupStack::Pop( );// >> identity
+
+        wInfo->SetWatcherDisplayNameL( watchers->MdcaPoint( j ) );
+        wInfo->SetWatcherTypeL( MPresenceWatcherInfo::EPresenceSubscriber );
+
+        actives->AddObjectL( wInfo );
+        CleanupStack::Pop( );                           // >> wInfo
+        }
+
+    MProtocolPresencePublishingDataHost& publishHost =
+         iConnObs.Host()->ProtocolPresenceDataHost().PublishingDataHost();
+
+    publishHost.HandlePresenceWatcherListL( actives );
+   
+    CleanupStack::Pop();                  // >> actives      
+    CleanupStack::PopAndDestroy( watchers );        // >> watchers
+   
+    CleanupStack::PopAndDestroy( &elems );          // >> elems
+    DP_SDA("CPresencePluginPublisher::WinfoNotificationL end");      
+    }
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::WinfoTerminatedL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::WinfoTerminatedL( TInt aReason )
+    {
+    DP_SDA("CPresencePluginPublisher::WinfoTerminatedL - begin");      
+    
+    // call SetPresenceWatcherListDataSubscriptionStateL  
+    iSubscribed = EFalse;    
+
+    MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();    
+    MProtocolPresencePublishingDataHost& publishHost =
+        iConnObs.Host()->ProtocolPresenceDataHost().PublishingDataHost();
+    MXIMPDataSubscriptionState *state =
+        myFactory.NewDataSubscriptionStateLC();
+        
+    MXIMPStatus* status = myFactory.NewStatusLC();
+    state->SetSubscriptionStateL( 
+        MXIMPDataSubscriptionState::ESubscriptionInactive );
+        
+    state->SetDataStateL( MXIMPDataSubscriptionState::EDataUnavailable );
+    status->SetResultCode( aReason );
+    publishHost.SetPresenceWatcherListDataSubscriptionStateL( state, status );
+    CleanupStack::Pop( 2 ); // status, state  
+    DP_SDA("CPresencePluginPublisher::WinfoTerminatedL - end");
+    }  
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::NewETagL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::NewETagL( const TDesC8& aVal )
+    {
+    DP_SDA("CPresencePluginPublisher::NewETagL");        
+    // Set ETag value 
+    DP_SDA("CPresencePluginPublisher::NewETagL Set ETag");
+    TBuf8<KBufSize255> buf;
+    buf.Copy( aVal );
+    iConnObs.SetETag( buf );
+    buf.Zero(); 
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::MakeCurrentWatcherListLC
+// ---------------------------------------------------------------------------
+//
+CDesCArrayFlat* CPresencePluginPublisher::MakeCurrentWatcherListLC()
+    {
+    DP_SDA("CPresencePluginPublisher::MakeCurrentWatcherListLC - begin");        
+    // No one should be added more than once
+    const TInt KMyGran = 10;    
+    CDesCArrayFlat* watchers = new (ELeave) CDesCArrayFlat( KMyGran );
+    CleanupStack::PushL( watchers );      // << watchers            
+       
+    // add user only once here.
+    TDblQueIter<CPresencePluginWatcherInfo> rIter( iWatcherList );
+    rIter.SetToFirst();
+    
+    while ( rIter )
+        {
+        CPresencePluginWatcherInfo* w = rIter;
+        rIter++;
+        
+        TInt dummy = 0;
+        // Zero -> Found
+        if ( watchers->Find( w->SipId(), dummy ))
+            {            
+            watchers->AppendL( w->SipId() );
+            }                    
+        }
+    
+    DP_SDA("CPresencePluginPublisher::MakeCurrentWatcherListLC - end");        
+    return watchers;    
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::CollectWatchers
+// --------------------------------------------------------------------------- 
+//
+void CPresencePluginPublisher::CollectWatchersL(  
+	RPointerArray<MSimpleElement>& aElems )
+	{
+	using namespace NPresencePlugin::NPresence;
+	HBufC* nodeContent = NULL;
+	
+	TInt count = aElems.Count();
+	DP_SDA2("CPresencePluginPublisher::CollectWatchers elem count %d",count);
+		
+	for ( TInt i = 0; i < count; i++ )
+		{
+		MSimpleElement* elem = aElems[i];
+		TPtrC8 p8( elem->LocalName());
+
+		if (!( p8.CompareF( KPresenceWatcher8 )))
+			{
+			DP_SDA("CPresencePluginPublisher::CollectWatchers watchers found");
+			const TDesC8* pp8 = elem->AttrValue( KPresenceStatus8 );
+			// Active wathers here
+			if ( pp8 && !pp8->CompareF( KPresenceActive8 ))
+    			{
+    			DP_SDA("CollectWatchers: ACTIVE found");	
+				// save id since there may be multiple subscriptions 
+				// from a single watcher SIP identity.
+				const TDesC8* pId8 = elem->AttrValue( KPresenceId8 );
+                                             
+				// Build collection of grant requests
+				// Find the child node containing the SIP entity
+				nodeContent = elem->ContentUnicodeL();
+				CleanupStack::PushL( nodeContent );// << nodeContent
+                    
+				AddWatcherIfNotExistsL( 
+				    pId8 ? *pId8 : KNullDesC8, nodeContent->Des() );
+				
+				CleanupStack::PopAndDestroy( nodeContent ); //>> nodeContent
+				}
+			// Terminated wathers here
+			else if ( pp8 && !pp8->CompareF( KPresenceTerminated8 ))
+    			{
+			    DP_SDA("CollectWatchers: Terminated");
+				const TDesC8* pId8 = elem->AttrValue( KPresenceId8 );
+				                
+				// Remove terminated from iWatcherList
+				nodeContent = elem->ContentUnicodeL();
+				CleanupStack::PushL( nodeContent );// << nodeContent                
+	    
+				RemoveWatcherIfExists( 
+    				pId8 ? *pId8 : KNullDesC8, nodeContent->Des() );                     
+    
+				CleanupStack::PopAndDestroy( nodeContent );// >> nodeContent
+        		}
+    		}
+		}
+	} 
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::CreatePublisherL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginPublisher::CreatePublisherL()
+    {
+    DP_SDA("CPresencePluginPublisher::CreatePublisherL");
+    if( iPublisher )
+        {
+        DP_SDA("CPresencePluginPublisher::CreatePublisherL create");
+        iPublisher->Close();
+        iPublisher = NULL; 
+        iPublisher = TSimpleFactory::NewPublisherL( iConnection, *this );
+        }
+    DP_SDA("CPresencePluginPublisher::CreatePublisherL end");
+    }
+	
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::StoreOwnStatusToCacheL
+// --------------------------------------------------------------------------- 
+//
+void CPresencePluginPublisher::StoreOwnStatusToCacheL()
+	{	
+	DP_SDA("CPresencePluginPublisher::StoreOwnStatusToCacheL" );
+	
+	using namespace NPresencePlugin::NPresence;
+    using namespace NPresencePlugin::NPresenceStates;
+    using namespace NPresenceInfo::NFieldType;
+	
+    DP_SDA(" CPresencePluginPublisher -> convert uri" );
+    HBufC* entityUri = 
+        CnvUtfConverter::ConvertToUnicodeFromUtf8L( 
+            *iDocument->EntityURI() );
+    CleanupStack::PushL( entityUri );
+
+    DP_SDA(" CPresencePluginPublisher -> strip prefix" );
+    HBufC16* prefixStripped = iPresenceData->RemovePrefixLC( 
+        *entityUri );
+             
+    DP_SDA(" CPresencePluginPublisher -> fetch simple elements" );
+    RPointerArray<MSimpleElement> simpleElements;
+    CleanupClosePushL( simpleElements );
+    DP_SDA(" CPresencePluginPublisher -> do fetch simple elements" );
+    TInt error = iDocument->SimpleElementsL( simpleElements );    
+    DP_SDA2(" CPresencePluginPublisher -> fetch error: %d", error );
+    User::LeaveIfError( error );
+    TBool handled = EFalse;
+    DP_SDA2(" CPresencePluginPublisher -> element count: %d", 
+        simpleElements.Count() );
+    
+    MSimpleElement* basicSimpleElem(NULL);
+    MSimpleElement* noteSimpleElem(NULL);
+    
+    TBuf<KBufSize100> activitiesContentBuf;
+    TBool activitiesHandled( EFalse );
+    
+    for( TInt index = 0 ; index < simpleElements.Count() ; index++ )
+        {
+        DP_SDA(" CPresencePluginPublisher -> check for person element" );
+        // Check for person element
+        if (!( simpleElements[index]->LocalName().CompareF( KPresencePerson8 )) ||
+            !( simpleElements[index]->LocalName().CompareF( KPresenceTuple8 )) )
+            {
+            DP_SDA(" CPresencePluginPublisher -> person/tuple element found" );
+            RPointerArray<MSimpleElement> personSubElems;
+            CleanupClosePushL( personSubElems );
+            simpleElements[index]->SimpleElementsL( personSubElems );
+            DP_SDA2(" CPresencePluginPublisher -> person/tuple sub elemen count: %d", 
+                personSubElems.Count() );
+
+            for ( TInt j = 0; j < personSubElems.Count(); j++ )
+                {
+                DP_SDA(" CPresencePluginPublisher -> check for status/activities element");
+                if ( !personSubElems[j]->LocalName().CompareF( KPresenceStatus8 ) ||
+                     !personSubElems[j]->LocalName().CompareF( KPresenceActivities8 ))
+                    {
+         	        DP_SDA(" CPresencePluginPublisher -> status/activities element found");
+         	        //Get childs
+         	        RPointerArray<MSimpleElement> basicElems;
+         	        CleanupClosePushL( basicElems );
+         	        
+		            personSubElems[j]->SimpleElementsL( basicElems );
+                    DP_SDA2(" CPresencePluginPublisher -> child elem count: %d", 
+                        basicElems.Count() );
+		            for ( TInt k = 0; k < basicElems.Count(); k++ )
+		                {
+		                DP_SDA(" CPresencePluginPublisher -> check child elems");
+		                if ( !basicElems[k]->LocalName().CompareF( 
+		                		KPresenceBasic8 ))
+		                    {
+		                    DP_SDA(" -> basic element found");
+		                    basicSimpleElem = basicElems[k];
+		                    }
+                 	    else if ( basicSimpleElem && 
+                 	        !basicElems[k]->LocalName().CompareF( KPresenceActivities8 ) )
+                 	        {
+                 	        DP_SDA(" -> activities found from basic elem");
+                 	        RPointerArray<MSimpleElement> activitiesElems;
+                 	        CleanupClosePushL( activitiesElems );
+    			            
+    			            DP_SDA(" -> get activities");
+    			            basicElems[k]->SimpleElementsL( activitiesElems );
+    			            DP_SDA2(" -> activities count: %d", 
+    			                activitiesElems.Count() );
+                            if ( activitiesElems.Count() )
+                                {
+                                DP_SDA(" -> get activities, multiple, use last");
+        			            TInt lastActiviesIndex = 
+        			                ( activitiesElems.Count() - 1 );
+    			                activitiesContentBuf.Copy( 
+    			                    activitiesElems[lastActiviesIndex]->LocalName() );
+    			                activitiesHandled = ETrue;
+    			                DP_SDA(" -> activity elem ok");
+                                }
+    			            CleanupStack::PopAndDestroy( &activitiesElems );    
+                 	        }
+                 	    else if ( basicSimpleElem && 
+                 	            !personSubElems[j]->LocalName().CompareF( KPresenceActivities8 ) )
+                 	        {
+                 	        DP_SDA(" -> activities found from person elem");    
+                 	        RPointerArray<MSimpleElement> activitiesElems;
+                 	        CleanupClosePushL( activitiesElems );
+    			            
+    			            DP_SDA(" -> get activities");
+    			            personSubElems[j]->SimpleElementsL( activitiesElems );
+    			            DP_SDA2(" -> activities count: %d", 
+    			                activitiesElems.Count() );
+                            if ( activitiesElems.Count() )
+                                {
+                                DP_SDA(" -> get activities, multiple, use last");
+        			            TInt lastActiviesIndex = 
+        			                ( activitiesElems.Count() - 1 );
+    			                activitiesContentBuf.Copy( 
+    			                    activitiesElems[lastActiviesIndex]->LocalName() );
+    			                activitiesHandled = ETrue;
+    			                DP_SDA2(" -> activities len: %d", 
+    			                    activitiesContentBuf.Length() );
+    			                DP_SDA(" -> activity elem ok");
+                                }
+    			            CleanupStack::PopAndDestroy( &activitiesElems );                     	                     	     
+                 	        }
+		                } 
+		            CleanupStack::PopAndDestroy( &basicElems );
+         	        }
+                }
+            CleanupStack::PopAndDestroy( &personSubElems );
+            }
+ 	    else if ( !simpleElements[index]->LocalName().CompareF( KPresenceNote8 ))
+ 	        {
+ 	        DP_SDA(" CPresencePluginPublisher -> note element found" );
+            noteSimpleElem = simpleElements[index];    
+ 	        }
+        }
+    DP_SDA(" CPresencePluginPublisher -> elements handled");
+    __ASSERT_ALWAYS( basicSimpleElem, User::Leave( KErrCorrupt ) );
+    
+    if ( !activitiesHandled )
+        {
+        DP_SDA(" -> activities not handled, set unknown");
+        activitiesContentBuf.Copy( KPresenceUnknow );
+        }
+    
+    HBufC* nodeContent = basicSimpleElem->ContentUnicodeL();
+    CleanupStack::PushL( nodeContent );
+    
+    HBufC* noteContent = NULL;
+    if ( noteSimpleElem )
+        {
+        noteContent = noteSimpleElem->ContentUnicodeL();
+        CleanupStack::PushL( noteContent );
+        }
+    else
+        {
+        noteContent = KNullDesC().AllocLC();
+        }
+    
+    MPresenceBuddyInfo2::TAvailabilityValues cacheAvailability =
+        MPresenceBuddyInfo2::ENotAvailable;
+    NPresenceInfo::TAvailabilityValues ximpAvailability =
+        NPresenceInfo::ENotAvailable;
+    
+    HBufC* extendedCacheAvailability = HBufC::NewLC( KBufSize255 );
+    TPtr extendedCacheAvailabilityPtr( extendedCacheAvailability->Des() );
+    if ( nodeContent )
+        {
+        handled = ResolveOwnCacheValues( *nodeContent, 
+            activitiesContentBuf, cacheAvailability, 
+            extendedCacheAvailabilityPtr, ximpAvailability );
+        }
+
+    __ASSERT_ALWAYS( handled, User::Leave( KErrCorrupt ));
+
+    DP_SDA(" CPresencePluginPublisher -> write to cache" );
+    
+    DP_SDA2(" CPresencePluginPublisher -> availability: %d", 
+        cacheAvailability );
+    DP_SDA2(" CPresencePluginPublisher -> ext availability len: %d", 
+        extendedCacheAvailabilityPtr.Length() );        
+
+    iPresenceData->WriteStatusToCacheL( 
+        *prefixStripped, cacheAvailability, 
+        extendedCacheAvailabilityPtr, *noteContent );           
+             
+    // Store publish variables for republish
+    iPresenceData->StorePresenceOwnPresenceL(
+        iConnObs.ServiceId(), ximpAvailability, *noteContent );
+
+    CleanupStack::PopAndDestroy( extendedCacheAvailability );    
+    CleanupStack::PopAndDestroy( noteContent );        
+    CleanupStack::PopAndDestroy( nodeContent );        
+
+    DP_SDA(" CPresencePluginPublisher -> attributes handled" );    
+    CleanupStack::PopAndDestroy( &simpleElements );
+        
+    DP_SDA(" CPresencePluginPublisher -> write to cache ok, cleanup" );
+    
+    // prefixStripped, entityUri
+    CleanupStack::PopAndDestroy( 2 );	
+    DP_SDA("CPresencePluginPublisher::StoreOwnStatusToCacheL out" );
+	}
+
+// ---------------------------------------------------------------------------
+// CPresencePluginPublisher::ResolveOwnCacheValues
+// --------------------------------------------------------------------------- 
+//
+TBool CPresencePluginPublisher::ResolveOwnCacheValues( 
+    const TDesC& aUnicodeContent,
+    const TDesC& aActivities, 
+    MPresenceBuddyInfo2::TAvailabilityValues& aCacheAvailability,
+    TPtr& aExtendedCacheAvailability,
+    NPresenceInfo::TAvailabilityValues& aXimpApiAvailability )
+    {
+    DP_SDA("CPresencePluginPublisher::ResolveOwnCacheValuesL" );
+    using namespace NPresencePlugin::NPresence;
+    using namespace NPresencePlugin::NPresenceStates;
+    using namespace NPresenceInfo::NFieldType;
+    
+    TBool handled = EFalse;
+    if ( !aUnicodeContent.CompareF( KPresenceOpen ) &&
+        !aActivities.CompareF ( KPresenceBusy ) )
+        {
+        DP_SDA(" CPresencePluginPublisher -> busy");
+        aCacheAvailability = MPresenceBuddyInfo2::EBusy;
+        aExtendedCacheAvailability.Copy( KDndState() );
+        aXimpApiAvailability = NPresenceInfo::EBusy;
+        handled = ETrue;
+        }
+    // On-The-Phone case
+    else if ( !aUnicodeContent.CompareF( KPresenceOpen ) &&
+        !aActivities.CompareF ( KPresenceOnThePhone ) )
+        {
+        DP_SDA(" CPresencePluginPublisher ->  on-the-phone");
+        aCacheAvailability = MPresenceBuddyInfo2::EBusy;
+        aExtendedCacheAvailability.Copy( KOnPhoneState() );
+        aXimpApiAvailability = NPresenceInfo::EOnPhone;
+        handled = ETrue;
+        }
+    //Away case  
+    else if ( !aUnicodeContent.CompareF( KPresenceOpen ) &&
+        !aActivities.CompareF ( KPresenceAway ) )
+        {
+        DP_SDA(" CPresencePluginPublisher -> away");
+        aCacheAvailability = MPresenceBuddyInfo2::EBusy;
+        aExtendedCacheAvailability.Copy( KAwayState() );
+        aXimpApiAvailability = NPresenceInfo::EAway;
+        handled = ETrue;
+        }
+    //Dnd case  
+    else if ( !aUnicodeContent.CompareF( KPresenceOpen ) &&
+        !aActivities.CompareF ( KPresenceDoNotDisturb ) )
+        {
+        DP_SDA(" CPresencePluginPublisher -> dnd");
+        aCacheAvailability = MPresenceBuddyInfo2::EBusy;
+        aExtendedCacheAvailability.Copy( KDndState() );
+        aXimpApiAvailability = NPresenceInfo::EDoNotDisturb;
+        handled = ETrue;
+        }        
+    // Unknown open
+    else if ( !aUnicodeContent.CompareF( KPresenceOpen ) &&
+        !aActivities.CompareF ( KPresenceUnknow ) )
+        {
+        DP_SDA(" CPresencePluginPublisher -> open");
+        aCacheAvailability = MPresenceBuddyInfo2::EAvailable;
+        aExtendedCacheAvailability.Copy( KDefaultAvailableStatus() );
+        aXimpApiAvailability = NPresenceInfo::EAvailable;
+        handled = ETrue;
+        }
+    // available open
+    else if ( !aUnicodeContent.CompareF( KPresenceOpen ) &&
+        !aActivities.CompareF ( KPresenceAvailable ) )
+        {
+        DP_SDA(" CPresencePluginPublisher -> open");
+        aCacheAvailability = MPresenceBuddyInfo2::EAvailable;
+        aExtendedCacheAvailability.Copy( KDefaultAvailableStatus() );
+        aXimpApiAvailability = NPresenceInfo::EAvailable;
+        handled = ETrue;
+        } 
+    // available open
+    else if ( !aUnicodeContent.CompareF( KPresenceOpen ) &&
+        !aActivities.CompareF ( KPresenceOpen ) )
+        {
+        DP_SDA(" CPresencePluginPublisher -> open/open");
+        aCacheAvailability = MPresenceBuddyInfo2::EAvailable;
+        aExtendedCacheAvailability.Copy( KDefaultAvailableStatus() );
+        aXimpApiAvailability = NPresenceInfo::EAvailable;
+        handled = ETrue;
+        }                
+    //Unknown closed
+    else if ( !aUnicodeContent.CompareF( KPresenceClosed ) &&
+        !aActivities.CompareF ( KPresenceUnknow ) )
+        {
+        DP_SDA(" CPresencePluginPublisher -> closed");
+        aCacheAvailability = MPresenceBuddyInfo2::ENotAvailable;
+        aExtendedCacheAvailability.Copy( KInvisibleState() );
+        aXimpApiAvailability = NPresenceInfo::ENotAvailable;
+        handled = ETrue;
+        }
+    //All other states are closed
+    else
+        {
+        DP_SDA(" CPresencePluginPublisher -> else closed");
+        aCacheAvailability = MPresenceBuddyInfo2::ENotAvailable;
+        aExtendedCacheAvailability.Copy( KInvisibleState() );
+        aXimpApiAvailability = NPresenceInfo::ENotAvailable;
+        handled = ETrue;
+        }
+    DP_SDA2("CPresencePluginPublisher::ResolveOwnCacheValuesL out, ret: %d", 
+        handled );    
+    return handled;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginsession.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,498 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <e32std.h>
+#include <ximpserviceinfo.h> //For MXIMPServiceInfo
+#include <ximpprotocolconnectionhost.h> //Handle command
+#include <msimpleconnectionobserver.h>//Connection callback methods
+#include <simplefactory.h> //create instances to abstract class
+#include <msimpleconnection.h> //Part of Registration API from SIMPLE engine
+#include <msimpleconnectionobserver.h>
+#include <pressettingsapi.h> //for TPresSettingsSet
+#include <XdmSettingsApi.h>
+#include <spsettings.h>
+#include <spentry.h>
+#include <spproperty.h>
+#include <spdefinitions.h>
+
+#include "presencepluginxdmutils.h"
+#include "presencepluginsession.h"
+#include "mpresencepluginconnectionobs.h" 
+#include "presencepluginauthorization.h"
+#include "presenceplugindata.h"
+
+// ======== MEMBER FUNCTIONS ========
+     
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::CPresencePluginSession()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginSession::CPresencePluginSession( 
+    MPresencePluginConnectionObs& aObs )
+    : CActive( CActive::EPriorityStandard ),iObs(aObs),
+    iType( MPresencePluginConnectionObs::ENoReq ),iSipConnected( EFalse ),
+    iXdmConnected( EFalse ), iXdmLocalMode( EFalse ), iOperation( ENoOperation ),
+    iServiceId( KErrNotFound )
+    {
+    CActiveScheduler::Add(this);
+    }
+  
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::ConstructL()
+// ---------------------------------------------------------------------------
+//  
+void CPresencePluginSession::ConstructL( const MXIMPServiceInfo& aService )
+    {
+    DP_SDA2("CPresencePluginSession::ConstructL: service id: %d", 
+        aService.IapId() );
+
+    CSPSettings* spSettings = CSPSettings::NewL();
+    CleanupStack::PushL( spSettings );
+    
+    CSPProperty* property = CSPProperty::NewLC();
+    spSettings->FindPropertyL( aService.IapId(),
+                                ESubPropertyPresenceSettingsId,
+                                *property );    
+    if ( property )
+        {
+        property->GetValue( iPresSettingId );
+        }
+        
+    CleanupStack::PopAndDestroy( property );        
+    CleanupStack::PopAndDestroy( spSettings );
+
+    DP_SDA2("PluginSession::ConstructL iPresSettingId %d",iPresSettingId );
+    __ASSERT_ALWAYS( iPresSettingId > 0, User::Leave( KErrArgument ) );
+    iServiceId = aService.IapId();
+    
+    //Create connection
+    iConnection = TSimpleFactory::NewConnectionL( *this, aService.IapId() );
+    
+    //Check here is xdm settings ok
+    CheckXDMSettingsL( aService.IapId() );
+    
+    DP_SDA("CPresencePluginSession::ConstructL end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::NewL()
+// ---------------------------------------------------------------------------
+//  
+CPresencePluginSession* CPresencePluginSession::NewL( 
+    const MXIMPServiceInfo& aService,
+    MPresencePluginConnectionObs& aObs )
+    {
+    DP_SDA("CPresencePluginSession::NewL");
+    CPresencePluginSession* self =
+        new( ELeave ) CPresencePluginSession( aObs );
+    CleanupStack::PushL( self );
+    self->ConstructL( aService );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::~CPresencePluginSession()
+// ---------------------------------------------------------------------------
+//  
+CPresencePluginSession::~CPresencePluginSession()
+    {
+    DP_SDA("CPresencePluginSession::~CPresencePluginSession");
+
+    delete iUserId8;
+    delete iDomain;
+    if ( iConnection )
+        {
+        iConnection->Close();        
+        }    
+    
+    DP_SDA("~CPresencePluginSession iXdmUtils");
+    delete iXdmUtils;
+    iXdmUtils = NULL;
+    DP_SDA("CPresencePluginSession::~CPresencePluginSession end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::SimpleConnection()
+// ---------------------------------------------------------------------------
+//
+TInt32 CPresencePluginSession::GetPresenceSetId( ) const
+    {
+    return iPresSettingId;            
+    }
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::SimpleConnection()
+// ---------------------------------------------------------------------------
+//
+MSimpleConnection* CPresencePluginSession::SimpleConnection( )
+    {
+    return iConnection;            
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::XdmSettingsId()
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginSession::XdmSettingsId( )
+    {
+    DP_SDA("CPresencePluginSession::XdmSettingsId");
+    return iXdmSetting;            
+    } 
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::CurrentDomain()
+// ---------------------------------------------------------------------------
+//
+TPtrC16 CPresencePluginSession::CurrentDomain( )
+    {
+    return iDomain ? iDomain->Des() : TPtrC16();
+    }    
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::IsXdmLocalmode()
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginSession::IsXdmLocalmode()
+	{
+	DP_SDA("CPresencePluginSession::IsXdmLocalmode");
+	return iXdmLocalMode;  
+	}
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::OpenSessionL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginSession::OpenSessionL()
+    {
+    DP_SDA("CPresencePluginSession::OpenSessionL");
+    //Check connection status
+    MSimpleConnection::TSimpleState connectionStatus =
+    	iConnection->ConnectionStatus();
+    DP_SDA2("OpenSessionL Connection Status %d", connectionStatus);
+    
+    if(  connectionStatus == MSimpleConnection::EInactive )
+        {
+        DP_SDA("CPresencePluginSession::OpenSessionL Not connected yet"); 
+        iSipConnected = EFalse;
+        // SIP register using by give presence setting id
+        iOpId = iConnection->LoginL( iPresSettingId );
+        iType = MPresencePluginConnectionObs::EOpenSess;
+        }
+    else if ( connectionStatus == MSimpleConnection::EActive )
+        {
+        DP_SDA(":OpenSessionL already connected complete");
+        iSipConnected = ETrue;
+        iType = MPresencePluginConnectionObs::EOpenSess;
+        RequestCompleteL( iOpId, KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::ConnectionStatusL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginSession::ConnectionStatusL( 
+    MSimpleConnection::TSimpleState aState )
+    {
+    DP_SDA2("CPresencePluginSession::ConnectionStatusL aState %d", aState );
+        
+    if ( (aState == MSimpleConnection::EInactive ) 
+        && iSipConnected )
+        {
+        DP_SDA("CPresencePluginSession::ConnectionStatusL EInactive");
+        
+        DP_SDA("CPresencePluginSession::ConnectionStatusL clear pres cache");
+        iObs.InternalPresenceAuthorization().PluginData().RemoveCacheL();
+        DP_SDA("CPresencePluginSession::ConnectionStatusL clear cache ok");
+        
+        // cancel all XDM request
+  		iObs.XdmUtilsL()->Cancel();
+  		//Set connection Terminated, terminate will be remove all client binds
+  		iObs.TerminateConnectionL();
+        iSipConnected = EFalse;
+        iXdmConnected = EFalse;
+        }
+    else if( ( aState == MSimpleConnection::EUnavailable && iSipConnected ) )
+		{
+		//Its seems that SIP connection is unavaible 
+		DP_SDA("CPresencePluginSession::ConnectionStatusL EUnavailable");
+		}
+
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::CloseConnection()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginSession::CloseConnection()
+    {
+    DP_SDA("CPresencePluginSession::CloseConnection");
+    if( iConnection )
+        {
+        DP_SDA("CPresencePluginSession::CloseConnection close called");
+        iConnection->Close();
+        iConnection = NULL;
+        }
+    DP_SDA("CPresencePluginSession::CloseConnection end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::ConnectionStatus()
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginSession::ConnectionStatus()
+    {
+    DP_SDA("CPresencePluginSession::ConnectionStatus");
+    TBool connection = EFalse;
+    if( iXdmConnected && iSipConnected )
+    	{
+    	connection = ETrue;
+    	}
+    return connection;
+    }
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::RequestCompleteL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginSession::RequestCompleteL( TInt /*aOpId*/, TInt aStatus )
+    {
+    DP_SDA("CPresencePluginSession::RequestCompleteL");
+    MPresencePluginConnectionObs::TReqType current = iType;
+     
+    if ( !aStatus  )
+       {
+       DP_SDA("CPresencePluginSession::RequestCompleteL SIP session is open");
+       iSipConnected = ETrue;
+       if( iXdmConnected )
+    	   {
+    	   DP_SDA("CPresencePluginSession::RequestCompleteL xdm IS OK");
+    	   iType = MPresencePluginConnectionObs::ENoReq;
+    	   iObs.CompleteReq( current, aStatus );
+    	   }
+       else
+    	   {
+    	   DP_SDA("CPresencePluginSession::RequestCompleteL Initialize XDM");
+    	   __ASSERT_DEBUG( !IsActive(), User::Leave( KErrNotReady ) );
+	       //Lets test XDM connection before complete
+		   iXdmUtils = CPresencePluginXdmUtils::NewL( 
+					iObs, iXdmSetting, iXdmLocalMode );
+		   
+		   iOperation =  EInitializeXdm;
+		   iXdmUtils->InitializeXdmL( iStatus );
+		   SetActive();
+    	   }
+	   
+       }
+    DP_SDA("CPresencePluginSession::RequestCompleteL END");
+    } 
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::CurrentSipPresentity()
+// ---------------------------------------------------------------------------
+//
+TPtrC8 CPresencePluginSession::CurrentSipPresentity()
+    {
+    DP_SDA("CPresencePluginSession::CurrentSipPresentity");
+    // Get from Simple engine
+    delete iUserId8;
+    iUserId8 = NULL;
+    TRAPD(err, iUserId8 = iConnection->CurrentSIPIdentityL().AllocL() )
+    if ( err == KErrNone )
+        {
+        return iUserId8 ? iUserId8->Des() : TPtrC8();
+        }
+    else
+        {
+        return iUserId8 ? KNullDesC8() : TPtrC8();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::CheckXDMSettings()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginSession::CheckXDMSettingsL( TUint aServiceId )
+	{
+	//Check if xdm settings not valid or there is text http://localhost
+	//in settings. If not valid or text found client will be save resourcelist
+	//to in phonememory
+    
+	TPresSettingsSet mySet;    
+    User::LeaveIfError( 
+            PresSettingsApi::SettingsSetL( iPresSettingId, mySet ));
+    iXdmSetting = mySet.iXDMSetting;
+    if( iDomain )
+        {
+        delete iDomain;
+        iDomain = NULL;
+        }
+    iDomain = mySet.iDomainSyntax.AllocL(); 
+    
+    DP_SDA(" -> CheckXDMSettings - store domain to service table");
+    // Service table 
+    CSPSettings* spsettings = CSPSettings::NewLC();
+    CSPProperty* property = CSPProperty::NewLC();
+    
+    DP_SDA(" -> CheckXDMSettings - spsettings and property created");
+    User::LeaveIfError( property->SetName( ESubPropertyPresenceAddrScheme ) );
+    DP_SDA(" -> CheckXDMSettings - property name set");
+    
+    TInt atPosInDomain = iDomain->Locate( '@' );
+    DP_SDA2(" -> CheckXDMSettings - @ position in domain: %d", atPosInDomain );
+    if ( KErrNotFound == atPosInDomain )
+        {
+        DP_SDA(" -> CheckXDMSettings - no @ in domain, set");
+        property->SetValue( iDomain->Des() );
+        }
+    else
+        {
+        DP_SDA(" -> CheckXDMSettings - @ found in domain, remove");
+        HBufC* formattedDomain = HBufC::NewLC( iDomain->Length() );    
+        TPtr formattedDomainPtr( formattedDomain->Des() );
+        formattedDomainPtr.Copy( iDomain->Mid( ( atPosInDomain + 1 ) ) );
+        property->SetValue( formattedDomainPtr );
+        CleanupStack::PopAndDestroy( formattedDomain );
+        }
+    DP_SDA(" -> CheckXDMSettings - property value set");
+    User::LeaveIfError( 
+        spsettings->AddOrUpdatePropertyL( aServiceId, *property ) );
+    DP_SDA(" -> CheckXDMSettings - property added or updated");
+    
+    CleanupStack::PopAndDestroy( property );
+    CleanupStack::PopAndDestroy( spsettings );    
+
+#ifdef _DEBUG    
+    DP_SDA2("XdmSettingsId xdmSetting id %d",iXdmSetting );    
+    DP_SDA2("CheckXDMSettings::XdmSettingsId domain %S",iDomain );   
+#endif
+    
+    //Continue check, add localhost to buf2
+    HBufC* buf2 = KLocalhost().AllocLC();
+    
+	//Get Uri from XDM settings 
+	HBufC* xcaproot = NULL;
+	
+	TRAPD( error, xcaproot =
+		TXdmSettingsApi::PropertyL( iXdmSetting, EXdmPropUri ) );
+	DP_SDA2("CheckXDMSettings Set localmode, err %d", error);
+
+	if( KErrNotFound != error && xcaproot )
+		{
+		//Compare buf2 to xcaproot
+		if ( !xcaproot->Compare( buf2->Des() ) )
+        	{
+        	DP_SDA("CheckXDMSettings Set localmode");
+        	iXdmLocalMode = ETrue;
+        	}
+        else
+        	{
+        	DP_SDA("CheckXDMSettings Set Normal Mode");
+        	iXdmLocalMode = EFalse;
+        	}
+		
+		DP_SDA("CheckXDMSettings PopAndDestroy buf2");
+		}
+	else
+		{
+		//It seems there is no valid XCAP settings, so we try localmode
+		//Shuld we create automaticaly XCAP localhost settings?
+		iXdmLocalMode = ETrue;
+		}
+	
+	DP_SDA("CheckXDMSettings PopAndDestroy xcaproot");
+	CleanupStack::PopAndDestroy( buf2 );
+	delete xcaproot;
+	}
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::XdmUtilsL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginXdmUtils* CPresencePluginSession::XdmUtilsL()
+	{
+	if ( !iXdmUtils )
+		{
+		DP_SDA("CPresencePluginSession::XdmUtilsL !iXdmUtils");                
+		iXdmUtils = CPresencePluginXdmUtils::NewL( 
+				iObs, iXdmSetting, iXdmLocalMode );
+		}
+	
+	return iXdmUtils;
+	}
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::ServiceId()
+// ---------------------------------------------------------------------------
+//
+TInt& CPresencePluginSession::ServiceId()
+    {
+    return iServiceId;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginSession::DoCancel(  )
+    {
+    DP_SDA("CPresencePluginSession::DoCancel CANCEL");
+    iXdmUtils->Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::RunL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginSession::RunL(  )
+    {
+    DP_SDA("CPresencePluginSession::RunL");
+    TInt status = iStatus.Int();
+    DP_SDA2("CPresencePluginSession::RunL status %d", status );
+    
+    if(  ( iOperation == EInitializeXdm ) && !status )
+    	{
+    	DP_SDA("CPresencePluginSession::RequestCompleteL connection ready");
+    	iXdmConnected = ETrue;
+        MPresencePluginConnectionObs::TReqType current = iType;
+        iType = MPresencePluginConnectionObs::ENoReq;
+        iObs.CompleteReq( current, status );
+    	}
+    else
+    	{
+    	DP_SDA("Connection FAIL terminated");
+    	iXdmConnected = EFalse;
+    	iSipConnected = EFalse;
+    	iType = MPresencePluginConnectionObs::ECloseSess;
+    	iObs.CompleteReq( iType, status );
+    	}
+
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginSession::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginSession::RunError( TInt /*aError*/ )
+    {
+    DP_SDA("CPresencePluginSession::RunError"); 
+    return KErrNone;
+    }
+
+ // End of file
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginutility.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <ximpidentity.h>
+#include "presencepluginutility.h"
+#include "presencelogger.h"
+
+// -----------------------------------------------------------------------------
+// TPresencePluginUtility::ResetAndDestroyIdentities
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void TPresencePluginUtility::ResetAndDestroyIdentities( TAny* anArray )
+	{
+	DP_SDA("TPresencePluginUtility::ResetAndDestroyIdentities"); 	 
+	
+    RPointerArray<MXIMPIdentity>* array = 
+        reinterpret_cast<RPointerArray<MXIMPIdentity>*>( anArray );
+        
+    if ( array )
+        {
+        DP_SDA("  ->  reset and destroy array items"); 	 
+        array->ResetAndDestroy();
+        DP_SDA("  ->  close array"); 	 
+        array->Close();
+        }
+	DP_SDA("TPresencePluginUtility::ResetAndDestroyIdentities out"); 	 
+	}
+    
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginvirtualgroup.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,222 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+#include <e32std.h>
+
+#include <protocolpresentitygroupsdatahost.h>
+#include <presentitygroupmemberinfo.h>
+#include <protocolpresencedatahost.h>
+#include <presenceobjectfactory.h>
+#include <ximpobjectcollection.h>
+#include <ximpobjectfactory.h>
+#include <ximpidentity.h>
+
+#include "presencepluginvirtualgroup.h"
+#include "mpresencepluginconnectionobs.h"
+#include "presenceplugincommon.h"
+#include "presenceplugindata.h"
+
+const TInt KArrayGranularity = 5; 
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginVirtualGroup::~CPresencePluginVirtualGroup
+// ---------------------------------------------------------------------------
+CPresencePluginVirtualGroup::CPresencePluginVirtualGroup( 
+    MPresencePluginConnectionObs& aObs,
+    CPresencePluginData* aPresenceData )
+    :iConnObs( aObs ),
+    iPresenceData( aPresenceData ),
+    iVirtualMember( NULL )
+    {
+    DP_SDA("CPresencePluginVirtualGroup::CPresencePluginVirtualGroup");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginVirtualGroup::~CPresencePluginVirtualGroup
+// ---------------------------------------------------------------------------
+CPresencePluginVirtualGroup::~CPresencePluginVirtualGroup()
+    {
+    DP_SDA("CPresencePluginVirtualGroup::~CPresencePluginVirtualGroup1");
+    delete iVirtualMember;
+    delete iListName;
+    DP_SDA("CPresencePluginVirtualGroup::~CPresencePluginVirtualGroup2");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginVirtualGroup::NewL
+// ---------------------------------------------------------------------------
+//
+CPresencePluginVirtualGroup* CPresencePluginVirtualGroup::NewL( 
+    MPresencePluginConnectionObs& aObs,
+    const TDesC16& aListName,
+    CPresencePluginData* aPresenceData )
+    {
+    CPresencePluginVirtualGroup* self =
+        new (ELeave) CPresencePluginVirtualGroup( aObs, aPresenceData );
+    CleanupStack::PushL( self );
+    self->ConstructL( aListName );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginVirtualGroup::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginVirtualGroup::ConstructL( const TDesC16& aListName )
+    {
+    DP_SDA("CPresencePluginVirtualGroup::ConstructL begin");
+    iVirtualMember = new (ELeave) CDesCArrayFlat( KArrayGranularity );
+    iListName = aListName.AllocL();
+    DP_SDA("CPresencePluginVirtualGroup::ConstructL end");        
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginVirtualGroup::GetVirtualEntities
+// ---------------------------------------------------------------------------
+void CPresencePluginVirtualGroup::GetVirtualEntitiesL( 
+    MXIMPObjectCollection& aColl )
+    {           
+    DP_SDA("CPresencePluginVirtualGroup::GetVirtualEntities begin");
+    TInt count = iVirtualMember->Count();
+    if ( count )
+        {
+        DP_SDA("CPresencePluginVirtualGroup MXIMPObjectFactory& myFactory");
+        MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();
+        for ( TInt i=0; i < count; i++ )
+            {
+            MXIMPIdentity* member = myFactory.NewIdentityLC(); 
+            HBufC* withoutPrefix = iPresenceData->RemovePrefixLC( (*iVirtualMember)[i] );
+            member->SetIdentityL( *withoutPrefix );
+            CleanupStack::PopAndDestroy( withoutPrefix );
+            // create here MXIMPPresentityGroupMemberInfo
+            MPresentityGroupMemberInfo* info = 
+                iConnObs.PresenceObjectFactoryOwn().
+                    NewPresentityGroupMemberInfoLC();
+                    
+            DP_SDA("CPresencePluginVirtualGroup:: info->SetGroupMemberIdL");
+            info->SetGroupMemberIdL( member ); //ownership taken
+            info->SetGroupMemberDisplayNameL( member->Identity() );
+            aColl.AddObjectL( info );           
+            CleanupStack::Pop( 2 ); // >> info, member
+            DP_SDA2("CPresencePluginVirtualGroup:: done= handle next = %d", i);
+            }
+        DP_SDA("CPresencePluginVirtualGroup::GetOnlineEntities all done");
+        }
+    DP_SDA("CPresencePluginVirtualGroup::GetOnlineEntities end");        
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginVirtualGroup::AddEntityL
+// ---------------------------------------------------------------------------
+void CPresencePluginVirtualGroup::AddEntityL( const TDesC& aIdentityUri )
+    {
+    DP_SDA("CPresencePluginVirtualGroup::AddOnlineEntity - begin");
+    HBufC* prefixStripped = aIdentityUri.AllocLC();
+    if ( KErrNotFound == IdentityExists( aIdentityUri ) )
+        {
+        DP_SDA("CPresencePluginVirtualGroup::ivirtuaBuddys->AddObjectL");
+        iVirtualMember->AppendL( *prefixStripped );
+        }
+    CleanupStack::PopAndDestroy( prefixStripped );
+    DP_SDA("CPresencePluginVirtualGroup::AddOnlineEntity - end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginVirtualGroup::RemoveOnlineEntity
+// ---------------------------------------------------------------------------
+void CPresencePluginVirtualGroup::RemoveEntityL( 
+    const TDesC& aIdentityUri )
+    {
+    DP_SDA("CPresencePluginVirtualGroup::RemoveOnlineEntity - begin");
+    if ( iVirtualMember->Count() )
+        {
+        DP_SDA("CPresencePluginVirtualGroup::RemoveOnlineEntity - find");        
+        HBufC* prefixStripped = aIdentityUri.AllocLC();
+        TInt result = IdentityExists( *prefixStripped );
+        if ( KErrNotFound != result && result < iVirtualMember->Count() )
+            {
+            DP_SDA("CPresencePluginVirtualGroup:: - Remove");        
+            iVirtualMember->Delete( result );
+            }        
+        CleanupStack::PopAndDestroy( prefixStripped );                   
+        }
+    DP_SDA("CPresencePluginVirtualGroup::RemoveOnlineEntity - end");        
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginVirtualGroup::IdentityExists
+// ---------------------------------------------------------------------------
+TInt CPresencePluginVirtualGroup::IdentityExists( const TDesC& aIdentityUri )
+    {
+    DP_SDA("CPresencePluginVirtualGroup::IdentityExists - begin");
+    
+    TInt result( KErrNotFound );
+    
+    for ( TInt i=0; i<iVirtualMember->Count(); i++ )
+        {
+        if ( (*iVirtualMember)[i].CompareF( aIdentityUri ) == 0 )
+            {
+            DP_SDA2("IdentityExists - found at index = %d", i);
+            result = i;
+            break;
+            }
+        }
+            
+    DP_SDA("CPresencePluginVirtualGroup::IdentityExists - end");                
+    return result;
+    }
+ 
+// ---------------------------------------------------------------------------
+// CPresencePluginVirtualGroup::GetVirtualIdentityArray
+// --------------------------------------------------------------------------- 
+CDesCArray* CPresencePluginVirtualGroup::GetVirtualIdentityArray( )
+	{
+ 	DP_SDA("CPresencePluginVirtualGroup::GetVirtualIdentityArray - begin");
+ 	return iVirtualMember;	
+ 	} 
+ 	
+// ---------------------------------------------------------------------------
+// CPresencePluginVirtualGroup::HandlePresentityGroupMemberAddedL
+// --------------------------------------------------------------------------- 
+void CPresencePluginVirtualGroup::HandlePresentityGroupMemberAddedL(
+    const TDesC& aIdentityUri )
+    {
+    DP_SDA("CPresencePluginVirtualGroup::HandlePresentityGroupMemberAddedL");
+
+    MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();
+    MProtocolPresentityGroupsDataHost& dataHost =
+        iConnObs.ProtocolPresenceHost().GroupsDataHost();
+    MXIMPIdentity* groupid = myFactory.NewIdentityLC(); 
+    groupid->SetIdentityL( iListName->Des() );
+    MXIMPIdentity* member = myFactory.NewIdentityLC(); 
+    member->SetIdentityL( aIdentityUri );
+    MPresentityGroupMemberInfo* info = 
+       iConnObs.PresenceObjectFactoryOwn().NewPresentityGroupMemberInfoLC();
+    info->SetGroupMemberIdL( member ); //ownership taken
+    info->SetGroupMemberDisplayNameL( member->Identity() );
+    dataHost.HandlePresentityGroupMemberAddedL( 
+        groupid, info );// ownership taken
+    DP_SDA("CPresencePluginVirtualGroup:: Notify Pop( 3 )");
+    CleanupStack::Pop( 3 ); // groupid, member, info
+    
+    DP_SDA("CPresencePluginVirtualGroup::HandlePresentityGroupMemberAddedL End");
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginwatcher.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,788 @@
+/*
+* Copyright (c) 2006-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <e32std.h>
+#include <e32svr.h>
+#include <utf.h>
+#include <s32strm.h>
+#include <ximpprotocolconnectionhost.h>
+#include <ximpidentity.h>
+#include <ximperrors.hrh>
+#include <msimpleconnection.h>
+#include <protocolpresentitygroupsdatahost.h>
+#include <protocolpresencedatahost.h>
+#include <ximpobjectcollection.h>
+#include <ximpobjectfactory.h>
+#include <presenceobjectfactory.h>
+#include <escapeutils.h>
+
+#include "presencepluginvirtualgroup.h"
+#include "mpresencepluginconnectionobs.h"
+#include "presenceplugincommon.h"
+#include "presencepluginwatcher.h"
+#include "presencepluginentitywatcher.h"
+#include "presencepluginxdmutils.h"
+#include "presenceplugindata.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::CPresencePluginWatcher()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginWatcher::CPresencePluginWatcher(
+    MPresencePluginConnectionObs& aObs,
+    MSimpleConnection& aConn, CPresencePluginData* aPresenceData )
+    : CActive( CActive::EPriorityStandard ),
+    iConnObs(aObs), iConnection(aConn), iPresenceData( aPresenceData ),
+    iXdmState( EPluginIdle ),iCompleted( ETrue ),
+    iOperation( EPluginUndef )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginWatcher* CPresencePluginWatcher::NewL(
+    MPresencePluginConnectionObs& aObs,
+    MSimpleConnection& aConn,
+    CPresencePluginData* aPresenceData )
+    {
+    DP_SDA("CPresencePluginWatcher::NewL");
+    CPresencePluginWatcher* self =
+        new( ELeave ) CPresencePluginWatcher( aObs, aConn, aPresenceData );
+    CleanupStack::PushL( self );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::~CPresencePluginWatcher()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginWatcher::~CPresencePluginWatcher()
+    {
+    iWatchers.ResetAndDestroy();
+    iWatchers.Close();
+    iWatcherCandidates.ResetAndDestroy();
+    delete iPresIdentity;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::DoSubscribePresentityPresenceL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::DoSubscribePresentityPresenceL(
+    const MXIMPIdentity& aPresentityId,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginWatcher::DoSubscribePresentityPresenceL");
+    DP_SDA2(" DoSubscribePresentityPresenceL - identity: %S", 
+        &aPresentityId.Identity() );
+
+    iOperation = EPluginSubscribeSingle;
+    iXdmState = EPluginIdle;    
+   
+    SetPresIdentityL( aPresentityId, ETrue );
+    
+    //Saving reguestID
+    iXIMPId = aReqId;    
+    iCompleted = EFalse;
+    
+    HBufC8* pres8 = NULL;
+    pres8 =
+        CnvUtfConverter::ConvertFromUnicodeToUtf8L( iPresIdentity->Des() );
+    CleanupStack::PushL( pres8 ); // << pres8
+        
+    CPresencePluginEntityWatcher* watcher =
+        MatchWatcherL( pres8->Des(), ETrue );      
+    watcher->StartSubscribeL( pres8->Des() );
+    CleanupStack::PopAndDestroy( pres8 );  // >> pres8
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::DoPerformSubscribePresentityPresenceL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::DoPerformSubscribePresentityPresenceL(
+    const MXIMPIdentity& aPresentityId,
+    TRequestStatus& aStatus )
+    {        
+    DP_SDA( "CPresencePluginWatcher::DoPerformSubscribePresentityPresenceL ");
+    DP_SDA( " -> From list operation");
+    
+    iOperation = EPluginSubscribeByAdding;
+    iXdmState = EPluginIdle;    
+   
+    SetPresIdentityL( aPresentityId, ETrue );
+    
+    iCompleted = EFalse;
+    
+    HBufC8* pres8 = NULL;
+    pres8 =
+        CnvUtfConverter::ConvertFromUnicodeToUtf8L( iPresIdentity->Des() );
+    CleanupStack::PushL( pres8 ); // << pres8
+    
+    // remove escapes
+    HBufC8* encodedUsername = EscapeUtils::EscapeEncodeL( *pres8, EscapeUtils::EEscapeNormal );
+    CleanupStack::PopAndDestroy( pres8 );
+    CleanupStack::PushL( encodedUsername );
+    
+    CPresencePluginEntityWatcher* watcher =
+        MatchWatcherL( encodedUsername->Des(), ETrue );      
+    watcher->StartSubscribeL( encodedUsername->Des(), aStatus );
+    CleanupStack::PopAndDestroy( encodedUsername );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::DoUpdatePresentityPresenceSubscriptionPifL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::DoUpdatePresentityPresenceSubscriptionPifL(
+    const MXIMPIdentity& /*aPresentityId*/,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    // Notice: later
+    User::Leave( KXIMPErrServiceRequestTypeNotSupported );
+    }             
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::DoUnsubscribePresentityPresenceL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::DoUnsubscribePresentityPresenceL(
+    const MXIMPIdentity& aPresentityId,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginWatcher::DoUnsubscribePresentityPresenceL");
+    SetPresIdentityL( aPresentityId, ETrue );
+    iXIMPId = aReqId;  
+    iCompleted = EFalse;
+    
+    HBufC8* pres8 = NULL;
+    pres8 =
+        CnvUtfConverter::ConvertFromUnicodeToUtf8L( iPresIdentity->Des() );
+    CleanupStack::PushL( pres8 ); // << pres8
+            
+    CPresencePluginEntityWatcher* watcher =
+        MatchWatcherL( pres8->Des(), EFalse );
+    if ( !watcher )
+        {
+        DP_SDA("DoUnsubscribePresentityPresenceL error");
+        User::Leave( KErrNotFound ); // Notice: error code
+        }
+    else
+        {
+      	DP_SDA("DoUnsubscribePresentityPresenceL stop subscripe");
+        watcher->StopSubscribeL();      
+        }    
+    CleanupStack::PopAndDestroy( pres8 );  // >> pres8   
+    }             
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::DoPerformUnsubscribePresentityPresenceL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::DoPerformUnsubscribePresentityPresenceL(
+    const MXIMPIdentity& aPresentityId,
+    TRequestStatus& aStatus )
+    {
+    DP_SDA("CPresencePluginWatcher::DoPerformUnsubscribePresentityPresenceL");
+    
+    SetPresIdentityL( aPresentityId, ETrue );
+    iCompleted = EFalse;
+    
+    iOperation = EPluginUnSubscribeByRemoving;
+    
+    HBufC8* pres8 = NULL;
+    pres8 =
+        CnvUtfConverter::ConvertFromUnicodeToUtf8L( iPresIdentity->Des() );
+    CleanupStack::PushL( pres8 ); // << pres8
+            
+    CPresencePluginEntityWatcher* watcher =
+        MatchWatcherL( pres8->Des(), EFalse );
+    if ( !watcher )
+        {
+        DP_SDA("DoUnsubscribePresentityPresenceL watcher not found");
+        aStatus = KRequestPending;
+        TRequestStatus* temp = &aStatus;
+        User::RequestComplete( temp, KErrNotFound );
+        }
+    else
+        {
+      	DP_SDA("DoUnsubscribePresentityPresenceL stop subscribe");
+        watcher->StopSubscribeL( aStatus );
+        }
+    CleanupStack::PopAndDestroy( pres8 );  // >> pres8
+    
+    DP_SDA("CPresencePluginWatcher::DoPerformUnsubscribePresentityPresenceL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::DoSubscribePresentityGroupMembersPresenceL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::DoSubscribePresentityGroupMembersPresenceL(
+    const MXIMPIdentity& aGroupId,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("DoSubscribePresentityGroupMembersPresenceL");
+    //Subscribe all buddys from virtual group
+
+    iOperation = EPluginSubscribeGroup;
+    iXdmState = EPluginIdle;    
+    
+    SetPresIdentityL( aGroupId, EFalse );
+    iXIMPId = aReqId;
+    iCompleted = EFalse;
+  
+    StartXdmOperationL();
+    }             
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::
+//  DoUpdatePresentityGroupMembersPresenceSubscriptionPifL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::
+    DoUpdatePresentityGroupMembersPresenceSubscriptionPifL(
+    const MXIMPIdentity& /*aGroupId*/,
+    const MPresenceInfoFilter& /*aPif*/,
+    TXIMPRequestId /*aReqId*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }             
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::DoUnsubscribePresentityGroupMembersPresenceL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::DoUnsubscribePresentityGroupMembersPresenceL(
+    const MXIMPIdentity& aGroupId,
+    TXIMPRequestId aReqId )
+    {
+    DP_SDA("DoUnsubscribePresentityGroupMembersPresenceL");
+
+    iOperation = EPluginUnsubscribeGroup;
+    iXdmState = EPluginIdle;    
+    
+    SetPresIdentityL( aGroupId, EFalse );
+    iXIMPId = aReqId;
+    iCompleted = EFalse;
+  
+    StartXdmOperationL();
+    }             
+       
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::GetInterface()
+// ---------------------------------------------------------------------------
+//
+TAny* CPresencePluginWatcher::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions )
+    {
+    DP_SDA("CPresencePluginWatcher::GetInterface (......) ");
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        DP_SDA("GetInterface : aInterfaceId == GetInterfaceId()");
+        // caller wants this interface
+        MProtocolPresenceWatching* myIf = this;
+        return myIf;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        DP_SDA("GetInterface: aOptions == MXIMPBase::EPanicIfUnknown");
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }  
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::GetInterface()
+// ---------------------------------------------------------------------------
+//
+const TAny* CPresencePluginWatcher::GetInterface(
+    TInt32 aInterfaceId,
+    TIfGetOps aOptions ) const
+    {
+    DP_SDA("CPresencePluginWatcher::GetInterface (......) const ");
+    if ( aInterfaceId == GetInterfaceId() )
+        {
+        DP_SDA("GetInterface : aInterfaceId == GetInterfaceId()");
+        // caller wants this interface
+        const MProtocolPresenceWatching* myIf = this;
+        return myIf;
+        }
+    if ( aOptions == MXIMPBase::EPanicIfUnknown )
+        {
+        DP_SDA("GetInterface: aOptions == MXIMPBase::EPanicIfUnknown");
+        User::Panic( KPluginName, KErrExtensionNotSupported );
+        }  
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::GetInterfaceId()
+// ---------------------------------------------------------------------------
+//
+TInt32 CPresencePluginWatcher::GetInterfaceId() const
+    {
+    DP_SDA("CPresencePluginWatcher::GetInterfaceId() const");
+    return MProtocolPresenceWatching::KInterfaceId;
+    }
+     
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::MatchWatcherL
+// ---------------------------------------------------------------------------
+//
+CPresencePluginEntityWatcher* CPresencePluginWatcher::MatchWatcherL( 
+    const TDesC8& aPresentityid, TBool aCreate )
+    {
+    DP_SDA("CPresencePluginWatcher::MatchWatcherL");
+    DP_SDA2("CPresencePluginWatcher::MatchWatcherL %d", aCreate )
+    TInt count = iWatchers.Count();
+    DP_SDA2( "MatchWatcherL watcher count %d", count );
+    for ( TInt i = 0; i < count; i++ )
+        {
+        CPresencePluginEntityWatcher* temp = ( iWatchers[i] );
+        //Check if prentity found from watcher
+        if ( !temp->PresentityId().CompareF( aPresentityid ))
+            {
+            DP_SDA("CPresencePluginWatcher::MatchWatcherL return temp");
+            return temp;
+            }
+        }
+    if ( !aCreate )
+        {
+        DP_SDA("CPresencePluginWatcher::MatchWatcherL return NULL");
+        return NULL;
+        }
+    else
+        {
+        // Run this if like create new wathcer
+        DP_SDA("CPresencePluginWatcher::MatchWatcherL Else");                
+        CPresencePluginEntityWatcher* watcher =
+            CPresencePluginEntityWatcher::NewL( 
+            		iConnObs, iConnection, *this, iPresenceData );
+        CleanupStack::PushL( watcher );
+        iWatcherCandidates.AppendL( watcher );
+        CleanupStack::Pop();
+        DP_SDA("CPresencePluginWatcher::MatchWatcherL end");
+        return watcher;
+        }
+    }    
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::DeleteWatcher
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::DeleteWatcher(
+    const TDesC8& aPresentityid )
+    {
+    DP_SDA( "CPresencePluginWatcher::DeleteWatcher" );
+    TInt count = iWatchers.Count();
+    DP_SDA2( "CPresencePluginWatcher::DeleteWatcher count %d", count);
+    
+    for ( TInt i = 0; i < count; i++ )
+        {
+        CPresencePluginEntityWatcher* temp = ( iWatchers[i] );
+        if ( !temp->PresentityId().CompareF( aPresentityid ) )
+            {
+            DP_SDA2( "CPresencePluginWatcher::DeleteWatcher %d", i );
+            iWatchers.Remove( i );
+            iWatchers.GranularCompress();
+            delete temp;
+            temp = NULL;
+            break; // delete all watchers?
+            }
+        }
+    DP_SDA( "CPresencePluginWatcher::DeleteWatcher end" );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::SetPresIdentityL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::SetPresIdentityL(
+     const MXIMPIdentity& aPresentityId,
+     TBool aFormatUri )
+    {
+    DP_SDA2("CPresencePluginWatcher::SetPresIdentityL: %S", 
+        &aPresentityId.Identity() ); 
+     
+    delete iPresIdentity;
+    iPresIdentity = NULL;
+     
+    if( aFormatUri )
+        {
+        HBufC8* identityCopy = HBufC8::NewLC( KBufSize255 );
+        TPtr8 identityCopyPtr( identityCopy->Des() );
+        identityCopyPtr.Copy( aPresentityId.Identity() );
+        DP_SDA2(" SetPresIdentityL, org identity: %S", identityCopy );
+        
+        HBufC8* prefixUri = iPresenceData->CreatePresenceUri8LC( 
+            identityCopyPtr );
+        
+        HBufC* prefixUri16 = HBufC::NewLC( KBufSize255 );
+        TPtr prefixUri16Ptr( prefixUri16->Des() );
+        prefixUri16Ptr.Copy( *prefixUri );
+
+        DP_SDA2("CPresencePluginWatcher::SetPresIdentityL: with prefix: %S", 
+            prefixUri16 ); 
+        
+        iPresIdentity = prefixUri16;
+        CleanupStack::Pop( prefixUri16 );
+        CleanupStack::PopAndDestroy( 2, identityCopy );
+        }
+    else
+        {
+        DP_SDA("CPresencePluginWatcher::SetPresIdentityL, use as it is");
+        iPresIdentity = aPresentityId.Identity().AllocL();
+        }
+    } 
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::CompleteXIMPReq()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::CompleteXIMPReq( TInt aStatus )
+    {
+    DP_SDA("CPresencePluginWatcher::CompleteXIMPReq"); 
+    iXdmState = EPluginIdle;
+    if ( iCompleted )
+        {
+        return;
+        }
+    iCompleted = ETrue;
+    iConnObs.CompleteReq( iXIMPId, aStatus );
+    iXIMPId = TXIMPRequestId();
+    DP_SDA("CPresencePluginWatcher::CompleteXIMPReq END");
+    iOperation = EPluginUndef;    
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::MatchWatcherId
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginWatcher::MatchWatcherId(
+    const TDesC8& aPresentityId ) const
+    {
+    DP_SDA("CPresencePluginWatcher::MatchWatcherId");
+    
+    TBool watcherFound( EFalse );
+    TInt count = iWatchers.Count();
+    
+    DP_SDA2("CPresencePluginWatcher::MatchWatcherId watcher count %d", count);
+    
+    for ( TInt i = 0; i < count; i++ )
+        {
+        CPresencePluginEntityWatcher* temp = ( iWatchers[i] );
+        
+        //Check if ID is found from watcher
+        if ( !temp->PresentityId().CompareF( aPresentityId ) )
+            {
+            DP_SDA("CPresencePluginWatcher::MatchWatcherId - Match!");
+            watcherFound = ETrue;
+            }
+        }
+
+    return watcherFound;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::CompleteWatcher
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::CompleteWatcher( TInt aStatus )
+    {
+    
+    DP_SDA("CPresencePluginWatcher::CompleteWatcher");
+    DP_SDA2("CPresencePluginWatcher::CompleteWatcher status %d", aStatus);
+    // start to remove RLS service when needed.
+    if ( iOperation == EPluginUnsubscribeGroup )
+        {
+        DP_SDA("CompleteWatcher EPluginUnsubscribeGroup");
+        if ( iXdmState == EPluginIdle )
+            {
+            TRAPD( err, iXdmUtils->InitializeXdmsOnlyL( iStatus ));
+            if ( err )
+                {
+                DP_SDA2("CompleteWatcher EPluginUnsubscribeGroup err %d",err);
+                CompleteXIMPReq( err );                 
+                }
+            else
+                {
+                DP_SDA("CompleteWatcher EPluginUnsubscribeGroup fetch RLS");
+                iXdmState = EPluginFetchRls;
+                if( !IsActive() )
+                	{
+                	SetActive();
+                	}
+                }   
+            return;                  
+            }                    
+        }
+    else
+        {
+        DP_SDA("CPresencePluginWatcher::CompleteWatcher complete");
+        CompleteXIMPReq( aStatus );
+        }    
+    DP_SDA("CPresencePluginWatcher::CompleteWatcher end");  
+    }    
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::StartXdmOperationL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::StartXdmOperationL()
+    {
+    DP_SDA("CPresencePluginWatcher::StartXdmOperationL");  
+    __ASSERT_DEBUG( !IsActive(), User::Leave( KErrCorrupt ) );
+    if ( !iXdmUtils )
+        {
+        iXdmUtils = iConnObs.XdmUtilsL();
+        }   
+    iXdmUtils->InitializeXdmsOnlyL( iStatus );
+    
+    iXdmState = EPluginInitXdm;
+    
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::DoCancel(  )
+    {
+    iXdmUtils->Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::RunL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::RunL()
+    {
+
+    TInt status = iStatus.Int();
+    
+    DP_SDA2("CPresencePluginWatcher::RunL mystatus %d ", status);
+    
+    if ( !status )
+        {
+        if( iOperation == EPluginUnsubscribeGroup )
+            {
+            DP_SDA("CPresencePluginWatcher::RunL EPluginUnsubscribeGroup ");
+            UnSubscribeAllL();	
+            }
+        if ( iOperation == EPluginSubscribeGroup )
+            {
+            //First check we have complete buddy list from server
+            if ( iXdmState == EPluginInitXdm )
+                {
+                // get members of the list first         
+                SubscribeAllL();
+                return; 
+                }
+            }
+        if ( iOperation == EPluginSubscribeSingle )
+            {
+            DP_SDA("CPresencePluginWatcher::RunL EPluginSubscribeSingle ");
+            if ( iXdmState == EPluginIdle )
+                {
+                DP_SDA("RunL EPluginSubscribeSingle complete");
+                iOperation = EPluginUndef;
+                CompleteXIMPReq( status );                  
+                }
+            else
+                {
+                iOperation = EPluginUndef; 
+                CompleteXIMPReq( status );
+                }
+            }
+        }
+    else
+        {
+        DP_SDA("CPresencePluginWatcher::RunL error, complete");
+        CompleteXIMPReq( status );
+        }
+    DP_SDA("CPresencePluginWatcher::RunL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::SubscribeL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::SubscribeL( const TDesC& aIdentity )
+    {
+    DP_SDA2("CPresencePluginWatcher::SubscribeL identity: %S", &aIdentity );
+    
+    MXIMPIdentity* member = iConnObs.ObjectFactory().NewIdentityLC(); 
+    member->SetIdentityL( aIdentity );
+   
+    SetPresIdentityL( *member, EFalse );
+                    
+    HBufC8* pres8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( 
+        member->Identity() );
+    CleanupStack::PushL( pres8 );
+   
+    DP_SDA("CPresencePluginWatcher::SubscribeL try to subsribe");
+   
+    CPresencePluginEntityWatcher* watcher = MatchWatcherL( 
+        pres8->Des(),ETrue );    
+    if ( !watcher )
+        {
+        DP_SDA("CPresencePluginWatcher::SubscribeL no watcher, create");
+        watcher = CPresencePluginEntityWatcher::NewL( 
+            iConnObs, iConnection, *this, iPresenceData );
+        CleanupStack::PushL( watcher );
+        iWatcherCandidates.AppendL( watcher );
+        CleanupStack::Pop( watcher );
+        }
+    DP_SDA("CPresencePluginWatcher::SubscribeL do subsribe");
+    watcher->StartSubscribeL( pres8->Des() );
+    DP_SDA("CPresencePluginWatcher::SubscribeL do subsribe ok");
+    
+    CleanupStack::PopAndDestroy( pres8 );
+    CleanupStack::PopAndDestroy( 1 ); // >> member
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::SubscribeAllL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::SubscribeAllL()
+    {
+    DP_SDA("CPresencePluginWatcher::SubscribeAllL");
+    
+    CDesCArray* subsribed = 
+        iConnObs.SubscribedContacts()->GetVirtualIdentityArray();
+    
+    //Get count
+    TInt count = subsribed->Count();
+    DP_SDA2( "CPresencePluginWatcher::SubscribeAllL contact count %d", count);
+    
+    //Subsribe contact one by one
+    if( count > 0 )
+        {
+        for( TInt i = 0;i < count;i++)
+    	    {
+    	    DP_SDA2( "SubscribeAllL handle contact no: %d", i );
+    	    SubscribeL( subsribed->MdcaPoint( i ) );
+    	    }
+        }
+    DP_SDA( "CPresencePluginWatcher::SubscribeAllL end" );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::UnSubscribeAllL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::UnSubscribeAllL()
+    {
+    DP_SDA("CPresencePluginWatcher::UnSubscribeAllL");
+    CDesCArray* subsribed = 
+        iConnObs.SubscribedContacts()->GetVirtualIdentityArray();
+    
+    //Get count
+    TInt count = subsribed->Count();
+    DP_SDA2("CPresencePluginWatcher::UnSubscribeAllL contact count %d",count);
+    //UnSubsribe contact one by one
+
+    for( TInt i = 0;i < count;i++)
+	    {
+	    DP_SDA2("UnSubscribeAllL handle contact no: %d",i);
+	    //Get identity form array
+	    MXIMPIdentity* member = iConnObs.ObjectFactory().NewIdentityLC(); 
+	    member->SetIdentityL( (*subsribed)[i] );
+	    
+	    SetPresIdentityL( *member, EFalse );
+
+	    HBufC8* pres8 =
+	        CnvUtfConverter::ConvertFromUnicodeToUtf8L( member->Identity() );
+	    CleanupStack::PushL( pres8 ); // << pres8
+	    
+	    DP_SDA("CPresencePluginWatcher::UnSubscribeAllL try to unsubsribe");
+	    TInt watcherCount = iWatchers.Count();
+	    DP_SDA2("UnSubscribeAllL watcher count %d", watcherCount);
+	    
+	    TBool notFound( EFalse );    
+	    for ( TInt j = 0; j < watcherCount; j++ )
+	        {
+	        CPresencePluginEntityWatcher* watcher =
+	        	MatchWatcherL( pres8->Des(), EFalse );
+	        if ( !watcher )
+	            {
+	            DP_SDA("UnSubscribeAllL error not found");
+	            notFound = ETrue;
+	            }
+	        else
+	            {
+	          	DP_SDA("UnSubscribeAllL stop subscripe");
+	            watcher->StopSubscribeL();      
+	            }
+	        DP_SDA2("CPresencePluginWatcher: done= handle next = %d", i);    
+	        }
+	   	if ( notFound )
+	    	{
+	    	DP_SDA("CPresencePluginWatcher::UnSubscribeAllL cotact not found");
+	    	}
+	    CleanupStack::PopAndDestroy( pres8 );    
+	   	CleanupStack::PopAndDestroy( 1 ); // >> member
+	    }
+    DP_SDA("CPresencePluginWatcher::UnSubscribeAllL end");
+    }
+       
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginWatcher::RunError( TInt aError )
+    {
+    DP_SDA2("CPresencePluginWatcher::RunError = %d", aError);
+    CompleteXIMPReq( aError );
+    return KErrNone;
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcher::AcceptL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcher::AcceptL( const CPresencePluginEntityWatcher* aWatcher )
+    {
+    DP_SDA( "CPresencePluginWatcher::AcceptL" );
+    
+    if ( KErrNotFound == iWatchers.Find( aWatcher ) )
+        {
+        iWatchers.AppendL( aWatcher );
+        
+        TInt index = iWatcherCandidates.Find( aWatcher );
+        if ( KErrNotFound != index )
+            {
+            iWatcherCandidates.Remove( index );
+            }
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginwatcherinfo.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,116 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <e32std.h>
+#include <utf.h>
+
+#include "presencepluginwatcherinfo.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcherInfo::CPresencePluginWatcherInfo
+// ---------------------------------------------------------------------------
+CPresencePluginWatcherInfo::CPresencePluginWatcherInfo( )
+        {}
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcherInfo::~CPresencePluginWatcherInfo
+// ---------------------------------------------------------------------------
+CPresencePluginWatcherInfo::~CPresencePluginWatcherInfo()
+    {
+    delete iId;
+    delete iSipId;
+    }
+
+// ----------------------------------------------------------
+// CPresencePluginWatcherInfo::NewL
+// ----------------------------------------------------------
+//
+CPresencePluginWatcherInfo* CPresencePluginWatcherInfo::NewL(
+   const TDesC8& aId, const TDesC& aSipId )
+    {
+    CPresencePluginWatcherInfo* self =
+    	new (ELeave) CPresencePluginWatcherInfo( );
+    CleanupStack::PushL( self );
+    self->ConstructL( aId, aSipId );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcherInfo::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWatcherInfo::ConstructL( 
+    const TDesC8& aId, const TDesC& aSipId  )
+    {
+    iId = aId.AllocL();
+    iSipId = aSipId.AllocL();
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcherInfo::Destroy
+// ---------------------------------------------------------------------------
+void CPresencePluginWatcherInfo::Destroy()
+    {
+    DP_SDA("CPresencePluginWatcherInfo::Destroy");
+    iLink.Deque();
+    delete this;
+    DP_SDA("CPresencePluginWatcherInfo::Destroy end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcherInfo::Match
+// ---------------------------------------------------------------------------
+TBool CPresencePluginWatcherInfo::Match( 
+	const TDesC8& aId,
+	const TDesC& aSipId )
+    {
+    DP_SDA("CPresencePluginWatcherInfo::Match");
+    if ( (!iId->Des().CompareF( aId )) && (!iSipId->Des().CompareF( aSipId )) )    
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }       
+    }
+       
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcherInfo::SipId
+// ---------------------------------------------------------------------------
+//
+TPtrC CPresencePluginWatcherInfo::SipId( )
+    {
+    DP_SDA("CPresencePluginWatcherInfo::SipId");
+    return iSipId ? iSipId->Des() : TPtrC();       
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginWatcherInfo::LinkOffset
+// ---------------------------------------------------------------------------
+//    
+TInt CPresencePluginWatcherInfo::LinkOffset()
+    {
+    return _FOFF(CPresencePluginWatcherInfo, iLink);
+    }
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginwinfo.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,181 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <e32std.h>
+#include <simplefactory.h>
+#include <msimplewinfowatcher.h>
+#include <msimpleconnection.h>				 
+
+#include "presencepluginwinfo.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWinfo::CPresencePluginWinfo()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginWinfo::CPresencePluginWinfo(
+    MPresencePluginConnectionObs& aObs,
+    MSimpleConnection& aConn )
+    :iConnObs( aObs ), iConnection( aConn ),
+    iSubscribed( EFalse ),
+    iWinfoCompleted( EFalse )
+    {       
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWinfo::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWinfo::ConstructL( )
+    {        
+    iWinfoWatcher = TSimpleFactory::NewWinfoWatcherL( iConnection, *this );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWinfo::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginWinfo* CPresencePluginWinfo::NewL(
+    MPresencePluginConnectionObs& aObs,
+    MSimpleConnection& aConn )
+    {
+    DP_SDA("CPresencePluginWinfo::NewL");
+    CPresencePluginWinfo* self =
+        new( ELeave ) CPresencePluginWinfo( aObs, aConn );
+    CleanupStack::PushL( self );
+    self->ConstructL(  );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWinfo::~CPresencePluginWinfo()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginWinfo::~CPresencePluginWinfo()
+    {
+    if ( iWinfoWatcher )
+        {
+        iWinfoWatcher->Close();
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginWinfo::SetHost()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginWinfo::SetHost( 
+    MXIMPProtocolConnectionHost* aHost )
+    {
+    iHost = aHost;    
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginWinfo::SubscribeWinfoListL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginWinfo::SubscribeWinfoListL( TXIMPRequestId aReqId )
+    {
+    DP_SDA("CPresencePluginWinfo::SubscribeWinfoListL");
+    iWinfoCompleted = EFalse;
+    if ( !iSubscribed )
+        {
+        DP_SDA("CPresencePluginWinfo::SubscribeWinfoListL !iSubscribed");    
+        iSimpleId = iWinfoWatcher->SubscribeWatcherListL( NULL );
+        iSubscribed = ETrue;
+        iXIMPId = aReqId;       
+        }
+    else
+        {
+        DP_SDA("CPresencePluginWinfo::SubscribeWinfoListL else ");
+        iSimpleId = 0;
+        iXIMPId = aReqId;         
+        WinfoReqCompleteL( iSimpleId, KErrNone );
+        }
+    DP_SDA("CPresencePluginWinfo::SubscribeWinfoListL end");           
+    } 
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginWinfo::UnsubscribeWinfoListL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginWinfo::UnsubscribeWinfoListL( TXIMPRequestId aReqId )
+    {
+    if ( iSubscribed )
+        {    
+        iSubscribed = EFalse;        
+        iSimpleId = iWinfoWatcher->UnsubscribeL();
+        iXIMPId = aReqId;       
+        }
+    else
+        {
+        iSimpleId = 0;
+        iXIMPId = aReqId;         
+        WinfoReqCompleteL( iSimpleId, KErrNone );
+        }           
+    }  
+      
+// ---------------------------------------------------------------------------
+// CPresencePluginWinfo::WinfoReqCompleteL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWinfo::WinfoReqCompleteL( TInt aOpId, TInt aStatus )
+    {
+    DP_SDA("CPresencePluginWinfo::WinfoReqCompleteL");
+    if ( iSimpleId == aOpId )
+        {
+        iWinfoCompleted = ETrue;
+        iSimpleId = 0;    
+        iConnObs.CompleteReq( iXIMPId, aStatus ); 
+        // Do not wait MXIMPProtocolConnectionHostObserver callback, this
+        // class is ready to serve the next request now.
+        iXIMPId = TXIMPRequestId();              
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWinfo::WinfoTerminatedL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWinfo::WinfoTerminatedL(
+    TInt aOpId, TInt aReason )
+    {
+
+    if ( iSimpleId == aOpId )
+        {
+        iSimpleId = 0;        
+        iConnObs.WinfoTerminatedL( aReason );
+        }
+ }              
+
+// ---------------------------------------------------------------------------
+// CPresencePluginWinfo::WinfoNotificationL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginWinfo::WinfoNotificationL(
+    MSimpleWinfo& aWinfo )
+    {
+    if ( !iWinfoCompleted )
+        {
+        WinfoReqCompleteL( iSimpleId, KErrNone );
+        }
+    iConnObs.WinfoNotification( aWinfo );    
+    }
+ 
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginxdmpresrules.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,1155 @@
+/*
+* Copyright (c) 2006-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+#include <XdmEngine.h>
+#include <XdmProtocolInfo.h>
+#include <XdmDocument.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include <XdmErrors.h>
+#include <XdmProtocolUidList.h>
+
+#include "presencepluginxdmpresrules.h"
+#include "mpresrulesasynchandler.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::NewLC()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginXdmPresRules* CPresencePluginXdmPresRules::NewLC( 
+	const TInt aSettingId, TBool aLocalMode )
+    {
+    CPresencePluginXdmPresRules* self =
+    	new (ELeave) CPresencePluginXdmPresRules( aSettingId );
+    CleanupStack::PushL( self );
+    self->ConstructL( aSettingId, aLocalMode );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginXdmPresRules* CPresencePluginXdmPresRules::NewL(
+    const TInt aXmdId, TBool aLocalMode )
+    {
+    CPresencePluginXdmPresRules* self =
+        new( ELeave ) CPresencePluginXdmPresRules( aXmdId );
+    CleanupStack::PushL( self );
+    self->ConstructL( aXmdId, aLocalMode  );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::CPresencePluginXdmPresRules()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginXdmPresRules::CPresencePluginXdmPresRules( const TInt aXdmId )
+    :CActive( EPriorityStandard ),
+    iSettingsId( aXdmId ),
+    iXdmState( EStateIdle ), //Listeting xdState
+    iRulesUpdateState(EStateNoOperation),
+	iPresXdmOk( EFalse ),
+	iAsyncReq( ENoOperation )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmPresRules::ConstructL( 
+	const TInt aXmdId,
+	TBool aLocalMode )
+    {
+    DP_SDA2("CPresencePluginXdmPresRules::ConstructL - aXdmId: %d", aXmdId );
+    using namespace NPresencePlugin::NPresence;
+    if ( !aLocalMode )
+        {
+        DP_SDA("CPresencePluginXdmPresRules::ConstructL Normal Mode");
+        CXdmProtocolInfo* xdmProtocolInfo = CXdmProtocolInfo::NewL( aXmdId );
+        CleanupStack::PushL( xdmProtocolInfo );
+        DP_SDA("CPresencePluginXdmPresRules::ConstructL - protocol info created");
+        xdmProtocolInfo->SetCacheUsage( EFalse );
+        DP_SDA("CPresencePluginXdmPresRules::ConstructL - create xdm engine");
+        iXdmEngine = CXdmEngine::NewL( *xdmProtocolInfo );
+        CleanupStack::PopAndDestroy( xdmProtocolInfo );
+        DP_SDA("CPresencePluginXdmPresRules::ConstructL - xdm engine created");
+        
+        DP_SDA("CPresencePluginXdmPresRules::ConstructL - create doc model");
+		//Create empty document model
+		iPresRulesDoc =
+            iXdmEngine->CreateDocumentModelL( 
+                KPresencePresRules, EXdmOmaPresenceRules );
+        DP_SDA("CPresencePluginXdmPresRules::ConstructL - create doc model ok");        
+        }
+    else
+        {
+        DP_SDA("CPresencePluginXdmPresRules::ConstructL LocalMode Mode");
+        //Lets Try localmode 
+        CXdmProtocolInfo* xdmProtocolInfo =
+            CXdmProtocolInfo::NewL( 0, KLocalProtocol, KNullDesC );
+        CleanupStack::PushL( xdmProtocolInfo );
+        iXdmEngine = CXdmEngine::NewL( *xdmProtocolInfo );
+        CleanupStack::PopAndDestroy( xdmProtocolInfo );
+
+				//Create empty document model
+		iPresRulesDoc =
+            iXdmEngine->CreateDocumentModelL( 
+                KPresencePresRules, EXdmOmaPresenceRules );
+        }
+    DP_SDA("CPresencePluginXdmPresRules::ConstructL create root");
+	CreateRootIfNeededL();
+	DP_SDA("CPresencePluginXdmPresRules::ConstructL - out" );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::~CPresencePluginXdmPresRules()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginXdmPresRules::~CPresencePluginXdmPresRules()
+    {
+	DP_SDA("CPresencePluginXdmPresRules::~CPresencePluginXdmPresRules");
+    
+    if ( iPresRulesDoc )
+        {
+        DP_SDA("CPresencePluginXdmPresRules::~CPresencePluginXdmPresRules 2");
+        if ( iXdmEngine )
+            {
+            DP_SDA("CPresencePluginXdmPresRules::~CPresencePluginXdmPresRules 3");
+            TRAP_IGNORE( iXdmEngine->DeleteDocumentModelL( iPresRulesDoc ));
+            }
+        }
+       
+    delete iXdmEngine;  
+    delete iEntityUri;
+
+    DP_SDA("CPresencePluginXdmPresRules::~CPresencePluginXdmPresRules Done");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::GetXdmRulesL()
+// ---------------------------------------------------------------------------
+//    
+TInt CPresencePluginXdmPresRules::GetXdmRulesL( 
+    MPresRulesAsyncHandler* const aHandler )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::GetXdmRulesL");
+	__ASSERT_ALWAYS(aHandler, User::Leave(KErrArgument));
+	if (IsActive())
+        return KErrAlreadyExists;
+	iAsyncReq = EXdmGetRulesFromServer;
+	iAsyncHandler = aHandler;
+	using namespace NPresencePlugin::NPresence;
+	
+    if ( !iPresXdmOk )
+        {
+        DP_SDA("CPresencePluginXdmPresRules::GetXdmRulesL !iPresXdmOk");
+
+                
+        iPresRulesDoc->FetchDataL();
+        DP_SDA("CPresencePluginXdmPresRules::GetXdmRulesL !iPresXdmOk end");
+        }
+    else
+        {
+        // Document already exists, no need to search from a server
+        DP_SDA("CPresencePluginXdmPresRules::GetXdmRulesL Already exists");
+        iStatus = KRequestPending;
+        SetActive();        
+        }
+  	return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::UpdateXdmRulesL()
+// ---------------------------------------------------------------------------
+//     
+TInt CPresencePluginXdmPresRules::UpdateXdmRulesL( 
+	MPresRulesAsyncHandler* const aHandler )
+    {
+    __ASSERT_ALWAYS(aHandler, User::Leave(KErrArgument));
+    if (IsActive())
+		{
+		return KErrAlreadyExists;
+		}
+	iAsyncReq = EXdmUpdateRules;
+    iAsyncHandler = aHandler;
+    
+    iPresRulesDoc->AppendL();
+    iXdmEngine->UpdateL(iPresRulesDoc, iStatus);
+    SetActive();
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::MakeInitialRulesDocumentL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginXdmPresRules::MakeInitialRulesDocumentL( 
+    MPresRulesAsyncHandler* const aHandler )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::MakeInitialXdmsDocumentL");
+   	__ASSERT_ALWAYS(aHandler, User::Leave(KErrArgument));
+	iAsyncReq = EXdmInitialPresDoc;
+	iAsyncHandler = aHandler;
+	
+	CXdmDocumentNode* root = iPresRulesDoc->DocumentRoot();
+	if ( !root )
+	    {
+	    DP_SDA("CPresencePluginXdmPresRules:: Create root");
+	    root = iPresRulesDoc->CreateRootL();
+	    }
+   
+    using namespace NPresencePlugin::NPresence;
+    root->SetNameL( KPresenceRuleset );
+
+    // send to the server and start wait a response
+    iPresRulesDoc->AppendL( root );
+    DP_SDA("CPresencePluginXdmPresRules::MakeInitialXdmsDocumentL append");
+    iAsyncReq = EXdmInitialPresDoc;
+    DP_SDA("CPresencePluginXdmPresRules::MakeInitialXdmsDocumentL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::AddWhiteListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmPresRules::AddWhiteListL( CXdmDocumentNode* aRoot )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::AddWhiteList");
+    using namespace NPresencePlugin::NPresence;
+    using namespace NPresencePlugin::NPresenceTransformations;
+    
+    if ( aRoot->IsEmptyNode() )
+        {
+        DP_SDA("AddWhiteList is empty node");
+        aRoot->SetEmptyNode( EFalse );
+        }
+    // whitelist
+    CXdmDocumentNode* child2 = aRoot->CreateChileNodeL( KPresenceRule );
+    CleanupStack::PushL( child2 );
+    CXdmNodeAttribute* name2 = child2->CreateAttributeL( KPresenceId );
+    CleanupStack::PushL( name2 );
+    name2->SetAttributeValueL( KPresenceXdmWhiteList );
+    DP_SDA("CPresencePluginXdmPresRules::AddWhiteList 2");
+    
+    CXdmDocumentNode* conditionsNode2 =
+        child2->CreateChileNodeL( KPresenceConditions );
+
+    conditionsNode2->CreateChileNodeL( KPresenceIdentity ); 
+    CXdmDocumentNode* actionNode2 =
+        child2->CreateChileNodeL( KPresenceAction );
+        
+    DP_SDA("CPresencePluginXdmPresRules::AddWhiteList 3"); 
+    CXdmDocumentNode* subNode2 = actionNode2->CreateChileNodeL( KPresenceSub );
+    DP_SDA("CPresencePluginXdmPresRules::MakeInitialXdmsDocumentL 4");
+    
+    subNode2->SetLeafNode( ETrue ); 
+    subNode2->SetLeafNodeContentL( KPresenceAllow8 );
+    DP_SDA("CPresencePluginXdmPresRules::AddWhiteList 5"); 
+    
+    //Add transformations
+    /*<transformations>
+    <pr:provide-services>
+    <pr:all-services/>
+    </pr:provide-services>
+    
+    <pr:provide-persons>
+    <pr:all-persons/>
+    </pr:provide-persons>
+    
+    <pr:provide-devices>
+    <pr:all-devices/>
+    </pr:provide-devices>
+    
+    <pr:provide-all-attributes/>
+    </transformations>*/
+
+    CXdmDocumentNode* trasform2 =
+        child2->CreateChileNodeL( KPresenceTrasformations );
+    CXdmDocumentNode* services2 =
+        trasform2->CreateChileNodeL( KPresenceProvideServices );
+    services2->CreateChileNodeL( KPresenceAllServices );
+    CXdmDocumentNode* person2 =
+        trasform2->CreateChileNodeL( KPresenceProvidePersons );
+    person2->CreateChileNodeL( KPresenceAllPersons );
+    CXdmDocumentNode* devices2 =
+        trasform2->CreateChileNodeL( KPresenceProvidedevices );
+    devices2->CreateChileNodeL( KPresenceAlldevices );
+    trasform2->CreateChileNodeL( KPresenceProvideAllAttributes );
+    
+    CleanupStack::Pop( name2 );
+    CleanupStack::Pop( child2 );
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::AddBlackList()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmPresRules::AddBlackListL( CXdmDocumentNode* aRoot )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::AddBlackList");
+    // add all the list nodes
+    // buddylist
+    using namespace NPresencePlugin::NPresence;
+    using namespace NPresencePlugin::NPresenceTransformations;
+    if ( aRoot->IsEmptyNode() )
+        {
+        DP_SDA("AddBlackList is empty node");
+        aRoot->SetEmptyNode( EFalse );
+        }
+    CXdmDocumentNode* child1 = aRoot->CreateChileNodeL( KPresenceRule );
+    CleanupStack::PushL( child1 );
+    CXdmNodeAttribute* name = child1->CreateAttributeL( KPresenceId );
+    CleanupStack::PushL( name );
+    
+    name->SetAttributeValueL( KPresenceXdmBlockRule );
+    // add condition
+    CXdmDocumentNode* conditionsNode =
+        child1->CreateChileNodeL( KPresenceConditions );
+    conditionsNode->CreateChileNodeL( KPresenceIdentity );
+    
+    CXdmDocumentNode* actionNode =
+        child1->CreateChileNodeL( KPresenceAction );
+        
+    DP_SDA("CPresencePluginXdmPresRules::AddBlackList 1");
+    CXdmDocumentNode* subNode =
+        actionNode->CreateChileNodeL( KPresenceSub );
+    DP_SDA("CPresencePluginXdmPresRules::MakeInitialXdmsDocumentL 1/2");
+    subNode->SetLeafNode(ETrue);
+    subNode->SetLeafNodeContentL( KPresenceBlock8 ); 
+    DP_SDA("CPresencePluginXdmPresRules::AddBlackList 1/3");
+    
+    CXdmDocumentNode* trasform =
+        child1->CreateChileNodeL( KPresenceTrasformations );
+    CXdmDocumentNode* services =
+        trasform->CreateChileNodeL( KPresenceProvideServices );
+    services->CreateChileNodeL( KPresenceAllServices );
+      
+    CXdmDocumentNode* person =
+        trasform->CreateChileNodeL( KPresenceProvidePersons );
+    person->CreateChileNodeL( KPresenceAllPersons );
+    CXdmDocumentNode* devices =
+        trasform->CreateChileNodeL( KPresenceProvidedevices );
+    devices->CreateChileNodeL( KPresenceAlldevices );
+    trasform->CreateChileNodeL( KPresenceProvideAllAttributes );     
+    CleanupStack::Pop( name );
+    CleanupStack::Pop( child1 );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::RunL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmPresRules::RunL( )
+    {    
+    DP_SDA("CPresencePluginXdmPresRules::RunL");    
+    TPluginPresRulesXdmOperation origState = iAsyncReq;
+    iAsyncReq = ENoOperation;
+    TInt myStatus = iStatus.Int();
+     
+    DP_SDA2("CPresencePluginXdmPresRules::RunL mystatus %d ", myStatus);
+    DP_SDA2("CPresencePluginXdmPresRules::RunL state %d ", origState);
+    
+    switch( origState )
+        {
+        case EXdmGetRulesFromServer:
+            {
+            DP_SDA("CPresencePluginXdmPresRules::RunL EXdmGetRulesFromServer");
+            iAsyncHandler->HandlePresUpdateDocumentL( 
+                iStatus.Int() );
+            }     
+        break;
+        case EXdmInitialPresDoc:
+            {
+            DP_SDA("CPresencePluginXdmPresRules::RunL EXdmInitialPresDoc");
+            iAsyncHandler->HandlePresUpdateDocumentL( 
+                iStatus.Int() );
+            }
+        break;
+        case EXdmUpdateRules:
+            {
+            DP_SDA("CPresencePluginXdmPresRules::RunL EXdmUpdateRules");
+            iAsyncHandler->HandlePresUpdateDocumentL( 
+                iStatus.Int() );
+            }
+        break;
+        case EXdmUpdateRulesFromServer:
+            {
+            DP_SDA("RunL ExdmUpdateRulesFromServer");
+			CreateRootIfNeededL(); //This check is added for Openser/OpenXcap
+            iAsyncHandler->HandlePresUpdateDocumentL( iStatus.Int() );           
+            iRulesUpdateState = EStateNoOperation;
+            }
+        break;
+        case ENoOperation:
+        default:
+            break;
+        }
+     DP_SDA("CPresencePluginXdmPresRules::RunL end"); 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::DoCancel()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginXdmPresRules::DoCancel(  )
+    {
+	DP_SDA("CPresencePluginXdmPresRules::DoCancel");
+	iXdmEngine->CancelUpdate(iPresRulesDoc);
+    iAsyncReq = ECancelDocument;   
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::RunError()
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginXdmPresRules::RunError( TInt /*aError*/ )
+    {
+	DP_SDA("CPresencePluginXdmPresRules::RunError");
+    return KErrNone;
+    }
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::AddEntityToWhiteListL()
+// ---------------------------------------------------------------------------
+// 
+void CPresencePluginXdmPresRules::AddEntityToWhiteListL(
+	const TDesC&  aUri,
+	MPresRulesAsyncHandler* const aHandler )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::AddEntityToWhiteListL");
+    iEntityUri = aUri.Alloc();
+    DP_SDA2( "AddEntityToWhiteListL entity %S", iEntityUri );
+    __ASSERT_ALWAYS(aHandler, User::Leave(KErrArgument));
+    
+    iAsyncReq = EXdmUpdateRules;
+    iAsyncHandler = aHandler;
+    iRulesUpdateState = EStateAddToWhiteList;
+    DoOneAddUserL( KPresenceXdmWhiteList, iEntityUri->Des() );
+    
+    UpdateXdmRulesL( aHandler );   
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::RemoveEntityFromWhiteListL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginXdmPresRules::RemoveEntityFromWhiteListL(
+	const TDesC& aUri,
+	MPresRulesAsyncHandler* const aHandler )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::RemoveEntityFromWhiteListL");
+    iEntityUri =  aUri.Alloc();
+    __ASSERT_ALWAYS(aHandler, User::Leave(KErrArgument));
+    
+    iAsyncReq = EXdmUpdateRules;
+    iAsyncHandler = aHandler;
+    iRulesUpdateState = EStateRemoveFromWhiteList;
+    RemoveOneFromRuleL( KPresenceXdmWhiteList, iEntityUri->Des() );
+    
+    UpdateXdmRulesL( aHandler );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::AddEntityToBlockedRulesL()
+// ---------------------------------------------------------------------------
+// 
+void CPresencePluginXdmPresRules::AddEntityToBlockedRulesL(
+    const TDesC& aUri,
+	MPresRulesAsyncHandler* const aHandler )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::AddEntityToBlockedRulesL");
+    iEntityUri =  aUri.Alloc();
+     __ASSERT_ALWAYS(aHandler, User::Leave(KErrArgument));
+
+    iAsyncReq = EXdmUpdateRules;
+    iAsyncHandler = aHandler;
+    iRulesUpdateState = EStateAddToBlockList;
+    DoOneAddUserL( KPresenceXdmBlockRule, iEntityUri->Des() );
+    
+    UpdateXdmRulesL( aHandler );    
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::RemoveEntityBlockedRulesL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmPresRules::RemoveEntityBlockedRulesL(
+	const TDesC& aUri,
+	MPresRulesAsyncHandler* const aHandler )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::RemoveEntityBlockedRulesL");
+    iEntityUri =  aUri.Alloc();
+    __ASSERT_ALWAYS(aHandler, User::Leave(KErrArgument));
+    
+    iAsyncReq = EXdmUpdateRules;
+    iAsyncHandler = aHandler;
+	iRulesUpdateState = EStateRemoveFromBlackList;
+    RemoveOneFromRuleL( KPresenceXdmBlockRule, iEntityUri->Des() );
+    
+    UpdateXdmRulesL( aHandler );
+    DP_SDA("CPresencePluginXdmPresRules::RemoveEntityBlockedRulesL end");   
+    }    
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::RemoveOneFromRule()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginXdmPresRules::RemoveOneFromRuleL(
+   const TDesC& aRule, const TDesC&  aUri )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::RemoveOneFromRule");
+    CXdmDocumentNode* ruleNode = NULL;
+    CXdmNodeAttribute* attr = NULL;
+    TBool found( EFalse );
+    TBool ruleAvaible( EFalse );
+    
+    using namespace NPresencePlugin::NPresence;
+
+    RPointerArray<CXdmDocumentNode> rules;
+    CleanupClosePushL( rules );
+
+    RPointerArray<CXdmDocumentNode> nodes;
+    CleanupClosePushL( nodes );
+    
+    RPointerArray<CXdmDocumentNode> ones;
+    CleanupClosePushL( ones );
+    
+    if ( iPresRulesDoc )
+        {
+        DP_SDA("RemoveOneFromRule iPresRulesDoc ok");
+        
+        //Check if rule exist
+        ruleAvaible = FindRuleL( aRule, EFalse );
+        
+        if ( ruleAvaible )
+            {
+            
+            TRAPD( err, ruleNode =  GetRulesL( aRule, rules ) );
+			if( !err )
+			    {
+			    found = ETrue;
+			    }
+            }
+        }
+    
+    if ( found )
+        {
+        DP_SDA("CPresencePluginXdmPresRules::RemoveOneFromRule found");
+        TInt findErr = ruleNode->Find( KPresenceOne, nodes );
+        if ( !findErr )
+            {
+            TInt nodeCount = nodes.Count();
+            for ( TInt i = 0; i < nodeCount; i++ )
+                {
+                CXdmDocumentNode* currNode = nodes[i];
+                attr = ( currNode )->Attribute( KPresenceId );
+                
+                TBool uriMatch = CompareUriWithoutPrefixL( 
+                    aUri, attr->AttributeValue() );
+                 
+                if ( attr && uriMatch )
+                    {
+                    DP_SDA("RemoveOneFromRule Remove");
+                    //First remove currNode form model
+                    iPresRulesDoc->RemoveFromModelL( currNode );
+                    
+                    //Check how many rules are in group now
+                    DP_SDA("RemoveOneFromRule Find all one field from rule");
+                    User::LeaveIfError( ruleNode->Find( KPresenceOne, ones ) );
+                    TInt oneCount = ones.Count();
+                    DP_SDA2("RemoveOneFromRule ones count %d", oneCount);
+                    //if there is no any ones in rule remove it
+                    if( KErrNone == oneCount )
+                    	{
+                    	//Remove group
+        				DP_SDA("RemoveOneFromRule Remove GROUP");
+        				RemoveRuleGroupL( aRule );	
+                    	}
+                    // Update model to server
+                    iPresRulesDoc->AppendL();
+                    break;
+                    }
+                }
+            }
+        }
+      
+    CleanupStack::PopAndDestroy( &ones ); // >>> nodes         
+    CleanupStack::PopAndDestroy( &nodes ); // >>> nodes
+    CleanupStack::PopAndDestroy( &rules ); // >>> lists
+    }    
+ 
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::DoOneAddUserL()
+// ---------------------------------------------------------------------------
+//
+ void CPresencePluginXdmPresRules::DoOneAddUserL(
+    const TDesC& aRule, const TDesC&  aUri )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::DoOneAddUserL");
+    using namespace NPresencePlugin::NPresence;
+    
+    CXdmDocumentNode* ruleNode = NULL;
+    RPointerArray<CXdmDocumentNode> identityNode;
+    CleanupClosePushL( identityNode );
+    
+    TBool found( EFalse );
+    TBool ruleAvaible( EFalse );
+    
+    using namespace NPresencePlugin::NPresence;
+
+    RPointerArray<CXdmDocumentNode> rules;
+    CleanupClosePushL( rules );
+    
+
+    DP_SDA("CPresencePluginXdmPresRules::DoOneAddUserL iPresRulesDoc");
+    if ( iPresRulesDoc )
+        {
+        DP_SDA("DoOneAddUserL iPresRulesDoc Exist");
+        
+        ruleAvaible = FindRuleL( aRule, ETrue );
+        
+        if ( ruleAvaible )
+            {
+			TRAPD( err, ruleNode =  GetRulesL( aRule, rules ) );
+			if( !err )
+			    {
+			    found = ETrue;
+			    }
+            }
+        }
+   
+    //Finaly add entity to rules
+    if ( found )
+        {
+        //Check if enity already in list
+        if( !CheckIfOneExistL( aRule, aUri ) )
+            {
+            DP_SDA("CPresencePluginXdmPresRules::DoOneAddUserL Found");
+            // Find identityNode inside rulenode
+            User::LeaveIfError( 
+            ruleNode->Find( KPresenceIdentity, identityNode ) );
+            if ( identityNode[0] )    
+                {
+                if ( identityNode[0]->IsEmptyNode() )
+                    {
+                    DP_SDA("DoOneAddUserL rule node empty");
+                    identityNode[0]->SetEmptyNode( EFalse );
+                    }
+                
+                // create new one node inside identity
+                CXdmDocumentNode* newNode =
+                    identityNode[0]->CreateChileNodeL( KPresenceOne );
+                CXdmNodeAttribute* attributeOneId =
+                    newNode->CreateAttributeL( KPresenceId );
+                
+                attributeOneId->SetAttributeValueL( aUri );
+                iPresRulesDoc->AppendL();
+                DP_SDA("DoOneAddUserL added");
+                }
+            }
+        }
+    else
+        {
+        DP_SDA("CPresencePluginXdmPresRules::DoOneAddUserL error not found");
+        User::Leave( KErrNotFound );
+        } 
+    DP_SDA("CPresencePluginXdmPresRules::DoOneAddUserL end");     
+    CleanupStack::PopAndDestroy( 2 );
+              
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::GetRulesL()
+// ---------------------------------------------------------------------------
+//
+CXdmDocumentNode* CPresencePluginXdmPresRules::GetRulesL( const TDesC& aRule,
+    RPointerArray<CXdmDocumentNode>& aRuleArray )
+    {
+    DP_SDA("GetRulesL find Again if rule now exist");
+    using namespace NPresencePlugin::NPresence;
+    
+    CXdmDocumentNode* ruleNode = NULL;
+    CXdmNodeAttribute* attr = NULL;
+    
+    TBool result(EFalse);
+    // find if rule tag is exist
+    User::LeaveIfError( iPresRulesDoc->Find( KPresenceRule, aRuleArray ) );
+
+    // How many rules found
+    TInt count = aRuleArray.Count();
+    DP_SDA2("GetRulesL ruleCount %d ", count);
+
+    // Check is needed rule id exist
+    for ( TInt i=0; i < count; i++ )
+        {
+        ruleNode = aRuleArray[i];
+        TBuf<KBufSize100> buf;
+        buf.Copy( 
+        ruleNode->Attribute( KPresenceId )->AttributeValue() );
+        DP_SDA2("GetRulesL ruleNode %S", &buf);
+
+        attr = ruleNode->Attribute( KPresenceId );
+        if ( attr && !attr->AttributeValue().CompareF( aRule ) )
+            {
+            DP_SDA("CPresencePluginXdmPresRules::GetRulesL FOUND");
+            result = ETrue;
+            break;
+            }
+        }
+        
+    // Make second compare
+    if( !result )
+        {
+        User::LeaveIfError(iPresRulesDoc->Find( KPresenceRule, aRuleArray )); 
+        TInt count2 = aRuleArray.Count();
+
+        for ( TInt i=0; i < count2; i++ )
+            {
+            ruleNode = aRuleArray[i];
+            attr = ruleNode->Attribute( KPresenceId );
+            if ( attr && attr->AttributeValue().CompareF( aRule ) )
+                {
+                DP_SDA("CPresencePluginXdmPresRules::GetRulesL NOT FOUND");
+                User::Leave( KErrNotFound );
+                }
+            }
+        }
+
+    return ruleNode;    
+    }
+                                
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::FindRuleL()
+// ---------------------------------------------------------------------------
+//	
+TBool CPresencePluginXdmPresRules::FindRuleL( 
+    const TDesC& aRule, TBool aCreateRule )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::FindRuleL");
+    using namespace NPresencePlugin::NPresence;
+    
+   	 if ( iPresRulesDoc )
+        {
+        DP_SDA("CPresencePluginXdmPresRules::FindRuleL pres document exists");
+        RPointerArray<CXdmDocumentNode> rule;
+        CleanupClosePushL( rule );
+        
+        CXdmDocumentNode* ruleNode = NULL;
+        CXdmNodeAttribute* attr = NULL;
+        
+        TBool found = EFalse;
+        //Find all rules from document and but them to array
+        DP_SDA("CPresencePluginXdmPresRules::FindRuleL find rule");
+        TInt err = iPresRulesDoc->Find( KPresenceRule, rule );
+        DP_SDA2("FindRuleL find rule error %d", err);
+        
+        // There is no any rules yet avaible create 
+        if ( err == KErrNotFound && aCreateRule )
+            {
+            DP_SDA("FindRuleL Not any rules exist");
+            if ( iRulesUpdateState == EStateAddToWhiteList )
+                {
+                DP_SDA("FindRuleL add white list");
+                AddWhiteListL( iPresRulesDoc->DocumentRoot() );
+                CleanupStack::PopAndDestroy( 1 );
+                return ETrue;
+                }
+            else if ( iRulesUpdateState == EStateAddToBlockList  )
+                {
+                DP_SDA("FindRuleL add black list");
+                AddBlackListL( iPresRulesDoc->DocumentRoot() );
+                CleanupStack::PopAndDestroy( 1 );
+                return ETrue;
+                }
+            }
+            
+        // if rule element found find if aRule exist
+        TInt count = rule.Count();
+        for ( TInt i=0; i < count; i++ )
+            {
+            ruleNode = rule[i];
+            TBuf<KBufSize100> buf;
+            buf.Copy( 
+                ruleNode->Attribute( KPresenceId )->AttributeValue() );
+            DP_SDA2("FindRuleL ruleNode %S", &buf);
+      
+            attr = ruleNode->Attribute( KPresenceId );
+            if ( attr && !attr->AttributeValue().CompareF( aRule ) )
+                {
+                DP_SDA("CPresencePluginXdmPresRules::FindRuleL FOUND");
+                found = ETrue;
+                }
+            }
+                
+        if ( !found && aCreateRule)
+            {
+            // if rule not found create it
+            DP_SDA("CPresencePluginXdmPresRules::FindRuleL not found");
+            //if rule not found add rule and check again
+            if ( EStateAddToWhiteList == iRulesUpdateState )
+                {
+                DP_SDA("FindRuleL add white list2");
+                AddWhiteListL( iPresRulesDoc->DocumentRoot() );
+                CleanupStack::PopAndDestroy( 1 );
+                return ETrue;
+                }
+                else if ( EStateAddToBlockList == iRulesUpdateState )
+                {
+                DP_SDA("FindRuleL add black list 2");
+                AddBlackListL( iPresRulesDoc->DocumentRoot() );
+                CleanupStack::PopAndDestroy( 1 );
+                return ETrue;
+                }         
+            }
+        
+        CleanupStack::PopAndDestroy( 1 );    
+        return ETrue;
+        }
+     else
+        {
+        // Should we create presrules document
+        DP_SDA("CPresencePluginXdmPresRules::FindRuleL end");
+        return EFalse;
+        } 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::CheckIfOneExistL
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginXdmPresRules::CheckIfOneExistL(
+    const TDesC& aRule,
+    const TDesC& aUri )
+    {
+    using namespace NPresencePlugin::NPresence;
+    DP_SDA("CPresencePluginXdmPresRules::CheckIfOneExistL");
+    
+    using namespace NPresencePlugin::NPresence;
+    
+    CXdmNodeAttribute* attr = NULL;
+    RPointerArray<CXdmDocumentNode> nodes;
+    CleanupClosePushL( nodes );
+    TBool state( EFalse );
+    
+    CXdmDocumentNode* root = iPresRulesDoc->DocumentRoot();
+    CXdmDocumentNode* foundNode = SearchListUnderParentL( root, aRule );
+    
+    if ( foundNode )
+        {
+        DP_SDA("CPresencePluginXdmPresRules::CheckIfOneExistL check nodes");
+        TInt findErr = foundNode->Find( KPresenceOne, nodes );
+        DP_SDA2("CheckIfEnityExist - findErr: %d", findErr );
+
+        if ( findErr )
+            {
+            DP_SDA("CheckIfOneExistL One not exist ");
+            state = EFalse;
+            }
+        else
+            {
+            DP_SDA("CPresencePluginXdmPresRules::CheckIfOneExistL Else");
+            TInt nodeCount = nodes.Count();
+            for ( TInt i = 0; i < nodeCount; i++ )
+                {
+                CXdmDocumentNode* currNode = nodes[i];
+                attr = ( currNode )->Attribute( KPresenceId );
+                
+                TBool uriMatch( EFalse );                
+                uriMatch = CompareUriWithoutPrefixL( 
+                    aUri, attr->AttributeValue() );
+                
+                if ( attr && uriMatch )
+                    {
+                    DP_SDA("CheckIfOneExistL entity exists");
+                    //Enity is exist
+                    state = ETrue;
+                    break;
+                    }
+                }
+            }
+        }
+    DP_SDA("CPresencePluginXdmPresRules::CheckIfOneExistL Destroy nodes");
+    CleanupStack::PopAndDestroy( &nodes ); // >>> nodes    
+    return state;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::RemoveRuleGroupL( )
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmPresRules::RemoveRuleGroupL( const TDesC& aRule )
+    {
+    DP_SDA("CPresencePluginXdmUtils::RemoveRuleGroupL");
+    CXdmDocumentNode* ruleNode = NULL;
+    CXdmNodeAttribute* attr = NULL;
+    TBool found( EFalse );
+    TBool ruleAvaible( EFalse );
+    
+    using namespace NPresencePlugin::NPresence;
+
+    RPointerArray<CXdmDocumentNode> rules;
+    CleanupClosePushL( rules );
+
+    RPointerArray<CXdmDocumentNode> nodes;
+    CleanupClosePushL( nodes );
+
+    //Find rules
+    if ( iPresRulesDoc )
+        {
+        DP_SDA("RemoveRuleGroupL iPresRulesDoc ok");
+        
+        //Check if rule exist
+        ruleAvaible = FindRuleL( aRule, EFalse );
+        
+        if ( ruleAvaible )
+            {
+            // If rule found get count how many rules are in xml
+            TInt findErr = iPresRulesDoc->Find( KPresenceRule, rules );
+            DP_SDA2("RemoveRuleGroupL findError %d", findErr);
+            if ( !findErr )
+                {
+                DP_SDA("RemoveRuleGroupL found EFalse");
+                found = EFalse;
+                }
+            else
+                {
+                TInt count = rules.Count();
+                DP_SDA2("RemoveRuleGroupL rule count %d", count);
+                for ( TInt i=0; i < count; i++ )
+                    {
+                    ruleNode = rules[i];
+                    attr = ruleNode->Attribute( KPresenceId );
+                    if ( attr && !attr->AttributeValue().CompareF( aRule ))
+                        {
+                        found = ETrue;
+                        break;
+                        }
+                    }
+                }
+            }
+        }
+        
+    if ( found )
+        {
+        User::LeaveIfError( iPresRulesDoc->Find( KPresenceRule, nodes ));
+        TInt ruleCount = nodes.Count();
+        DP_SDA2("L node count %d", ruleCount);
+        for ( TInt i = 0; i < ruleCount; i++ )
+            {
+            CXdmDocumentNode* currNode = nodes[i];
+            attr = currNode->Attribute( KPresenceId );
+            if ( attr && !attr->AttributeValue().CompareF( aRule ))
+                {
+                DP_SDA("RemoveRuleGroupL remove rule");
+                // This is the user we are looking for deletion.
+                iPresRulesDoc->RemoveFromModelL( currNode );
+                //Update
+                iPresRulesDoc->AppendL();
+                break;
+                }
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+    CleanupStack::PopAndDestroy( &nodes ); // >>> nodes
+    CleanupStack::PopAndDestroy( &rules ); // >>> rules
+    DP_SDA("CPresencePluginXdmUtils::RemoveRuleGroupL end");
+    } 
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::UpdateFromServerL()
+// ---------------------------------------------------------------------------
+//    
+TInt CPresencePluginXdmPresRules::UpdateFromServerL( 
+	MPresRulesAsyncHandler* const aHandler )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::UpdateFromServer");
+    using namespace NPresencePlugin::NPresence;
+    __ASSERT_ALWAYS(aHandler, User::Leave(KErrArgument));
+
+    if ( IsActive() )
+	{
+    return KErrAlreadyExists;
+	}
+	iPresRulesDoc->ResetContents();
+    iPresRulesDoc->FetchDataL();
+    iAsyncReq = EXdmUpdateRulesFromServer;
+    iAsyncHandler = aHandler;
+    iXdmEngine->UpdateL( iPresRulesDoc, iStatus );
+    SetActive();
+    DP_SDA("CPresencePluginXdmPresRules::UpdateFromServer end");
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::CreateRootIfNeededL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginXdmPresRules::CreateRootIfNeededL()
+    {
+    DP_SDA("CPresencePluginXdmPresRules::CreateRootIfNeededL");
+    using namespace NPresencePlugin::NPresence;
+
+    CXdmDocumentNode* myRootNode = iPresRulesDoc->DocumentRoot();
+    
+    if ( myRootNode )
+        {
+        DP_SDA("CreateRootIfNeededL document root exists");
+        myRootNode->SetEmptyNode(EFalse);
+        return;
+        }
+        
+    DP_SDA("CPresencePluginXdmPresRules::CreateRootIfNeededL create root");    
+    myRootNode = iPresRulesDoc->CreateRootL();
+    DP_SDA("CreateRootIfNeededL create root pushL");
+    CleanupStack::PushL( myRootNode );
+    myRootNode->SetNameL( KPresenceRuleset );
+    DP_SDA("CPresencePluginXdmPresRules::CreateRootIfNeededL create root POP");    
+    CleanupStack::Pop( myRootNode );
+    DP_SDA("CPresencePluginXdmPresRules::CreateRootIfNeededL create root end");
+    }
+
+void CPresencePluginXdmPresRules::ResetAndDestroy1( TAny* aPointerArray )
+	{
+    if ( aPointerArray )
+        {
+        RPointerArray<CXdmDocumentNode>* array =
+            static_cast<RPointerArray<CXdmDocumentNode>*>( aPointerArray );
+        array->ResetAndDestroy();
+        array->Close();
+        }
+	}
+
+void CPresencePluginXdmPresRules::ResetAndDestroy2( TAny* aPointerArray )
+	{
+    if ( aPointerArray )
+        {
+        RPointerArray<SXdmAttribute16>* array =
+            static_cast<RPointerArray<SXdmAttribute16>*>( aPointerArray );
+        array->ResetAndDestroy();
+        array->Close();
+        }
+	}
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::SearchListUnderParentL
+// ---------------------------------------------------------------------------
+//
+CXdmDocumentNode* CPresencePluginXdmPresRules::SearchListUnderParentL(
+    CXdmDocumentNode* aParent,
+    const TDesC& aName )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::SearchListUnderParentL");
+    
+    using namespace NPresencePlugin::NPresence;
+
+    if ( !aParent )
+        {
+        DP_SDA("CPresencePluginXdmPresRules::SearchListUnderParentL return NULL");
+        return NULL;
+        }
+
+    RPointerArray<CXdmDocumentNode> resultArray;
+    RPointerArray<SXdmAttribute16>  attributeArray;
+
+    CleanupClosePushL( resultArray );           // <<< resultArray
+    CleanupClosePushL( attributeArray );        // <<< attributeArray
+
+    SXdmAttribute16 attr;
+    attr.iName.Set( KPresenceId );
+    attr.iValue.Set( aName );
+    attributeArray.AppendL( &attr );
+    
+    CXdmDocumentNode* currNode = NULL;
+    
+    aParent->Find( KPresenceRule, resultArray, attributeArray );
+
+    TInt count = resultArray.Count();
+    DP_SDA2("SearchListUnderParentL node count %d",count);
+    for ( TInt i=0; i < count; i++ )
+        {
+        currNode = resultArray[i];
+        CXdmDocumentNode* parent = currNode->Parent();
+        if ( parent == aParent )
+            {
+            DP_SDA("SearchListUnderParentL parent MATCH");
+            break;
+            }
+        currNode = NULL;
+        }
+
+    CleanupStack::PopAndDestroy(); // clItem
+    CleanupStack::PopAndDestroy(); // clItem2
+    DP_SDA("CPresencePluginXdmPresRules::SearchListUnderParentL return");
+    return currNode;
+    }
+   
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmPresRules::SearchListUnderParentL
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginXdmPresRules::CompareUriWithoutPrefixL( 
+    const TDesC& aUri, const TDesC& aAttribute )
+    {
+    DP_SDA("CPresencePluginXdmPresRules::CompareUriWithoutPrefixL");
+    
+    TBool match( EFalse );
+    
+    RBuf uriWithoutPrefix;
+    CleanupClosePushL( uriWithoutPrefix );
+    uriWithoutPrefix.CreateL( aUri );
+    TInt prefixLocation = uriWithoutPrefix.Locate( ':' );
+                   
+    if ( KErrNotFound != prefixLocation )
+        {
+        uriWithoutPrefix.Delete( 0, ( prefixLocation + 1 ) );
+        }
+        
+     RBuf attributeWithoutprefix;
+     CleanupClosePushL( attributeWithoutprefix );
+     attributeWithoutprefix.CreateL( aAttribute );
+     prefixLocation = attributeWithoutprefix.Locate( ':' );
+                   
+     if ( KErrNotFound != prefixLocation )
+         {
+         attributeWithoutprefix.Delete( 0, ( prefixLocation + 1 ) );
+         }
+                    
+     DP_SDA2("    --> uri without prefix=%S", &uriWithoutPrefix );
+     DP_SDA2("    --> attribute without prefix=%S", &attributeWithoutprefix );                 
+                
+     if ( uriWithoutPrefix.Compare( attributeWithoutprefix ) == 0 )
+         {
+         match = ETrue;
+         }
+                   
+    CleanupStack::PopAndDestroy( &attributeWithoutprefix );
+    CleanupStack::PopAndDestroy( &uriWithoutPrefix );
+    
+    return match;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presencepluginxdmutils.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,1687 @@
+/*
+* Copyright (c) 2006-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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <e32std.h>
+#include <utf.h>
+#include <e32test.h>
+#include <ximpobjectfactory.h>
+#include <presenceobjectfactory.h>
+#include <ximpidentity.h>
+#include <ximpobjectcollection.h>
+#include <presentitygroupinfo.h>
+#include <presentitygroupmemberinfo.h>
+#include <XdmEngine.h>
+#include <XdmDocument.h>
+#include <XdmProtocolInfo.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include <XdmErrors.h>
+#include <pressettingsapi.h> //for TPresSettingsSet
+#include <XdmSettingsApi.h>
+#include <XdmProtocolUidList.h>
+#include <avabilitytext.h>
+
+#include "presencepluginxdmpresrules.h"
+#include "mpresencepluginconnectionobs.h"
+#include "presenceplugincommon.h"
+#include "presencepluginxdmutils.h"
+#include "presencepluginvirtualgroup.h"
+#include "presencepluginauthorization.h"
+#include "presenceplugindata.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::CPresencePluginXdmUtils()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginXdmUtils::CPresencePluginXdmUtils(  
+	MPresencePluginConnectionObs& aObs , TInt aXmdId, TBool aLocalmode )
+    : CActive( CActive::EPriorityStandard ),
+    iConnObs(aObs), iSettingsId(aXmdId),
+    iXdmState(EStateIdle), iOperation( ENoOperation ),
+	iPresXdmOk( EFalse ), iXdmOk( EFalse ),
+	iRulesUpdateState(EStateNoOperation), iLocalMode( aLocalmode )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::ConstructL( )
+    {
+    
+    //If we are in normalmode we need presence rules too
+    if ( !iLocalMode )
+        {
+        DP_SDA("CPresencePluginXdmUtils::ConstructL NormalMode");
+        iXdmPresRules = CPresencePluginXdmPresRules::NewL( 
+            iSettingsId, EFalse );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginXdmUtils* CPresencePluginXdmUtils::NewL(
+    MPresencePluginConnectionObs& aObs, TInt aXmdId, TBool aLocalmode )
+    {
+    CPresencePluginXdmUtils* self =
+    	new( ELeave ) CPresencePluginXdmUtils( aObs, aXmdId, aLocalmode );
+    CleanupStack::PushL( self );
+    self->ConstructL(   );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::~CPresencePluginXdmUtils()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginXdmUtils::~CPresencePluginXdmUtils()
+    {
+    DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils");
+    if ( iXdmDoc )
+        {
+        DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils 1");
+        if (iXdmEngine)
+            {
+            DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils del doc");
+            TRAP_IGNORE( iXdmEngine->DeleteDocumentModelL( iXdmDoc ));
+            }
+        }
+        
+    DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils 3");
+    delete iXdmEngine;
+    iXdmEngine = NULL;
+
+
+    DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils 4");
+    delete iXdmPresRules;
+    iXdmPresRules = NULL;
+
+
+    DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils 5");
+    delete iEntityUri;
+    iEntityUri = NULL;
+
+    iBlockedContacts.ResetAndDestroy();
+
+    DP_SDA("CPresencePluginXdmUtils::~CPresencePluginXdmUtils end"); 
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::InitializeXdmL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::InitializeXdmL( TRequestStatus& aStatus )
+    {
+    DP_SDA("CPresencePluginXdmUtils::InitializeXdmL");
+    
+    aStatus = KRequestPending;
+	iClientStatus = &aStatus;
+    
+	// if resource-list not ready
+    if ( !iXdmOk ) 
+        {
+        DP_SDA("CPresencePluginXdmUtils::InitializeXdmL !iXdmOk");
+        if ( !iLocalMode )
+            {
+            DP_SDA("CPresencePluginXdmUtils::InitializeXdmL NormalMode");
+            GetXdmListsL( ETrue, EFalse );
+            }
+        else
+            {
+            DP_SDA("CPresencePluginXdmUtils::InitializeXdmL LocalMode");
+            GetXdmListsL( ETrue, ETrue );
+            }
+        }
+    else if ( !iPresXdmOk && !iLocalMode )
+        {
+        DP_SDA("CPresencePluginXdmUtils::InitializeXdmL  !iPresXdmOk");
+        GetXdmRulesL();  
+        }
+    else
+        {
+        DP_SDA("CPresencePluginXdmUtils::InitializeXdmL All is OK ");
+        // All is ok
+        DP_SDA("CPresencePluginXdmUtils::InitializeXdmL SEND COMPLETE")        
+        CompleteClientReq( KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::InitializeXdmL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginXdmUtils::InitializePresRulesL( )
+    {
+    DP_SDA("CPresencePluginXdmUtils:: MakeInitialRules");
+    iXdmState = ECreateXdmRules;
+	iRulesUpdateState = EStateInitializeRules;
+    iXdmPresRules->MakeInitialRulesDocumentL( this );
+    UpdateXdmRulesL();
+    DP_SDA("CPresencePluginXdmUtils:: MakeInitialRules done");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::GetXdmRulesL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginXdmUtils::GetXdmRulesL()
+    {
+    DP_SDA("CPresencePluginXdmUtils:: GetXdmRulesL");
+
+	if ( !iXdmPresRules )
+		{
+    // get data from a network if not done so yet
+		if ( !iLocalMode )
+			{
+			iXdmPresRules = CPresencePluginXdmPresRules::NewL( 
+				iSettingsId, EFalse );
+			}
+		else
+			{
+			/*localmode*/
+			//iXdmPresRules 
+			//= CPresencePluginXdmPresRules::NewL( iSettingsId, ETrue );
+			}
+		}
+    
+	if( !iLocalMode && iXdmPresRules )
+	    {
+	    User::LeaveIfError( iXdmPresRules->UpdateFromServerL( this ));
+	    }
+    iXdmState = EGetXdmRules;
+    DP_SDA("CPresencePluginXdmUtils:: GetXdmRulesL done");
+    DP_SDA("CPresencePluginXdmUtils::GetXdmRulesL - add buddies to virtual");
+    AddIdentityToVirtualListL( KPresenceBuddyList );
+    
+    DP_SDA("CPresencePluginXdmUtils::GetXdmRulesL - add blocked to virtual");
+    AddIdentityToVirtualListL( KPresenceBlockedList );
+    }
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::InitializeXdmsOnlyL()
+// ---------------------------------------------------------------------------
+//   
+void CPresencePluginXdmUtils::InitializeXdmsOnlyL( TRequestStatus& aStatus )
+    {
+    DP_SDA("CPresencePluginXdmUtils::InitializeXdmsOnlyL");             
+	aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+
+    if ( !iXdmOk )
+        {
+        DP_SDA("CPresencePluginXdmUtils::InitializeXdmsOnlyL 1");
+        GetXdmListsL( EFalse, EFalse );        
+        }
+    else
+        {
+        DP_SDA("CPresencePluginXdmUtils::InitializeXdmsOnlyL all ok");
+        // All is ok
+        DP_SDA("CPresencePluginXdmUtils::InitializeXdmsOnlyL SEND COMPLETE")        
+        CompleteClientReq( KErrNone );
+        }
+    DP_SDA("CPresencePluginXdmUtils::InitializeXdmsOnlyL end");
+    }
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::CheckXdmDoc()
+// ---------------------------------------------------------------------------
+//    
+TBool CPresencePluginXdmUtils::CheckXdmDoc()
+    {
+    DP_SDA("CPresencePluginXdmUtils::CheckXdmDoc");
+    
+    if ( iXdmDoc )
+        {
+        CXdmDocumentNode* root = iXdmDoc->DocumentRoot();
+        DP_SDA("CPresencePluginXdmUtils::CheckXdmDoc2");
+        if( root )
+        	{	
+            TInt count = root->NodeCount();
+            DP_SDA2("CPresencePluginXdmUtils::CheckXdmDoc count %d", count);
+            if ( !count )
+                {
+                DP_SDA("CPresencePluginXdmUtils::CheckXdmDoc NotFound");
+                iXdmOk = EFalse;
+                }
+            else
+                {
+                DP_SDA("CPresencePluginXdmUtils::CheckXdmDoc file ok");
+                iXdmOk = ETrue;
+                }
+        	}
+        }
+    else
+        {
+        DP_SDA("CPresencePluginXdmUtils::CheckXdmDoc file False");
+        iXdmOk = EFalse;
+        }
+    
+    return iXdmOk;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::CheckIfError
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginXdmUtils::CheckIfErrorL( TInt aMyStatus )
+    {
+    TInt myStatus = aMyStatus;
+    DP_SDA2("CPresencePluginXdmUtils::CheckIfError ErrorCode %d ", myStatus);
+    if ( myStatus == KErrTimedOut )
+        {
+        DP_SDA("CPresencePluginXdmUtils::CheckIfError  TimeOut error");
+        myStatus = KErrTimedOut;
+        User::Leave( KErrTimedOut );
+        }
+    else if ( myStatus == KErrCouldNotConnect || 
+    	myStatus == KXcapErrorNetworkNotAvailabe )
+        {
+        DP_SDA("CheckIfError KErrCouldNotConnect error");
+        myStatus = aMyStatus;
+        }
+	else if ( myStatus == KXcapErrorHttpNotFound )
+		{
+		DP_SDA("CheckIfError KXcapErrorHttpNotFound");
+        myStatus = aMyStatus;
+		}
+    else if ( myStatus == KXcapErrorAuthentication )
+        {
+        DP_SDA("CPresencePluginXdmUtils::CheckIfError auth error");                        
+        myStatus = aMyStatus;
+        }
+    else if ( myStatus == KXcapErrorTooManyOccurencies )
+        {
+        DP_SDA("CPresencePluginXdmUtils KXcapErrorTooManyOccurencies");                        
+        myStatus = 0;
+        }
+    else if( myStatus == KErrDisconnected )
+        {
+        myStatus = aMyStatus;
+        User::Leave( KErrCancel );
+        }
+    else if( myStatus == KXcapErrorHttpPrecondFailed )
+    	{
+    	DP_SDA("CheckIfError KXcapErrorHttpPrecondFailed");
+        myStatus = aMyStatus;
+    	}
+    else if ( KErrNoMemory == myStatus )
+        {
+        DP_SDA("CheckIfError KErrNoMemory");
+        User::Leave( KErrNoMemory );
+        }
+    else
+        {
+        DP_SDA("CPresencePluginXdmUtils::CheckIfError ERROR");
+        myStatus = aMyStatus;
+        }
+    return myStatus;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::RunL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::RunL(  )
+    {    
+    DP_SDA("CPresencePluginXdmUtils::RunL");    
+    TPluginXdmState origState = iXdmState;
+    iXdmState = EStateIdle;
+    TInt myStatus = iStatus.Int();
+    
+    DP_SDA2("CPresencePluginXdmUtils::RunL mystatus %d ", myStatus);
+    DP_SDA2("CPresencePluginXdmUtils::RunL state %d ", origState);
+    DP_SDA2("CPresencePluginXdmUtils:: ClientStatus %d",iClientStatus->Int() );
+    
+    if ( myStatus == KErrCancel )
+        {
+        DP_SDA("CPresencePluginXdmUtils::RunL CANCEL SEND COMPLETE")
+        CompleteClientReq( KErrCancel );
+        }
+    
+    switch ( origState )
+        {
+        case EGetXdmLists:
+		case EGetXdmListsOnly:
+            {
+            DoGetXdmListsL( myStatus, origState );
+            }
+        break;
+                
+        case ECreateXdmLists:
+            {
+            DoCreateXdmListsL( myStatus, origState, EFalse );
+            }
+        break;
+        
+        case ECreateXdmListsOnly:
+            {
+            DoCreateXdmListsL( myStatus, origState, ETrue );
+            }
+        break;
+          
+        case EGetXdmBlockList:
+            {
+            DP_SDA("RunL EGetXdmBlockList SEND COMPLETE");
+            CompleteClientReq( KErrNone );
+            }
+        break;
+        
+        case EUpdateXdmList:
+            {
+            DoUpdateXdmListsL( myStatus, origState );
+            }
+        break;
+
+        case EUpdateBlockedContactPresenceCache:
+            DoUpdateBlockedContactPresenceCacheL( myStatus );
+            break;
+
+        default:
+            {
+            DP_SDA("CPresencePluginXdmUtils::RunL last else");        
+            //check myStatus error
+            myStatus = CheckIfErrorL( myStatus );
+                
+            if ( myStatus )
+                {
+                // complete reqular request
+                DP_SDA("CPresencePluginXdmUtils::RunL SEND LAST COMPLETE");
+                CompleteClientReq( myStatus );
+                }
+            DP_SDA("CPresencePluginXdmUtils::RunL default end")
+            }
+        break;
+          
+        }
+    DP_SDA("CPresencePluginXdmUtils::RunL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::DoUpdateXdmLists()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::DoUpdateXdmListsL( 
+    TInt aMyStatus,
+    TPluginXdmState /*aOrigState*/)
+    {
+    DP_SDA("CPresencePluginXdmUtils::DoUpdateXdmLists EUpdateXdmList");
+    if ( !iLocalMode )
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoUpdateXdmLists updaterules");
+        if( aMyStatus )
+        	{
+        	DP_SDA("DoUpdateXdmLists updaterules error");
+        	aMyStatus = CheckIfErrorL( aMyStatus );
+        	CompleteClientReq( aMyStatus );
+        	}
+        else
+        	{
+        	DP_SDA("DoUpdateXdmLists updaterules else");	 
+        	UpdateXdmRulesL();
+        	}
+        }
+    else
+        {
+        DP_SDA("EUpdateXdmList LOCALMODE SEND COMPLETE");
+        aMyStatus = CheckIfErrorL( aMyStatus );
+        CompleteClientReq( aMyStatus );
+        } 
+    iRulesUpdateState = EStateNoOperation;
+    DP_SDA("CPresencePluginXdmUtils::DoUpdateXdmLists EUpdateXdmList end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::DoCreateXdmLists()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::DoCreateXdmListsL( 
+    TInt aMyStatus,
+    TPluginXdmState /*aOrigState*/,
+    TBool aOnlyResourceList )
+    {
+    DP_SDA("CPresencePluginXdmUtils::DoCreateXdmListsL ECreateXdmLists");
+    //check myStatus error
+    aMyStatus = CheckIfErrorL( aMyStatus );
+    if( !aOnlyResourceList )
+        {
+        if ( aMyStatus )
+            {
+            DP_SDA("DoCreateXdmLists ECreateXdmLists SEND COMPLETE");
+            CompleteClientReq( aMyStatus );
+            }
+        else if ( !iLocalMode )
+            {
+            DP_SDA("ECreateXdmLists !myStatus GetXdmRules");
+            iXdmOk = ETrue;
+            GetXdmRulesL();
+            }
+        else if ( iLocalMode )
+            {
+            DP_SDA("DoCreateXdmLists ECreateXdmLists SEND COMPLETE 2");
+            iXdmOk = ETrue;
+            CompleteClientReq( aMyStatus );
+            }
+        }
+    else
+        {
+        //check myStatus error
+        aMyStatus = CheckIfErrorL( aMyStatus );     
+        if ( aMyStatus == KErrTimedOut  )
+            { 
+            DP_SDA("DoCreateXdmLists EGetXdmListsOnly 1");
+            aMyStatus = 0;
+            }           
+        if ( !aMyStatus )
+            {
+            DP_SDA("DoCreateXdmLists EGetXdmListsOnly 2");
+            iXdmOk = ETrue;
+            }
+        
+        if( !(KXcapErrorNetworkNotAvailabe == aMyStatus || 
+              KErrCouldNotConnect == aMyStatus ) )
+            {
+            DP_SDA("DoCreateXdmLists EGetXdmListsOnly SEND COMPLETE");
+            CompleteClientReq( aMyStatus );
+            }
+        }
+    DP_SDA("CPresencePluginXdmUtils::DoCreateXdmListsL ECreateXdmLists end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::DoGetXdmLists()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::DoGetXdmListsL( 
+    TInt aMyStatus,
+    TPluginXdmState aOrigState )
+    {
+    DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists EGetXdmLists");
+    //check myStatus error
+    aMyStatus = CheckIfErrorL( aMyStatus );
+
+    if ( aMyStatus )//Check is file includes nodes
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists CreateXDM");
+        // no resource-list, let's start to create it.
+        CreateXdmListsL( ETrue );
+        }
+    else
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists EGetXdmLists else");
+        if( iLocalMode )
+            {
+            //Check if document empty
+            TBool empty = CheckXdmDoc();
+            if( !empty )
+                {
+                CreateXdmListsL( ETrue );
+                }
+            else
+                {
+                iXdmOk = ETrue;
+                DP_SDA("DoGetXdmLists Localmode SEND COMPLETE"); 
+                CompleteClientReq( KErrNone );
+                }
+            }
+        else
+            {
+            iXdmOk = ETrue;
+            if ( !iPresXdmOk && !iLocalMode && aOrigState == EGetXdmLists )
+                {
+                DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists GetXDM");
+                GetXdmRulesL();
+                }
+            else
+                {
+                DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists SEND COMPLETE"); 
+                CompleteClientReq( KErrNone );
+                }
+            }
+        }
+    DP_SDA("CPresencePluginXdmUtils::DoGetXdmLists end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::DoCancel()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::DoCancel( )
+    {										  
+    DP_SDA("CPresencePluginXdmUtils::DoCancel");
+    iOperation = EXdmCancel;
+
+    if ( iXdmState == EGetXdmLists || iXdmState == ECreateXdmLists ||
+         iXdmState == EUpdateXdmRules || iXdmState == EUpdateXdmList ||
+         iXdmState == EGetXdmBlockList || iXdmState == ECreateXdmRules ||
+         iXdmState == ESubsBlockList || 
+         iXdmState == EGetResourceListFromServer ||
+         iXdmState == EGetXdmListsOnly || iXdmState == ECreateXdmListsOnly )
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoCancel list get or create");
+        iXdmState = ECancelDocument;
+        iXdmEngine->CancelUpdate( iXdmDoc );
+        // cancel presrules too
+        iXdmPresRules->Cancel();
+        }
+    else
+        {
+        iStatus = KRequestPending;
+        TRequestStatus* s= &iStatus;
+        DP_SDA("CPresencePluginXdmUtils::DoCancel SEND COMPLETE");
+        User::RequestComplete( s, KErrCancel );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::RunError()
+// ---------------------------------------------------------------------------
+//
+TInt CPresencePluginXdmUtils::RunError( TInt aError )
+    {
+    DP_SDA("CPresencePluginXdmUtils::RunError");
+    // complete the open request
+    CompleteClientReq( aError );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::AddEntityToGrantedL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::AddEntityToGrantedL(
+    const TDesC&  aUri,
+    TRequestStatus& aStatus )
+    {
+  	DP_SDA("CPresencePluginXdmUtils::AddEntityToGrantedL");
+  	DP_SDA2("CPresencePluginXdmUtils::AddEntityToGrantedL, uri: %S", &aUri );
+  	
+  	TRAPD( err, iEntityUri =  aUri.AllocL() );
+  	DP_SDA2(" AddEntityToGrantedL, uri alloc err: %d", err );
+   
+   //Add entity to virtualGroup
+  	iConnObs.SubscribedContacts()->AddEntityL( iEntityUri->Des() );
+  	
+  	if ( !err )
+  	    {
+  	    DP_SDA("CPresencePluginXdmUtils::AddEntityToGrantedL !err");
+  	    iXdmState = EUpdateXdmList;
+        iClientStatus = &aStatus;
+        iOperation = EXdmAddUserToGroup;
+        iRulesUpdateState = EStateAddToWhiteList;
+        
+        //add user to resouce-list list
+        DoAddUserToListL( KPresenceBuddyList, aUri );
+        DP_SDA("CPresencePluginXdmUtils::AddEntityToGrantedL 1");
+        UpdateXdmsL();
+        
+        *iClientStatus = KRequestPending;
+        DP_SDA("CPresencePluginXdmUtils::AddEntityToGrantedL end");
+  	    }
+  	 else
+  	    {
+  	    DP_SDA("AddEntityToGrantedL else error SEND COMPLETE");
+  	    //If error we can complete request
+  	    CompleteClientReq( KErrNone );
+  	    }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::AddEntityToBlockedL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::AddEntityToBlockedL(
+    const TDesC&  aUri,
+    TRequestStatus& aStatus )
+    {
+    DP_SDA("CPresencePluginXdmUtils::AddEntityToBlockedL");
+    iClientStatus = &aStatus;
+        
+    if( iLocalMode )
+        {
+        //Block is not used in localmode
+        DP_SDA("AddEntityToBlockedL localmode rules not support");
+        CompleteClientReq( KErrNotSupported );
+        }
+    else
+        {
+        DP_SDA("CPresencePluginXdmUtils::AddEntityToBlockedL !localmode");
+        TRAPD(err, iEntityUri =  aUri.AllocL() );
+		//Remove entity form subscribed virtual group
+    	iConnObs.SubscribedContacts()->RemoveEntityL( iEntityUri->Des() );
+    	
+        if ( !err )
+            {
+            DP_SDA("CPresencePluginXdmUtils::AddEntityToBlockedL no error");
+            iXdmState = EUpdateXdmList;
+            iOperation = EXdmAddUserToGroup;
+            iRulesUpdateState = EStateAddToBlockList;
+
+            DoAddUserToListL( KPresenceBlockedList, aUri );
+            UpdateXdmsL();
+
+            *iClientStatus = KRequestPending;
+            DP_SDA("CPresencePluginXdmUtils::AddEntityToBlockedL ready");
+            }
+        else
+        	{
+        	//If error we can complete request
+        	DP_SDA("AddEntityToBlockedL SEND COMPLETE");
+        	CompleteClientReq( KErrNone );
+        	}
+        }
+    DP_SDA("CPresencePluginXdmUtils::AddEntityToBlockedL end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::DoAddUserToListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::DoAddUserToListL(
+    const TDesC& aList,
+    const TDesC&  aUri )
+    {
+    DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL");
+    DP_SDA2("CPresencePluginXdmUtils::DoAddUserToListL aList: %S", &aList);
+    DP_SDA2("CPresencePluginXdmUtils::DoAddUserToListL aUri: %S", &aUri);
+    
+    using namespace NPresencePlugin::NPresence;
+     
+    CXdmDocumentNode* root = iXdmDoc->DocumentRoot();
+    CXdmDocumentNode* foundNode = SearchListUnderParentL( root, aList );
+        
+    if ( foundNode )
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL found");
+        if ( !CheckIfEnityExistL( aList, aUri ) )
+            {
+            DP_SDA("DoAddUserToListL entity not exist");
+            if ( foundNode->IsEmptyNode() )
+                {
+                DP_SDA("DoAddUserToListL IsEmptyNode");
+                foundNode->SetEmptyNode( EFalse );
+                }
+                
+			DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL newNode");
+            CXdmDocumentNode* newNode = 
+                foundNode->CreateChileNodeL( KPresenceEntry );
+            DP_SDA("DoAddUserToListL entry attribute");    
+            CXdmNodeAttribute* attributeEntryUri = 
+                newNode->CreateAttributeL( KPresenceUri );
+            DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL set entry");    
+            attributeEntryUri->SetAttributeValueL( aUri );
+            DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL Append");
+            iXdmDoc->AppendL( );
+            }
+        }
+    else
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL leave");
+        User::Leave( KErrNotFound );
+        }
+	DP_SDA("CPresencePluginXdmUtils::DoAddUserToListL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::CheckIfEnityExistL
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginXdmUtils::CheckIfEnityExistL(
+    const TDesC& aList,
+    const TDesC&  aUri )
+    {
+    DP_SDA("CPresencePluginXdmUtils::CheckIfEnityExist");
+    
+    using namespace NPresencePlugin::NPresence;
+    
+    CXdmNodeAttribute* attr = NULL;
+    RPointerArray<CXdmDocumentNode> nodes;
+    CleanupClosePushL( nodes );
+    TBool state( EFalse );
+    
+    CXdmDocumentNode* root = iXdmDoc->DocumentRoot();
+    CXdmDocumentNode* foundNode = SearchListUnderParentL( root, aList );
+    
+    if ( foundNode )
+        {
+        DP_SDA("CPresencePluginXdmUtils::CheckIfEnityExist check nodes");
+        TInt findErr = foundNode->Find( KPresenceEntry, nodes );
+        DP_SDA2("CheckIfEnityExist - findErr: %d", findErr );
+
+        if ( findErr )
+            {
+            DP_SDA("CheckIfEnityExist Enity not exist ");
+            state = EFalse;
+            }
+        else
+            {
+            DP_SDA("CPresencePluginXdmUtils::CheckIfEnityExist Else");
+            TInt nodeCount = nodes.Count();
+            for ( TInt i = 0; i < nodeCount; i++ )
+                {
+                CXdmDocumentNode* currNode = nodes[i];
+                attr = ( currNode )->Attribute( KPresenceUri );
+                
+                TBool uriMatch( EFalse );
+                uriMatch = CompareUriWithoutPrefixL( 
+                    aUri, attr->AttributeValue() );
+                
+                if ( attr && uriMatch )
+                    {
+                    DP_SDA("CheckIfEnityExist entity exists");
+                    //Enity is exist
+                    state = ETrue;
+                    break;
+                    }
+                }
+            }
+        }
+    DP_SDA("CPresencePluginXdmUtils::CheckIfEnityExist Destroy nodes");
+    CleanupStack::PopAndDestroy( &nodes ); // >>> nodes    
+    return state;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::SearchListUnderParentL
+// ---------------------------------------------------------------------------
+//
+CXdmDocumentNode* CPresencePluginXdmUtils::SearchListUnderParentL(
+    CXdmDocumentNode* aParent,
+    const TDesC& aName )
+    {
+    DP_SDA("CPresencePluginXdmUtils::SearchListUnderParentL");
+    
+    using namespace NPresencePlugin::NPresence;
+
+    if ( !aParent )
+        {
+        DP_SDA("CPresencePluginXdmUtils::SearchListUnderParentL return NULL");
+        return NULL;
+        }
+
+    RPointerArray<CXdmDocumentNode> resultArray;
+    RPointerArray<SXdmAttribute16>  attributeArray;
+
+    CleanupClosePushL( resultArray );           // <<< resultArray
+    CleanupClosePushL( attributeArray );        // <<< attributeArray
+
+    SXdmAttribute16 attr;
+    attr.iName.Set( KPresenceName );
+    attr.iValue.Set( aName );
+    attributeArray.AppendL( &attr );
+
+    CXdmDocumentNode* currNode = NULL;
+
+    aParent->Find( KPresenceList, resultArray, attributeArray );
+
+    TInt count = resultArray.Count();
+    DP_SDA2("SearchListUnderParentL node count %d",count);
+    for ( TInt i=0; i < count; i++ )
+        {
+        currNode = resultArray[i];
+        CXdmDocumentNode* parent = currNode->Parent();
+        if ( parent == aParent )
+            {
+            DP_SDA("SearchListUnderParentL parent MATCH");
+            break;
+            }
+        currNode = NULL;
+        }
+
+    CleanupStack::PopAndDestroy( &attributeArray); // >>> attributeArray
+    CleanupStack::PopAndDestroy( &resultArray );   // >>> resultArray
+    DP_SDA("CPresencePluginXdmUtils::SearchListUnderParentL return");
+    return currNode;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::RemoveEntityFromGrantedL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginXdmUtils::RemoveEntityFromGrantedL(
+    const TDesC&  aUri,
+    TRequestStatus& aStatus )
+    {
+    DP_SDA("CPresencePluginXdmUtils::RemoveEntityFromGrantedL");
+    
+    iEntityUri =  aUri.AllocL();
+  	iConnObs.SubscribedContacts()->RemoveEntityL( iEntityUri->Des() );
+  	
+    iClientStatus = &aStatus;
+    *iClientStatus = KRequestPending;
+    
+    iRulesUpdateState = EStateRemoveFromWhiteList;
+    iOperation = EXdmRemoveUserFromGroup;
+
+    TRAPD( err, DoRemoveUserFromListL( KPresenceBuddyList, aUri ) );
+    
+    if ( !err )
+        {
+        // send to the server and start wait a response
+        UpdateXdmsL();
+        iXdmState = EUpdateXdmList;
+        }
+    else
+        {
+        //complete request with error
+        DP_SDA2( "RemoveEntityFromGrantedL -DoRemoveUserFromListL error = %d", err );
+        CompleteClientReq( err );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::RemoveEntityFromBlockedL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::RemoveEntityFromBlockedL(
+    const TDesC&  aUri,
+    TRequestStatus& aStatus )
+    {
+    DP_SDA("CPresencePluginXdmUtils::RemoveEntityFromBlockedL");
+    TRAPD(err, iEntityUri =  aUri.AllocL() );
+    
+    if ( !err )
+        {
+        iClientStatus = &aStatus;
+        iRulesUpdateState = EStateRemoveFromBlackList;
+        iOperation = EXdmRemoveUserFromGroup;
+
+        DoRemoveUserFromListL( KPresenceBlockedList, aUri );
+        // send to the server and start wait a response
+        UpdateXdmsL();
+        iXdmState = EUpdateXdmList;
+        *iClientStatus = KRequestPending;
+        }
+    else
+        {
+        //If error we can complete request
+        DP_SDA("RemoveEntityFromBlockedL SEND COMPLETE");
+  	    CompleteClientReq( KErrNone );
+        }  
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::DoRemoveUserFromListL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginXdmUtils::DoRemoveUserFromListL(
+    const TDesC& aList,
+    const TDesC&  aUri )
+    {
+    DP_SDA("CPresencePluginXdmUtils::DoRemoveUserFromListL");
+    CXdmNodeAttribute* attr = NULL;
+
+    using namespace NPresencePlugin::NPresence;
+
+    RPointerArray<CXdmDocumentNode> lists;
+    CleanupClosePushL( lists );
+
+    RPointerArray<CXdmDocumentNode> nodes;
+    CleanupClosePushL( nodes );
+
+    CXdmDocumentNode* root = iXdmDoc->DocumentRoot();
+    CXdmDocumentNode* foundNode = SearchListUnderParentL( root, aList );
+    if ( foundNode )
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoRemoveUserFromListL Node Found");		
+        User::LeaveIfError( foundNode->Find( KPresenceEntry, nodes ));
+        TInt nodeCount = nodes.Count();
+        for ( TInt i = 0; i < nodeCount; i++ )
+            {
+            CXdmDocumentNode* currNode = nodes[i];         
+            attr = ( currNode )->Attribute( KPresenceUri );
+            
+            TBool uriMatch( EFalse );
+            uriMatch = CompareUriWithoutPrefixL( 
+                aUri, attr->AttributeValue() );
+            
+            if ( attr && uriMatch )
+                {
+                DP_SDA(" DoRemoveUserFromListL Node Found, do delete");	
+            
+                // This is the user we are looking for deletion.
+                //First remove currNode form model
+                iXdmDoc->RemoveFromModelL( currNode );
+                // Update model to server
+                iXdmDoc->AppendL();
+                break;
+                }
+            }
+        }
+    else
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoRemoveUserFromListL Leave");	
+        User::Leave( KErrNotFound );
+        }
+
+    CleanupStack::PopAndDestroy( &nodes ); // >>> nodes
+    CleanupStack::PopAndDestroy( &lists ); // >>> lists
+    DP_SDA("CPresencePluginXdmUtils::DoRemoveUserFromListL END");
+    }
+       
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::SubscribeBuddyListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::SubscribeBuddyListL( 
+    RPointerArray<MXIMPIdentity>& aMembers )
+    {
+    DP_SDA("CPresencePluginXdmUtils::SubscribeBuddyListL");
+
+    iOperation = EXdmGetBuddyList;
+    DoGetListMembersL( KPresenceBuddyList, aMembers );
+
+    DP_SDA("CPresencePluginXdmUtils::SubscribeBuddyListL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::SubscribeBlockListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::SubscribeBlockListL( 
+    RPointerArray<MXIMPIdentity>& aMembers )
+    {
+    DP_SDA("CPresencePluginXdmUtils::SubscribeBlockListL");
+
+    if ( !iLocalMode )
+        {
+        DP_SDA("CPresencePluginXdmUtils::SubscribeBlockListL !iLocalMode");
+        iOperation = EXdmGetBlockedList;
+        DoGetListMembersL( KPresenceBlockedList, aMembers );
+        }
+    DP_SDA("CPresencePluginXdmUtils::SubscribeBlockListL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::DoGetListMembersL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::DoGetListMembersL(
+    const TDesC& aList,
+    RPointerArray<MXIMPIdentity>& aMembers  )
+    {
+    DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL");
+    using namespace NPresencePlugin::NPresence;
+
+    aMembers.Reset();
+
+    RPointerArray<CXdmDocumentNode> nodes;
+    CleanupClosePushL( nodes );
+
+    CXdmDocumentNode* listNode = NULL;
+    CXdmNodeAttribute* attr = NULL;
+
+    TBool found(EFalse);
+        
+    if ( iXdmDoc )
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL iXdmDoc");
+        User::LeaveIfError( iXdmDoc->Find( KPresenceList, nodes ) );
+        DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL find ready");
+        TInt count = nodes.Count();
+        DP_SDA2("DoGetListMembersL find Count %d", count);
+        for ( TInt i=0; i < count; i++ )
+            {
+            listNode = nodes[i];
+            attr = listNode->Attribute( KPresenceName );
+            if ( attr && !attr->AttributeValue().CompareF( aList ))
+                {
+                // That's the right list
+                DP_SDA("DoGetListMembersL Target found");
+                found = ETrue;
+                break;
+                }
+            }
+        }
+   
+    if ( found )
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL found");
+        MXIMPObjectFactory& myFactory = iConnObs.ObjectFactory();
+        nodes.Reset();
+        TInt err = listNode->Find( KPresenceEntry, nodes );
+        DP_SDA2("CPresencePluginXdmUtils::DoGetListMembersL err %d", err);
+        if( !err )
+            {
+            DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL Entry found");
+            TInt nodeCount = nodes.Count();
+            for ( TInt i = 0; i < nodeCount; i++ )
+                {
+                attr = (nodes[i])->Attribute( KPresenceUri );
+                if ( attr )
+                    {
+                    DP_SDA("DoGetListMembersL attr check");
+                    MXIMPIdentity* entity =
+                        myFactory.NewIdentityLC(); // << entity
+                    entity->SetIdentityL( attr->AttributeValue() );
+                    aMembers.AppendL( entity );
+                    CleanupStack::Pop(); // >> entity
+                    }
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy( &nodes );
+    DP_SDA("CPresencePluginXdmUtils::DoGetListMembersL end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::GetXdmListsL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::GetXdmListsL( 
+    TBool aCreateRules,
+    TBool aLocalMode )
+    {
+    DP_SDA("CPresencePluginXdmUtils::GetXdmListsL");
+    //Normal Mode start
+    if ( !iXdmEngine && !aLocalMode )
+        {
+        DP_SDA2("!iXdmEngine settingID = %d", iSettingsId);
+        
+#ifdef _DEBUG
+        //Get xdmSettings
+        HBufC* accesPoint = TXdmSettingsApi::PropertyL( 
+            iSettingsId, EXdmPropToNapId );
+        CleanupStack::PushL( accesPoint );
+        DP_SDA2("CPresencePluginXdmUtils::GetXdmListsL accesPoint %S", 
+            accesPoint);
+#endif
+        
+        // get data from a network if not done so yet
+        CXdmProtocolInfo* info = CXdmProtocolInfo::NewL( iSettingsId );
+        CleanupStack::PushL( info );
+        
+        // Notice: we do not use cache for XDM
+        info->SetCacheUsage( EFalse ); //False in normal case
+        
+        iXdmEngine = CXdmEngine::NewL( *info );
+        CleanupStack::PopAndDestroy( info );
+#ifdef _DEBUG        
+        CleanupStack::PopAndDestroy( accesPoint );
+#endif        
+        }
+    //LocalMode Start, !!! THERE IS LIMIT !!!
+    //Only one settings can use localmode 
+    else if ( !iXdmEngine && aLocalMode )
+        {
+        DP_SDA("CPresencePluginXdmUtils::GetXdmListsL aLocalMode");
+        CXdmProtocolInfo* info =
+            CXdmProtocolInfo::NewL( 0, KLocalProtocol, KNullDesC );
+        CleanupStack::PushL( info );
+        
+        iXdmEngine = CXdmEngine::NewL( *info );
+        CleanupStack::PopAndDestroy( info );
+        DP_SDA("CPresencePluginXdmUtils::GetXdmListsL aLocalMode end");
+        }   
+    if ( !iXdmOk )
+        {
+        DP_SDA("CPresencePluginXdmUtils::GetXdmListsL !XdmOK "); 
+        using namespace NPresencePlugin::NPresence;
+        // Get data from network
+        DP_SDA("GetXdmListsL Create Document Model ");
+        
+        iXdmDoc = iXdmEngine->CreateDocumentModelL( 
+            KPresenceResourceList, EXdmResourceLists );
+       
+        
+        DP_SDA("Create Document Model FetchData");
+        iXdmDoc->FetchDataL();    
+        DP_SDA("CPresencePluginXdmUtils::GetXdmListsL !XdmOK SETACTIVE ");
+        UpdateXdmsL();
+        iXdmState = aCreateRules ? EGetXdmLists : EGetXdmListsOnly;
+        DP_SDA("CPresencePluginXdmUtils::GetXdmListsL !XdmOK END"); 
+        }
+    else
+        {
+        DP_SDA("CPresencePluginXdmUtils::GetXdmListsL else");
+        // Document already exists, no need to search from a server
+        iStatus = KRequestPending;
+        TRequestStatus* s= &iStatus;
+        DP_SDA("CPresencePluginXdmUtils::GetXdmListsL SEND COMPLETE");
+        User::RequestComplete( s, KErrNone );
+        iXdmState = aCreateRules ? EGetXdmLists : EGetXdmListsOnly;
+        SetActive();        
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::CreateXdmListsL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::CreateXdmListsL( TBool aCreateRules )
+    {
+    DP_SDA("CPresencePluginXdmUtils::CreateXdmListsL");
+ 
+    CXdmDocumentNode* root = iXdmDoc->CreateRootL();
+    CleanupStack::PushL( root );
+    
+    using namespace NPresencePlugin::NPresence;
+    root->SetNameL( KPresenceResourceLists );
+
+    // add all the list nodes
+    // buddylist
+    using namespace NPresencePlugin::NPresence;
+    if ( root->IsEmptyNode() )
+        {
+        root->SetEmptyNode( EFalse );
+        }
+    //buddy list
+    CXdmDocumentNode* child1 = root->CreateChileNodeL( KPresenceList );
+    CleanupStack::PushL( child1 );
+    CXdmNodeAttribute* name = child1->CreateAttributeL( KPresenceName );
+    CleanupStack::PushL( name );
+    name->SetAttributeValueL( KPresenceBuddyList );
+
+    // blockedcontacts
+    CXdmDocumentNode* child2 = root->CreateChileNodeL( KPresenceList );
+    CleanupStack::PushL( child2 );
+    CXdmNodeAttribute* name2 = child2->CreateAttributeL( KPresenceName );
+    CleanupStack::PushL( name2 );
+    name2->SetAttributeValueL( KPresenceBlockedList );
+
+    // send to the server and start wait a response
+    iXdmDoc->AppendL();
+    UpdateXdmsL();
+    iXdmState = aCreateRules ? ECreateXdmLists : ECreateXdmListsOnly;
+    
+    CleanupStack::Pop( name2 );
+    CleanupStack::Pop( child2 );
+    CleanupStack::Pop( name );
+    CleanupStack::Pop( child1 );
+    CleanupStack::Pop( root );
+    DP_SDA("CPresencePluginXdmUtils::CreateXdmListsL end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::GetEntitiesInListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::GetEntitiesInListL(
+    const TDesC&  aList,
+    MXIMPObjectCollection& aColl )
+    {
+    DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL ");
+    using namespace NPresencePlugin::NPresence;
+
+    CXdmDocumentNode* buddylist = DoGetBuddyListL( aList );
+
+    // make a collection of MXIMPPresentityGroupMemberInfo
+    RPointerArray<CXdmDocumentNode> entries;
+    CleanupClosePushL(entries);       // <<< entries
+
+    RPointerArray<CXdmDocumentNode> nodes;
+    CleanupClosePushL(nodes);         // <<< nodes
+
+    buddylist->Find( KPresenceEntry, entries );
+    DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL entries");
+    TInt count = entries.Count();
+    DP_SDA2("GetEntitiesInListL entries count %d",count);
+    for ( TInt i=0; i < count; i++ )
+        {
+        DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL 1");
+        // create here MXIMPPresentityGroupMemberInfo
+        MPresentityGroupMemberInfo* info =
+            iConnObs.PresenceObjectFactoryOwn().
+                NewPresentityGroupMemberInfoLC();
+
+        // ID
+        CXdmDocumentNode* entry = entries[i];
+        CXdmNodeAttribute* attr = entry->Attribute( KPresenceUri );
+        if ( attr )
+            {
+            DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL 2");
+            MXIMPIdentity* id =
+                iConnObs.ObjectFactory().NewIdentityLC();//<< id
+            id->SetIdentityL( attr->AttributeValue() );
+            info->SetGroupMemberIdL( id );
+            CleanupStack::Pop(); // >> id
+            }
+
+        // Display name
+        TInt err = entry->Find( KPresenceDisplayName, nodes );
+        // Notice: assume there is only one display-name
+        if ( !err )
+            {
+            DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL display name");
+            CXdmDocumentNode* disName = nodes[0];
+                HBufC16* uri16 = NULL;
+                uri16 = 
+                    CnvUtfConverter::ConvertToUnicodeFromUtf8L( 
+                        disName->LeafNodeContent() );
+                    
+                CleanupStack::PushL( uri16 );  // << uri16
+                info->SetGroupMemberDisplayNameL( uri16->Des() );
+                CleanupStack::PopAndDestroy( uri16 );  // >> uri16
+            }
+
+		DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL 3");
+        aColl.AddObjectL( info );
+        
+        //if contact is from buddylist add it to virtual subscribed list too
+        if( !aList.CompareF( KPresenceBuddyList ) )
+            {
+            DP_SDA("GetEntitiesInListL add virtualgroup");
+            //Add identity to virtual list
+            iConnObs.SubscribedContacts()->AddEntityL( 
+            	info->GroupMemberId().Identity() );
+            }
+            
+        CleanupStack::Pop(); // >> info
+        }
+
+    CleanupStack::PopAndDestroy( &nodes ); // >>> nodes
+    CleanupStack::PopAndDestroy( &entries ); // >>> entries*/
+    DP_SDA("CPresencePluginXdmUtils::GetEntitiesInListL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::AddIdentityToVirtualListL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::AddIdentityToVirtualListL( const TDesC&  aList )
+	{
+	DP_SDA("CPresencePluginXdmUtils::AddIdentityToVirtualListL ");
+	using namespace NPresencePlugin::NPresence;
+
+	if ( aList.Compare( KPresenceBlockedList ) == NULL )
+	    {
+	    iBlockedContacts.ResetAndDestroy();
+	    }
+
+    CXdmDocumentNode* buddylist = DoGetBuddyListL( aList );
+
+    // make a collection of MXIMPPresentityGroupMemberInfo
+    RPointerArray<CXdmDocumentNode> entries;
+    CleanupClosePushL(entries);       // <<< entries
+
+    buddylist->Find( KPresenceEntry, entries );
+    DP_SDA("CPresencePluginXdmUtils::AddIdentityToVirtualListL entries");
+    TInt count = entries.Count();
+    DP_SDA2("AddIdentityToVirtualListL entries count %d",count);
+    for ( TInt i=0; i < count; i++ )
+        {
+        DP_SDA("CPresencePluginXdmUtils::AddIdentityToVirtualListL 1");
+        // ID
+        CXdmDocumentNode* entry = entries[i];
+        CXdmNodeAttribute* attr = entry->Attribute( KPresenceUri );
+        if ( attr )
+            {
+            if( !aList.CompareF( KPresenceBuddyList ) )
+                {
+                DP_SDA("AddIdentityToVirtualListL add to buddies");
+                //Add identity to virtual list
+                iConnObs.SubscribedContacts()->AddEntityL( 
+                		attr->AttributeValue() );
+                }
+            else if ( !aList.CompareF( KPresenceBlockedList ) )
+                {
+                DP_SDA("AddIdentityToVirtualListL add to blocked");
+                HBufC* withoutPrefix = 
+                    iConnObs.InternalPresenceAuthorization().
+                        PluginData().RemovePrefixLC( attr->AttributeValue() );
+                CleanupStack::Pop( withoutPrefix );
+                iBlockedContacts.AppendL( withoutPrefix );
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy( &entries ); // >>> entries
+    DP_SDA("CPresencePluginXdmUtils::AddIdentityToVirtualListL end");
+	}
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::DoGetBuddyListL()
+// ---------------------------------------------------------------------------
+//
+CXdmDocumentNode* CPresencePluginXdmUtils::DoGetBuddyListL( 
+    const TDesC&  aParent )
+    {
+    DP_SDA("CPresencePluginXdmUtils::DoGetBuddyListL");
+    CXdmDocumentNode* root = iXdmDoc->DocumentRoot();
+    
+    CXdmDocumentNode* ret = SearchListUnderParentL( root, aParent );
+    if ( !ret )
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoGetBuddyListL !found");
+        User::Leave( KErrNotFound );
+        }
+    return ret;
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::DoGetUserListL()
+// ---------------------------------------------------------------------------
+//
+CXdmDocumentNode* CPresencePluginXdmUtils::DoGetUserListL(
+    const TDesC& aList, CXdmDocumentNode* aBuddyList )
+    {
+    DP_SDA("CPresencePluginXdmUtils::DoGetUserListL");
+    CXdmDocumentNode* listNode = NULL;
+    CXdmNodeAttribute* attr = NULL;
+    TBool found( EFalse );
+
+    using namespace NPresencePlugin::NPresence;
+
+    RPointerArray<CXdmDocumentNode> lists;
+    CleanupClosePushL( lists );
+
+    User::LeaveIfError( aBuddyList->Find( KPresenceEntry, lists ));
+    TInt count = lists.Count();
+    DP_SDA2("CPresencePluginXdmUtils::DoGetUserListL count %d",count);
+    for ( TInt i=0; i < count; i++ )
+        {
+        listNode = lists[i];
+        attr = listNode->Attribute( KPresenceUri );
+        if ( attr && !attr->AttributeValue().CompareF( aList ))
+            {
+            // List is found
+            found = ETrue;
+            break;
+            }
+        }
+    if ( !found )
+        {
+        DP_SDA("CPresencePluginXdmUtils::DoGetUserListL !found");
+        User::Leave( KErrNotFound );
+        }
+
+    CleanupStack::PopAndDestroy( &lists );
+    DP_SDA("CPresencePluginXdmUtils::DoGetUserListL end");
+    return listNode;
+    }
+        
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::UpdateXdmsL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginXdmUtils::UpdateXdmsL()
+    {
+    DP_SDA("CPresencePluginXdmUtils::UpdateXdmsL");
+    iXdmEngine->UpdateL( iXdmDoc, iStatus );
+    if ( !IsActive() )
+    	{
+    	DP_SDA("CPresencePluginXdmUtils::UpdateXdmsL SetActive");
+    	SetActive();
+    	}
+    DP_SDA("CPresencePluginXdmUtils::UpdateXdmsL end");
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::UpdateXdmRulesL()
+// ---------------------------------------------------------------------------
+//    
+void CPresencePluginXdmUtils::UpdateXdmRulesL()
+    {
+    DP_SDA("CPresencePluginXdmUtils::UpdateXdmRulesL");
+    iXdmState = EUpdateXdmRules;
+    
+	if( iRulesUpdateState == EStateInitializeRules )
+    	{
+    	User::LeaveIfError( iXdmPresRules->UpdateXdmRulesL( this ));
+    	}
+    //Add entity to presrules too
+    if ( iRulesUpdateState == EStateAddToWhiteList )
+        {
+        DP_SDA("EStateAddToWhiteList");
+        iXdmPresRules->AddEntityToWhiteListL( 
+        		iEntityUri->Des(), this );
+        }
+    if ( iRulesUpdateState == EStateAddToBlockList )
+        {
+        DP_SDA("EStateAddToBlockList");
+        iXdmPresRules->AddEntityToBlockedRulesL( 
+        		iEntityUri->Des(), this );
+        }
+    if ( iRulesUpdateState == EStateRemoveFromWhiteList)
+        {
+        DP_SDA("EStateRemoveFromWhiteList");
+        iXdmPresRules->RemoveEntityFromWhiteListL( 
+        		iEntityUri->Des(), this );
+        }
+    if ( iRulesUpdateState == EStateRemoveFromBlackList)
+        {
+        DP_SDA("EStateRemoveFromBlackList");
+        iXdmPresRules->RemoveEntityBlockedRulesL( 
+        		iEntityUri->Des(), this );
+        }
+    DP_SDA("CPresencePluginXdmUtils::UpdateXdmRulesL end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::DoHandlePresUpdateDocumentL()
+// ---------------------------------------------------------------------------
+//      
+void CPresencePluginXdmUtils::DoHandlePresUpdateDocumentL( TInt aErrorCode )
+    {
+    DP_SDA("CPresencePluginXdmUtils::DoHandlePresUpdateDocumentL");
+    
+    // check if error
+    CheckIfErrorL( aErrorCode );
+
+    if ( iXdmState == EGetXdmRules )
+        {
+        DP_SDA("DoHandlePresUpdateDocumentL EGetXdmRules");
+        iXdmState = EStateIdle;
+		if ( aErrorCode && aErrorCode == KXcapErrorHttpNotFound )
+            {
+            DP_SDA("DoHandlePresUpdateDocumentL EGetXdmRules ini rules ERROR");
+			InitializePresRulesL();
+            }
+        else
+            {
+            DP_SDA("DoHandlePresUpdateDocumentL EGetXdmRules SEND COMPLETE ");
+            // Complete with ok or error the last initial opreration
+
+            // update presence cache if needed before complete client req.
+            iPresXdmOk = ETrue;
+
+            if ( iBlockedContacts.Count() > 0 )
+                {
+                iConnObs.InternalPresenceAuthorization().
+                    IsBlockedContactFriendRequestL(
+                         *iBlockedContacts[ iBlockedContacts.Count() - 1 ],
+                         *this, iStatus );
+
+                iXdmState = EUpdateBlockedContactPresenceCache;
+                SetActive();
+                }
+            else
+                {
+                CompleteClientReq( aErrorCode );
+                }
+            }
+        }
+    else if ( iXdmState == EUpdateXdmRules )
+        {
+        DP_SDA("DoHandlePresUpdateDocumentL EUpdateXdmRules SEND COMPLETE ");
+        // Complete with ok or error the last initial opreration
+        CompleteClientReq( aErrorCode );
+        }
+    else if ( iXdmState == ECreateXdmRules )
+        {
+        DP_SDA("DoHandlePresUpdateDocumentL ECreateXdmRules SEND COMPLETE ");
+        iPresXdmOk = ETrue;
+        CompleteClientReq( aErrorCode );
+        }
+
+	else if ( iXdmState == EUpdateXdmList)
+		{
+		DP_SDA("DoHandlePresUpdateDocumentL EUpdateXdmList SEND COMPLETE");
+		CompleteClientReq( aErrorCode );
+		}
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::CompleteClientReq()
+// ---------------------------------------------------------------------------
+//               
+void CPresencePluginXdmUtils::CompleteClientReq( TInt aStatus )
+    {
+    DP_SDA("CPresencePluginXdmUtils::CompleteClientReq");
+    DP_SDA2("CPresencePluginXdmUtils::CompleteClientReq status %d ", aStatus);
+    iXdmState = EStateIdle;
+    iOperation = ENoOperation;
+    TRequestStatus* s = iClientStatus;
+    User::RequestComplete( s, aStatus );
+    DP_SDA("CPresencePluginXdmUtils::CompleteClientReq end");
+    }
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::HandlePresUpdateDocumentL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::HandlePresUpdateDocumentL( 
+    TInt aErrorCode )
+    {
+#ifdef _DEBUG
+    DP_SDA2("HandlePresUpdateDocumentL errorCode %d ", aErrorCode );
+    DP_SDA2("HandlePresUpdateDocumentL mystatus %d ", iStatus.Int());
+    DP_SDA2("HandlePresUpdateDocumentL state %d ", iXdmState);
+    DP_SDA2("HandlePresUpdateDocumentL ClientStatus %d",iClientStatus->Int() );
+#endif
+    
+    DP_SDA("CPresencePluginXdmUtils::HandlePresUpdateDocumentL");      
+    if ( aErrorCode == KErrTimedOut  )
+		{
+		DP_SDA("CPresencePluginXdmUtils::HandlePresUpdateDocumentL TimeOut");                        
+		aErrorCode  = 0;
+		}
+	    
+    TRAPD( err, DoHandlePresUpdateDocumentL( aErrorCode ));
+    if ( err )
+        {
+        DP_SDA("CPresencePluginXdmUtils::HandlePresUpdateDocumentL complete");
+        // Complete with ok or error the last initial opreration
+        CompleteClientReq( err );
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::SearchListUnderParentL
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginXdmUtils::CompareUriWithoutPrefixL( 
+    const TDesC& aUri, const TDesC& aAttribute )
+    {
+    DP_SDA("CPresencePluginXdmUtils::CompareUriWithoutPrefixL");
+    
+    TBool match( EFalse );
+    
+    RBuf uriWithoutPrefix;
+    CleanupClosePushL( uriWithoutPrefix );
+    uriWithoutPrefix.CreateL( aUri );
+    TInt prefixLocation = uriWithoutPrefix.Locate( ':' );
+                   
+    if ( KErrNotFound != prefixLocation )
+        {
+        uriWithoutPrefix.Delete( 0, ( prefixLocation + 1 ) );
+        }
+        
+     RBuf attributeWithoutprefix;
+     CleanupClosePushL( attributeWithoutprefix );
+     attributeWithoutprefix.CreateL( aAttribute );
+     prefixLocation = attributeWithoutprefix.Locate( ':' );
+                   
+     if ( KErrNotFound != prefixLocation )
+         {
+         attributeWithoutprefix.Delete( 0, ( prefixLocation + 1 ) );
+         }
+                    
+     DP_SDA2("    --> uri without prefix=%S", &uriWithoutPrefix );
+     DP_SDA2("    --> attribute without prefix=%S", &attributeWithoutprefix );                 
+                
+     if ( uriWithoutPrefix.Compare( attributeWithoutprefix ) == 0 )
+         {
+         match = ETrue;
+         }
+                   
+    CleanupStack::PopAndDestroy( &attributeWithoutprefix );
+    CleanupStack::PopAndDestroy( &uriWithoutPrefix );
+    
+    return match;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginXdmUtils::DoUpdateBlockedContactPresenceCacheL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::DoUpdateBlockedContactPresenceCacheL(
+    TInt aMyStatus )
+    {
+    DP_SDA( "CPresencePluginXdmUtils::DoUpdateBlockedContactPresenceCache" );
+
+    const TInt KTextBufferSize = 10;
+    TInt contactsCount = iBlockedContacts.Count();
+
+    if ( contactsCount > 0 )
+        {
+        if ( iPresenceContactsAsyncReqResult )
+            {
+            DP_SDA(" RunL  -write blocked status to cache" );
+            TBuf<KTextBufferSize> buf;
+            buf.Copy( KBlockedExtensionValue );
+            iConnObs.InternalPresenceAuthorization().PluginData().
+                WriteStatusToCacheL( *iBlockedContacts[ contactsCount - 1 ],
+                     MPresenceBuddyInfo2::EUnknownAvailability,
+                     buf,
+                     KNullDesC() );
+           }
+       delete iBlockedContacts[ contactsCount - 1 ];
+       iBlockedContacts.Remove( contactsCount - 1 );
+
+       if ( iBlockedContacts.Count() > 0 )
+           {
+            iConnObs.InternalPresenceAuthorization().
+                IsBlockedContactFriendRequestL(
+                    *iBlockedContacts[ iBlockedContacts.Count() - 1 ],
+                    *this, iStatus );
+
+           iXdmState = EUpdateBlockedContactPresenceCache;
+           SetActive();
+           }
+       else
+           {
+           CompleteClientReq( aMyStatus );
+           }
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// From MPresencePluginContactsObs
+// CPresencePluginXdmUtils::RequestComplete
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginXdmUtils::RequestComplete( TAny* aResult,
+    TPresenceContactsOperation /*aOperation*/, TInt aError )
+    {
+    iPresenceContactsAsyncReqResult = EFalse;
+    if ( NULL != aResult && KErrNone == aError )
+        {
+        iPresenceContactsAsyncReqResult =
+            *static_cast<TBool*>( aResult );
+        }
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/simpledatamodeladapter/src/presensepluginlocalstore.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,208 @@
+/*
+* 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:  IETF SIMPLE Protocol implementation for XIMP Framework
+*
+*/
+
+
+#include <AknUtils.h>
+#include "presencepluginlocalstore.h"
+#include "presencelogger.h"
+
+_LIT( KContactId, "ContactId" );
+_LIT( KContactTable, "Contacts" );
+_LIT( KStorageExtn, ".db" );
+_LIT( KDbPath, "c:\\MeCo\\" );
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CPresencePluginLocalstore::CPresencePluginLocalstore
+// ---------------------------------------------------------------------------
+//
+CPresencePluginLocalstore::CPresencePluginLocalstore()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginLocalstore::ConstructL()
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginLocalstore::ConstructL( const TDesC& aServiceName )
+    {
+    DP_SDA( "CPresencePluginLocalstore::ConstructL Start" );
+
+    iLocalDBName =
+        HBufC::NewL( aServiceName.Length()+ KStorageExtn().Length() );
+    TPtr localDBNamePtr = iLocalDBName->Des();
+    localDBNamePtr.Append( aServiceName );
+
+    _LIT( KSpecialChar, "/\\:*?<>\"" );
+    AknTextUtils::StripCharacters( localDBNamePtr, KSpecialChar );
+    localDBNamePtr.Append( KStorageExtn() );
+
+    DP_SDA2( "CPresencePluginLocalstore::ConstructL - localDBName: %S" , &localDBNamePtr );
+
+    User::LeaveIfError( iFs.Connect() );
+    if ( DbExists() )
+        {
+        DP_SDA( "CPresencePluginLocalstore::ConstructL - DB exists" );
+        OpenDbL();
+        }
+    else
+        {
+        DP_SDA( "CPresencePluginLocalstore::ConstructL - DB does not exist LEAVE!" );
+        User::Leave( KErrNotReady );
+        }
+
+    User::LeaveIfError( iTable.Open( iDb, KContactTable ) );
+    iColset = iDb.ColSetL( KContactTable );
+
+    DP_SDA( "CPresencePluginLocalstore::ConstructL End" );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginLocalstore::NewL()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginLocalstore* CPresencePluginLocalstore::NewL(
+    const TDesC& aServiceName )
+    {
+    CPresencePluginLocalstore* self =
+        CPresencePluginLocalstore::NewLC( aServiceName );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginLocalstore::NewLC()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginLocalstore* CPresencePluginLocalstore::NewLC(
+    const TDesC& aServiceName )
+    {
+    CPresencePluginLocalstore* self =
+        new( ELeave ) CPresencePluginLocalstore();
+    CleanupStack::PushL( self );
+    self->ConstructL( aServiceName );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginLocalstore::~CPresencePluginLocalstore()
+// ---------------------------------------------------------------------------
+//
+CPresencePluginLocalstore::~CPresencePluginLocalstore()
+    {
+    DP_SDA( "CPresencePluginLocalstore::~CPresencePluginLocalstore Start" );
+
+    delete iLocalDBName;
+    delete iFileStore;
+    delete iColset;
+
+    iTable.Close();
+    iDb.Close();
+    iFs.Close();
+
+    DP_SDA( "CPresencePluginLocalstore::~CPresencePluginLocalstore End" );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginLocalstore::OpenDbL
+// ---------------------------------------------------------------------------
+//
+void CPresencePluginLocalstore::OpenDbL()
+    {
+    DP_SDA( "CPresencePluginLocalstore::OpenDbL() Start" );
+
+    TBuf< KMaxPath > storagePath;
+    storagePath.Append( KDbPath );
+    storagePath.Append( *iLocalDBName );
+    iFileStore = CPermanentFileStore::OpenL( iFs, storagePath,
+        EFileShareReadersOrWriters|EFileWrite );
+    iFileStore->SetTypeL( iFileStore->Layout() );
+    iDb.OpenL( iFileStore, iFileStore->Root() );
+
+    DP_SDA( "CPresencePluginLocalstore::OpenDbL() End" );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginLocalstore::DbExists
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginLocalstore::DbExists()
+    {
+    DP_SDA( "CPresencePluginLocalstore::DbExists() Start" );
+
+    TBool ret( ETrue );
+    RFile temp;
+    TBuf< KMaxPath > storagePath;
+    storagePath.Append( KDbPath );
+    storagePath.Append( *iLocalDBName );
+
+    TInt err( temp.Open( iFs, *( &storagePath ),
+        EFileShareReadersOrWriters|EFileRead ) );
+    TInt size( 0 );
+
+    if ( KErrNone == err )
+        {
+        temp.Size( size );
+        }
+
+    temp.Close();
+
+    if ( ( 0 == size ) || ( KErrNone != err ) )
+        {
+        ret = EFalse;
+        }
+
+    DP_SDA( "CPresencePluginLocalstore::DbExists() End" );
+    return ret;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CPresencePluginLocalstore::SeekRowL()
+// ---------------------------------------------------------------------------
+//
+TBool CPresencePluginLocalstore::SeekRowAtContactColL(
+    TInt32& aIdentifier )
+    {
+    DP_SDA( "CPresencePluginLocalstore::SeekRowAtContactColL() Start" );
+
+    TBool ret( EFalse );
+    TDbColNo colNo = iColset->ColNo( KContactId );
+    iTable.BeginningL();
+
+    while ( iTable.NextL() )
+        {
+        DP_SDA( "CPresencePluginLocalstore::SeekRowAtContactColL() - next found" );
+        iTable.GetL();
+        if ( iTable.ColInt32( colNo ) == aIdentifier )
+            {
+            ret = ETrue;
+            break;
+            }
+        }
+
+    DP_SDA2( "CPresencePluginLocalstore::SeekRowAtContactColL() End - ret = %d", ret );
+    return ret;
+    }
--- a/simpleengine/engine/BWINS/simpleengineU.DEF	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/engine/BWINS/simpleengineU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -13,4 +13,5 @@
 	?NsPrefixL@TSimpleUtils@@SA?AVTPtrC8@@ABVTDesC8@@@Z @ 12 NONAME ; class TPtrC8 TSimpleUtils::NsPrefixL(class TDesC8 const &)
 	?NsUriL@TSimpleUtils@@SA?AVTPtrC8@@ABVTDesC8@@@Z @ 13 NONAME ; class TPtrC8 TSimpleUtils::NsUriL(class TDesC8 const &)
 	?NewInstantMessageL@TSimpleFactory@@SAPAVMSimpleInstantMessage@@AAVMSimpleConnection@@AAVMSimpleInstantMsgObserver@@@Z @ 14 NONAME ; class MSimpleInstantMessage * TSimpleFactory::NewInstantMessageL(class MSimpleConnection &, class MSimpleInstantMsgObserver &)
+	?NewConnectionL@TSimpleFactory@@SAPAVMSimpleConnection@@AAVMSimpleConnectionObserver@@J@Z @ 15 NONAME ; class MSimpleConnection * TSimpleFactory::NewConnectionL(class MSimpleConnectionObserver &, long)
 
--- a/simpleengine/engine/EABI/simpleengineU.DEF	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/engine/EABI/simpleengineU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -29,4 +29,5 @@
 	_ZN14TSimpleFactory18NewInstantMessageLER17MSimpleConnectionR25MSimpleInstantMsgObserver @ 28 NONAME
 	_ZTI22CSimpleEngineImHandler @ 29 NONAME ; #<TI>#
 	_ZTV22CSimpleEngineImHandler @ 30 NONAME ; #<VT>#
+	_ZN14TSimpleFactory14NewConnectionLER25MSimpleConnectionObserverl @ 31 NONAME
 
--- a/simpleengine/engine/inc/simpleconnection.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/engine/inc/simpleconnection.h	Wed Sep 01 12:23:14 2010 +0100
@@ -53,6 +53,8 @@
      */
     static CSimpleConnection* NewL( MSimpleConnectionObserver& aObserver );
 
+    static CSimpleConnection* NewL( MSimpleConnectionObserver& aObserver, TInt32 aServiceId );
+    
     /**
      * Destructor.
      */
@@ -134,7 +136,7 @@
     /**
      * Two-phase constructor
      */
-    void ConstructL( );
+    void ConstructL( TInt32 aServiceId );
 
     /**
      * constructor
--- a/simpleengine/engine/inc/simpleengineimhandler.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/engine/inc/simpleengineimhandler.h	Wed Sep 01 12:23:14 2010 +0100
@@ -11,11 +11,10 @@
 *
 * Contributors:
 *
-* Description:  SIMPLE Engine IM Handler
+* Description:    SIMPLE Engine IM Handler
 *
 */
 
-
 #ifndef C_SIMPLEENGINEIMHANDLER_H
 #define C_SIMPLEENGINEIMHANDLER_H
 
--- a/simpleengine/engine/inc/simplepublisher.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/engine/inc/simplepublisher.h	Wed Sep 01 12:23:14 2010 +0100
@@ -226,7 +226,7 @@
      * Zero length is ignored.
      * @return operation id
      */        
-    TInt DoStartPublishL( MSimpleDocument& aDocument,
+    TInt CSimplePublisher::DoStartPublishL( MSimpleDocument& aDocument,
         TBool aRefresh, const TDesC8& aETag );
 
 
--- a/simpleengine/engine/src/simpleconnection.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/engine/src/simpleconnection.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -65,7 +65,7 @@
 // CSimpleConnection::ConstructL
 // ----------------------------------------------------------
 //
-void CSimpleConnection::ConstructL()
+void CSimpleConnection::ConstructL( TInt32 aServiceId )
     {
     // Create CSimpleSipConnection entity in simplesiputils.dll
     iConnection = CSimpleSipConnection::NewL();
@@ -79,6 +79,10 @@
     CSimpleEngineRequest* req = CSimpleEngineRequest::NewL(
         *this, MSimpleEngineRequest::EListenEvents, iOpId );
     CleanupStack::PushL( req );
+    if ( aServiceId )
+        {
+        iConnection->SetServiceId( aServiceId );
+        }
     iConnection->DispatchReqL( *req );
     iRequestList.AddLast( *req );
     CleanupStack::Pop( req );
@@ -96,7 +100,24 @@
 #endif
     CSimpleConnection* self = new (ELeave) CSimpleConnection( aObserver );
     CleanupStack::PushL( self );
-    self->ConstructL();
+    self->ConstructL( NULL );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CSimpleConnection::NewL
+// ----------------------------------------------------------
+//
+CSimpleConnection* CSimpleConnection::NewL(
+    MSimpleConnectionObserver& aObserver, TInt32 aServiceId )
+    {
+#ifdef _DEBUG
+    TSimpleLogger::Log(_L("SimpleConnection: NewL" ));
+#endif
+    CSimpleConnection* self = new (ELeave) CSimpleConnection( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL( aServiceId );
     CleanupStack::Pop( self );
     return self;
     }
--- a/simpleengine/engine/src/simpleengineimhandler.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/engine/src/simpleengineimhandler.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -11,11 +11,10 @@
 *
 * Contributors:
 *
-* Description:  SIMPLE ENGINE IM Handler
+* Description:    SIMPLE Engine IM Handler
 *
 */
 
-
 #include "simpleengineimhandler.h"
 #include "simpleenginerequest.h"
 #include "simpleinstantmsgobserver.h"
--- a/simpleengine/engine/src/simplefactory.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/engine/src/simplefactory.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -47,6 +47,10 @@
 #include "msimplewinfowatcher.h"
 #include "simpleinstantmessage.h"
 
+#ifdef _DEBUG
+#include "simpledebugutils.h"
+#endif
+
 class MSimpleConnectionObserver;
 class MSimplePublishObserver;
 class MSimpleWatcherObserver;
@@ -91,6 +95,9 @@
 EXPORT_C MSimpleConnection* TSimpleFactory::NewConnectionL(
     MSimpleConnectionObserver& aObserver)
     {
+    #ifdef _DEBUG
+    TSimpleLogger::Log(_L("TSimpleFactory::NewConnectionL" ) );
+    #endif
     return CSimpleConnection::NewL( aObserver );
     }
 
@@ -134,7 +141,11 @@
         aContentID, aContentType );    
     }
       
+EXPORT_C MSimpleConnection* TSimpleFactory::NewConnectionL(
+    MSimpleConnectionObserver& aObserver, TInt32 aServiceId )
+    {
+    return CSimpleConnection::NewL( aObserver, aServiceId );
+    }
 
 
 
-
--- a/simpleengine/inc/simplecommon.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/inc/simplecommon.h	Wed Sep 01 12:23:14 2010 +0100
@@ -28,6 +28,7 @@
 const TInt KRangeSize = 100;  // range of operation ids for each client handle
     
 const TUint KSimpleOK = 200;  // return code for SIP
+const TUint KCreatedOK = 201; // return code for SIP
 const TUint KSimpleAccepted = 202;  // return code for SIP
 
 _LIT8 ( KSimpleApplicationType, "application");
--- a/simpleengine/presencedm/src/presencedmadapter.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/presencedm/src/presencedmadapter.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -14,9 +14,6 @@
 * Description:    OMA Presence Settings Device Management Adapter's source file 
 *
 */
-
-
-
  
 #include <implementationproxy.h>
 #include <nsmldmuri.h>
@@ -362,6 +359,7 @@
     TPresSettingsProperty property;
 
     HBufC8* luid = Callback().GetLuidAllocL( aUri );
+    PRES_DM_LOG(LOG_LIT8("   GetLuidAllocL() => '%S'"), luid );
     TInt settingsId = DesToInt( *luid );
     
     PRES_DM_LOG(LOG_LIT("   settingsId after callback:%d"), settingsId);
@@ -370,12 +368,16 @@
     if (!IsPresIDValidL(settingsId))
         {
         //try to find it another way
-        TPtrC8 removedLastSeg = NSmlDmURI::RemoveLastSeg(aUri);
-        TPtrC8 idSegment = NSmlDmURI::LastURISeg(removedLastSeg);
-        TInt settingsId = DesToInt(idSegment);
-        if (!IsPresIDValidL(settingsId))
-            status = CSmlDmAdapter::ENotFound;
-        PRES_DM_LOG(LOG_LIT("   settingsId found local way:%d"), settingsId);
+        if( NSmlDmURI::NumOfURISegs( aUri ) > 1 )
+            {
+            TPtrC8 idSegment = NSmlDmURI::URISeg( aUri, 2 );
+            settingsId = DesToInt(idSegment);
+            if(!IsPresIDValidL(settingsId))
+                {
+                status = CSmlDmAdapter::ENotFound;
+                }
+            PRES_DM_LOG(LOG_LIT("   settingsId found local way:%d"), settingsId);
+            }
         }
     
     // if previous settings id processing was ok
@@ -519,12 +521,16 @@
     if (!IsPresIDValidL(settingsId))
         {
         //try to find it another way
-        TPtrC8 removedLastSeg = NSmlDmURI::RemoveLastSeg(aUri);
-        TPtrC8 idSegment = NSmlDmURI::LastURISeg(removedLastSeg);
-        TInt settingsId = DesToInt(idSegment);
-        if (!IsPresIDValidL(settingsId))
-            status = CSmlDmAdapter::ENotFound; 
-        PRES_DM_LOG(LOG_LIT("   settingsId found local way:%d"), settingsId);
+        if( NSmlDmURI::NumOfURISegs( aUri ) > 1 )
+            {
+            TPtrC8 idSegment = NSmlDmURI::URISeg( aUri, 2 );
+            settingsId = DesToInt(idSegment);
+            if (!IsPresIDValidL(settingsId))
+                {
+                status = CSmlDmAdapter::ENotFound;
+                }
+            PRES_DM_LOG(LOG_LIT("   settingsId found local way:%d"), settingsId);
+            }
         }
     
     // if previous settings id processing was ok
@@ -722,6 +728,7 @@
                                          const TInt aStatusRef )
     {
     // Not supported 
+    PRES_DM_LOG(LOG_LIT("ExecuteCommandL"));    
     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
     }
 
@@ -736,6 +743,7 @@
                                          const TInt aStatusRef )
     {
     // Not supported
+    PRES_DM_LOG(LOG_LIT("ExecuteCommandL"));
     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
     }
 
@@ -751,6 +759,7 @@
                                       TInt aStatusRef )
     {
     // Not supported
+    PRES_DM_LOG(LOG_LIT("CopyCommandL"));    
     Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError );
     }
 
@@ -760,6 +769,7 @@
 //
 void CPresenceDMAdapter::StartAtomicL()
     {
+    PRES_DM_LOG(LOG_LIT("StartAtomicL"));
     // Not supported
     }
 
@@ -769,6 +779,7 @@
 //
 void CPresenceDMAdapter::CommitAtomicL()
     {
+    PRES_DM_LOG(LOG_LIT("CommitAtomicL"));
     // Not supported
     }
 
@@ -778,6 +789,7 @@
 //
 void CPresenceDMAdapter::RollbackAtomicL()
     {
+    PRES_DM_LOG(LOG_LIT("RollbackAtomicL"));
     // Not supported
     }
 
@@ -787,6 +799,7 @@
 //
 TBool CPresenceDMAdapter::StreamingSupport( TInt& /*aItemSize*/ )
     {
+    PRES_DM_LOG(LOG_LIT("StreamingSupport"));    
     return EFalse;
     }
 
@@ -796,6 +809,7 @@
 //
 void CPresenceDMAdapter::StreamCommittedL()
     {
+    PRES_DM_LOG(LOG_LIT("StreamCommittedL"));    
     // Not supported
     }
     
@@ -877,10 +891,10 @@
         aObject.InsertL( 0, *utfValue );
         CleanupStack::PopAndDestroy(utfValue);  // >>> utfValue
         CleanupStack::PopAndDestroy(value);  // >>> value
-        PRES_DM_LOG(LOG_LIT(" return(%d)"),CSmlDmAdapter::EOk);  
+        PRES_DM_LOG(LOG_LIT(" return( EOk )"));  
         return CSmlDmAdapter::EOk;
         }
-    PRES_DM_LOG(LOG_LIT(" return(%d)"),CSmlDmAdapter::ENotFound);      
+    PRES_DM_LOG(LOG_LIT(" return( ENotFound )"));      
     return CSmlDmAdapter::ENotFound;
     }
     
@@ -1056,7 +1070,7 @@
 CSmlDmAdapter::TError CPresenceDMAdapter::GetConRefFromSipIDL( TInt aSipID,
                                                       CBufBase& aObject)
     {
-    PRES_DM_LOG(LOG_LIT(" GetConRefFromSipIDL(%d)"),aSipID);
+    PRES_DM_LOG(LOG_LIT(" GetConRefFromSipIDL(aSipId:%d)"),aSipID);
 
     CSmlDmAdapter::TError status = CSmlDmAdapter::EOk;
     
@@ -1069,12 +1083,14 @@
         
         // Request all the sip settings identifiers 
         Callback().FetchLinkL( KPresDMSipDMNode, *result, status);
+        PRES_DM_LOG(LOG_LIT("   FetchLinkL(SIP) status : %d"), status );
         
         if( status == EOk )
             {
             TPtr8 uriSeg8Ptr = result->Ptr(0);
             
-            HBufC8* uriSegBuffer = uriSeg8Ptr.AllocLC();
+            HBufC8* uriSegBuffer = uriSeg8Ptr.AllocLC(); // << uriSegBuffer
+            PRES_DM_LOG(LOG_LIT8("   uri : '%S'"), uriSegBuffer );
             
             TPtr8 uriSegBufferPtr = uriSegBuffer->Des();
             
@@ -1087,7 +1103,7 @@
                      
             // Check if given SIP set id match with any of found
             // SIP settings identifiers
-            while( numOfUriSegs > 1)
+            while( numOfUriSegs > 0 )
                 {
                 idLinkBuffer = NSmlDmURI::LastURISeg(uriSegBufferPtr);
                 uriSegBufferPtr = NSmlDmURI::RemoveLastSeg(uriSegBufferPtr);
@@ -1102,17 +1118,20 @@
                 //Reqest the ID
                 result->Reset();
                 Callback().FetchLinkL( finalLink, *result, status);
-                        
-                foundId = DesToInt(result->Ptr(0));
-                        
-                if (foundId == aSipID)
+                PRES_DM_LOG(LOG_LIT8("   FetchLinkL(%S) status : %d"), &idLinkBuffer, status );                        
+                if( status == EOk )
                     {
-                    found = ETrue;
-                    aObject.InsertL(0, NSmlDmURI::RemoveLastSeg(finalLink));
+                    foundId = DesToInt(result->Ptr(0));
+                    PRES_DM_LOG(LOG_LIT("   foundId : %d"), foundId );                        
+                    if (foundId == aSipID)
+                        {
+                        found = ETrue;
+                        aObject.InsertL(0, NSmlDmURI::RemoveLastSeg(finalLink));
                         break;
                         }
+                    }
                 
-                numOfUriSegs -= 1;  
+                numOfUriSegs--;  
                 }
             CleanupStack::PopAndDestroy( uriSegBuffer );    // >>> uriSegBuffer
             }
@@ -1137,7 +1156,7 @@
 CSmlDmAdapter::TError CPresenceDMAdapter::GetConRefFromXdmIDL( TInt aXdmID,
                                                       CBufBase& aObject)
     {
-    PRES_DM_LOG(LOG_LIT(" GetConRefFromXdmIDL(%d)"),aXdmID);
+    PRES_DM_LOG(LOG_LIT(" GetConRefFromXdmIDL(aXdmId:%d)"),aXdmID);
 
     CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound;
     
@@ -1148,6 +1167,7 @@
         
         // Request all the XDM settings identifiers 
         Callback().FetchLinkL( KPresDMXdmDMNode, *result, status);
+        PRES_DM_LOG(LOG_LIT("   FetchLinkL(XDM) status : %d"), status );
         TInt id(KErrNotFound);
         
         TPtrC8 lastUriSegXdm;
@@ -1211,6 +1231,7 @@
     TPresSettingsSet tempSet;
     if ((PresSettingsApi::SettingsSetL(aSetId,tempSet)) == KErrNone)
         return ETrue;
+    PRES_DM_LOG(LOG_LIT8(" IsPresIDValidL - Invalid settings : %d"), aSetId );
     return EFalse;   
     }
     
@@ -1248,8 +1269,7 @@
         
     if( status == EOk )
         {
-        TUint32 id(NULL);
-        id = DesToInt( result->Ptr( 0 ) );
+        TUint32 id = DesToInt( result->Ptr( 0 ) );
         returnId = (TInt)id;       
         }
     CleanupStack::PopAndDestroy( result );   // >>> result   
--- a/simpleengine/presenceprovisioning/inc/presenceprovitem.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/presenceprovisioning/inc/presenceprovitem.h	Wed Sep 01 12:23:14 2010 +0100
@@ -164,7 +164,7 @@
         * @param aName Name of the parameter
         * @param aValue Value of the parameter
         */
-        void DetermineNamedParameter( const TDesC& aName, const TDesC& aValue );
+        void DetermineNamedParameterL( const TDesC& aName, const TDesC& aValue );
         
         /**
         * Check presence settings duplicate names, provide alternate name
--- a/simpleengine/presenceprovisioning/src/presenceprovadapter.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/presenceprovisioning/src/presenceprovadapter.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -289,7 +289,7 @@
         // APPID into place [0].
         TPtrC8 appId ( KPresProvisioningAppId8 );
         HBufC8* appIdBuf = appId.AllocLC();             // << appIdBuf
-        aSavingInfo.Append( appIdBuf );
+        aSavingInfo.AppendL( appIdBuf );
         CleanupStack::Pop( appIdBuf );                  // >> appIdBuf
         appIdBuf = NULL;
         
--- a/simpleengine/presenceprovisioning/src/presenceprovitem.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/presenceprovisioning/src/presenceprovitem.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -251,7 +251,7 @@
         case EWPParameterToAppRef:
             {
             PRES_PROV_LOG(LOG_LIT8( " EWPParameterToAppRef"));
-            iToAppReferences.Append( aParameter.Value() );  
+            iToAppReferences.AppendL( aParameter.Value() );  
             }
             break;
     
@@ -271,7 +271,7 @@
                                  
         default:
             {
-            DetermineNamedParameter( aParameter.Name(), aParameter.Value() );
+            DetermineNamedParameterL( aParameter.Name(), aParameter.Value() );
             }
             break;
         }
@@ -282,7 +282,7 @@
 // CPresProvItem::DetermineNamedParameter
 // -----------------------------------------------------------------------------
 //
-void CPresProvItem::DetermineNamedParameter( const TDesC& aName, const TDesC& aValue )
+void CPresProvItem::DetermineNamedParameterL( const TDesC& aName, const TDesC& aValue )
     {
     PRES_PROV_LOG(LOG_LIT( "DetermineNamedParameter(%S, %S)"), &aName, &aValue);
     if ( !aName.Compare( KPresProvClientObjDataLim ) )
@@ -316,7 +316,7 @@
     else if (!aName.Compare(KPresIToAppRef))
         {
         if(iToAppReferences.Count() < 2) // if any of SIP or XDM id is missing
-            iToAppReferences.Append(aValue);        
+            iToAppReferences.AppendL(aValue);        
         }
     PRES_PROV_LOG(LOG_LIT8( "   CPresProvItem::DetermineNamedParameter ends" ) );      
     }
--- a/simpleengine/presencesettingsapi/group/bld.inf	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/presencesettingsapi/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -27,6 +27,6 @@
 presencesettingsapi.mmp
 
 PRJ_EXPORTS
-../inc/pressettingsapi.h	MW_LAYER_PLATFORM_EXPORT_PATH(pressettingsapi.h)
-../inc/simpleenginedomaincrkeys.h	MW_LAYER_PLATFORM_EXPORT_PATH(simpleenginedomaincrkeys.h)
-../inc/pressettingsset.h	MW_LAYER_PLATFORM_EXPORT_PATH(pressettingsset.h)
+../inc/pressettingsapi.h	/epoc32/include/mw/pressettingsapi.h
+../inc/simpleenginedomaincrkeys.h	/epoc32/include/mw/simpleenginedomaincrkeys.h
+../inc/pressettingsset.h	/epoc32/include/mw/pressettingsset.h
--- a/simpleengine/presencesettingsapi/group/presencesettingsapi.mmp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/presencesettingsapi/group/presencesettingsapi.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -43,7 +43,7 @@
 LIBRARY                         centralrepository.lib
 
 
-#if defined( EABI )
+#if defined( ARMCC )
 DEFFILE ../eabi/ 
 #elif defined ( WINSCW )
 deffile ../bwinscw/ 
--- a/simpleengine/presencesettingsapi/src/pressettingsapi.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/presencesettingsapi/src/pressettingsapi.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -78,7 +78,7 @@
         else
             {
             sets->AppendL(setName);
-            aSetIds.Append(setId);
+            aSetIds.AppendL(setId);
             }
         setName.Zero();           
         }
--- a/simpleengine/rom/simpleengine.iby	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/rom/simpleengine.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -24,17 +24,17 @@
 
 #ifdef __SIP_SIMPLE_PRESENCE_PROTOCOL
 
-file=ABI_DIR\BUILD_DIR\simpleengine.dll         SHARED_LIB_DIR\simpleengine.dll
-file=ABI_DIR\BUILD_DIR\simplesiputils.dll       SHARED_LIB_DIR\simplesiputils.dll
-file=ABI_DIR\BUILD_DIR\simplexmlutils.dll       SHARED_LIB_DIR\simplexmlutils.dll
-file=ABI_DIR\BUILD_DIR\rlspresxdm.dll               SHARED_LIB_DIR\rlspresxdm.dll
-file=ABI_DIR\BUILD_DIR\presencesettingsapi.dll      SHARED_LIB_DIR\presencesettingsapi.dll
+file=ABI_DIR/BUILD_DIR/simpleengine.dll         SHARED_LIB_DIR/simpleengine.dll
+file=ABI_DIR/BUILD_DIR/simplesiputils.dll       SHARED_LIB_DIR/simplesiputils.dll
+file=ABI_DIR/BUILD_DIR/simplexmlutils.dll       SHARED_LIB_DIR/simplexmlutils.dll
+file=ABI_DIR/BUILD_DIR/rlspresxdm.dll               SHARED_LIB_DIR/rlspresxdm.dll
+file=ABI_DIR/BUILD_DIR/presencesettingsapi.dll      SHARED_LIB_DIR/presencesettingsapi.dll
 
 ECOM_PLUGIN(PresenceDM.dll, 10282415.rsc) 
 ECOM_PLUGIN(PresenceProvisioning.dll, 10282417.rsc)  
 
 // backup registry
-data=DATAZ_\private\10281EEB\backup_registration.xml  private\10281EEB\backup_registration.xml
+data=DATAZ_/private/10281EEB/backup_registration.xml  private/10281EEB/backup_registration.xml
 
 #endif // __SIP_SIMPLE_PRESENCE_PROTOCOL
 #endif
--- a/simpleengine/rom/simpleengineresources.iby	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/rom/simpleengineresources.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -25,7 +25,7 @@
 #include <bldvariant.hrh>
 #ifdef __SIP_SIMPLE_PRESENCE_PROTOCOL
 
-data=DATAZ_\RESOURCE_FILES_DIR\PresenceProvisioningTexts.RSC       RESOURCE_FILES_DIR\PresenceProvisioningTexts.RSC
+data=DATAZ_/RESOURCE_FILES_DIR/PresenceProvisioningTexts.RSC       RESOURCE_FILES_DIR/PresenceProvisioningTexts.RSC
 
 #endif        //__SIP_SIMPLE_PRESENCE_PROTOCOL
 
--- a/simpleengine/siputils/BWINS/simplesiputilsU.DEF	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/BWINS/simplesiputilsU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -5,5 +5,5 @@
 	?NewL@CSimpleSipConnection@@SAPAV1@XZ @ 4 NONAME ; class CSimpleSipConnection * CSimpleSipConnection::NewL(void)
 	?SIPState@CSimpleSipConnection@@QAE?AW4TSimpleSipState@@XZ @ 5 NONAME ; enum TSimpleSipState CSimpleSipConnection::SIPState(void)
 	?SIPStatus@CSimpleSipConnection@@QAEIHAAH@Z @ 6 NONAME ; unsigned int CSimpleSipConnection::SIPStatus(int, int &)
-	?SipSubscriptionState@CSimpleSipConnection@@QAE?AW4TSimpleSipSubscriptionState@MSimpleEngineRequest@@AAV3@@Z @ 7 NONAME ; enum MSimpleEngineRequest::TSimpleSipSubscriptionState CSimpleSipConnection::SipSubscriptionState(class MSimpleEngineRequest &)
-
+	?SetServiceId@CSimpleSipConnection@@QAEXJ@Z @ 7 NONAME ; void CSimpleSipConnection::SetServiceId(long)
+	?SipSubscriptionState@CSimpleSipConnection@@QAE?AW4TSimpleSipSubscriptionState@MSimpleEngineRequest@@AAV3@@Z @ 8 NONAME ; enum MSimpleEngineRequest::TSimpleSipSubscriptionState CSimpleSipConnection::SipSubscriptionState(class MSimpleEngineRequest &)
--- a/simpleengine/siputils/EABI/simplesiputilsU.DEF	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/EABI/simplesiputilsU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -1,25 +1,28 @@
 EXPORTS
 	_ZN20CSimpleSipConnection12DispatchReqLER20MSimpleEngineRequest @ 1 NONAME
-	_ZN20CSimpleSipConnection19CurrentSIPIdentityLEv @ 2 NONAME
-	_ZN20CSimpleSipConnection4NewLEv @ 3 NONAME
-	_ZN20CSimpleSipConnection8SIPStateEv @ 4 NONAME
-	_ZN20CSimpleSipConnection9SIPStatusEiRi @ 5 NONAME
-	_ZN20CSimpleSipConnectionD0Ev @ 6 NONAME
-	_ZN20CSimpleSipConnectionD1Ev @ 7 NONAME
-	_ZN20CSimpleSipConnectionD2Ev @ 8 NONAME
-	_ZTI14CSimpleRequest @ 9 NONAME ; #<TI>#
-	_ZTI18CSimpleExpiryTimer @ 10 NONAME ; #<TI>#
-	_ZTI18CSimpleSettingFile @ 11 NONAME ; #<TI>#
-	_ZTI19CSimpleRefreshTimer @ 12 NONAME ; #<TI>#
-	_ZTI20CSimpleSipConnection @ 13 NONAME ; #<TI>#
-	_ZTI25CSimpleSipProfileObserver @ 14 NONAME ; #<TI>#
-	_ZTI28CSimpleSipConnectionObserver @ 15 NONAME ; #<TI>#
-	_ZTV14CSimpleRequest @ 16 NONAME ; #<VT>#
-	_ZTV18CSimpleExpiryTimer @ 17 NONAME ; #<VT>#
-	_ZTV18CSimpleSettingFile @ 18 NONAME ; #<VT>#
-	_ZTV19CSimpleRefreshTimer @ 19 NONAME ; #<VT>#
-	_ZTV20CSimpleSipConnection @ 20 NONAME ; #<VT>#
-	_ZTV25CSimpleSipProfileObserver @ 21 NONAME ; #<VT>#
-	_ZTV28CSimpleSipConnectionObserver @ 22 NONAME ; #<VT>#
-	_ZN20CSimpleSipConnection20SipSubscriptionStateER20MSimpleEngineRequest @ 23 NONAME
+	_ZN20CSimpleSipConnection12SetServiceIdEl @ 2 NONAME
+	_ZN20CSimpleSipConnection19CurrentSIPIdentityLEv @ 3 NONAME
+	_ZN20CSimpleSipConnection20SipSubscriptionStateER20MSimpleEngineRequest @ 4 NONAME
+	_ZN20CSimpleSipConnection4NewLEv @ 5 NONAME
+	_ZN20CSimpleSipConnection8SIPStateEv @ 6 NONAME
+	_ZN20CSimpleSipConnection9SIPStatusEiRi @ 7 NONAME
+	_ZN20CSimpleSipConnectionD0Ev @ 8 NONAME
+	_ZN20CSimpleSipConnectionD1Ev @ 9 NONAME
+	_ZN20CSimpleSipConnectionD2Ev @ 10 NONAME
+	_ZTI14CSimpleRequest @ 11 NONAME ; #<TI>#
+	_ZTI18CSimpleExpiryTimer @ 12 NONAME ; #<TI>#
+	_ZTI18CSimpleSettingFile @ 13 NONAME ; #<TI>#
+	_ZTI19CSimpleRefreshTimer @ 14 NONAME ; #<TI>#
+	_ZTI20CSimpleSipConnection @ 15 NONAME ; #<TI>#
+	_ZTI25CSimpleSipProfileObserver @ 16 NONAME ; #<TI>#
+	_ZTI28CSimpleSipConnectionObserver @ 17 NONAME ; #<TI>#
+	_ZTV14CSimpleRequest @ 18 NONAME ; #<VT>#
+	_ZTV18CSimpleExpiryTimer @ 19 NONAME ; #<VT>#
+	_ZTV18CSimpleSettingFile @ 20 NONAME ; #<VT>#
+	_ZTV19CSimpleRefreshTimer @ 21 NONAME ; #<VT>#
+	_ZTV20CSimpleSipConnection @ 22 NONAME ; #<VT>#
+	_ZTV25CSimpleSipProfileObserver @ 23 NONAME ; #<VT>#
+	_ZTV28CSimpleSipConnectionObserver @ 24 NONAME ; #<VT>#
 
+
+
--- a/simpleengine/siputils/group/simplesiputils.mmp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/group/simplesiputils.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -42,7 +42,7 @@
 USERINCLUDE                     ../../inc
 
 // default system include paths for middleware layer modules
-MW_LAYER_SYSTEMINCLUDE
+APP_LAYER_SYSTEMINCLUDE
 
 DEBUGLIBRARY                    flogger.lib
 DEBUGLIBRARY                    efsrv.lib   // file server
@@ -56,3 +56,5 @@
 LIBRARY                         bafl.lib  // string pool
 LIBRARY                         centralrepository.lib
 LIBRARY                         presencesettingsapi.lib
+// access to uiservicetabsettings
+LIBRARY         				vimpstsettings.lib
--- a/simpleengine/siputils/inc/simplesettings.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/inc/simplesettings.h	Wed Sep 01 12:23:14 2010 +0100
@@ -120,7 +120,7 @@
      * @param aId key id
      * @return value of the key      
      */
-    TInt GetCenRepIntValueL( 
+    TInt TSimpleSettings::GetCenRepIntValueL( 
         CRepository* aRepository,
         TUint32 aId );
                 
--- a/simpleengine/siputils/inc/simplesipconncallback.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/inc/simplesipconncallback.h	Wed Sep 01 12:23:14 2010 +0100
@@ -53,6 +53,13 @@
      */
     virtual void ConnectionStateChange( 
         TSimpleSipState aState, TInt aSipError) = 0;
+    
+    /**
+     * Connection method has changed (Roaming). 
+     * 
+     * @since S60 3.2.3
+     */
+    virtual void ConnectionChanged() = 0;
 
     /**
      * Time to refresh a request
--- a/simpleengine/siputils/inc/simplesipconnection.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/inc/simplesipconnection.h	Wed Sep 01 12:23:14 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -120,6 +120,12 @@
         MSimpleEngineRequest& aReq );	   
     
     /**
+     * Set service id
+     * @param aServiceId new service id 
+     */
+    IMPORT_C void SetServiceId( TInt32 aServiceId );
+    
+    /**
      * Search the corresponding client request
      *
      * @since S60 v3.2      
@@ -241,6 +247,13 @@
      */
     TInt HandleReceivedMessage( const TDesC8& aFrom,
         const TDesC8& aContent );
+    
+    /**
+     * Connection method has changed (Roaming). 
+     * 
+     * @since S60 3.2.3
+     */
+    void ConnectionChanged();  
 
 protected:
 
@@ -360,7 +373,15 @@
      * @since S60 v3.2       
      */
     void DeleteRequests();
-
+    
+    /**
+     * Delete all pending specified type of requests.
+     *
+     * @since S60 5.0 
+     * @param aRequestType request type
+     */
+    void DeleteRequests( CSimpleRequest::TSimpleSipReqType aRequestType );
+    
     /**
      * Destroy the request
      *
@@ -559,6 +580,13 @@
      */
     void DoHandleReceivedMessageL( const TDesC8& aFrom,
         const TDesC8& aContent, CSimpleRequest& aRequest );
+    
+    /**
+     * Stores ETag to vimpstsettingstore
+     *
+     * @since S60 5.0       
+     */
+    void StoreETagL( HBufC8& aTag );
 
 private:    // Data
 
@@ -611,6 +639,11 @@
      * Current number of subscriptions
      */
     TUint iCurrentNbrSubs;
+    
+    /**
+     * Service id of current service
+     */
+    TInt32 iServiceId;
 
 #ifdef _DEBUG
     friend class T_CSimpleSipConnection;
--- a/simpleengine/siputils/inc/simplesipconnectionobserver.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/inc/simplesipconnectionobserver.h	Wed Sep 01 12:23:14 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -85,7 +85,15 @@
      * @param aSipError SIP error code
      */
     void ProfileStateChanged( 
-        CSIPConnection::TState aState, TInt aSipError );             
+        CSIPConnection::TState aState, TInt aSipError );   
+    
+    /**
+     * SIP Profile has updated. 
+     * 
+     * @see MSIPProfileRegistryObserver::EProfileUpdated
+     * @since S60 3.2.3
+     */
+    void ProfileUpdated();
 
 // from base class MSIPConnectionObserver
 
@@ -112,7 +120,6 @@
     /**
      * A SIP response received from the network.
      * @param aTransaction contains response elements.
-     * The ownership is transferred.
      */
     void IncomingResponse( CSIPClientTransaction& aTransaction );
 
@@ -281,7 +288,6 @@
     /**
      * A SIP response received from the network.
      * @param aTransaction contains response elements.
-     * The ownership is transferred.
      */
     void DoIncomingResponse( CSIPClientTransaction& aTransaction );
     
--- a/simpleengine/siputils/src/simpledebugutils.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/src/simpledebugutils.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -57,6 +57,9 @@
     _LIT(KLogFile, "simple.txt");
     // Write to log file
     RFileLogger::Write(KLogDir, KLogFile, EFileLoggingModeAppend, buf);
+    
+    _LIT( KSimplePrefix,  "[simple] ");    
+    buf.Insert( 0, KSimplePrefix );
     RDebug::RawPrint( buf );
 
     }
--- a/simpleengine/siputils/src/simplesettings.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/src/simplesettings.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -127,8 +127,8 @@
     TRAP_IGNORE( repository = CRepository::NewL( KCRUIDSimpleVariation ));
     if ( repository )
         {
-        TRAP_IGNORE( iExpiryPuhlish = GetCenRepIntValueL(
-            repository, KSimplePublishRefresh ));
+        //TRAP_IGNORE( iExpiryPuhlish = GetCenRepIntValueL(
+        //    repository, KSimplePublishRefresh ));
         TRAP_IGNORE( iExpiryWatcher = GetCenRepIntValueL(
             repository, KSimpleSubscribeRefresh ));
         TRAP_IGNORE( iExpiryWinfo = GetCenRepIntValueL(
--- a/simpleengine/siputils/src/simplesipconnection.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/src/simplesipconnection.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -36,6 +36,7 @@
 #include <siprefresh.h>
 #include <sipmessageelements.h>
 #include <sipsubscribedialogassoc.h>
+#include <sipregistrationcontext.h>
 
 // sip codec api
 #include <sipfromheader.h>
@@ -51,6 +52,8 @@
 #include <sipsupportedheader.h>
 #include <sipacceptheader.h>
 
+#include <cvimpstsettingsstore.h>
+
 // own simple
 #include "simplesipconnection.h"
 #include "simplesipconnectionobserver.h"
@@ -80,10 +83,6 @@
 _LIT8 ( KSimpleNoresource, "Noresource" );
 _LIT8 ( KSipPrefix, "sip:" );
 
-// UID given for CSIP class. SIP Utils listens to new SIP requests 
-// (when receiving IM) outside SIP dialogs.
-const TUid KSimpleSIPUtilsUID = { 0x10281EEC };
-
 // ================= MEMBER FUNCTIONS =======================
 //
 
@@ -114,6 +113,7 @@
     delete iConnectionObserver;
     delete iSip;
     DeleteRequests();
+    DeleteRequests( CSimpleRequest::EReqReceiveIM );
     SIPStrings::Close();
     }
 
@@ -140,11 +140,8 @@
     TSimpleLogger::Log(
         _L("SipConnection: ConstructL 20-01-07 this=%d" ), (TInt)this );
 #endif
-    // initialize members
-    iSip = CSIP::NewL( KSimpleSIPUtilsUID, *this );
+    
     iConnectionObserver = CSimpleSipConnectionObserver::NewL( *this);
-    iProfileObserver = 
-        CSimpleSipProfileObserver::NewL( iSip, *iConnectionObserver);
     SIPStrings::OpenL();
     // read static cenrep settings
     iSettings.ReadCentRepSettings();
@@ -450,36 +447,22 @@
         // Start to fill header, Remote URI
         CSIPRequestElements* elems = CSIPRequestElements::NewL( uri );
         CleanupStack::PushL( elems );  // CS: 3
-
+        
         TUriParser8 parser3;
         User::LeaveIfError( parser3.Parse( iProfileObserver->
             GiveUserAorL() ));
-        uri = CUri8::NewLC( parser3 );  // CS: 4
-        
+        uri = CUri8::NewL( parser3 );
         CSIPAddress* sipAddress = CSIPAddress::NewL( uri );
-        CleanupStack::Pop( uri ); // ownership given to sipAddress  // CS: 3
-        CleanupStack::PushL( sipAddress );  // CS: 4
         
         // From Header
         CSIPFromHeader* fromH = CSIPFromHeader::NewL( sipAddress );
-        CleanupStack::Pop( sipAddress ); // ownership given to FromH  // CS: 3
-        CleanupStack::PushL( fromH );  // CS: 4
-        elems->SetFromHeaderL( fromH );
-        // fromH, ownership given to elems
-        CleanupStack::Pop( fromH );  // CS: 3
+        elems->SetFromHeaderL( fromH ); // fromH, ownership given to elems
         
-        uri = CUri8::NewLC( parser );  // CS: 4
-        
+        uri = CUri8::NewL( parser );
         CSIPAddress* addr = CSIPAddress::NewL( uri );
-        CleanupStack::Pop( uri );  // CS: 3
-        CleanupStack::PushL( addr );  // CS: 4
-        
         // To Header
         CSIPToHeader* toHeader = CSIPToHeader::NewL( addr );
-        CleanupStack::Pop( addr );  // CS: 3
-        CleanupStack::PushL( toHeader );  // CS: 4   
         elems->SetToHeaderL( toHeader );
-        CleanupStack::Pop( toHeader );  // CS: 3
         
         CSIPMessageElements& mesElems = elems->MessageElements();
         
@@ -497,29 +480,30 @@
             
             mesElems.SetUserHeadersL( headers );
             // headers ownership given to mesElems
-            CleanupStack::Pop( &headers ); // CS: 3            
+            CleanupStack::Pop( &headers ); // CS: 3
             }
         
         // Set content type and content
-        CSIPContentTypeHeader* contTypeH = CSIPContentTypeHeader::NewLC(
-            KSimpleMediaType, KSimpleMediaSubType );  // CS: 4
-        HBufC8* buffer = aContent.AllocLC();  // CS: 5
+        HBufC8* buffer = aContent.AllocLC(); // CS: 4
+        CSIPContentTypeHeader* contTypeH = CSIPContentTypeHeader::NewL(
+            KSimpleMediaType, KSimpleMediaSubType );
+        CleanupStack::Pop( buffer ); // CS: 3
         mesElems.SetContentL( buffer, contTypeH );
         // buffer ownership given to mesElems
-        CleanupStack::Pop( buffer );  // CS: 4
         // contTypeH ownership given to mesElems
-        CleanupStack::Pop( contTypeH );  // CS: 3
         
         // Set method
         elems->SetMethodL( SIPStrings::StringF( SipStrConsts::EMessage ) );
         
+        CleanupStack::Pop( elems ); // CS: 2
         // Send the request transaction
+        // elems, ownership given
         CSIPClientTransaction* sipTrans = iSipConnection->SendRequestL( elems,
             *regContext );
         
         // Save SIP client transaction
         request->SetTransaction( sipTrans );
-        CleanupStack::Pop( elems ); // elems, ownership given  // CS: 2
+        
         CleanupStack::PopAndDestroy( temp ); // CS: 1
         
         // Start refresh timer, it's used for garbage collection too.
@@ -1091,6 +1075,15 @@
             KSimpleMultiType, KSimpleMultipartSubType );
         User::LeaveIfError( headers.Append( acceH ));
         ++popCount;
+
+        // add supported header with value eventlist
+        RPointerArray<CSIPSupportedHeader> suppHs =
+            CSIPSupportedHeader::DecodeL( KSimpleEventlist);
+        for( TInt count=0; count < suppHs.Count(); count++ )
+            {
+            User::LeaveIfError( headers.Append( suppHs[count] ));
+            }
+        suppHs.Close();
         }
     if ( r->Match( CSimpleRequest::EReqSubscribeWinfo ))
         {
@@ -1270,6 +1263,49 @@
     }
 
 // ----------------------------------------------------------
+// CSimpleSipConnection::ConnectionChanged
+// ----------------------------------------------------------
+//
+void CSimpleSipConnection::ConnectionChanged() 
+    {
+#ifdef _DEBUG
+    TSimpleLogger::Log(_L("SipConnection: ConnectionChanged"));
+    if( iSipConnection )
+        {
+        TSimpleLogger::Log(_L("SipConnection: ConnectionChanged : old conn state %d (internal:%d)"), iSipConnection->State(), iSipState );
+        TSimpleLogger::Log(_L("SipConnection: ConnectionChanged : old IAP %d"),  iSipConnection->IapId() );
+        }
+#endif
+
+    iCurrentNbrSubs = 0;
+    CSIPConnection* conn = NULL;
+    TRAPD( err, conn = iProfileObserver->GiveConnectionL() );
+    if( !err )
+        {
+        delete iSipConnection;
+        iSipConnection = conn;
+#ifdef _DEBUG
+        TSimpleLogger::Log(_L("SipConnection: ConnectionChanged : new conn state %d"), iSipConnection->State() );
+        TSimpleLogger::Log(_L("SipConnection: ConnectionChanged : new IAP %d"),  iSipConnection->IapId() );
+#endif
+        }
+#ifdef _DEBUG
+    else
+        {
+        TSimpleLogger::Log(_L("SipConnection: ConnectionChanged : Get SIP connection error %d"), err );        
+        }
+#endif
+    
+    if( iSipConnection )
+        {
+        if( iSipState != iSipConnection->State() )
+            {
+            iConnectionObserver->ConnectionStateChanged( iSipConnection->State() );
+            }
+        }
+    }
+
+// ----------------------------------------------------------
 // CSimpleSipConnection::StartToCheckExpiryL
 // ----------------------------------------------------------
 //
@@ -1370,7 +1406,40 @@
         {
         CSimpleRequest* req = rIter;
         rIter++; //lint !e1757
-        req->Destroy();
+        
+        // open request EReqReceiveIM should not be deleted
+        // will be deleted only when im message received
+        // or destructor is called.
+        if ( !req->Match( CSimpleRequest::EReqReceiveIM ) )
+            {
+            req->Destroy();
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CSimpleSipConnection::DeleteRequests
+// -----------------------------------------------------------------------------
+void CSimpleSipConnection::DeleteRequests( 
+    CSimpleRequest::TSimpleSipReqType aRequestType )
+    {
+#ifdef _DEBUG
+    TSimpleLogger::Log(_L("SipConnection: DeleteRequests type=%d" ),
+        aRequestType );
+#endif
+    // Delete buffered transaction requests match to the aRequestType
+    TDblQueIter<CSimpleRequest> rIter( iRequestList );
+    rIter.SetToFirst();
+
+    while ( rIter )
+        {
+        CSimpleRequest* req = rIter;
+        rIter++; //lint !e1757
+        
+        if ( req->Match( aRequestType ) )
+            {
+            req->Destroy();
+            }
         }
     }
 
@@ -1676,6 +1745,8 @@
             HBufC8* hValue = header->ToTextValueL();
             // hValue ownership is transferred
             aReq->SetETag( hValue );
+            // store etag to vimpstsettingstore
+            StoreETagL( *hValue );
             ETagReceived = ETrue;
             }
         else if ( header->Name() == SIPStrings::StringF( SipStrConsts::EExpiresHeader))
@@ -1695,6 +1766,12 @@
         {
         // Remove old ETag if nore received or if the expires header was 0 in our request.
         aReq->SetETag( NULL );
+        //TPtrC8 nullETag = nullETag.Alloc( KNullDesC8 ); 
+        TBufC8<1> nullETag( KNullDesC8 );
+        HBufC8* buf;
+        buf = nullETag.Alloc();
+        StoreETagL( *buf );
+        delete buf;
         }
     // PopAndDestroy calls extensionName.Close()
     CleanupStack::PopAndDestroy( &extensionName );
@@ -2070,7 +2147,19 @@
 #endif
 
     iSettings.ReadOTASettingsL( aReq.Aux() );
-
+    
+    TInt32 uniqueId = iSettings.SipProfileId();
+    TUid uniqueUid;
+    uniqueUid.iUid = uniqueId;
+        
+    if ( !iSip && !iProfileObserver )
+        {        
+        iSip = CSIP::NewL( uniqueUid, *this );
+        
+        iProfileObserver = CSimpleSipProfileObserver::NewL( 
+            iSip, *iConnectionObserver);        
+        }
+    
     iProfileObserver->RegisterGivenProfileL( iSettings.SipProfileId() );
     SetSipState( ESimpleSipIdle );
     TRAPD( err, iSipConnection = iProfileObserver->GiveConnectionL() );
@@ -2539,11 +2628,9 @@
     {
     if ( aState == ESimpleSipActive )
         {
-        // Check that both SIP Profile and SIP connection are ready.
+        // Check that SIP Profile is ready.
         // iProfileObserver is created in ConstructL.
-        if ( iProfileObserver->IsProfileActive() && 
-             iSipConnection &&
-             iSipConnection->State() == CSIPConnection::EActive )
+        if ( iProfileObserver->IsProfileActive() )
             {
             SetSipState( aState );            
             }
@@ -2577,3 +2664,36 @@
 #endif
     }
 
+// -----------------------------------------------------------------------------
+// CSimpleRequest::SetServiceId
+// -----------------------------------------------------------------------------
+EXPORT_C void CSimpleSipConnection::SetServiceId( TInt32 aServiceId )
+    {
+#ifdef _DEBUG
+    TSimpleLogger::Log( _L(
+               "CSimpleSipConnection::SetServiceId old serviceId = %d, new serviceId = %d" ),
+                   iServiceId, aServiceId );
+#endif
+    iServiceId = aServiceId;
+    }
+
+// -----------------------------------------------------------------------------
+// CSimpleRequest::StoreETag
+// -----------------------------------------------------------------------------
+void CSimpleSipConnection::StoreETagL( HBufC8& aETag )
+    {
+#ifdef _DEBUG
+    TBuf<255> printDocumentId;
+        printDocumentId.Copy( aETag );
+    TSimpleLogger::Log(_L("CSimpleSipConnection: StoreETag ETag = %S, serviceId = %d" ),
+        &printDocumentId, iServiceId );
+#endif
+    MVIMPSTSettingsStore* settings = CVIMPSTSettingsStore::NewLC();
+    
+    // Store ETag to uiservicetabsettings
+    User::LeaveIfError( settings->SetL( 
+        iServiceId, EServicePresenceSessionIdentifier, aETag ) );
+    
+    CleanupStack::PopAndDestroy(); //settings   
+    }
+
--- a/simpleengine/siputils/src/simplesipconnectionobserver.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/src/simplesipconnectionobserver.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -160,6 +160,18 @@
     }     
     
 // -----------------------------------------------------------------------------
+// CSimpleSipConnectionObserver::ProfileUpdated
+// -----------------------------------------------------------------------------
+//
+void CSimpleSipConnectionObserver::ProfileUpdated()
+    {
+#ifdef _DEBUG
+    TSimpleLogger::Log(_L("SipConnectionObserver: ProfileUpdated"));
+#endif
+    iCallback.ConnectionChanged();
+    }
+
+// -----------------------------------------------------------------------------
 // CSimpleSipConnectionObserver::ConnectionStateChanged2
 // -----------------------------------------------------------------------------
 //
@@ -568,13 +580,15 @@
             Extract( EUriUserinfo );
         const TDesC8& host = fromHeader->SIPAddress().Uri8().Uri().
             Extract( EUriHost );
+        
+        CleanupStack::PushL( aTransaction ); // CS: 1
+        
         HBufC8* from = HBufC8::NewLC( user.Length() + KAt().Length() +
             host.Length() ); // CS: 1
         from->Des().Copy( user );
         from->Des().Append( KAt() );
         from->Des().Append( host );
         
-        CleanupStack::PushL( aTransaction ); // CS: 2
         CSIPResponseElements* respElem = CSIPResponseElements::NewLC( // CS: 3
             KSimpleOK, SIPStrings::StringF( SipStrConsts::EPhraseOk ) );
         
@@ -582,10 +596,10 @@
         aTransaction->SendResponseL( respElem );
         
         CleanupStack::Pop( respElem );     // CS: 2
-        CleanupStack::Pop( aTransaction ); // CS: 1
-        
+
         iCallback.HandleReceivedMessage( *from, content );
-        CleanupStack::PopAndDestroy( from ); // CS: 0
+        CleanupStack::PopAndDestroy( from ); // CS: 1
+        CleanupStack::Pop( aTransaction ); // CS: 0
         }
     
     // We no longer need aTransaction. Just delete it.
--- a/simpleengine/siputils/src/simplesipprofileobserver.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/siputils/src/simplesipprofileobserver.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -272,7 +272,14 @@
         }     
     else if ( aEvent == EProfileUpdated )
         {
-        iObs.ProfileStateChanged( CSIPConnection::EUnavailable, KErrNone );
+#ifdef _DEBUG
+        TSimpleLogger::Log(_L("SipProfileObserver: EProfileUpdated - ProfileEnabled : %d" ), iRegistry->IsEnabled( *iProfile ) );
+        TSimpleLogger::Log(_L("SipProfileObserver: EProfileUpdated - Profile reg er : %d" ), iRegistry->LastRegistrationError( *iProfile ) );
+        TSimpleLogger::Log(_L("SipProfileObserver: EProfileUpdated - IsContextActive : %d" ), iProfile->IsContextActive() );
+#endif
+
+        // Notify observer to refresh SIP connection.
+        iObs.ProfileUpdated();
         }           
     else if ( aEvent == EProfileDestroyed )
         {      
--- a/simpleengine/xdmrlspres/eabi/rlspresxdmU.DEF	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/xdmrlspres/eabi/rlspresxdmU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -98,14 +98,14 @@
 	_ZN7CRLSXDM18UpdateDisplayNameLERK7TDesC16S2_S2_ @ 97 NONAME
 	_ZN7CRLSXDM19DeleteAllEmptyListsEP23MRLSPresXDMAsyncHandler @ 98 NONAME
 	_ZN7CRLSXDM19SwitchToServiceURILERK7TDesC16 @ 99 NONAME
-	_ZN7CRLSXDM20NegotiatedServiceUriEv @ 100 NONAME
-	_ZN7CRLSXDM20UpdateAllFromServerLEP23MRLSPresXDMAsyncHandler @ 101 NONAME
-	_ZN7CRLSXDM26DeleteAllEmptyServiceUrisLEv @ 102 NONAME
-	_ZN7CRLSXDM4NewLEi @ 103 NONAME
-	_ZN7CRLSXDM5NewLCEi @ 104 NONAME
-	_ZN7CRLSXDM9DeleteAllEv @ 105 NONAME
-	_ZTI12CPresenceXDM @ 106 NONAME
-	_ZTI7CRLSXDM @ 107 NONAME
-	_ZTV12CPresenceXDM @ 108 NONAME
-	_ZTV7CRLSXDM @ 109 NONAME
+	_ZN7CRLSXDM20UpdateAllFromServerLEP23MRLSPresXDMAsyncHandler @ 100 NONAME
+	_ZN7CRLSXDM26DeleteAllEmptyServiceUrisLEv @ 101 NONAME
+	_ZN7CRLSXDM4NewLEi @ 102 NONAME
+	_ZN7CRLSXDM5NewLCEi @ 103 NONAME
+	_ZN7CRLSXDM9DeleteAllEv @ 104 NONAME
+	_ZTI12CPresenceXDM @ 105 NONAME ; #<TI>#
+	_ZTI7CRLSXDM @ 106 NONAME ; #<TI>#
+	_ZTV12CPresenceXDM @ 107 NONAME ; #<VT>#
+	_ZTV7CRLSXDM @ 108 NONAME ; #<VT>#
+	_ZN7CRLSXDM20NegotiatedServiceUriEv @ 109 NONAME
 
--- a/simpleengine/xdmrlspres/group/bld.inf	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/xdmrlspres/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -27,14 +27,14 @@
 rlspresxdm.mmp
 
 PRJ_EXPORTS
-../inc/rlspresxdmconsts.h	MW_LAYER_PLATFORM_EXPORT_PATH(rlspresxdmconsts.h)
-../inc/cpresencexdm.h	MW_LAYER_PLATFORM_EXPORT_PATH(cpresencexdm.h)
-../inc/mrlspresxdmasynchandler.h	MW_LAYER_PLATFORM_EXPORT_PATH(mrlspresxdmasynchandler.h)
-../inc/presenceactionxdm.h	MW_LAYER_PLATFORM_EXPORT_PATH(presenceactionxdm.h)
-../inc/prescondidentityone.h	MW_LAYER_PLATFORM_EXPORT_PATH(prescondidentityone.h)
-../inc/prescondidentitymany.h	MW_LAYER_PLATFORM_EXPORT_PATH(prescondidentitymany.h)
-../inc/prescondvalidity.h	MW_LAYER_PLATFORM_EXPORT_PATH(prescondvalidity.h)
-../inc/prescondsphere.h	MW_LAYER_PLATFORM_EXPORT_PATH(prescondsphere.h)
-../inc/presencetransformxdm.h	MW_LAYER_PLATFORM_EXPORT_PATH(presencetransformxdm.h)
-../inc/crlsxdm.h	MW_LAYER_PLATFORM_EXPORT_PATH(crlsxdm.h)
-../inc/prescondmisc.h    MW_LAYER_PLATFORM_EXPORT_PATH(prescondmisc.h)
+../inc/rlspresxdmconsts.h	/epoc32/include/mw/rlspresxdmconsts.h
+../inc/cpresencexdm.h	/epoc32/include/mw/cpresencexdm.h
+../inc/mrlspresxdmasynchandler.h	/epoc32/include/mw/mrlspresxdmasynchandler.h
+../inc/presenceactionxdm.h	/epoc32/include/mw/presenceactionxdm.h
+../inc/prescondidentityone.h	/epoc32/include/mw/prescondidentityone.h
+../inc/prescondidentitymany.h	/epoc32/include/mw/prescondidentitymany.h
+../inc/prescondvalidity.h	/epoc32/include/mw/prescondvalidity.h
+../inc/prescondsphere.h	/epoc32/include/mw/prescondsphere.h
+../inc/presencetransformxdm.h	/epoc32/include/mw/presencetransformxdm.h
+../inc/crlsxdm.h	/epoc32/include/mw/crlsxdm.h
+../inc/prescondmisc.h    /epoc32/include/mw/prescondmisc.h
--- a/simpleengine/xdmrlspres/group/rlspresxdm.mmp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/xdmrlspres/group/rlspresxdm.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -53,7 +53,7 @@
 LIBRARY                         charconv.lib
 
 
-#if defined( EABI )
+#if defined( ARMCC )
 DEFFILE ../eabi/ 
 #elif defined ( WINSCW )
 deffile ../bwinscw/ 
--- a/simpleengine/xdmrlspres/src/crlsxdm.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/xdmrlspres/src/crlsxdm.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -709,7 +709,7 @@
     RPointerArray<CXdmDocumentNode> confirmedNodes;
     
     CXdmDocumentNode* currentNode = serviceUriNode;
-    confirmedNodes.Append(currentNode);
+    confirmedNodes.AppendL(currentNode);
     
     if(count>1) // if some list(s) exist in path info
         {
@@ -734,7 +734,7 @@
     for (TInt j=0;j<count;j++)
         {
         iListPath->AppendL(aLists.MdcaPoint(j));
-        iListPointerPath.Append(confirmedNodes[j]);
+        iListPointerPath.AppendL(confirmedNodes[j]);
         }
     
     confirmedNodes.Close();    
--- a/simpleengine/xdmrlspres/src/prescondvalidity.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/xdmrlspres/src/prescondvalidity.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -61,6 +61,8 @@
     OPENG_DP(D_OPENG_LIT( "TPresCondValidity::GetValidity()" ) );
     OPENG_DP(D_OPENG_LIT( "     aRuleID = %S"),&aRuleID);
 
+    CleanupClosePushL (aValidTimes);
+    
 	CXdmDocumentNode* validityNode = GetValidityNodeL(aRuleID, EFalse);
 	if(validityNode==NULL)
 	    return KErrNotFound;
@@ -99,7 +101,7 @@
 
 	for(TInt i=0; i<nodeCount; i++)
 	    {
-        aValidTimes.Append(myTimePeriod);
+        aValidTimes.AppendL(myTimePeriod);
 
 	    // processing from
 	    (fromNodes[i])->SetLeafNode(ETrue);
@@ -134,6 +136,8 @@
 	    
     fromNodes.Close();
     untilNodes.Close();
+    
+    CleanupStack::Pop();
 	return KErrNone;
 	}
 
--- a/simpleengine/xdmrlspres/src/presencetransformxdm.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/xdmrlspres/src/presencetransformxdm.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -181,7 +181,7 @@
         if ((nodeName==KPresAllDevices)||(nodeName==KPresAllPersons)||
                                                     (nodeName==KPresAllServices))
             {
-            aTypeAndValues.Append(myDataCompo);
+            aTypeAndValues.AppendL(myDataCompo);
             break;
             }
        
--- a/simpleengine/xmlutils/inc/simpleelement.h	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/xmlutils/inc/simpleelement.h	Wed Sep 01 12:23:14 2010 +0100
@@ -276,7 +276,7 @@
     void ConstructL( const TDesC8& aNsUri,
         const TDesC8& aLocalName );
 
-    void ConstructL(
+    void CSimpleElement::ConstructL(
         CSenElement* aElem,
         TBool aOwn );
 
--- a/simpleengine/xmlutils/src/simpledocument.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/xmlutils/src/simpledocument.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -196,12 +196,14 @@
 void CSimpleDocument::GetDirectContentsL( 
     RPointerArray<MSimpleContent>& aContents )
     {
+    CleanupClosePushL( aContents ); 
     aContents.Reset();
     TInt myCount = iContents.Count();
     for ( TInt i = 0; i<myCount; i++ )
         {
-        User::LeaveIfError( aContents.Append( iContents[i] ));
-        }               
+        aContents.AppendL( iContents[i] );
+        }
+    CleanupStack::Pop( &aContents );
     }
     
 // ----------------------------------------------------------
@@ -653,7 +655,7 @@
     // Let's convert first ROOT element into CBodyPart
     CBodyPart* root = CBodyPart::NewL();
     // Add into cleanup array
-    aBodies.Append( root );     
+    aBodies.AppendL( root );     
     CSenElement* e = Root()->BaseElement();
     
     // externalize the document into stream
@@ -676,7 +678,7 @@
     // calculate the size of headers
     TInt headerSize = KContentTypeSize + KCIDSize;
     HBufC8* headers = HBufC8::NewL( headerSize );  
-    aBuffers.Append( headers );
+    aBuffers.AppendL( headers );
     TPtr8 pH(headers->Des());
     // append to MIME headers for the root part   
     pH.Append( NSimpleDocument::NSimpleRoot::KContentType );
@@ -689,7 +691,7 @@
         { 
         // Let's convert next element into CBodyPart
         CBodyPart* cp = CBodyPart::NewL();
-        aBodies.Append( cp );                
+        aBodies.AppendL( cp );                
          
         // Set Headers
         headerSize = NSimpleDocument::NSimpleContent::KContentTypeSize + 
@@ -700,7 +702,7 @@
         
         headers = HBufC8::NewL( headerSize );
         // Append to cleanup array  
-        aBuffers.Append( headers );
+        aBuffers.AppendL( headers );
         pH.Set( headers->Des() );
 
         // _LIT8( KMyContentType, "Content-Type: %S\r\n"); 
@@ -716,7 +718,7 @@
                     
         // BASE64 encode
         HBufC8* body64 = HBufC8::NewL( (iContents[i])->Body().Length() * KB64Expand );  
-        aBuffers.Append( body64 );        
+        aBuffers.AppendL( body64 );        
         TImCodecB64 codec64;
         codec64.Initialise();        
         TPtr8 desti8 = body64->Des();  
--- a/simpleengine/xmlutils/src/simpleelement.cpp	Tue Aug 31 15:35:50 2010 +0300
+++ b/simpleengine/xmlutils/src/simpleelement.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -221,6 +221,7 @@
 TInt CSimpleElement::SimpleElementsL( 
     RPointerArray<MSimpleElement>& aElementArray )
     {
+    CleanupClosePushL( aElementArray );
     // Reset the output array first.
     aElementArray.Reset();
     iElements.ResetAndDestroy();
@@ -234,10 +235,12 @@
         CSenElement* pElement = elems[i];
         CSimpleElement* simple = CSimpleElement::NewL( pElement, EFalse );
         CleanupStack::PushL( simple );
-        User::LeaveIfError( aElementArray.Append( simple ));
+        iElements.AppendL( simple );
         CleanupStack::Pop( simple );
-        User::LeaveIfError( iElements.Append( simple ) );
+        aElementArray.AppendL( simple );
         }
+    CleanupStack::Pop( &aElementArray ); 
+    
     return elemCount ? KErrNone : KErrNotFound;
     }
 
@@ -292,6 +295,8 @@
 //
 TInt CSimpleElement::SimpleAttributesL( RPointerArray<MSimpleAttribute>& aArray )
     {  
+    CleanupClosePushL( aArray );
+    
     // Reset the output array first.
     aArray.Reset();
     iAttributes.ResetAndDestroy();
@@ -304,10 +309,12 @@
         CSenBaseAttribute* pAttr = elems[i];
         CSimpleAttribute* attr = CSimpleAttribute::NewL( pAttr );
         CleanupStack::PushL( attr );
-        User::LeaveIfError(iAttributes.Append( attr ));
+        iAttributes.AppendL( attr );
         CleanupStack::Pop( attr );        
-        User::LeaveIfError(aArray.Append( attr ));
+        aArray.AppendL( attr );
         }
+    CleanupStack::Pop( &aArray );
+    
     return elemCount ? KErrNone : KErrNotFound;
     }
 
--- a/sysdef_1_5_1.dtd	Tue Aug 31 15:35:50 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
- <!ELEMENT SystemDefinition (systemModel?, build?)>
- <!ATTLIST SystemDefinition
-  name CDATA #REQUIRED
-  schema CDATA #REQUIRED>
- <!ELEMENT systemModel (layer+)>
- <!ELEMENT layer (logicalset* | module*)*>
- <!ATTLIST layer
-  name CDATA #REQUIRED
-  levels CDATA #IMPLIED
-  span CDATA #IMPLIED>
- <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
- <!ATTLIST logicalset name CDATA #REQUIRED>
- <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
- <!ATTLIST logicalsubset name CDATA #REQUIRED>
- <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
- <!ATTLIST module
-  name CDATA #REQUIRED
-  level CDATA #IMPLIED>
- <!ELEMENT component (unit* | package* | prebuilt*)*>
- <!ATTLIST component name CDATA #REQUIRED>
- <!ELEMENT unit EMPTY>
- <!ATTLIST unit
-  unitID ID #REQUIRED
-  name CDATA #REQUIRED
-  mrp CDATA #REQUIRED
-  filter CDATA #IMPLIED
-  bldFile CDATA #REQUIRED
-  priority CDATA #IMPLIED
-  contract CDATA #IMPLIED
-  proFile CDATA #IMPLIED
-  qmakeArgs CDATA #IMPLIED>
- <!ELEMENT package EMPTY>
- <!ATTLIST package
-  name CDATA #REQUIRED
-  mrp CDATA #REQUIRED
-  filter CDATA #IMPLIED
-  contract CDATA #IMPLIED>
- <!ELEMENT prebuilt EMPTY>
- <!ATTLIST prebuilt
-  name CDATA #REQUIRED
-  version CDATA #REQUIRED
-  late (Y|N) #IMPLIED
-  filter CDATA #IMPLIED
-  contract CDATA #IMPLIED>
- <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
- <!ELEMENT unitList (unitRef+)>
- <!ATTLIST unitList
-  name ID #REQUIRED
-  description CDATA #REQUIRED>
- <!ELEMENT unitRef EMPTY>
- <!ATTLIST unitRef unit IDREF #REQUIRED>
- <!ELEMENT targetList EMPTY>
- <!ATTLIST targetList
-  name ID #REQUIRED
-  description CDATA #REQUIRED
-  target IDREFS #REQUIRED>
- <!ELEMENT target EMPTY>
- <!ATTLIST target
-  name ID #REQUIRED
-  abldTarget CDATA #REQUIRED
-  description CDATA #REQUIRED>
- <!ELEMENT option EMPTY>
- <!ATTLIST option
-  name ID #REQUIRED
-  abldOption CDATA #REQUIRED
-  description CDATA #REQUIRED
-  enable (Y | N | y | n) #REQUIRED>
- <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
- <!ATTLIST configuration
-  name ID #REQUIRED
-  description CDATA #REQUIRED
-  filter CDATA #REQUIRED>
- <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
- <!ELEMENT unitListRef EMPTY>
- <!ATTLIST unitListRef unitList IDREF #REQUIRED>
- <!ELEMENT layerRef EMPTY>
- <!ATTLIST layerRef layerName CDATA #REQUIRED>
- <!ELEMENT buildLayer EMPTY>
- <!ATTLIST buildLayer
-  command CDATA #REQUIRED
-  targetList IDREFS #IMPLIED
-  unitParallel (Y | N | y | n) #REQUIRED
-  targetParallel (Y | N | y | n) #IMPLIED>
- <!ELEMENT specialInstructions EMPTY>
- <!ATTLIST specialInstructions
-  name CDATA #REQUIRED
-  cwd CDATA #REQUIRED
-  command CDATA #REQUIRED>  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/BWINSCW/LocalOperationsU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/eabi/LocalOperationsU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/group/LocalOperations.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,71 @@
+/*
+* 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: LocalOperations.mmp
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                          localoperations.dll
+UID                             0x10009D8D 0x10275086
+CAPABILITY                      CAP_ECOM_PLUGIN
+VENDORID                        VID_DEFAULT
+TARGETTYPE                      PLUGIN
+
+SOURCEPATH                      ../src
+
+START RESOURCE                  10275086.rss
+ 
+    TARGET                      localoperations.rsc
+ 
+END
+
+SOURCE                          LocalAddition.cpp
+SOURCE                          LocalDeletion.cpp
+SOURCE                          LocalRetrieval.cpp
+SOURCE                          LocalReplacement.cpp
+SOURCE                          LocalOperationBase.cpp
+SOURCE                          LocalOperationFactory.cpp
+
+USERINCLUDE                     ../inc
+USERINCLUDE                     ../../inc
+USERINCLUDE                     ../../../inc
+
+//Parser
+USERINCLUDE                     ../../../XdmXmlParser/inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE                   /epoc32/include/xml
+SYSTEMINCLUDE                   /epoc32/include/ecom
+SYSTEMINCLUDE                   ../../../../inc
+
+LIBRARY                         hal.lib
+LIBRARY                         ecom.lib
+LIBRARY                         efsrv.lib
+LIBRARY                         euser.lib
+LIBRARY                         xdmengine.lib
+LIBRARY                         xdmxmlparser.lib
+LIBRARY                         localprotocol.lib
+
+#if defined( ARMCC )
+DEFFILE ../eabi/ 
+#elif defined ( WINSCW )
+deffile ../BWINSCW/ 
+#elif defined (WINS )
+deffile ../BWINS/ 
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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: LocalOperations bld.inf
+*
+*/
+
+
+
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+LocalOperations.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/inc/LocalAddition.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CLocalAddition
+*
+*/
+
+
+
+
+#ifndef __LOCALADDITION__
+#define __LOCALADDITION__
+
+#include <e32base.h>
+#include "XdmOperation.h"
+#include "LocalOperationBase.h"
+
+//FORWARD DECLARATIONS
+class CXdmDocumentNode;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CLocalAddition ) : public CLocalOperationBase
+    {
+    public:
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CLocalAddition* NewL( CLocalDocument& aParentDoc,
+                                     CLocalDocumentNode* aDocumentSubset,
+                                     CLocalOperationFactory& aOperationFactory );
+        
+        /**
+        * Destructor.
+        */      
+        virtual ~CLocalAddition();
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CLocalAddition( CLocalDocument& aParentDoc,
+                        CLocalDocumentNode* aDocumentSubset,
+                        CLocalOperationFactory& aOperationFactory );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void HandlePartialUpdateL( TInt aDataLength );
+    
+    private:        //From MXdmOperation
+        
+        /**
+        * Execute this operation synchronously
+        */      
+        void ExecuteL();
+        
+        /**
+        * Set this operation to completed state.
+        */      
+        void Destroy();                
+
+    private:  //Data
+        
+
+        TXdmOperationType               iOperationType;
+        CXdmDocumentNode*               iDocumentSubset;
+    };
+
+#endif      //__LOCALADDITION__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/inc/LocalDeletion.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,88 @@
+/*
+* 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:  CLocalDeletion
+*
+*/
+
+
+
+
+#ifndef __LOCALDELETION__
+#define __LOCALDELETION__
+
+#include <e32base.h>
+#include "XdmOperation.h"
+#include "LocalOperationBase.h"
+
+//FORWARD DECLARATIONS
+class CXdmDocumentNode;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CLocalDeletion ) : public CLocalOperationBase
+    {
+    public:
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CLocalDeletion* NewL( CLocalDocument& aParentDoc,
+                                     CLocalDocumentNode* aDocumentSubset,
+                                     CLocalOperationFactory& aOperationFactory );
+       
+        /**
+        * Destructor.
+        */      
+        virtual ~CLocalDeletion();
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CLocalDeletion( CLocalDocument& aTargetDoc,
+                        CLocalDocumentNode* aDocumentSubset,
+                        CLocalOperationFactory& aOperationFactory );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */    
+        void HandlePartialDeletionL( TInt aDataLength );
+    
+    private:        //From MXdmOperation
+        
+        /**
+        * Execute this operation synchronously
+        */      
+        void ExecuteL();
+        
+        /**
+        * Set this operation to completed state.
+        */      
+        void Destroy();                
+
+    private:  //Data
+    
+        CLocalDocumentNode*             iDocumentSubset;
+        TXdmOperationType               iOperationType;
+    };
+
+#endif      //__LOCALDELETION__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/inc/LocalOperationBase.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,155 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CLocalOperationBase
+*
+*/
+
+
+
+
+#ifndef __LOCALOPERATIONBASE__
+#define __LOCALOPERATIONBASE__
+
+#include <e32base.h>
+#include "XdmOperation.h"
+
+//FORWARD DECLARATIONS
+class CXdmXmlParser;
+class CLocalDocument;
+class CXdmDocumentNode;
+class CLocalDocumentNode;
+class CLocalOperationFactory;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CLocalOperationBase ) : public CBase,
+                                           public MXdmOperation
+    {
+    public:
+        
+        /**
+        * Destructor.
+        */      
+        virtual ~CLocalOperationBase();
+
+    protected:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CLocalOperationBase( const CLocalDocument& aTargetDoc,
+                             CLocalOperationFactory& aOperationFactory );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void BaseConstructL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */    
+        void WriteFileL( const CXdmDocumentNode* aRootNode );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        HBufC8* FetchXmlDataL( TInt aFileSize  );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */   
+        void ReplaceDataFileL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */   
+        void DeleteDataFileL();
+                
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        TInt OpenDataFileL( const TDesC& aFilePath );
+        
+    private:
+    
+        /**
+        * Execute this operation asynchronously.
+        */      
+        void ExecuteL( TRequestStatus& aStatus, TUint aOptions );
+        
+        /**
+        * Cancel this operation.
+        */      
+        void CancelOperation();
+        
+        /**
+        * Get the result of this operation.
+        */      
+        TInt Result() const;
+
+        /**
+        * Get the completion data of this operation.
+        */      
+        const TXdmCompletionData& CompletionData() const;
+        
+        /**
+        * Set this operation to completed state.
+        */      
+        TBool IsCompleted() const;
+        
+        /**
+        * Set this operation to completed state.
+        */      
+        CXdmDocumentNode* TargetNode() const;
+        
+        /**
+        * Set this operation to completed state.
+        */   
+        void GenerateTimeStampL();
+        
+        HBufC* ConstructTimestampNameL();
+        
+        /**
+        * Set this operation to completed state.
+        */   
+        HBufC8* TimeLC();
+    
+    protected:  //Data
+        
+        RFile                           iXmlFile;
+        TPtrC                           iFullPath;
+        CFileMan*                       iFileManager;
+        CLocalDocument&                 iTargetDoc;
+        CXdmXmlParser*                  iXmlParser;
+        TXdmOperationType               iOperationType;
+        TXdmCompletionData              iCompletionData;
+        CLocalOperationFactory&         iOperationFactory;
+    };
+
+#endif      //__LOCALOPERATIONBASE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/inc/LocalOperationFactory.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CLocalOperationFactory
+*
+*/
+
+
+
+
+#ifndef __LOCALOPERATIONFACTORY__
+#define __LOCALOPERATIONFACTORY__
+
+#include <e32base.h>
+#include "XdmOperationFactory.h"
+
+_LIT( KLocalOpLogFile,                          "LocalOperations" );
+const TInt KLocalProtLogBufferMaxSize		      = 2000;
+
+//FORWARD DECLARATION
+class CXdmDocument;
+class MXdmOperation;
+class CXdmLogWriter;
+class CXdmDocumentNode;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CLocalOperationFactory ) : public CXdmOperationFactory
+    {
+    public:
+        
+        /**
+        * Two-phased constructor.
+        * @param CXdmProtocolInfo Protocol info
+        * @return CXdmProtocol
+        */
+        static CLocalOperationFactory* NewL();
+        
+        /**
+        * Destructor. A simple wrapper to the C++ destructor.
+        *
+        */
+	    virtual ~CLocalOperationFactory();
+	
+	private:  //From CXdmoperationFactory
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * whole documents
+        */
+        MXdmOperation* FetchL( CXdmDocument& aTargetDocument,
+                               CXdmDocumentNode* aTargetNode = NULL ) const;
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        MXdmOperation* InsertL( CXdmDocument& aTargetDocument,
+                                CXdmDocumentNode* aTargetNode ) const;
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        MXdmOperation* ReplaceL( CXdmDocument& aOldDocument, 
+                                 CXdmDocumentNode* aNewNode,
+                                 CXdmDocumentNode* aOldNode ) const;
+
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        MXdmOperation* AppendL( CXdmDocument& aTargetDocument,
+                                CXdmDocumentNode* aTargetNode ) const;
+
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        MXdmOperation* DeletionL( CXdmDocument& aTargetDocument,
+                                  CXdmDocumentNode* aTargetNode ) const;
+                                  
+    public:
+     
+        /**
+        * Logging function
+        * @param TRefByValue<const TDesC8> aFmt,...
+        * @return void
+        */ 
+        void WriteToLog( TRefByValue<const TDesC8> aFmt,... );
+    
+    private:
+        
+        /**
+        * C++ constructor
+        * @return CImpsTcpCirWatcher
+        */      
+        void ConstructL();
+        
+        /**
+        * C++ constructor
+        * @return CImpsTcpCirWatcher
+        */      
+        CLocalOperationFactory();
+        
+    private:  //Data
+    
+        CXdmLogWriter*                      iLogWriter;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/inc/LocalReplacement.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,90 @@
+/*
+* 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:  CLocalReplacement
+*
+*/
+
+
+
+
+#ifndef __LOCALREPLACEMENT__
+#define __LOCALREPLACEMENT__
+
+#include <e32base.h>
+#include "XdmOperation.h"
+#include "LocalOperationBase.h"
+
+//FORWARD DECLARATIONS
+class CLocalDocumentNode;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CLocalReplacement ) : public CLocalOperationBase
+    {
+    public:
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CLocalReplacement* NewL( CLocalDocument& aParentDoc,
+                                        CLocalDocumentNode* aOldNode,
+                                        CLocalDocumentNode* aNewNode,
+                                        CLocalOperationFactory& aOperationFactory );
+        
+        /**
+        * Destructor.
+        */      
+        virtual ~CLocalReplacement();
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CLocalReplacement( CLocalDocument& aTargetDoc,
+                           CLocalDocumentNode* aOldNode,
+                           CLocalDocumentNode* aNewNode,
+                           CLocalOperationFactory& aOperationFactory );
+        
+    private:        //From MXdmOperation
+        
+        /**
+        * Execute this operation synchronously
+        */      
+        void ExecuteL();
+        
+        /**
+        * Execute this operation synchronously
+        */    
+        void HandlePartialReplacementL( TInt aDataLength );
+        
+        /**
+        * Set this operation to completed state.
+        */      
+        void Destroy();                
+
+    private:  //Data
+
+        CLocalDocumentNode*             iNewNode;
+        CLocalDocumentNode*             iTargetNode;
+        TXdmOperationType               iOperationType;
+        
+    };
+
+#endif      //__LOCALREPLACEMENT__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/inc/LocalRetrieval.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,79 @@
+/*
+* 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: CLocalRetrieval
+*
+*/
+
+
+
+
+#ifndef __LOCALRETRIEVAL__
+#define __LOCALRETRIEVAL__
+
+#include <e32base.h>
+#include "LocalOperationBase.h"
+
+class CLocalDocumentNode;
+   
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CLocalRetrieval ) : public CLocalOperationBase
+    {
+    public:
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CLocalRetrieval* NewL( CLocalDocument& aParentDoc,
+                                      CLocalDocumentNode* aTargetNode,
+                                      CLocalOperationFactory& aOperationFactory );
+        
+        /**
+        * Destructor.
+        */      
+        virtual ~CLocalRetrieval();
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CLocalRetrieval( CLocalDocument& aTargetDoc,
+                         CLocalDocumentNode* aDocumentSubset,
+                         CLocalOperationFactory& aOperationFactory );
+    
+    private:        //From MXdmOperation
+        
+        /**
+        * Execute this operation synchronously
+        */      
+        void ExecuteL();
+        
+        /**
+        * Set this operation to completed state.
+        */      
+        void Destroy();                
+
+    private:  //Data
+        
+        CLocalDocumentNode*                 iDocumentSubset;
+        TXdmOperationType                   iOperationType;
+    };
+
+#endif      //__LOCALRETRIEVAL__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/src/10275086.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: XdmOperationInfo
+*
+*/
+
+
+// 10275086.RSS
+//
+#include "registryinfo.rh"
+
+//Declares the interface implementations provided
+RESOURCE REGISTRY_INFO XdmOperationInfo
+	{
+	dll_uid = 0x10275086;
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x10207425;
+			implementations = 
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10275088;
+					version_no = 1;
+					display_name = "Local Operation API||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/src/LocalAddition.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,143 @@
+/*
+* 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: CLocalAddition
+*
+*/
+
+
+
+
+// INCLUDES
+#include "LocalProtocol.h"
+#include "LocalDocument.h"
+#include "LocalAddition.h"
+#include "XdmXmlParser.h"
+#include "LocalDocumentNode.h"
+#include "LocalNodeAttribute.h"
+#include "LocalOperationFactory.h"
+    
+// ---------------------------------------------------------
+// CLocalAddition::CLocalAddition
+//
+// ---------------------------------------------------------
+//
+CLocalAddition::CLocalAddition( CLocalDocument& aParentDoc,
+                                CLocalDocumentNode* aDocumentSubset,
+                                CLocalOperationFactory& aOperationFactory ) :
+                                CLocalOperationBase( aParentDoc, aOperationFactory ),
+                                iOperationType( aDocumentSubset == NULL ?
+                                EXdmDocument : EXdmPartialDocument ),         
+                                iDocumentSubset( aDocumentSubset )
+                                                      
+    {
+    }
+
+// ---------------------------------------------------------
+// CLocalAddition::NewL
+//
+// ---------------------------------------------------------
+//
+CLocalAddition* CLocalAddition::NewL( CLocalDocument& aParentDoc,
+                                      CLocalDocumentNode* aDocumentSubset,
+                                      CLocalOperationFactory& aOperationFactory )
+    {
+    CLocalAddition* self = new ( ELeave ) CLocalAddition( aParentDoc, aDocumentSubset, aOperationFactory );
+    CleanupStack::PushL( self );
+    self->BaseConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CLocalAddition::ExecuteL
+//
+// ---------------------------------------------------------
+//
+void CLocalAddition::ExecuteL()
+    {
+    TPtrC fileName = iTargetDoc.XmlFilePath();
+    TInt size = OpenDataFileL( fileName );
+    if( size > 0 )      //The document already exists
+        {
+        //Only a subset of a document
+        if( iTargetDoc.IsSubset() && iDocumentSubset != NULL )  
+            HandlePartialUpdateL( size );
+        else WriteFileL( iTargetDoc.DocumentRoot() );
+        }
+    else WriteFileL( iTargetDoc.DocumentRoot() );
+    iXmlFile.Close();
+    }
+
+// ---------------------------------------------------------
+// CLocalAddition::HandlePartialUpdateL
+//
+// ---------------------------------------------------------
+//
+void CLocalAddition::HandlePartialUpdateL( TInt aDataLength )
+    {
+    HBufC8* data = FetchXmlDataL( aDataLength );
+    CleanupStack::PushL( data );
+    CLocalDocument* copy = iTargetDoc.TempCopyL();
+    CleanupStack::PushL( copy );
+    iXmlParser->ParseDocumentL( copy, *data );
+    RPointerArray<CXdmDocumentNode> results;
+    CleanupClosePushL( results );
+    RPointerArray<SXdmAttribute16> attributes;
+    CleanupClosePushL( attributes );
+    TInt attrCount = iDocumentSubset->AttributeCount();
+    if( attrCount > 0 )
+        {
+        SXdmAttribute16 attribute;
+        for( TInt i = 0;i < attrCount;i++ )
+            {
+            attribute.iName.Set( iDocumentSubset->Attribute( i )->NodeName() );
+            attribute.iValue.Set( iDocumentSubset->Attribute( i )->AttributeValue() );
+            }
+        User::LeaveIfError( attributes.Append( &attribute ) );
+        }
+    copy->Find( iDocumentSubset->NodeName(), results, attributes );
+    if( results.Count() == 1 )
+        {
+        iXmlFile.Close();
+        ReplaceDataFileL();
+        CLocalDocumentNode* node = ( CLocalDocumentNode* )results[0];
+        node->AppendLocalL( ( CLocalDocumentNode* )iDocumentSubset );
+        WriteFileL( copy->DocumentRoot() );
+        }
+    else User::Leave( KErrGeneral );
+    CleanupStack::PopAndDestroy( 4 );  //attributes, results, copy, data
+    }
+        
+// ---------------------------------------------------------
+// CLocalAddition::Destroy
+//
+// ---------------------------------------------------------
+//     
+void CLocalAddition::Destroy()
+    {
+    delete this;
+    } 
+
+// ---------------------------------------------------------
+// Destructor
+//
+// ---------------------------------------------------------
+//
+CLocalAddition::~CLocalAddition()
+    {
+    
+    }
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/src/LocalDeletion.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,170 @@
+/*
+* 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: CLocalDeletion
+*
+*/
+
+
+
+
+// INCLUDES
+#include "XdmXmlParser.h"
+#include "LocalProtocol.h"
+#include "LocalDocument.h"
+#include "LocalDeletion.h"
+#include "LocalDocumentNode.h"
+#include "LocalNodeAttribute.h"
+    
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CLocalDeletion::CLocalDeletion( CLocalDocument& aTargetDoc,
+                                CLocalDocumentNode* aDocumentSubset,
+                                CLocalOperationFactory& aOperationFactory ) :
+                                CLocalOperationBase( aTargetDoc, aOperationFactory ),
+                                iDocumentSubset( aDocumentSubset ),
+                                iOperationType( aDocumentSubset == NULL ?
+                                EXdmDocument : EXdmPartialDocument )                                                      
+    {
+    }
+
+// ---------------------------------------------------------
+// CLocalDeletion::NewL
+//
+// ---------------------------------------------------------
+//
+CLocalDeletion* CLocalDeletion::NewL( CLocalDocument& aParentDoc,
+                                      CLocalDocumentNode* aDocumentSubset,
+                                      CLocalOperationFactory& aOperationFactory )
+    {
+    CLocalDeletion* self = new ( ELeave ) CLocalDeletion( aParentDoc, aDocumentSubset, aOperationFactory );
+    CleanupStack::PushL( self );
+    self->BaseConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+      
+// ---------------------------------------------------------
+// CLocalDeletion::ExecuteL
+//
+// ---------------------------------------------------------
+//
+void CLocalDeletion::ExecuteL()
+    {
+    TPtrC fileName = iTargetDoc.XmlFilePath();
+    TInt size = OpenDataFileL( fileName );
+    if( size > 0 )    
+        {
+        //Only a subset of a document
+        if( iTargetDoc.IsSubset() )
+            HandlePartialDeletionL( size );
+        else if( iDocumentSubset != NULL )
+            {
+            iTargetDoc.RemoveData( ( CLocalDocumentNode* )iDocumentSubset );
+            iXmlFile.Close();
+            ReplaceDataFileL();
+            WriteFileL( iTargetDoc.DocumentRoot() );
+            }
+        else 
+            {
+            iXmlFile.Close();
+            DeleteDataFileL();  //Delete the whole document
+            }
+        }
+    else User::Leave( KErrNotFound );
+    iXmlFile.Close();
+    }
+
+// ---------------------------------------------------------
+// CLocalAddition::HandlePartialUpdateL
+//
+// ---------------------------------------------------------
+//
+void CLocalDeletion::HandlePartialDeletionL( TInt aDataLength )
+    {
+    TInt error = KErrNone;
+    HBufC8* data = FetchXmlDataL( aDataLength );
+    CleanupStack::PushL( data );
+    TRAP( error, iXmlParser->ParseDocumentL( &iTargetDoc, *data ) );
+    CXdmDocumentNode* parent = iDocumentSubset->Parent();
+    RPointerArray<CXdmDocumentNode> parentResults;
+    CleanupClosePushL( parentResults );
+    RPointerArray<SXdmAttribute16> parentAttributes;
+    CleanupClosePushL( parentAttributes );
+    RPointerArray<CXdmDocumentNode> nodeResults;
+    CleanupClosePushL( nodeResults );
+    RPointerArray<SXdmAttribute16> nodeAttributes;
+    CleanupClosePushL( nodeAttributes );
+    TInt pAttrCount = parent->AttributeCount();
+    TInt dAttrCount = iDocumentSubset->AttributeCount();
+    if( pAttrCount > 0 )
+        {
+        SXdmAttribute16 attribute;
+        for( TInt i = 0;i < pAttrCount;i++ )
+            {
+            attribute.iName.Set( parent->Attribute( i )->NodeName() );
+            attribute.iValue.Set( parent->Attribute( i )->AttributeValue() );
+            }
+        User::LeaveIfError( parentAttributes.Append( &attribute ) );
+        }
+    if( dAttrCount > 0 )
+        {
+        SXdmAttribute16 attribute;
+        for( TInt i = 0;i < dAttrCount;i++ )
+            {
+            attribute.iName.Set( iDocumentSubset->Attribute( i )->NodeName() );
+            attribute.iValue.Set( iDocumentSubset->Attribute( i )->AttributeValue() );
+            }
+        User::LeaveIfError( nodeAttributes.Append( &attribute ) );
+        }
+    iTargetDoc.Find( parent->NodeName(), parentResults, parentAttributes );
+    iTargetDoc.Find( iDocumentSubset->NodeName(), nodeResults, nodeAttributes );
+    if( parentResults.Count() == 1 && nodeResults.Count() == 1 )
+        {
+        iXmlFile.Close();
+        ReplaceDataFileL();
+        CLocalDocumentNode* p = ( CLocalDocumentNode* )parentResults[0];
+        CLocalDocumentNode* r = ( CLocalDocumentNode* )nodeResults[0];
+        p->RemoveLocalL( r );
+        WriteFileL( iTargetDoc.DocumentRoot() );
+        }
+    else User::Leave( KErrGeneral );
+    CleanupStack::PopAndDestroy( 5 );  //nodeAttributes, nodeResults,
+                                       //parentAttributes, parentResults, data
+    }
+        
+// ---------------------------------------------------------
+// Symbian OS default constructor may leave.
+//
+// ---------------------------------------------------------
+//     
+void CLocalDeletion::Destroy()
+    {
+    delete this;
+    }                       
+
+// ---------------------------------------------------------
+// Destructor
+//
+// ---------------------------------------------------------
+//
+CLocalDeletion::~CLocalDeletion()
+    {
+    
+    }
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/src/LocalOperationBase.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,263 @@
+/*
+* 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: CLocalOperationBase
+*
+*/
+
+
+
+
+
+// INCLUDES
+#include "XdmXmlParser.h"
+#include "LocalProtocol.h"
+#include "LocalDocument.h"
+#include "LocalOperationBase.h"
+
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CLocalOperationBase::CLocalOperationBase( const CLocalDocument& aTargetDoc,
+                                          CLocalOperationFactory& aOperationFactory ) :
+                                          iTargetDoc( CONST_CAST( CLocalDocument&, aTargetDoc ) ),
+                                          iOperationFactory( aOperationFactory ) 
+    {
+    }
+
+// ---------------------------------------------------------
+// Destructor
+//
+// ---------------------------------------------------------
+//
+CLocalOperationBase::~CLocalOperationBase()
+    {
+    iXmlFile.Close();
+    delete iXmlParser;
+    delete iFileManager;
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationBase::BaseConstructL
+//
+// ---------------------------------------------------------
+//
+void CLocalOperationBase::BaseConstructL()
+    {
+    iXmlParser = CXdmXmlParser::NewL();
+    iFileManager = CFileMan::NewL( CLocalProtocol::FileSession() );
+    }
+    
+// ---------------------------------------------------------
+// CLocalOperationBase::WriteFileL
+//
+// ---------------------------------------------------------
+//
+void CLocalOperationBase::WriteFileL( const CXdmDocumentNode* aRootNode )
+    {
+    __ASSERT_DEBUG( aRootNode != NULL, User::Panic( _L( "CLocalOperationBase" ), 1 ) );
+    HBufC8* data = iXmlParser->FormatToXmlLC( ETrue, &iTargetDoc, aRootNode );
+    User::LeaveIfError( iXmlFile.Write( data->Des() ) );
+    CleanupStack::PopAndDestroy();  //data
+    GenerateTimeStampL();
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationBase::GenerateTimeStampL
+//
+// ---------------------------------------------------------
+//
+void CLocalOperationBase::GenerateTimeStampL()
+    {
+    RFile timeStamp;
+    HBufC8* time = TimeLC();
+    HBufC* timeStampName = ConstructTimestampNameL();
+    CleanupStack::PushL( timeStampName );
+    User::LeaveIfError( timeStamp.Replace( CLocalProtocol::FileSession(), timeStampName->Des(), EFileWrite ) );
+    User::LeaveIfError( timeStamp.Write( time->Des() ) );
+    timeStamp.Close();
+    CleanupStack::PopAndDestroy( 2 );  //timeStampName, time
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationBase::ConstructTimestampNameL
+//
+// ---------------------------------------------------------
+//
+HBufC* CLocalOperationBase::ConstructTimestampNameL()
+    {
+    const TChar backSlash = 92;
+    const TChar idSeparator = 46;
+    TInt index = iFullPath.LocateReverse( backSlash );
+    TPtrC path = iFullPath.Left( index + 1 );
+    HBufC* fileName = HBufC::NewLC( iTargetDoc.Name().Length() + KTimeStampFileExt().Length() );
+    HBufC* fullPath = HBufC::NewLC( path.Length() + fileName->Des().MaxLength() );
+    TPtr ptr( fileName->Des() );
+    ptr.Copy( iTargetDoc.Name() );
+    index = ptr.LocateReverse( idSeparator );
+    TPtrC tmspName = index > 0 ? ptr.Left( index ) : ptr;
+    fullPath->Des().Copy( path );
+    fullPath->Des().Append( tmspName );
+    fullPath->Des().Append( KTimeStampFileExt );
+    CleanupStack::Pop();  //fullPath
+    CleanupStack::PopAndDestroy();  //fileName
+    return fullPath;
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationBase::Time
+//
+// ---------------------------------------------------------
+//
+HBufC8* CLocalOperationBase::TimeLC()
+    {
+    TTime time;
+    TBuf<KDateBufferMaxSize> dateBuffer;
+	time.HomeTime();
+    time.FormatL( dateBuffer, KDateFormat );
+    TBuf<KDateBufferMaxSize> timeBuffer;
+	time.HomeTime();
+	time.FormatL( timeBuffer, KTimeFormat );
+    TBuf<KDateTimeMaxSize> buffer;
+    buffer.SetLength( 0 );
+    buffer.Copy( dateBuffer );
+    buffer.Append( _L( " " ) );
+    buffer.Append( timeBuffer );
+    HBufC8* ret = HBufC8::NewLC( buffer.Length() );
+    ret->Des().Copy( buffer );
+    return ret;        
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationBase::FetchXmlDataL
+//
+// ---------------------------------------------------------
+//
+HBufC8* CLocalOperationBase::FetchXmlDataL( TInt aFileSize )
+    {
+    HBufC8* data = HBufC8::NewLC( aFileSize );
+    TPtr8 desc( data->Des() );
+    User::LeaveIfError( iXmlFile.Read( desc ) );
+    CleanupStack::Pop();  //data
+    return data;
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationBase::FetchXmlDataL
+//
+// ---------------------------------------------------------
+//
+TInt CLocalOperationBase::OpenDataFileL( const TDesC& aFilePath )
+    {
+    TInt length = 0;
+    iFullPath.Set( aFilePath );
+    TInt error = iXmlFile.Open( CLocalProtocol::FileSession(), iFullPath,
+                                EFileRead | EFileWrite | EFileShareExclusive );
+    if( error != KErrNone )
+        {
+        if( error == KErrPathNotFound )
+            User::LeaveIfError( CLocalProtocol::FileSession().MkDirAll( CLocalProtocol::RootFolder() ) );
+        error = iXmlFile.Create( CLocalProtocol::FileSession(), iFullPath,
+                                 EFileRead | EFileWrite | EFileShareExclusive );                                 
+        }
+    error = error == KErrNone ? iXmlFile.Size( length ) : KErrUnknown;
+    return error == KErrNone ? length : error;
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationBase::ReplaceDataFileL
+//
+// ---------------------------------------------------------
+//
+void CLocalOperationBase::ReplaceDataFileL()
+    {
+    User::LeaveIfError( iXmlFile.Replace( CLocalProtocol::FileSession(), iFullPath,
+                                          EFileRead | EFileWrite | EFileShareExclusive ) );
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationBase::DeleteDataFileL
+//
+// ---------------------------------------------------------
+//
+void CLocalOperationBase::DeleteDataFileL()
+    {
+    User::LeaveIfError( CLocalProtocol::FileSession().Delete( iFullPath ) );
+    HBufC* timeStampName = ConstructTimestampNameL();
+    CleanupStack::PushL( timeStampName );
+    User::LeaveIfError( CLocalProtocol::FileSession().Delete( timeStampName->Des() ) );
+    CleanupStack::PopAndDestroy();  //timeStampName
+    }      
+
+// ---------------------------------------------------------
+// CLocalOperationBase::ExecuteL
+//
+// ---------------------------------------------------------
+//
+void CLocalOperationBase::ExecuteL( TRequestStatus& /*aStatus*/, TUint /*aOptions*/ )
+    {
+    }
+        
+// ---------------------------------------------------------
+// CLocalOperationBase::CancelOperation
+//
+// ---------------------------------------------------------
+//
+void CLocalOperationBase::CancelOperation()
+    {
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationBase::CompletionData
+//
+// ---------------------------------------------------------
+//     
+const TXdmCompletionData& CLocalOperationBase::CompletionData() const
+    {
+    return iCompletionData;
+    }
+        
+// ---------------------------------------------------------
+// CLocalOperationBase::IsCompleted
+//
+// ---------------------------------------------------------
+//        
+TBool CLocalOperationBase::IsCompleted() const
+    {
+    return ETrue;
+    }
+        
+// ---------------------------------------------------------
+// CLocalOperationBase::TargetNode
+//
+// ---------------------------------------------------------
+//      
+CXdmDocumentNode* CLocalOperationBase::TargetNode() const
+    {
+    return NULL;
+    }                      
+
+// ---------------------------------------------------------
+// CLocalOperationBase::Result
+//
+// ---------------------------------------------------------
+//        
+TInt CLocalOperationBase::Result() const
+    {
+    return KErrNone;
+    }   
+     
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/src/LocalOperationFactory.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,186 @@
+/*
+* 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: CLocalOperationFactory
+*
+*/
+
+
+
+#include <ecom.h>
+#include <e32debug.h>
+#include <xdmlogwriter.h>
+#include <implementationproxy.h>
+#include "XdmOperation.h"
+#include "LocalRetrieval.h"
+#include "LocalAddition.h"
+#include "LocalReplacement.h"
+#include "LocalDeletion.h"
+#include "LocalProtocol.h"
+#include "LocalOperationFactory.h"
+
+// ---------------------------------------------------------
+// CLocalOperationFactory::CLocalOperationFactory
+// 
+// ---------------------------------------------------------
+//
+CLocalOperationFactory::CLocalOperationFactory()
+    {   
+    }
+    
+// ---------------------------------------------------------
+// CLocalOperationFactory::NewL
+// 
+// ---------------------------------------------------------
+//
+CLocalOperationFactory* CLocalOperationFactory::NewL()
+    {
+    CLocalOperationFactory* self = new ( ELeave ) CLocalOperationFactory();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationFactory::ConstructL
+// 
+// ---------------------------------------------------------
+//
+void CLocalOperationFactory::ConstructL()
+    {
+    #ifdef _DEBUG
+        iLogWriter = CXdmLogWriter::NewL( KLocalOpLogFile );
+        WriteToLog( _L8( "CLocalOperationFactory::ConstructL()" ) );
+    #endif
+    }
+            
+// ---------------------------------------------------------
+// CLocalOperationFactory::~CLocalOperationFactory
+// 
+// ---------------------------------------------------------
+//
+CLocalOperationFactory::~CLocalOperationFactory()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CLocalOperationFactory::~CLocalOperationFactory()" ) );
+    #endif
+    delete iLogWriter;
+    }
+    
+// ---------------------------------------------------------
+// CLocalOperationFactory::FetchL
+// 
+// ---------------------------------------------------------
+//	
+MXdmOperation* CLocalOperationFactory::FetchL( CXdmDocument& aTargetDocument,
+                                               CXdmDocumentNode* aTargetNode ) const
+    {
+    return CLocalRetrieval::NewL( ( CLocalDocument& )aTargetDocument,
+                                  ( CLocalDocumentNode* )aTargetNode,
+                                  const_cast<CLocalOperationFactory&>( *this ) );
+    }       
+
+// ---------------------------------------------------------
+// CLocalOperationFactory::InsertL
+// 
+// ---------------------------------------------------------
+//
+MXdmOperation* CLocalOperationFactory::InsertL( CXdmDocument& aTargetDocument,
+                                                CXdmDocumentNode* aTargetNode ) const
+    {
+    return CLocalAddition::NewL( ( CLocalDocument& )aTargetDocument,
+                                 ( CLocalDocumentNode* )aTargetNode,
+                                 const_cast<CLocalOperationFactory&>( *this ) );
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationFactory::ReplaceL
+// 
+// ---------------------------------------------------------
+//
+MXdmOperation* CLocalOperationFactory::ReplaceL( CXdmDocument& aOldDocument, 
+                                                 CXdmDocumentNode* aNewNode,
+                                                 CXdmDocumentNode* aOldNode  ) const
+    {
+    return CLocalReplacement::NewL( ( CLocalDocument& )aOldDocument,
+                                    ( CLocalDocumentNode* )aNewNode,
+                                    ( CLocalDocumentNode* )aOldNode,
+                                    const_cast<CLocalOperationFactory&>( *this ) );
+    }
+
+// ---------------------------------------------------------
+// CLocalOperationFactory::AppendL
+// 
+// ---------------------------------------------------------
+//
+MXdmOperation* CLocalOperationFactory::AppendL( CXdmDocument& aTargetDocument,
+                                                CXdmDocumentNode* aTargetNode ) const
+    { 
+    return CLocalAddition::NewL( ( CLocalDocument& )aTargetDocument,
+                                 ( CLocalDocumentNode* )aTargetNode,
+                                 const_cast<CLocalOperationFactory&>( *this ) );
+    }              
+
+// ---------------------------------------------------------
+// CLocalOperationFactory::PartialDeletionL
+// 
+// ---------------------------------------------------------
+//
+MXdmOperation* CLocalOperationFactory::DeletionL( CXdmDocument& aTargetDocument,
+                                                  CXdmDocumentNode* aTargetNode ) const
+    {
+    return CLocalDeletion::NewL( ( CLocalDocument& )aTargetDocument,
+                                 ( CLocalDocumentNode* )aTargetNode,
+                                 const_cast<CLocalOperationFactory&>( *this ) );
+    }              
+
+// ----------------------------------------------------------
+// CLocalOperationFactory::WriteToLog
+// 
+// ----------------------------------------------------------
+//
+void CLocalOperationFactory::WriteToLog( TRefByValue<const TDesC8> aFmt,... )                                 
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf8<KLogBufferMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    iLogWriter->WriteToLog( buf );
+    }
+        
+// ---------------------------------------------------------
+// Map the interface UIDs to implementation factory functions
+// 
+// ---------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] = 
+	{
+#ifdef __EABI__
+    IMPLEMENTATION_PROXY_ENTRY( KLocalOperationFactory,	CLocalOperationFactory::NewL )
+#else
+    { { KLocalOperationFactory }, CLocalOperationFactory::NewL }
+#endif
+    };
+
+// ---------------------------------------------------------
+// Return the implementation table & number of implementations
+// 
+// ---------------------------------------------------------
+//
+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/xdmprotocols/LocalProtocol/LocalOperations/src/LocalReplacement.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,173 @@
+/*
+* 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: CLocalReplacement
+*
+*/
+
+
+
+
+// INCLUDES
+#include <XdmDocumentNode.h>
+#include "XdmXmlParser.h"
+#include "LocalProtocol.h"
+#include "LocalDocument.h"
+#include "LocalReplacement.h"
+#include "LocalDocumentNode.h"
+#include "LocalNodeAttribute.h"
+    
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CLocalReplacement::CLocalReplacement( CLocalDocument& aTargetDoc,
+                                      CLocalDocumentNode* aOldNode,
+                                      CLocalDocumentNode* aNewNode,
+                                      CLocalOperationFactory& aOperationFactory ) :
+                                      CLocalOperationBase( aTargetDoc, aOperationFactory ),
+                                      iNewNode( ( CLocalDocumentNode* )aNewNode ),
+                                      iTargetNode( ( CLocalDocumentNode* )aOldNode ),
+                                      iOperationType( iTargetNode == NULL ?
+                                      EXdmDocument : EXdmPartialDocument )                                                
+    {
+    }
+
+// ---------------------------------------------------------
+// Two-phased constructor.
+//
+// ---------------------------------------------------------
+//
+CLocalReplacement* CLocalReplacement::NewL( CLocalDocument& aParentDoc,
+                                            CLocalDocumentNode* aOldNode,
+                                            CLocalDocumentNode* aNewNode,
+                                            CLocalOperationFactory& aOperationFactory )
+    {
+    CLocalReplacement* self = new ( ELeave ) CLocalReplacement( aParentDoc, aOldNode, aNewNode, aOperationFactory );
+    CleanupStack::PushL( self );
+    self->BaseConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+      
+// ---------------------------------------------------------
+// CLocalReplacement::ExecuteL
+//
+// ---------------------------------------------------------
+//
+void CLocalReplacement::ExecuteL()
+    {
+    TPtrC fileName = iTargetDoc.XmlFilePath();
+    TInt size = OpenDataFileL( fileName );
+    if( size > 0 ) 
+        {
+        //Only a subset of a document
+        if( iTargetDoc.IsSubset() )
+            HandlePartialReplacementL( size );
+        else if( iTargetNode != NULL )
+            {
+            CLocalDocumentNode* parent = ( CLocalDocumentNode* )iTargetNode->Parent();
+            parent->ReplaceLocalL( iNewNode, iTargetNode );
+            }
+        else
+            {
+            iXmlFile.Close();
+            ReplaceDataFileL();
+            WriteFileL( iTargetDoc.DocumentRoot() );
+            }
+        }
+    else WriteFileL( iTargetDoc.DocumentRoot() );
+    iXmlFile.Close();
+    }
+
+// ---------------------------------------------------------
+// CLocalReplacement::HandlePartialReplacementL
+//
+// ---------------------------------------------------------
+//
+void CLocalReplacement::HandlePartialReplacementL( TInt aDataLength )
+    {
+    TInt error = KErrNone;
+    HBufC8* data = FetchXmlDataL( aDataLength );
+    CleanupStack::PushL( data );
+    TRAP( error, iXmlParser->ParseDocumentL( &iTargetDoc, *data ) );
+    CXdmDocumentNode* parent = iTargetNode->Parent();
+    RPointerArray<CXdmDocumentNode> parentResults;
+    CleanupClosePushL( parentResults );
+    RPointerArray<SXdmAttribute16> parentAttributes;
+    CleanupClosePushL( parentAttributes );
+    RPointerArray<CXdmDocumentNode> targetResults;
+    CleanupClosePushL( targetResults );
+    RPointerArray<SXdmAttribute16> targetAttributes;
+    CleanupClosePushL( targetAttributes );
+    TInt pAttrCount = parent->AttributeCount();
+    TInt tAttrCount = iTargetNode->AttributeCount();
+    if( pAttrCount > 0 )
+        {
+        SXdmAttribute16 attribute;
+        for( TInt i = 0;i < pAttrCount;i++ )
+            {
+            attribute.iName.Set( parent->Attribute( i )->NodeName() );
+            attribute.iValue.Set( parent->Attribute( i )->AttributeValue() );
+            }
+        User::LeaveIfError( parentAttributes.Append( &attribute ) );
+        }
+    if( tAttrCount > 0 )
+        {
+        SXdmAttribute16 attribute;
+        for( TInt i = 0;i < tAttrCount;i++ )
+            {
+            attribute.iName.Set( iTargetNode->Attribute( i )->NodeName() );
+            attribute.iValue.Set( iTargetNode->Attribute( i )->AttributeValue() );
+            }
+        User::LeaveIfError( targetAttributes.Append( &attribute ) );
+        }
+    iTargetDoc.Find( parent->NodeName(), parentResults, parentAttributes );
+    iTargetDoc.Find( iTargetNode->NodeName(), targetResults, targetAttributes );
+    if( parentResults.Count() == 1 && targetResults.Count() == 1 )
+        {
+        iXmlFile.Close();
+        ReplaceDataFileL();
+        CLocalDocumentNode* node = ( CLocalDocumentNode* )parentResults[0];
+        CLocalDocumentNode* target = ( CLocalDocumentNode* )targetResults[0];
+        node->ReplaceLocalL( iNewNode, target );
+        WriteFileL( iTargetDoc.DocumentRoot() );
+        }
+    else User::Leave( KErrGeneral );
+    CleanupStack::PopAndDestroy( 5 );  //targetAttributes, targetResults,
+                                       //parentAttributes, parentResults, data
+    }
+                
+// ---------------------------------------------------------
+// Symbian OS default constructor may leave.
+//
+// ---------------------------------------------------------
+//     
+void CLocalReplacement::Destroy()
+    {
+    delete this;
+    }                       
+
+// ---------------------------------------------------------
+// Destructor
+//
+// ---------------------------------------------------------
+//
+CLocalReplacement::~CLocalReplacement()
+    {
+    
+    }
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/LocalOperations/src/LocalRetrieval.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,127 @@
+/*
+* 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: CLocalRetrieval
+*
+*/
+
+
+
+
+// INCLUDES
+#include "XdmXmlParser.h"
+#include "LocalProtocol.h"
+#include "LocalDocument.h"
+#include "LocalRetrieval.h"
+#include "LocalDocumentNode.h"
+#include "LocalOperationFactory.h"
+    
+// ---------------------------------------------------------
+// CLocalRetrieval::CLocalRetrieval
+//
+// ---------------------------------------------------------
+//
+CLocalRetrieval::CLocalRetrieval( CLocalDocument& aTargetDoc,
+                                  CLocalDocumentNode* aDocumentSubset,
+                                  CLocalOperationFactory& aOperationFactory ) :
+                                  CLocalOperationBase( aTargetDoc, aOperationFactory ),
+                                  iDocumentSubset( aDocumentSubset ),
+                                  iOperationType( aDocumentSubset == NULL ?
+                                  EXdmDocument : EXdmPartialDocument )
+                                                      
+    {
+    }
+
+// ---------------------------------------------------------
+// CLocalRetrieval::NewL
+//
+// ---------------------------------------------------------
+//
+CLocalRetrieval* CLocalRetrieval::NewL( CLocalDocument& aParentDoc,
+                                        CLocalDocumentNode* aDocumentSubset,
+                                        CLocalOperationFactory& aOperationFactory )
+    {
+    CLocalRetrieval* self = new ( ELeave ) CLocalRetrieval( aParentDoc, aDocumentSubset, aOperationFactory );
+    CleanupStack::PushL( self );
+    self->BaseConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+      
+// ---------------------------------------------------------
+// CLocalRetrieval::ExecuteL
+//
+// ---------------------------------------------------------
+//
+void CLocalRetrieval::ExecuteL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CLocalRetrieval::ExecuteL()" ) );
+    #endif
+    HBufC8* data = NULL;
+    TInt error = KErrNone;
+    TInt length = OpenDataFileL( iTargetDoc.XmlFilePath() );
+    TRAP( error, data = FetchXmlDataL( length ) );
+    CleanupStack::PushL( data );
+    if( data != NULL )
+        {
+        if( iDocumentSubset == NULL )
+            {
+            TRAP( error, iXmlParser->ParseDocumentL( &iTargetDoc, *data ) );
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Document fetch complete - Error: %d" ), error );
+            #endif
+            }
+        else
+            {
+            iDocumentSubset->SetEmptyNode( ETrue );
+            iDocumentSubset->SetEmptyNode( EFalse );
+            TRAP( error, iXmlParser->ParseDocumentL( &iTargetDoc, *data, ( CXdmDocumentNode* )iDocumentSubset ) );
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Document fetch complete: %d" ), error );
+            #endif
+            }
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( " Reading of the document data failed: %d" ), error );
+        #endif
+        User::Leave( error );
+        }
+    CleanupStack::PopAndDestroy();  //data
+    iXmlFile.Close();
+    }
+            
+// ---------------------------------------------------------
+// CLocalRetrieval::Destroy
+//
+// ---------------------------------------------------------
+//     
+void CLocalRetrieval::Destroy()
+    {
+    delete this;
+    }  
+                         
+// ---------------------------------------------------------
+// CLocalRetrieval::~CLocalRetrieval
+//
+// ---------------------------------------------------------
+//
+CLocalRetrieval::~CLocalRetrieval()
+    {
+    
+    }
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/bwinscw/LocalProtocolU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,18 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+	??1CLocalDocumentNode@@UAE@XZ @ 2 NONAME ; CLocalDocumentNode::~CLocalDocumentNode(void)
+	??1CXdmNamespace@@UAE@XZ @ 3 NONAME ; CXdmNamespace::~CXdmNamespace(void)
+	?AppendLocalL@CLocalDocumentNode@@QAEXPAVCXdmDocumentNode@@@Z @ 4 NONAME ; void CLocalDocumentNode::AppendLocalL(class CXdmDocumentNode *)
+	?FileSession@CLocalProtocol@@SAAAVRFs@@XZ @ 5 NONAME ; class RFs & CLocalProtocol::FileSession(void)
+	?IsSubset@CLocalDocument@@QBEHXZ @ 6 NONAME ; int CLocalDocument::IsSubset(void) const
+	?NewL@CXdmNamespace@@SAPAV1@ABVTDesC8@@0@Z @ 7 NONAME ; class CXdmNamespace * CXdmNamespace::NewL(class TDesC8 const &, class TDesC8 const &)
+	?Prefix@CXdmNamespace@@QBE?AVTPtrC8@@XZ @ 8 NONAME ; class TPtrC8 CXdmNamespace::Prefix(void) const
+	?RemoveData@CLocalDocument@@QAEXPAVCLocalDocumentNode@@@Z @ 9 NONAME ; void CLocalDocument::RemoveData(class CLocalDocumentNode *)
+	?RemoveLocalL@CLocalDocumentNode@@QAEXPAVCXdmDocumentNode@@@Z @ 10 NONAME ; void CLocalDocumentNode::RemoveLocalL(class CXdmDocumentNode *)
+	?ReplaceLocalL@CLocalDocumentNode@@QAEXPAVCXdmDocumentNode@@0@Z @ 11 NONAME ; void CLocalDocumentNode::ReplaceLocalL(class CXdmDocumentNode *, class CXdmDocumentNode *)
+	?ResetSubset@CLocalDocument@@UAEXXZ @ 12 NONAME ; void CLocalDocument::ResetSubset(void)
+	?RootFolder@CLocalProtocol@@SA?AVTPtrC16@@XZ @ 13 NONAME ; class TPtrC16 CLocalProtocol::RootFolder(void)
+	?TempCopyL@CLocalDocument@@QAEPAV1@XZ @ 14 NONAME ; class CLocalDocument * CLocalDocument::TempCopyL(void)
+	?Uri@CXdmNamespace@@QBE?AVTPtrC8@@XZ @ 15 NONAME ; class TPtrC8 CXdmNamespace::Uri(void) const
+	?XmlFilePath@CLocalDocument@@QBE?AVTPtrC16@@XZ @ 16 NONAME ; class TPtrC16 CLocalDocument::XmlFilePath(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/eabi/LocalProtocolU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,26 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+	_ZN13CXdmNamespace4NewLERK6TDesC8S2_ @ 2 NONAME
+	_ZN13CXdmNamespaceD0Ev @ 3 NONAME
+	_ZN13CXdmNamespaceD1Ev @ 4 NONAME
+	_ZN13CXdmNamespaceD2Ev @ 5 NONAME
+	_ZN14CLocalDocument10RemoveDataEP18CLocalDocumentNode @ 6 NONAME
+	_ZN14CLocalDocument11ResetSubsetEv @ 7 NONAME
+	_ZN14CLocalDocument9TempCopyLEv @ 8 NONAME
+	_ZN14CLocalProtocol10RootFolderEv @ 9 NONAME
+	_ZN14CLocalProtocol11FileSessionEv @ 10 NONAME
+	_ZN18CLocalDocumentNode12AppendLocalLEP16CXdmDocumentNode @ 11 NONAME
+	_ZN18CLocalDocumentNode12RemoveLocalLEP16CXdmDocumentNode @ 12 NONAME
+	_ZN18CLocalDocumentNode13ReplaceLocalLEP16CXdmDocumentNodeS1_ @ 13 NONAME
+	_ZN18CLocalDocumentNodeD0Ev @ 14 NONAME
+	_ZN18CLocalDocumentNodeD1Ev @ 15 NONAME
+	_ZN18CLocalDocumentNodeD2Ev @ 16 NONAME
+	_ZNK13CXdmNamespace3UriEv @ 17 NONAME
+	_ZNK13CXdmNamespace6PrefixEv @ 18 NONAME
+	_ZNK14CLocalDocument11XmlFilePathEv @ 19 NONAME
+	_ZNK14CLocalDocument8IsSubsetEv @ 20 NONAME
+	_ZTI14CLocalDocument @ 21 NONAME ; #<TI>#
+	_ZTI14CLocalProtocol @ 22 NONAME ; #<TI>#
+	_ZTV14CLocalDocument @ 23 NONAME ; #<VT>#
+	_ZTV14CLocalProtocol @ 24 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/group/LocalProtocol.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* 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: LocalProtocol.mmp
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                          localprotocol.dll
+UID                             0x10009D8D 0x10207458
+CAPABILITY                      CAP_ECOM_PLUGIN
+VENDORID                        VID_DEFAULT
+TARGETTYPE                      PLUGIN
+
+SOURCEPATH                      ../src
+
+START RESOURCE                  10207458.rss
+
+TARGET                          localprotocol.rsc
+
+END
+
+SOURCE                          LocalProtocol.cpp
+SOURCE                          LocalDocument.cpp
+SOURCE                          LocalDirectory.cpp
+SOURCE                          LocalDocumentNode.cpp
+SOURCE                          LocalNodeAttribute.cpp
+SOURCE                          LocalDirectoryEntry.cpp
+
+//Sources common to all protocols
+SOURCEPATH                      ../../src
+SOURCE                          XdmNamespace.cpp
+
+USERINCLUDE                     ../inc
+USERINCLUDE                     ../../inc
+USERINCLUDE                     ../../XdmXmlParser/inc
+
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE                   /epoc32/include/xml
+SYSTEMINCLUDE                   /epoc32/include/ecom
+SYSTEMINCLUDE                   ../../../inc
+
+LIBRARY                         hal.lib
+LIBRARY                         ecom.lib
+LIBRARY                         efsrv.lib
+LIBRARY                         euser.lib
+LIBRARY                         flogger.lib
+LIBRARY                         charconv.lib
+LIBRARY                         xdmengine.lib
+LIBRARY                         xdmxmlparser.lib
+
+#if defined( ARMCC )
+DEFFILE ../eabi/ 
+#elif defined ( WINSCW )
+deffile ../bwinscw/ 
+#elif defined (WINS )
+deffile ../bwins/ 
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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: LocalProtocol bld.inf
+*
+*/
+
+
+
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+LocalProtocol.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/inc/LocalDirectory.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,172 @@
+/*
+* 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: CLocalDirectory
+*
+*/
+
+
+
+
+#ifndef __LOCALDIRECTORY__
+#define __LOCALDIRECTORY__
+
+#include <e32base.h>
+#include "XdmDirectory.h"
+
+//CONSTANTS
+
+//FORWARD DECLARATIONS
+class CXdmDocument;
+class CLocalProtocol;
+class CLocalDirectoryEntry;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CLocalDirectory ) : public CXdmDirectory
+    {
+    public:
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CLocalDirectory* NewL( const TDesC& aFilePath,
+                                      CXdmEngine& aXdmEngine,
+                                      CLocalProtocol& aLocalProtocol );
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        //void CancelUpdate();
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CLocalDirectory();
+        
+    private:  //From CXdmDirectory
+        
+        /**
+        * Start updating the contents of this directory model
+        * @param TRequestStatus& Request status of the client
+        * @param TDirUpdatePhase Phase of the update
+        * @return void
+        */
+        void StartUpdateL();
+        
+        /**
+        * Cancel a directory update
+		* @return void 
+        */
+        void CancelUpdate();
+        
+        /**
+        * Save the client's request status and update status
+        * @param TDirUpdatePhase The update phase
+        * @param TRequestStatus The client's request status
+		* @return void 
+        */
+        void SaveRequestData( TDirUpdatePhase aUpdatePhase,
+                              TRequestStatus& aClientStatus );
+                                        
+        /**
+        * Return the root element of this document
+        */
+        TInt DocumentCount();
+        
+        /**
+        * Return the root element of this document
+        */
+        TPtrC Document( TInt aIndex ) const;
+
+        /**
+        * Returns the path to this directory
+        *
+		* @return TPtrC8 The path to the directory this object models 
+        */
+        TPtrC DirectoryPath() const;
+        
+        /**
+        * Returns the path to this directory
+        *
+		* @return TPtrC8 The path to the directory this object models 
+        */
+        TXdmDocType DocumentTypeL( TInt aIndex ) const;
+        
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CLocalDirectory( CXdmEngine& aXdmEngine,
+                         CLocalProtocol& aLocalProtocol );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL();
+        
+        /**
+        * From CActive.
+        * @return void
+        */
+		void RunL();
+
+        /**
+        * From CActive.
+        * @return void
+        */
+		void DoCancel();
+        
+        /**
+        * From CXdmDirectory.
+        * @return void
+        */       
+        void FindTimeStampFilesL( const CDir* aDirectory );
+        
+        /**
+        * From CXdmDirectory.
+        * @return void
+        */       
+        void MatchWithStampFilesL( const CDir* aDirectory );
+        
+        /**
+        * From CXdmDirectory.
+        * @return void
+        */    
+        TInt OfferEntryL( const TDesC& aEntryName );
+        
+        /**
+        * From CXdmDirectory.
+        * @return void
+        */
+        void RefreshEntryArrayL();
+        
+    private:  //Data
+        
+        TRequestStatus*                             iClientStatus;
+        TDirUpdatePhase                             iUpdatePhase;
+        CLocalProtocol&                             iLocalProtocol;
+        RPointerArray<CLocalDirectoryEntry>         iEntryArray;
+    };
+
+#endif      //__LOCALDIRECTORY__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/inc/LocalDirectoryEntry.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,81 @@
+/*
+* 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: CLocalDirectoryEntry
+*
+*/
+
+
+
+
+#ifndef __LOCALDIRECTORYENTRY__
+#define __LOCALDIRECTORYENTRY__
+
+#include <e32base.h>
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CLocalDirectoryEntry ) : public CBase
+    {
+    public:
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CLocalDirectoryEntry* NewL( const TDesC& aFileName );
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        TPtrC EntryName() const;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        TBool OfferEntryL( const TDesC& aEntryName );
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CLocalDirectoryEntry();
+        
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CLocalDirectoryEntry();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL( const TDesC& aFilePath );
+        
+    private:  //Data
+        
+        HBufC*                      iXmlEntryName;
+        HBufC*                      iTimeStampEntryName;
+    };
+
+#endif      //__LOCALDIRECTORYENTRY__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/inc/LocalDocument.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,336 @@
+/*
+* 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: CLocalDocument
+*
+*/
+
+
+
+
+#ifndef __LOCALDOCUMENT__
+#define __LOCALDOCUMENT__
+
+#include <e32base.h>
+#include "XdmDocument.h"
+
+_LIT( KTimeStampFileExt,                           ".tmsp");
+_LIT( KDateFormat,                                 "%1-%2-%3");
+_LIT( KTimeFormat,                                 "%H:%T:%S");
+const TInt KDateTimeMaxSize                        = 200;
+const TInt KDateBufferMaxSize                      = 50;
+
+//FORWARD DECLARATIONS
+class CXdmNamespace;
+class MXdmOperation;
+class CLocalProtocol;
+class CLocalDocumentNode;
+class CXdmOperationFactory;
+
+//CLASS DECLARATION
+class CLocalDocument : public CXdmDocument
+    {
+    public:
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CLocalDocument* NewL( CXdmEngine& aXdmEngine,
+                                     const TDesC& aDocumentName,
+                                     CLocalProtocol& aLocalProtocol );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        //static CLocalDocument* NewL( const TDesC8& aDocumentName );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void StartInternalL( TRequestStatus& aStatus );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void CancelUpdate(); 
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CLocalDocument();
+    
+    public:  //Exported methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C CLocalDocument* TempCopyL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C TPtrC XmlFilePath() const;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C TBool IsSubset() const;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C virtual void ResetSubset();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C void RemoveData( CLocalDocumentNode* aDocumentNode );
+    
+    public:   //From CXdmDocument
+    
+        /**
+        * Return the root element of this document
+        *
+        * @return CXdmDocumentNode The root element of the document
+        *
+        * NOTE: The returning node may or may not contain any data,
+        *       since, in the case that this document model does not
+        *       have content yet, the element is a simple "entry point"
+        *       to the whole document. Thus, for instance, if the client
+        *       application requests the Xdm Engine to fetch a particular
+        *       document, the root element points to nothing until the 
+        *       request has been completed.
+        *         
+        */
+        CXdmDocumentNode* DocumentRoot() const;
+        
+    private:  //From CXdmDocument
+        
+        /**
+        * Construct an "anonymous" entry point for this document.
+        * This node effectively becomes the root of this document.
+        * 
+        */
+        CXdmDocumentNode* CreateRootL();
+        
+        /*
+        * Reset the contents of this document model.
+        */
+        void ResetContents();
+        
+        /**
+        * Return the time stamp for this document
+        *
+		* @return TTime 
+        */
+        TTime TimeStamp() const;
+        
+        /**
+        * Return an error document for a failed update
+        * 
+        * NOTE: Error document is not supported in this
+        *       protocol. The returning pointer will be NULL.
+        *
+		* @return CXdmDocument* The error document
+        */
+        CXdmDocumentNode* ErrorRoot();
+        
+        /**
+        * Append an element to the path identifying the 
+        * the current document subset
+        * @return void
+        */
+        void AppendPathPartL( const TDesC& aString );
+        
+        /**
+        * Return the current document subset (including descendants)
+        * @return void
+        */
+        CXdmDocumentNode* CurrentExtent() const;
+        
+        /**
+        * Construct an "anonymous" entry point for this document.
+        * This node effectively becomes the root of this document.
+        */
+        TXdmDocType DocumentType() const;
+        
+    private:  //From MXdmNamespaceContainer
+    
+        /**
+        * Return the number of namespace declarations
+        * @return TInt Namespace declaration count
+        */
+        TInt Count() const;
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        void AppendNamespaceL( const TDesC8& aUri, const TDesC8& aPrefix );
+        
+        /**
+        * Remove a namespace from the document
+        * @param TDesC8& URI of the namespace
+        * @param TDesC8& Prefix of the namespace
+        */
+        void RemoveNamespace( const TDesC8& aUri );
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        TPtrC8 Uri( const TDesC8& aPrefix ) const;
+        
+        /**
+        * Fetch the aIndex-th URI
+        * @param TInt The index of the desired URI string
+        * @return TPtrC URI string
+        */
+        TPtrC8 Uri( TInt aIndex ) const;
+        
+        /**
+        * Fetch the aIndex-th prefix
+        * @param TDesC8 The index of the desired prefix string
+        * @return TPtrC Prefix string
+        */
+        TPtrC8 Prefix( TInt aIndex ) const;
+    
+        /**
+        * Resets namespaces from the document
+        */
+        void ResetNamespaces( );
+    
+    private:
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CLocalDocument( CXdmEngine& aXdmEngine,
+                        CLocalProtocol& aLocalProtocol );
+        
+        /**
+        * From CActive.
+        * @return void
+        */
+		void RunL();
+
+        /**
+        * From CActive.
+        * @return void
+        */
+		void DoCancel();
+		
+		/**
+        * From CActive.
+        * @return void
+        */
+		void FinaliseOperation( TInt aIndex );
+		
+		/**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void StartUpdateL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void SaveClientStatus( TRequestStatus& aStatus );           
+        
+        /**
+        * _DEBUG
+        */
+        void DumpResponseBodyL( const TDesC8& aResponseBody ) const;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL( const TDesC8& aDocumentName );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void FetchTimeStampL();
+        
+    private:  //Data
+        
+        enum TLocalOperation
+            {
+            EFetch = 0,
+            EReplace,
+            EInsert,
+            EFetchPartial,
+            EInsertPartial,
+            EReplacePartial,
+            };
+            
+        enum TLocalDocumentState
+            {
+            EXdmDocIdle = 0,
+            EXdmDocUpdating,
+            EResolvingAsyncConflict,
+            };
+        
+        TInt                                    iDataLength;
+        TInt                                    iUpdateIndex;
+        TInt                                    iOperationCount;                                  
+        TInt                                    iOperationError;
+        TTime                                   iLastAccess;
+        TTime                                   iLastModification;
+        TBool                                   iWholeDoc;
+        HBufC*                                  iFullPath;
+        HBufC*                                  iDocSubsetPath;
+        TLocalOperation                         iOperationType;
+        CLocalProtocol&                         iLocalProtocol;
+        CLocalDocumentNode*                     iDocumentRoot;
+        TLocalDocumentState                     iDocumentState;
+        RPointerArray<CXdmNamespace>            iNamespaces;
+    };
+
+#endif      //__XCAPDOCUMENT__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/inc/LocalDocumentNode.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,242 @@
+/*
+* 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: CLocalDocumentNode
+*
+*/
+
+
+
+
+#ifndef __LOCALDOCUMENTNODE__
+#define __LOCALDOCUMENTNODE__
+
+#include "XdmNodeFactory.h"
+#include "XdmDocumentNode.h"
+
+class CLocalProtocol;
+class CXdmNodeAttribute;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CLocalDocumentNode ) : public CXdmDocumentNode,
+                                          public MXdmNodeFactory
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CLocalDocumentNode();
+
+    public: // New functions
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param TDesC8& Name of the new element 
+		* @return CXdmDocumentNode* 
+        */
+        static CLocalDocumentNode* NewL( CXdmEngine& aXdmEngine,
+                                         CLocalProtocol& aLocalProtocol );
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param TDesC8& Name of the new element 
+		* @return CXdmDocumentNode* 
+        */
+        static CLocalDocumentNode* NewL( CXdmEngine& aXdmEngine,
+                                         const TDesC& aNodeName,
+                                         CLocalProtocol& aLocalProtocol );
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param TDesC8& Name of the new element 
+		* @return CXdmDocumentNode* 
+        */
+        static CLocalDocumentNode* NewL( CXdmEngine& aXdmEngine,
+                                         CLocalProtocol& aLocalProtocol,
+                                         const CXdmDocumentNode& aAnotherNode,
+                                         const CXdmDocumentNode& aParentNode );
+        
+        /**
+        * Two-phased constructor.
+		*
+        * @param TDesC8& Name of the new element
+        * @param CXdmDocumentNode* The parent of the new node
+		* @return CXdmDocumentNode* 
+        */
+        static CLocalDocumentNode* NewL( CXdmEngine& aXdmEngine,
+                                         const TDesC& aNodeName,
+                                         CXdmDocumentNode* aParentNode,
+                                         CLocalProtocol& aLocalProtocol );
+
+        /**
+        * Two-phased constructor.
+		*
+        * @param TBool Leaf node indicator
+        * @param TDesC8& Name of the new element
+        * @param CXdmDocumentNode* The parent of the new node
+		* @return CXdmDocumentNode* 
+        */
+        static CLocalDocumentNode* NewL( const TBool aLeafNode,
+                                         CXdmEngine& aXdmEngine,
+                                         const TDesC& aNodeName,
+                                         CXdmDocumentNode* aParentNode,
+                                         CLocalProtocol& aLocalProtocol );
+                                       
+        /**
+        * Two-phased constructor.
+		*
+        * @param TBool Leaf node indicator
+        * @param TDesC8& Name of the new element
+        * @param CXdmDocumentNode* The parent of the new node
+		* @return CXdmDocumentNode* 
+        */
+        static CLocalDocumentNode* NewL( const TBool aLeafNode,
+                                         CXdmEngine& aXdmEngine,
+                                         CXdmDocumentNode* aParentNode,
+                                         CLocalProtocol& aLocalProtocol );
+        
+        /**
+        * Set the next node in the list
+        * @param The next node in the list
+		* @return void 
+        */
+        void SetParentNode( CLocalDocumentNode*& aParentNode );
+        
+    public:
+    
+        /**
+        * Set the next node in the list
+        * @param The next node in the list
+		* @return void 
+        */
+        IMPORT_C void RemoveLocalL( CXdmDocumentNode* aChileNode );
+        
+        /**
+        * Set the next node in the list
+        * @param The next node in the list
+		* @return void 
+        */
+        IMPORT_C void AppendLocalL( CXdmDocumentNode* aChileNode );
+        
+        /**
+        * Set the next node in the list
+        * @param The next node in the list
+		* @return void 
+        */
+        IMPORT_C void ReplaceLocalL( CXdmDocumentNode* aNewNode,
+                                     CXdmDocumentNode* aTargetNode );
+        
+    private:
+
+        /**
+        * C++ constructor, private version.
+        */
+        CLocalDocumentNode( CXdmEngine& aXdmEngine,
+                            CLocalProtocol& aLocalProtocol );
+
+        /**
+        * C++ constructor, protected version.
+        *
+        * @param CXdmDocumentNode* The parent node of this element
+        */
+		CLocalDocumentNode( CXdmEngine& aXdmEngine,
+		                    CXdmDocumentNode* aParentNode,
+		                    CLocalProtocol& aLocalProtocol );
+		
+        /**
+        * C++ constructor, another private version.
+        */
+		CLocalDocumentNode( const TBool aLeafNode,
+		                    CXdmEngine& aXdmEngine,
+		                    CXdmDocumentNode* aParentNode,
+		                    CLocalProtocol& aLocalProtocol );
+        
+        /**
+        * By default Symbian OS constructor is private.
+        *
+        * @param TDesC8& Name of this node
+        * @return void
+        */
+		virtual void CopyConstructL( const CXdmDocumentNode& aAnotherNode,
+                                     const CXdmDocumentNode& aParentNode );
+         
+    private:  //From MXdmNodeFactory
+                     
+        /**
+        * Create a new child element
+        *
+        * @param TDesC8& Name of the new element
+		* @return CXdmDocumentNode* 
+        */
+        CXdmDocumentNode* ChileNodeL();
+        
+        /**
+        * Create a new child element
+        *
+        * @param TDesC8& Name of the new element
+		* @return CXdmDocumentNode* 
+        */
+        CXdmDocumentNode* ChileNodeL( const TDesC& aChildName );
+        
+        /**
+        * Create a new child element
+        *
+        * @param TDesC8& Name of the new element
+		* @return CXdmDocumentNode* 
+        */
+        CXdmDocumentNode* ChileNodeL( const CXdmDocumentNode* aAnotherNode );
+        
+        /**
+        * Create a new attribute
+        *
+        * @param TDesC8& Name of the new attribute
+		* @return CXdmNodeAttribute* 
+        */
+        CXdmNodeAttribute* AttributeL();
+        
+        /**
+        * Create a new attribute
+        *
+        * @param TDesC8& Name of the new attribute
+		* @return CXdmNodeAttribute* 
+        */
+        CXdmNodeAttribute* AttributeL( const TDesC& aAttributeName );
+        
+    private:  //From MXdmNodeInterface                          
+                           
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        TPtrC8 Prefix() const;
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        void SetPrefixL( const TDesC8& aNamespacePrefix );
+        
+    private:
+        
+        HBufC8*                                      iPrefix;
+        CLocalProtocol&                              iLocalProtocol;
+        CLocalDocumentNode*                          iNextNode;
+    };
+
+#endif      //__LOCALDOCUMENTNODE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/inc/LocalNodeAttribute.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,130 @@
+/*
+* 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: CLocalNodeAttribute
+*
+*/
+
+
+
+
+#ifndef __LOCALNODEATTRIBUTE__
+#define __LOCALNODEATTRIBUTE__
+
+#include "XdmNodeAttribute.h"
+
+class CLocalProtocol;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CLocalNodeAttribute ) : public CXdmNodeAttribute
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param TDesC8& Name of this attribute
+        * @param CXdmDocumentNode* Parent of this attribute
+        * 
+        * NOTE! "Parent", in this case, denotes the 
+        *        element this attribute attributes.
+        *
+		* @return CXdmNodeAttribute* 
+        */
+        static CLocalNodeAttribute* NewL( CXdmEngine& aXdmEngine,
+                                          const TDesC& aAttributeName,
+                                          CXdmDocumentNode* aParentNode,
+                                          CLocalProtocol& aLocalProtocol );
+                                        
+        /**
+        * Two-phased constructor.
+        *
+        * @param CXdmDocumentNode* Parent of this attribute
+        * 
+        * NOTE! "Parent", in this case, denotes the 
+        *        element this attribute attributes.
+        *
+		* @return CXdmNodeAttribute* 
+        */
+        static CLocalNodeAttribute* NewL( CXdmEngine& aXdmEngine,
+                                          CXdmDocumentNode* aParentNode,
+                                          CLocalProtocol& aLocalProtocol );                                        
+
+        /**
+        * Destructor.
+        */
+        virtual ~CLocalNodeAttribute();
+
+    public: // New functions
+    
+        
+                                               
+    private:
+
+        /**
+        * C++ constructor, private version.
+        */
+        CLocalNodeAttribute( CXdmEngine& aXdmEngine,
+                             CLocalProtocol& aLocalProtocol );
+
+        /**
+        * C++ constructor, protected version.
+        *
+        * @param CXdmDocumentNode* The parent node of this element
+        */
+		CLocalNodeAttribute( CXdmEngine& aXdmEngine,
+                             CXdmDocumentNode* aParentNode,
+                             CLocalProtocol& aLocalProtocol );
+        
+        /**
+        * By default Symbian OS constructor is private.
+        *
+        * @param TDesC8& Name of this node
+        * @return void
+        */
+		void ConstructL( const TDesC& aNodeName );
+        
+        /**
+        * C++ constructor, another private version.
+        */
+		CLocalNodeAttribute( const TBool aLeafNode,
+                             CXdmDocumentNode* aParentNode );
+                             
+    private: //From MXdmNodeInterface
+         
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        TPtrC8 Prefix() const;
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        void SetPrefixL( const TDesC& aNamespacePrefix );
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        void SetPrefixL( const TDesC8& aNamespacePrefix );
+        
+    private:
+        
+        CLocalProtocol&                    iLocalProtocol;
+    };
+
+#endif      //__LOCALNODEATTRIBUTE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/inc/LocalProtocol.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: CLocalProtocol
+*
+*/
+
+
+
+
+#ifndef __LOCALPROTOCOL__
+#define __LOCALPROTOCOL__
+
+#include <e32base.h>
+#include "XdmEngine.h"
+#include "XdmProtocol.h"
+#include "XdmShutdownSwitch.h"
+
+//CONSTANTS
+_LIT( KLocalEngLogFile,                          "LocalProtocol" );
+_LIT( KLocalEngPrivateRoot,                      "C:\\private\\" );
+const TInt KLocalEngLogBufferMaxSize		    = 2000;
+
+//FORWARD DECLARATIONS
+class CXdmXmlParser;
+class CXdmLogWriter;
+class CXdmOperationFactory;
+
+//CLASS DECLARATION
+class CLocalProtocol : public CXdmProtocol
+    {
+    
+    public:
+        
+        /**
+        * Fetch the capabilities for this protocol. May require
+        * network operations.
+        */
+        IMPORT_C static RFs& FileSession(); 
+        
+                
+        /**
+        * A Global logging function
+        * @param TRefByValue<const TDesC8> aFmt,...
+        * @return void
+        */ 
+        IMPORT_C static TPtrC RootFolder();
+        
+    private:  //From CXdmProtocol
+   
+        /**
+        * Initialise the media used to transfer Xdm data
+        */
+        void InitTransferMedium( TInt aIdleTimeout,
+                                 TRequestStatus& aStatus  );
+        
+        /**
+        * Cancel initialisation of the transfer media.
+        */
+        void CancelTransferMediumInit();
+        
+        /**
+        * Is the transfer medium ready
+        */
+        TBool IsTransferAvailable() const;
+        
+        /**
+        * Create a new document node.
+        */
+        CXdmDocumentNode* CreateDocumentNodeL();
+        
+        /**
+        * Create a new protocol dependent document model
+        */
+        CXdmDocument* CreateDocumentL( const TDesC& aDocumentName,
+                                       const TXdmDocType aDocumentType );
+        
+        /**
+        * Create a new protocol dependent document model
+        */
+        CXdmDirectory* CreateDirectoryL( const TDesC& aDirectoryPath );
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CLocalProtocol();
+
+    public:  //Static
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CLocalProtocol* NewL( const TXdmProtocolParams& aProtocolInfo );
+        
+        /**
+        * A Global logging function
+        * @param TRefByValue<const TDesC8> aFmt,...
+        * @return void
+        */ 
+        RFs& RFSession();
+        
+        /**
+        * A Global logging function
+        * @param TRefByValue<const TDesC8> aFmt,...
+        * @return void
+        */ 
+        TPtrC Root();
+        
+    public:
+    
+        /**
+        * A logging function
+        * @param TRefByValue<const TDesC8> aFmt,...
+        * @return void
+        */ 
+        void WriteToLog( TRefByValue<const TDesC8> aFmt,... ) const;
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CLocalProtocol( const CXdmEngine& aXdmEngine,
+                        const CXdmProtocolInfo& aProtocolInfo );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void SetRootDirectoryL( const TDesC& aRootPath );
+    
+    private:
+    
+        /**
+        * From MXdmShutdownSwitch
+        * @return void
+        */ 
+        //void SwitchOff();
+
+    private:  //Data
+        
+        RFs                                      iFileSession;
+        TBool                                    iTransferMediaOpen;
+        HBufC*                                   iRootFolder;
+        CXdmEngine&                              iXdmEngine;
+        CXdmLogWriter*                           iLogWriter;
+        CXdmXmlParser*                           iXmlParser;
+        const CXdmProtocolInfo&                  iProtocolInfo;
+    };
+
+#endif      //__LOCALPROTOCOL__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/src/10207458.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: XdmLocalProtocolInfo
+*
+*/
+
+
+// 10207458.RSS
+//
+#include "registryinfo.rh"
+
+//Declares the interface implementations provided
+RESOURCE REGISTRY_INFO XdmLocalProtocolInfo
+    {
+    dll_uid = 0x10207458;
+    interfaces = 
+        {
+        INTERFACE_INFO
+            {
+            interface_uid = 0x10207422;
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    implementation_uid = 0x10207424;
+                    version_no = 1;
+                    display_name = "XDM Engine Local Protocol||Copyright © 2005 Nokia Ltd. All rights reserved.";
+                    default_data = "";
+                    opaque_data = "";
+                    }
+                };
+            }
+        };
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/src/LocalDirectory.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,308 @@
+/*
+* 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: CLocalDirectory
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <utf.h>
+#include <f32file.h>
+#include "LocalProtocol.h"
+#include "LocalDocument.h"
+#include "LocalDirectory.h"
+#include "XdmDocumentNode.h"
+#include "XdmNodeAttribute.h"
+#include "LocalDirectoryEntry.h"
+
+
+// ----------------------------------------------------------
+// CLocalDirectory::CLocalDirectory
+// 
+// ----------------------------------------------------------
+//
+CLocalDirectory::CLocalDirectory( CXdmEngine& aXdmEngine,
+                                  CLocalProtocol& aLocalProtocol ) : 
+                                  CXdmDirectory( aXdmEngine ),
+                                  iLocalProtocol( aLocalProtocol )                                              
+    { 
+    }
+
+// ----------------------------------------------------------
+// CLocalDirectory::NewL
+// 
+// ----------------------------------------------------------
+//
+CLocalDirectory* CLocalDirectory::NewL( const TDesC& aFilePath,
+                                        CXdmEngine& aXdmEngine,
+                                        CLocalProtocol& aLocalProtocol )
+    {
+    CLocalDirectory* self = new ( ELeave ) CLocalDirectory( aXdmEngine, aLocalProtocol );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aFilePath );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------
+// CLocalDirectory::~CLocalDirectory
+// 
+// ----------------------------------------------------
+//
+CLocalDirectory::~CLocalDirectory()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDirectory::~CLocalDirectory()" ) );
+    #endif
+    Cancel();
+    iEntryArray.ResetAndDestroy();
+    iEntryArray.Close();
+    }
+    
+// ----------------------------------------------------------
+// CLocalDirectory::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CLocalDirectory::ConstructL()
+    {
+    RefreshEntryArrayL();
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------
+// CLocalDirectory::RefreshEntryArrayL
+// 
+// ----------------------------------------------------------
+//
+void CLocalDirectory::RefreshEntryArrayL()
+    {
+    CDir* directory = NULL;
+    iEntryArray.ResetAndDestroy();
+    TPtrC path = iDirectoryPath->Des();
+    RFs& session = CLocalProtocol::FileSession();
+    User::LeaveIfError( session.GetDir( path, KEntryAttNormal, ESortByExt, directory ) );
+    CleanupStack::PushL( directory );
+    TInt count = directory->Count();
+    FindTimeStampFilesL( directory );
+    MatchWithStampFilesL( directory );
+    CleanupStack::PopAndDestroy();  //directory
+    }
+
+// ----------------------------------------------------------
+// CLocalDirectory::FindTimeStampFilesL
+// 
+// ----------------------------------------------------------
+//
+void CLocalDirectory::FindTimeStampFilesL( const CDir* aDirectory )
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDirectory::FindTimeStampFilesL()" ) );
+    #endif
+    TBool ready = EFalse;
+    TInt count = aDirectory->Count();
+    for( TInt i = 0;!ready && i < count;i++ )
+        {
+        TPtrC name = ( *aDirectory )[i].iName;
+        TInt index = name.Find( KTimeStampFileExt );
+        if( index > 0 )
+            {
+            TInt stampIndex = i;
+            CLocalDirectoryEntry* entry = NULL;
+            while( !ready )
+                {
+                entry = CLocalDirectoryEntry::NewL( name );
+                CleanupStack::PushL( entry );
+                User::LeaveIfError( iEntryArray.Append( entry ) );
+                CleanupStack::Pop();  //entry
+                stampIndex++;
+                if( stampIndex < count )
+                    {
+                    name.Set( ( *aDirectory )[stampIndex].iName );
+                    index = name.Find( KTimeStampFileExt );
+                    if( index <= 0 )
+                        ready = ETrue;
+                    }
+                else ready = ETrue;
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------
+// CLocalDirectory::MatchWithStampFilesL
+// 
+// ----------------------------------------------------------
+//
+void CLocalDirectory::MatchWithStampFilesL( const CDir* aDirectory )
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDirectory::MatchWithStampFilesL()" ) );
+    #endif
+    TInt count = aDirectory->Count();
+    for( TInt i = 0;i < count;i++ )
+        {
+        TPtrC name = ( *aDirectory )[i].iName;
+        TInt index = name.Find( KTimeStampFileExt );
+        if( index > 0 )
+            continue;
+        else 
+            {
+            TBool ready = EFalse;
+            TInt count = iEntryArray.Count();
+            for( TInt i = 0;!ready && i < count;i++ )
+                ready = iEntryArray[i]->OfferEntryL( name );
+            }
+        }
+    }
+
+// ----------------------------------------------------------
+// CLocalDirectory::DocumentCount
+// 
+// ----------------------------------------------------------
+//
+TInt CLocalDirectory::DocumentCount()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDirectory::DocumentCount()" ) );
+    #endif
+    RefreshEntryArrayL();
+    return iEntryArray.Count();
+    }
+
+// ----------------------------------------------------
+// CLocalDocument::DocumentTypeL
+// 
+// ----------------------------------------------------
+//
+TXdmDocType CLocalDirectory::DocumentTypeL( TInt /*aIndex*/ ) const
+    {
+    return EXdmDocGeneral;
+    }
+       
+// ----------------------------------------------------------
+// CLocalDirectory::Document
+// 
+// ----------------------------------------------------------
+//
+TPtrC CLocalDirectory::Document( TInt aIndex ) const
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDirectory::Document()" ) );
+    #endif
+    return aIndex < 0 || aIndex > iEntryArray.Count() ? TPtrC() :
+           iEntryArray[aIndex]->EntryName();
+    }
+
+// ----------------------------------------------------------
+// CLocalDirectory::ConstructL
+// 
+// ----------------------------------------------------------
+//
+TPtrC CLocalDirectory::DirectoryPath() const
+    {
+    return iDirectoryPath != NULL ? iDirectoryPath->Des() : TPtrC();
+    }
+
+// ----------------------------------------------------------
+// CXcapDirectory::SaveRequestData
+// 
+// ----------------------------------------------------------
+//
+void CLocalDirectory::SaveRequestData( TDirUpdatePhase aUpdatePhase,
+                                       TRequestStatus& aClientStatus )
+    {
+    iUpdatePhase = aUpdatePhase;
+    iClientStatus = &aClientStatus;
+    }
+               
+// ----------------------------------------------------------
+// CLocalDirectory::StartUpdateL
+// 
+// ----------------------------------------------------------
+//
+void CLocalDirectory::StartUpdateL()
+    
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDirectory::StartUpdateL()" ) );
+    #endif
+    switch( iUpdatePhase )
+        {
+        case EUpdateDocumentList:
+            RefreshEntryArrayL();
+            User::RequestComplete( iClientStatus, KErrNone );
+            break;
+        case ERefreshDocuments:
+            User::RequestComplete( iClientStatus, KErrNone );
+        default:
+            break;
+        } 
+    }
+
+// ---------------------------------------------------------
+// CLocalDirectory::RunL()
+// 
+// ---------------------------------------------------------
+//
+void CLocalDirectory::RunL()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDirectory::RunL() - Request: %d" ), iStatus.Int() );
+    #endif
+    }
+
+// ----------------------------------------------------
+// CLocalDirectory::CancelUpdate
+// 
+// ----------------------------------------------------
+//
+void CLocalDirectory::CancelUpdate()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDirectory::CancelUpdate()" ) );
+    #endif
+    Cancel();
+    }
+    
+// ---------------------------------------------------------
+// CLocalDirectory::DoCancel
+// 
+// ---------------------------------------------------------
+//
+void CLocalDirectory::DoCancel()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDirectory::DoCancel()" ) );
+    #endif
+    switch( iUpdatePhase )
+        {
+        case EDirPhaseIdle:
+            break;
+        case EUpdateDocumentList:
+            break;
+        case ERefreshDocuments:
+            break;
+        default:
+            break;
+        }
+    User::RequestComplete( iClientStatus, KErrCancel );
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/src/LocalDirectoryEntry.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -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: CLocalDirectoryEntry
+*
+*/
+
+
+
+
+#include "LocalProtocol.h"
+#include "LocalDocument.h"
+#include "LocalDirectoryEntry.h"
+
+// ----------------------------------------------------
+// CLocalDirectoryEntry::CLocalDirectoryEntry
+// 
+// ----------------------------------------------------
+//
+CLocalDirectoryEntry::CLocalDirectoryEntry()
+    {
+    }
+
+// ----------------------------------------------------
+// CLocalDirectoryEntry::CLocalDirectoryEntry
+// 
+// ----------------------------------------------------
+//
+CLocalDirectoryEntry* CLocalDirectoryEntry::NewL( const TDesC& aFileName )
+    {
+    CLocalDirectoryEntry* self = new ( ELeave ) CLocalDirectoryEntry();
+    CleanupStack::PushL( self );
+    self->ConstructL( aFileName );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------
+// CLocalDirectoryEntry::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CLocalDirectoryEntry::ConstructL( const TDesC& aFileName )
+    {
+    TChar comma = 46;
+    TInt index = aFileName.LocateReverse( comma );
+    TPtrC temp = aFileName.Left( index );
+    iTimeStampEntryName = HBufC::NewL( temp.Length() );
+    iTimeStampEntryName->Des().Copy( temp );
+    }
+
+// ----------------------------------------------------
+// CLocalDirectoryEntry::EntryName
+// 
+// ----------------------------------------------------
+//   
+TPtrC CLocalDirectoryEntry::EntryName() const
+    {
+    return iXmlEntryName != NULL ? iXmlEntryName->Des() : TPtrC();
+    }
+
+// ----------------------------------------------------
+// CLocalDirectoryEntry::CLocalDirectoryEntry
+// 
+// ----------------------------------------------------
+//       
+TBool CLocalDirectoryEntry::OfferEntryL( const TDesC& aEntryName )
+    {
+    TChar comma = 46;
+    TInt index = aEntryName.LocateReverse( comma );
+    TPtrC name( index > 0 ? aEntryName.Left( index ) : aEntryName );
+    if( iTimeStampEntryName->Des().Compare( name ) == 0 )
+        {
+        iXmlEntryName = HBufC::NewL( aEntryName.Length() );
+        iXmlEntryName->Des().Copy( aEntryName );
+        return ETrue;
+        }
+    else return EFalse;
+    }
+
+// ----------------------------------------------------
+// CLocalDirectoryEntry::CLocalDirectoryEntry
+// 
+// ----------------------------------------------------
+//
+CLocalDirectoryEntry::~CLocalDirectoryEntry()
+    {
+    delete iXmlEntryName;
+    delete iTimeStampEntryName;
+    }
+             
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/src/LocalDocument.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,525 @@
+/*
+* 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: CLocalDocument
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include "XdmProtocol.h"
+#include "XdmNamespace.h"
+#include "XdmOperation.h"
+#include "XdmXmlParser.h"
+#include "LocalProtocol.h"
+#include "LocalDocument.h"
+#include "LocalDocumentNode.h"
+#include "XdmOperationFactory.h"
+
+// ----------------------------------------------------
+// CLocalDocument::CLocalDocument
+// 
+// ----------------------------------------------------
+//
+CLocalDocument::CLocalDocument( CXdmEngine& aXdmEngine,
+                                CLocalProtocol& aLocalProtocol ) :
+                                CXdmDocument( aXdmEngine ),
+                                iLocalProtocol( aLocalProtocol )
+    {
+    }
+
+
+// ----------------------------------------------------------
+// CLocalDocument::NewL
+// 
+// ----------------------------------------------------------
+//
+CLocalDocument* CLocalDocument::NewL( CXdmEngine& aXdmEngine,
+                                      const TDesC& aDocumentName,
+                                      CLocalProtocol& aLocalProtocol )
+    {   
+    CLocalDocument* self = new ( ELeave ) CLocalDocument( aXdmEngine, aLocalProtocol );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( KLocalOperationFactory, aDocumentName );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+    
+// ----------------------------------------------------------
+// CLocalDocument::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CLocalDocument::ConstructL()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::ConstructL()" ) );
+    #endif
+    TPtrC name = iDocumentName->Des();
+    TPtrC root = iLocalProtocol.RootFolder();
+    iFullPath = HBufC::NewL( name.Length() + root.Length() );
+    iFullPath->Des().Copy( root );
+    iFullPath->Des().Append( name );
+    FetchTimeStampL();
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------
+// CLocalDocument::ResetContents
+// 
+// ----------------------------------------------------------
+//
+void CLocalDocument::ResetContents()
+    {
+    delete iDocumentRoot;
+    iDocumentRoot = NULL;
+    iNamespaces.ResetAndDestroy();
+    }
+
+// ----------------------------------------------------------
+// CLocalDocument::FetchTimeStampL
+// 
+// ----------------------------------------------------------
+//
+void CLocalDocument::FetchTimeStampL()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::FetchTimeStampL()" ) );
+    #endif
+    RFile timeStamp;
+    TBuf8<KDateTimeMaxSize> buf;
+    TBuf<KDateTimeMaxSize> buf16;
+    const TChar idSeparator = 46;
+    TPtrC fullPath( iFullPath->Des() );
+    HBufC* path = HBufC::NewLC( fullPath.Length() + KTimeStampFileExt().Length() );
+    TInt index = fullPath.LocateReverse( idSeparator );
+    TPtrC tmspName( index > 0 ? fullPath.Left( index ) : fullPath );
+    path->Des().Copy( tmspName );
+    path->Des().Append( KTimeStampFileExt );
+    TInt error = timeStamp.Open( CLocalProtocol::FileSession(), path->Des(), EFileRead );
+    if( error == KErrNone )
+        {
+        CleanupClosePushL( timeStamp );
+        User::LeaveIfError( timeStamp.Read( buf ) );
+        buf16.Copy( buf );
+        buf.Zero();
+        User::LeaveIfError( iLastModification.Parse( buf16 ) );
+        CleanupStack::PopAndDestroy();  //timeStamp
+        }
+    CleanupStack::PopAndDestroy();  //path
+    }
+// ----------------------------------------------------
+// CLocalDocument::~CLocalDocument
+// 
+// ----------------------------------------------------
+//
+CLocalDocument::~CLocalDocument()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::~CLocalDocument()" ) );
+    #endif
+    Cancel();
+    delete iFullPath;
+    delete iDocumentRoot;
+    iNamespaces.ResetAndDestroy();
+    }
+
+// ----------------------------------------------------
+// CLocalDocument::CreateRootL
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CLocalDocument::CreateRootL()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::DocumentSubsetL()" ) );
+    #endif
+    iDocumentRoot = CLocalDocumentNode::NewL( iXdmEngine, iLocalProtocol );
+    return iDocumentRoot;
+    }
+
+// ----------------------------------------------------
+// CLocalDocument::TempCopyL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CLocalDocument* CLocalDocument::TempCopyL()
+    {
+    return CLocalDocument::NewL( iXdmEngine, Name(), iLocalProtocol );
+    }
+        
+// ----------------------------------------------------
+// CLocalDocument::DocumentRoot
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CLocalDocument::DocumentRoot() const
+    {
+    return iDocumentRoot;
+    }    
+
+// ----------------------------------------------------
+// CLocalDocument::ErrorRoot
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CLocalDocument::ErrorRoot()
+    {
+    return NULL;
+    }
+
+// ----------------------------------------------------
+// CLocalDocument::ErrorRoot
+// 
+// ----------------------------------------------------
+//
+TXdmDocType CLocalDocument::DocumentType() const
+    {
+    return EXdmDocGeneral;
+    }
+              
+// ----------------------------------------------------
+// CLocalDocument::IsSubset
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TBool CLocalDocument::IsSubset() const
+    {
+    return iDocSubset; 
+    }
+
+// ----------------------------------------------------
+// CLocalDocument::ResetSubset
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CLocalDocument::ResetSubset()
+    {
+    CXdmDocument::ResetSubset();
+    delete iDocumentRoot;
+    iDocumentRoot = NULL;
+    }
+
+// ----------------------------------------------------
+// CLocalDocument::XmlFilePath
+// 
+// ------------------------------ ----------------------
+//
+EXPORT_C TPtrC CLocalDocument::XmlFilePath() const
+    {
+    return iFullPath != NULL ? iFullPath->Des() : TPtrC();
+    }
+    
+// ----------------------------------------------------
+// CLocalDocument::RemoveData
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CLocalDocument::RemoveData( CLocalDocumentNode* /*aDocumentNode*/ )
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::RemoveData()" ) );
+    #endif
+    
+    }
+           
+// ----------------------------------------------------
+// CLocalDocument::StartUpdateL
+// 
+// ----------------------------------------------------
+//
+void CLocalDocument::StartUpdateL()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::StartUpdateL()" ) );
+    #endif
+    TBool keepGoing = ETrue;
+    TInt completion = KErrNone;
+    TInt count = iChangeRequests.Count();
+    for( TInt i = 0;keepGoing && i < count;i++ )
+        {
+        //"First in, first served"
+        TRAPD( error, iChangeRequests[0]->ExecuteL() );
+        if( error == KErrNone )
+            {
+            #ifdef _DEBUG
+                iLocalProtocol.WriteToLog( _L8( " Execution of the operation no. %d was successful" ), i );
+            #endif
+            }
+        else
+            {
+            #ifdef _DEBUG
+                iLocalProtocol.WriteToLog( _L8( " Execution of the operation no. %d failed with %d" ), i, error );
+            #endif
+            completion = error;
+            keepGoing = EFalse;
+            }
+        FinaliseOperation( 0 );
+        }
+    User::RequestComplete( iClientStatus, completion );
+    }
+
+// ----------------------------------------------------
+// CLocalProtocol::AppendPathPartL
+// 
+// ----------------------------------------------------
+//
+void CLocalDocument::AppendPathPartL( const TDesC& aString )
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::PathPartL()" ) );
+    #endif
+    if( iDocumentRoot != NULL )
+        {
+        CXdmDocumentNode* node = NULL;
+        CXdmDocumentNode* parent = iDocumentRoot;
+        while( parent->NextNode() != NULL )
+            parent = parent->NextNode();
+        node = CLocalDocumentNode::NewL( iXdmEngine, aString, parent, iLocalProtocol );
+        parent->SetNextNode( node );
+        }
+    else
+        iDocumentRoot = CLocalDocumentNode::NewL( iXdmEngine, aString, iLocalProtocol );
+    }
+
+// ----------------------------------------------------
+// CLocalProtocol::CurrentExtent
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CLocalDocument::CurrentExtent() const
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::CurrentExtent()" ) );
+    #endif
+    CXdmDocumentNode* ret = NULL;
+    if( iDocumentRoot != NULL )
+        {
+        CXdmDocumentNode* node = iDocumentRoot;
+        while( node->NextNode() != NULL )
+            node = node->NextNode();
+        ret = node;
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iLocalProtocol.WriteToLog( _L8( " This document does not yet have a root, leave with KErrGeneral" ) );
+        #endif
+        User::Leave( KErrGeneral );
+        }
+    return ret;
+    }
+    
+// ----------------------------------------------------
+// CLocalDocument::StartUpdateL
+// 
+// ----------------------------------------------------
+//
+void CLocalDocument::StartInternalL( TRequestStatus& aStatus )
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::StartInternalL()" ) );
+    #endif
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    StartUpdateL();
+    }
+    
+// ----------------------------------------------------
+// CLocalDocument::CancelUpdate
+// 
+// ----------------------------------------------------
+//
+void CLocalDocument::CancelUpdate()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::CancelUpdate()" ) );
+    #endif
+    User::RequestComplete( iClientStatus, KErrCancel );
+    }
+
+// ---------------------------------------------------------
+// CLocalDocument::RunL()
+// 
+// ---------------------------------------------------------
+//
+void CLocalDocument::RunL()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::RunL()" ) );
+    #endif
+    }
+
+// ----------------------------------------------------
+// CLocalDocument::FinaliseOperation
+// 
+// ----------------------------------------------------
+//
+void CLocalDocument::FinaliseOperation( TInt aIndex )
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::FinaliseOperation()" ) );
+    #endif
+    TInt count = iChangeRequests.Count();
+    if( count > 0 && ( aIndex >= 0 && aIndex < count ) )
+        {
+        MXdmOperation* operation = NULL;
+        operation = iChangeRequests[aIndex];
+        iChangeRequests.Remove( aIndex );
+        operation->Destroy();
+        operation = NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// CLocalDocument::AppendNamespaceL
+// 
+// ---------------------------------------------------------
+//
+void CLocalDocument::AppendNamespaceL( const TDesC8& aUri, const TDesC8& aPrefix )
+    {
+    CXdmNamespace* ns = CXdmNamespace::NewL( aUri, aPrefix );
+    CleanupStack::PushL( ns );
+    User::LeaveIfError( iNamespaces.Append( ns ) );
+    CleanupStack::Pop();  //ns
+    }
+
+// ---------------------------------------------------------
+// CXcapDocument::RemoveNamespace
+// 
+// ---------------------------------------------------------
+//
+void CLocalDocument::RemoveNamespace( const TDesC8& aUri )
+    {
+    TBool found = EFalse;
+    CXdmNamespace* ns = NULL;
+    TInt count = iNamespaces.Count();
+    for( TInt i = 0;!found && i < count;i++ )
+        {
+        ns = iNamespaces[i];
+        if( ns->Uri().Compare( aUri ) == 0 )
+            {
+            found = ETrue;
+            iNamespaces.Remove( i );
+            delete ns;
+            ns = NULL;
+            }
+        }
+    }
+                
+// ---------------------------------------------------------
+// CLocalDocument::Uri
+// 
+// ---------------------------------------------------------
+//
+TPtrC8 CLocalDocument::Uri( const TDesC8& aPrefix ) const
+    {
+    TPtrC8 uri( _L8( "" ) );
+    TBool found = EFalse;
+    TInt count = iNamespaces.Count();
+    for( TInt i = 0;i < count && !found;i++ )
+        {
+        if( iNamespaces[i]->Prefix().Compare( aPrefix ) == 0 )
+            {
+            uri.Set( iNamespaces[i]->Uri() );
+            found = ETrue;
+            }
+        }
+    return uri;
+    }
+
+// ---------------------------------------------------------
+// CLocalDocument::Count
+// 
+// ---------------------------------------------------------
+//
+TInt CLocalDocument::Count() const
+    {
+    return iNamespaces.Count();
+    }
+
+// ---------------------------------------------------------
+// CLocalDocument::Prefix
+// 
+// ---------------------------------------------------------
+//
+TPtrC8 CLocalDocument::Prefix( TInt aIndex ) const
+    {
+    TInt count = iNamespaces.Count();
+    if( count > 0 && ( aIndex >= 0 && aIndex < count ) )
+        return iNamespaces[aIndex]->Prefix();
+    else return TPtrC8();
+    }
+    
+// ---------------------------------------------------------
+// CLocalDocument::Uri
+// 
+// ---------------------------------------------------------
+//
+TPtrC8 CLocalDocument::Uri( TInt aIndex ) const
+    {
+    TInt count = iNamespaces.Count();
+    if( count > 0 && ( aIndex >= 0 && aIndex < count ) )
+        return iNamespaces[aIndex]->Uri();
+    else return TPtrC8();
+    }
+    
+// ---------------------------------------------------------
+// CLocalDocument::ResetNamespaces
+// 
+// ---------------------------------------------------------
+//
+void CLocalDocument::ResetNamespaces( ) 
+    {   
+    iNamespaces.ResetAndDestroy();
+    }   
+    
+// ---------------------------------------------------------
+// CLocalDocument::TimeStamp
+// 
+// ---------------------------------------------------------
+//
+TTime CLocalDocument::TimeStamp() const
+    {
+    return iLastModification;
+    }
+
+// ---------------------------------------------------------
+// CLocalDocument::SaveClientStatus
+// 
+// ---------------------------------------------------------
+//   
+void CLocalDocument::SaveClientStatus( TRequestStatus& aStatus )
+    {
+    iClientStatus = &aStatus;
+    }
+    
+// ---------------------------------------------------------
+// CLocalDocument::DoCancel
+// 
+// ---------------------------------------------------------
+//
+void CLocalDocument::DoCancel()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocument::DoCancel()" ) );
+    #endif
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/src/LocalDocumentNode.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,331 @@
+/*
+* 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: CLocalDocumentNode
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XdmDocument.h"
+#include "LocalProtocol.h"
+#include "LocalDocumentNode.h"
+#include "LocalNodeAttribute.h"
+
+
+// ----------------------------------------------------------
+// CLocalDocumentNode::CLocalDocumentNode
+// 
+// ----------------------------------------------------------
+//
+CLocalDocumentNode::CLocalDocumentNode( CXdmEngine& aXdmEngine,
+                                        CLocalProtocol& aLocalProtocol ) :
+                                        CXdmDocumentNode( aXdmEngine, ( MXdmNodeFactory& )*this ),
+                                        iLocalProtocol( aLocalProtocol )            
+    {
+    }
+
+
+// ----------------------------------------------------------
+// CLocalDocumentNode::CLocalDocumentNode
+// 
+// ----------------------------------------------------------
+//
+CLocalDocumentNode::CLocalDocumentNode( CXdmEngine& aXdmEngine,
+                                        CXdmDocumentNode* aParentNode,
+                                        CLocalProtocol& aLocalProtocol ) :
+                                        CXdmDocumentNode( aXdmEngine,
+                                      ( MXdmNodeFactory& )*this, aParentNode ),
+                                        iLocalProtocol( aLocalProtocol )
+                                                
+    {   
+    }
+
+// ----------------------------------------------------------
+// CLocalDocumentNode::CLocalDocumentNode
+// 
+// ----------------------------------------------------------
+//
+CLocalDocumentNode::CLocalDocumentNode( const TBool aLeafNode,
+                                        CXdmEngine& aXdmEngine,
+                                        CXdmDocumentNode* aParentNode,
+                                        CLocalProtocol& aLocalProtocol ) :
+                                        CXdmDocumentNode( aLeafNode, aXdmEngine,
+                                      ( MXdmNodeFactory& )*this, aParentNode ),
+                                        iLocalProtocol( aLocalProtocol )
+    {
+    
+    }
+
+// ----------------------------------------------------------
+// CLocalDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CLocalDocumentNode* CLocalDocumentNode::NewL( CXdmEngine& aXdmEngine,
+                                              CLocalProtocol& aLocalProtocol )
+    {
+    return new ( ELeave ) CLocalDocumentNode( aXdmEngine, aLocalProtocol );
+    }
+
+// ----------------------------------------------------------
+// CLocalDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CLocalDocumentNode* CLocalDocumentNode::NewL( CXdmEngine& aXdmEngine,
+                                              const TDesC& aNodeName,
+                                              CLocalProtocol& aLocalProtocol )
+    {
+    CLocalDocumentNode* self = new ( ELeave ) CLocalDocumentNode( aXdmEngine, aLocalProtocol );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aNodeName );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CLocalDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CLocalDocumentNode* CLocalDocumentNode::NewL( CXdmEngine& aXdmEngine,
+                                              CLocalProtocol& aLocalProtocol,
+                                              const CXdmDocumentNode& aAnotherNode,
+                                              const CXdmDocumentNode& aParentNode )
+    {
+    CLocalDocumentNode* self = new ( ELeave ) CLocalDocumentNode( aXdmEngine, aLocalProtocol );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aAnotherNode.NodeName() );
+    self->CopyConstructL( aAnotherNode, aParentNode );
+    CleanupStack::Pop();
+    return self;
+    }
+    
+// ----------------------------------------------------------
+// CLocalDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CLocalDocumentNode* CLocalDocumentNode::NewL( CXdmEngine& aXdmEngine,
+                                              const TDesC& aNodeName,
+                                              CXdmDocumentNode* aParentNode,
+                                              CLocalProtocol& aLocalProtocol )
+    {
+    CLocalDocumentNode* self = new ( ELeave ) CLocalDocumentNode( aXdmEngine, aParentNode,
+                                                                  aLocalProtocol );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aNodeName );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CLocalDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CLocalDocumentNode* CLocalDocumentNode::NewL( const TBool aLeafNode,
+                                              CXdmEngine& aXdmEngine,
+                                              const TDesC& aNodeName,
+                                              CXdmDocumentNode* aParentNode,
+                                              CLocalProtocol& aLocalProtocol )
+    {
+    CLocalDocumentNode* self = new ( ELeave ) CLocalDocumentNode( aLeafNode, aXdmEngine,
+                                                                  aParentNode, aLocalProtocol );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aNodeName );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CLocalDocumentNode* CLocalDocumentNode::NewL( const TBool aLeafNode,
+                                              CXdmEngine& aXdmEngine,
+                                              CXdmDocumentNode* aParentNode,
+                                              CLocalProtocol& aLocalProtocol )
+    {
+    return new ( ELeave ) CLocalDocumentNode( aLeafNode, aXdmEngine,
+                                              aParentNode, aLocalProtocol );
+    }
+
+// ----------------------------------------------------------
+// CLocalDocumentNode::CopyConstructL
+// 
+// ----------------------------------------------------------
+//
+void CLocalDocumentNode::CopyConstructL(  const CXdmDocumentNode& aAnotherNode,
+                                          const CXdmDocumentNode& aParentNode  )
+    {
+    CXdmDocumentNode::CopyConstructL( aAnotherNode, aParentNode );
+    //TODO: Write the protocol specific copy operations
+    }
+    
+// ----------------------------------------------------
+// CLocalDocumentNode::~CLocalDocumentNode
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CLocalDocumentNode::~CLocalDocumentNode()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::~CLocalDocumentNode(): %x" ), this );
+    #endif
+    delete iPrefix;
+    delete iNextNode;
+    }
+
+// ----------------------------------------------------
+// CLocalDocumentNode::RemoveLocalL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CLocalDocumentNode::RemoveLocalL( CXdmDocumentNode* aChileNode )
+    {
+    RemoveChileNodeL( aChileNode );
+    }
+  
+// ----------------------------------------------------
+// CLocalDocumentNode::AppendLocalL
+// 
+// ----------------------------------------------------
+//      
+EXPORT_C void CLocalDocumentNode::AppendLocalL( CXdmDocumentNode* aChileNode )
+    {
+    if( aChileNode->Match( *this ) )
+        {
+        const TInt count = aChileNode->NodeCount();
+        for( TInt i = 0;i < count;i++ )
+            AppendChileNodeL( aChileNode->ChileNode( i ) );
+        }
+    else AppendChileNodeL( aChileNode );
+    }
+
+// ----------------------------------------------------
+// CLocalDocumentNode::ReplaceLocalL
+// 
+// ----------------------------------------------------
+//      
+EXPORT_C void CLocalDocumentNode::ReplaceLocalL( CXdmDocumentNode* aNewNode,
+                                                 CXdmDocumentNode* aTargetNode )
+    {
+    ReplaceChileNodeL( aNewNode, aTargetNode );                                            
+    }
+                                            
+// ----------------------------------------------------
+// CLocalDocumentNode::CreateChileNodeL
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CLocalDocumentNode::ChileNodeL()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::CreateChileNodeL()" ) );
+    #endif
+    return CLocalDocumentNode::NewL( EFalse, iXdmEngine, this, iLocalProtocol );
+    }
+    
+// ----------------------------------------------------
+// CLocalDocumentNode::CreateChileNodeL
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CLocalDocumentNode::ChileNodeL( const TDesC& aChildName )
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::CreateChileNodeL() - Name: %S" ), &aChildName );
+    #endif
+    return CLocalDocumentNode::NewL( EFalse, iXdmEngine, aChildName, this, iLocalProtocol );
+    }
+
+// ----------------------------------------------------
+// CLocalDocumentNode::CreateChileNodeL
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CLocalDocumentNode::ChileNodeL( const CXdmDocumentNode* aAnotherNode )
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::ChileNodeL() - Object: %x" ), aAnotherNode );
+    #endif
+    return CLocalDocumentNode::NewL( iXdmEngine, iLocalProtocol, *aAnotherNode, *this );
+    }
+
+// ----------------------------------------------------
+// CLocalDocumentNode::CreateAttributeL
+// 
+// ----------------------------------------------------
+//
+CXdmNodeAttribute* CLocalDocumentNode::AttributeL()
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::CreateAttributeL()" ) );
+    #endif
+    return CLocalNodeAttribute::NewL( iXdmEngine, this, iLocalProtocol );
+    }
+    
+// ----------------------------------------------------
+// CLocalDocumentNode::CreateAttributeL
+// 
+// ----------------------------------------------------
+//
+CXdmNodeAttribute* CLocalDocumentNode::AttributeL( const TDesC& aAttributeName )
+    {
+    #ifdef _DEBUG
+        iLocalProtocol.WriteToLog( _L8( "CLocalDocumentNode::CreateAttributeL() - Name: %S" ), &aAttributeName );
+    #endif
+    return CLocalNodeAttribute::NewL( iXdmEngine, aAttributeName, this, iLocalProtocol );
+    }
+
+// ----------------------------------------------------------
+// CLocalDocumentNode::SetParentNode
+// 
+// ----------------------------------------------------------
+//
+void CLocalDocumentNode::SetParentNode( CLocalDocumentNode*& aParentNode )
+    {
+    iParentNode = aParentNode;
+    }
+
+// ----------------------------------------------------------
+// CLocalDocumentNode::NamespacePrefix
+// 
+// ----------------------------------------------------------
+//
+TPtrC8 CLocalDocumentNode::Prefix() const
+    {
+    return iPrefix != NULL ? iPrefix->Des() : TPtrC8();
+    }
+        
+// ----------------------------------------------------------
+// CLocalDocumentNode::SetNamespacePrefixL
+// 
+// ----------------------------------------------------------
+//
+void CLocalDocumentNode::SetPrefixL( const TDesC8& aPrefix )
+    {
+    delete iPrefix;
+    iPrefix = NULL;
+    iPrefix = HBufC8::NewL( aPrefix.Length() );
+    iPrefix->Des().Copy( aPrefix );
+    }
+                       
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/src/LocalNodeAttribute.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,124 @@
+/*
+* 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: CLocalNodeAttribute
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "LocalProtocol.h"
+#include "LocalNodeAttribute.h"
+
+// ----------------------------------------------------------
+// CLocalNodeAttribute::CLocalNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+CLocalNodeAttribute::CLocalNodeAttribute( CXdmEngine& aXdmEngine,
+                                          CLocalProtocol& aLocalProtocol ) :
+                                          CXdmNodeAttribute( aXdmEngine,
+                                        ( MXdmNodeFactory& )*this ),
+                                          iLocalProtocol( aLocalProtocol )
+                                                
+    {   
+    }
+    
+// ----------------------------------------------------------
+// CLocalNodeAttribute::CLocalNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+CLocalNodeAttribute::CLocalNodeAttribute( CXdmEngine& aXdmEngine,
+                                          CXdmDocumentNode* aParentNode,
+                                          CLocalProtocol& aLocalProtocol ) :
+                                          CXdmNodeAttribute( aXdmEngine, 
+                                        ( MXdmNodeFactory& )*this, aParentNode ),
+                                          iLocalProtocol( aLocalProtocol )
+                                                
+    {   
+    }
+
+// ----------------------------------------------------------
+// CLocalNodeAttribute::CLocalNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+CLocalNodeAttribute* CLocalNodeAttribute::NewL( CXdmEngine& aXdmEngine,
+                                                const TDesC& aAttributeName,
+                                                CXdmDocumentNode* aParentNode,
+                                                CLocalProtocol& aLocalProtocol )
+    {
+    CLocalNodeAttribute* self = new ( ELeave ) CLocalNodeAttribute( aXdmEngine, aParentNode,aLocalProtocol );
+    CleanupStack::PushL( self );
+    self->CXdmNodeAttribute::BaseConstructL( aAttributeName );
+    CleanupStack::Pop();
+    return self;
+    }
+    
+// ----------------------------------------------------------
+// CLocalNodeAttribute::CLocalNodeAttribute
+// 
+// ----------------------------------------------------------
+//                                        
+CLocalNodeAttribute* CLocalNodeAttribute::NewL( CXdmEngine& aXdmEngine,
+                                                CXdmDocumentNode* aParentNode,
+                                                CLocalProtocol& aLocalProtocol )
+    {
+    CLocalNodeAttribute* self = new ( ELeave ) CLocalNodeAttribute( aXdmEngine, aParentNode, aLocalProtocol );
+    /*CleanupStack::PushL( self );
+    self->BaseConstructL();
+    CleanupStack::Pop();*/
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CLocalNodeAttribute::~CLocalNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+CLocalNodeAttribute::~CLocalNodeAttribute()
+    {
+    }
+
+// ----------------------------------------------------------
+// CLocalDocumentNode::NamespacePrefix
+// 
+// ----------------------------------------------------------
+//
+TPtrC8 CLocalNodeAttribute::Prefix() const
+    {
+    return TPtrC8();
+    }
+        
+// ----------------------------------------------------------
+// CLocalDocumentNode::SetNamespacePrefixL
+// 
+// ----------------------------------------------------------
+//
+void CLocalNodeAttribute::SetPrefixL( const TDesC& /*aNamespacePrefix*/ )
+    {
+    }
+        
+// ----------------------------------------------------------
+// CLocalDocumentNode::SetNamespacePrefixL
+// 
+// ----------------------------------------------------------
+//
+void CLocalNodeAttribute::SetPrefixL( const TDesC8& /*aNamespacePrefix*/ )
+    {
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/LocalProtocol/src/LocalProtocol.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,287 @@
+/*
+* 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: CLocalProtocol
+*
+*/
+
+
+
+#include <hal.h>
+#include <f32file.h>
+#include <xdmlogwriter.h>
+#include <implementationproxy.h>
+#include "XdmXmlParser.h"
+#include "LocalProtocol.h"
+#include "LocalDocument.h"
+#include "LocalDocumentNode.h"
+#include "LocalDirectory.h"
+#include "XdmCredentials.h"
+#include "XdmProtocolInfo.h"
+#include "XdmOperationFactory.h"
+
+// ----------------------------------------------------------
+// CLocalProtocol::CLocalProtocol
+// 
+// ----------------------------------------------------------
+//
+CLocalProtocol::CLocalProtocol( const CXdmEngine& aXdmEngine,
+                                const CXdmProtocolInfo& aProtocolInfo ) :
+                                iTransferMediaOpen( EFalse ),
+                                iXdmEngine( CONST_CAST( CXdmEngine&, aXdmEngine ) ),
+                                iProtocolInfo( aProtocolInfo )
+    {   
+    }
+    
+// ----------------------------------------------------------
+// CLocalProtocol::DeleteLogFileL
+// 
+// ----------------------------------------------------------
+//
+CLocalProtocol* CLocalProtocol::NewL( const TXdmProtocolParams& aProtocolParams )
+    {
+    CLocalProtocol* self = new ( ELeave ) CLocalProtocol( aProtocolParams.iXdmEngine,
+                                                          aProtocolParams.iProtocolInfo );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CLocalProtocol::DeleteLogFileL
+// 
+// ----------------------------------------------------------
+//
+CLocalProtocol::~CLocalProtocol()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CLocalProtocol::~CLocalProtocol()" ) );  
+    #endif
+    delete iRootFolder;
+    delete iXmlParser;
+    delete iLogWriter;
+    iFileSession.Close();
+    Dll::FreeTls();
+    }
+        
+// ----------------------------------------------------------
+// CLocalProtocol::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CLocalProtocol::ConstructL()
+    {
+    #ifdef _DEBUG
+        iLogWriter = CXdmLogWriter::NewL( KLocalEngLogFile );
+        WriteToLog( _L8( "CLocalProtocol::ConstructL() " ) );  
+    #endif
+    iXmlParser = CXdmXmlParser::NewL();
+    SetRootDirectoryL( iProtocolInfo.Root() ); 
+    User::LeaveIfError( iFileSession.Connect() );
+    Dll::SetTls( this );                                                                               
+    }
+
+// ----------------------------------------------------------
+// CLocalProtocol::SetRootDirectoryL
+// 
+// ----------------------------------------------------------
+//
+void CLocalProtocol::SetRootDirectoryL( const TDesC& aRootPath )
+    {
+    TUid id = RProcess().Identity();
+    TBuf<32> processId;
+    processId.Zero();
+    processId.Format( _L( "%x" ), id );
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CLocalProtocol::SetRootDirectoryL()" ) );  
+    #endif
+    if( aRootPath.Length() > 0 )
+        {
+        iRootFolder = HBufC::NewL( aRootPath.Length() +
+                                   processId.Length() + 
+                                   TPtrC( KLocalEngPrivateRoot ).Length() + 4 );
+        iRootFolder->Des().Copy( KLocalEngPrivateRoot );
+        iRootFolder->Des().Append( processId );
+        iRootFolder->Des().Append( _L( "\\" ) );
+        iRootFolder->Des().Append( aRootPath );
+        iRootFolder->Des().Append( _L( "\\" ) );
+        }
+    else
+        {
+        iRootFolder = HBufC::NewL( processId.Length() + 
+                                   KLocalEngPrivateRoot().Length() + 2 );
+        iRootFolder->Des().Copy( KLocalEngPrivateRoot );
+        iRootFolder->Des().Append( processId );
+        iRootFolder->Des().Append( _L( "\\" ) );
+        }
+    #ifdef _DEBUG
+        TBuf8<256> eight;
+        eight.Copy( iRootFolder->Des() );
+        WriteToLog( _L8( "  Path: %S" ), &eight );  
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CLocalProtocol::.WriteToLog
+// 
+// ----------------------------------------------------------
+//
+void CLocalProtocol::WriteToLog( TRefByValue<const TDesC8> aFmt,... ) const                                
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf8<KLogBufferMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    iLogWriter->WriteToLog( buf );
+    }
+    
+// ----------------------------------------------------
+// CLocalProtocol::InitTransferMedia
+// 
+// ----------------------------------------------------
+//
+void CLocalProtocol::InitTransferMedium( TInt /*aIdleTimeout*/,
+                                        TRequestStatus& aStatus )
+    {
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete( status, KErrNone );
+    }
+
+// ----------------------------------------------------
+// CLocalProtocol::CancelTransferMediaInit
+// 
+// ----------------------------------------------------
+//
+void CLocalProtocol::CancelTransferMediumInit()
+    {
+    }
+
+// ----------------------------------------------------
+// CLocalProtocol::IsTransferAvailable
+// 
+// ----------------------------------------------------
+//
+TBool CLocalProtocol::IsTransferAvailable() const
+    {
+    return ETrue;
+    }
+            
+// ----------------------------------------------------
+// CLocalProtocol::RFSession
+// 
+// ----------------------------------------------------
+//
+RFs& CLocalProtocol::RFSession()
+    {
+    return iFileSession;
+    }
+
+// ----------------------------------------------------
+// CLocalProtocol::Root
+// 
+// ----------------------------------------------------
+//
+TPtrC CLocalProtocol::Root()
+    {
+    return iRootFolder != NULL ? iRootFolder->Des() : TPtrC();
+    }
+    
+// ----------------------------------------------------------
+// void CXcapProtocol::DeleteLogFileL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C RFs& CLocalProtocol::FileSession()
+    {
+    TAny* ptr = Dll::Tls();
+    CLocalProtocol* self = ( CLocalProtocol* )ptr;
+    return self->RFSession();  
+    }
+    
+// ----------------------------------------------------
+// CLocalProtocol::RootFolder
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TPtrC CLocalProtocol::RootFolder()
+    {
+    TAny* ptr = Dll::Tls();
+    CLocalProtocol* self = ( CLocalProtocol* )ptr;
+    return self->Root();
+    }
+
+// ----------------------------------------------------
+// CLocalProtocol::CreateDocumentNodeL
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CLocalProtocol::CreateDocumentNodeL()
+    {
+    return CLocalDocumentNode::NewL( iXdmEngine, *this );
+    }
+    
+// ----------------------------------------------------
+// CLocalProtocol::CreateDocumentL
+// 
+// ----------------------------------------------------
+//
+CXdmDocument* CLocalProtocol::CreateDocumentL( const TDesC& aDocumentName,
+                                               const TXdmDocType /*aDocumentType*/ )
+    {
+    return CLocalDocument::NewL( iXdmEngine, aDocumentName, *this );
+    }
+
+// ----------------------------------------------------
+// CLocalProtocol::CreateDirectoryL
+//
+// ----------------------------------------------------
+//
+CXdmDirectory* CLocalProtocol::CreateDirectoryL( const TDesC& aDirectoryPath )
+    {
+    TPtrC root = iRootFolder->Des();
+    HBufC* fullName = HBufC::NewLC( root.Length() + aDirectoryPath.Length() );
+    fullName->Des().Copy( root );
+    fullName->Des().Append( aDirectoryPath );
+    CXdmDirectory* dir = CLocalDirectory::NewL( fullName->Des(), iXdmEngine, *this );
+    CleanupStack::PopAndDestroy();  //fullName
+    return dir;
+    }
+
+// ---------------------------------------------------------
+// Map the interface UIDs to implementation factory functions
+// 
+// ---------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] = 
+    {
+    #ifdef __EABI__
+        IMPLEMENTATION_PROXY_ENTRY( 0x10207424, CLocalProtocol::NewL )
+    #else
+        { { 0x10207424 }, CLocalProtocol::NewL }
+    #endif
+    };
+
+// ---------------------------------------------------------
+// Return the implementation table & number of implementations
+// 
+// ---------------------------------------------------------
+//
+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/xdmprotocols/XcapProtocol/XcapAppUsage/BWINSCW/XcapAppUsageU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,6 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+	?NewL@CXcapAppUsage@@QAEPAV1@ABVCXdmEngine@@H@Z @ 2 NONAME ; class CXcapAppUsage * CXcapAppUsage::NewL(class CXdmEngine const &, int)
+	?Validate@CXcapAppUsage@@QAEHAAVCXdmDocument@@H@Z @ 3 NONAME ; int CXcapAppUsage::Validate(class CXdmDocument &, int)
+	?Validate@CXcapAppUsage@@QAEHAAVCXdmDocumentNode@@PAVMXcapUriInterface@@H@Z @ 4 NONAME ; int CXcapAppUsage::Validate(class CXdmDocumentNode &, class MXcapUriInterface *, int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XCapCommonPolicyCapsUsage/inc/XcapIetfCommonPolicyUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,106 @@
+/*
+* 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:  CXcapIetfCommonPolicyUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPIETFCOMMONPOLICYUSAGE__
+#define __XCAPIETFCOMMONPOLICYUSAGE__
+
+#include "XcapAppUsage.h"
+
+
+// CLASS DECLARATION
+class CXcapIetfCommonPolicyUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapIetfCommonPolicyUsage*
+        */
+        static CXcapIetfCommonPolicyUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapIetfCommonPolicyUsage();
+        
+    public:  //From CXcapAppUsage
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;
+
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+        
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapIetfCommonPolicyUsage( const CXdmEngine& aXdmEngine );    
+        
+    private:    // Data
+    
+        
+    };
+
+#endif    //__XCAPIETFCOMMONPOLICYUSAGE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XCapCommonPolicyCapsUsage/inc/XcapOmaCommonPolicyUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  CXcapOmaCommonPolicyUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPOMACOMMONPOLICYUSAGE__
+#define __XCAPOMACOMMONPOLICYUSAGE__
+
+#include <e32base.h>
+#include "XcapAppUsage.h"
+
+
+// CLASS DECLARATION
+class CXcapOmaCommonPolicyUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapOmaCommonPolicyUsage*
+        */
+        static CXcapOmaCommonPolicyUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapOmaCommonPolicyUsage();
+        
+    public:  // From CXcapAppUsage
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;
+
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+                                
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */        
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapOmaCommonPolicyUsage( const CXdmEngine& aXdmEngine );    
+    };
+
+#endif    //__XCAPOMACOMMONPOLICYUSAGE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XCapCommonPolicyCapsUsage/src/XcapIetfCPUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,331 @@
+/*
+* 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:  CXcapIetfCommonPolicyUsage
+*
+*/
+
+
+
+
+#include <XdmErrors.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include "XcapIetfCommonPolicyUsage.h"
+
+// Used specifications
+// draft-ietf-geopriv-common-policy-08, 05 March 2006, expires 06 September 2006
+
+// ----------------------------------------------------
+// CXcapIetfCommonPolicyUsage::CXcapIetfCommonPolicyUsage
+// 
+// ----------------------------------------------------
+//
+CXcapIetfCommonPolicyUsage::CXcapIetfCommonPolicyUsage( const CXdmEngine& aXdmEngine ) 
+:CXcapAppUsage( aXdmEngine )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapIetfCommonPolicyUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapIetfCommonPolicyUsage* CXcapIetfCommonPolicyUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapIetfCommonPolicyUsage* self = new ( ELeave ) CXcapIetfCommonPolicyUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );	// << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapIetfCommonPolicyUsage::~CXcapIetfCommonPolicyUsage
+// 
+// ----------------------------------------------------
+//
+CXcapIetfCommonPolicyUsage::~CXcapIetfCommonPolicyUsage()
+    {
+    }
+        
+// ----------------------------------------------------
+// CXcapIetfCommonPolicyUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapIetfCommonPolicyUsage::ConstructL()
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapIetfCommonPolicyUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapIetfCommonPolicyUsage::AUID() const
+    {
+    return TPtrC8( KXdmIetfCommonPolicyUsageAUID );
+    }
+                
+// ----------------------------------------------------
+// CXcapIetfCommonPolicyUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapIetfCommonPolicyUsage::ContentType() const
+    {
+    return TPtrC8( KXdmIetfCommonPolicyUsageContType );
+    }
+
+// ----------------------------------------------------
+// CXcapIetfCommonPolicyUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapIetfCommonPolicyUsage::DefaultNamespace() const
+    {
+    return TPtrC8( KXdmIetfCommonPolicyNamespace );
+    }   
+    
+// ----------------------------------------------------
+// CXcapIetfCommonPolicyUsage::ValidateNodeL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapIetfCommonPolicyUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
+    {
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+    
+    TBool found ( EFalse );
+    TDataType dataType ( EDataTypeUndefined );
+    TPtrC element = aXdmNode.NodeName();
+            
+    // <ruleset> 
+    if ( Match( element, KXdmRuleset ) )
+        {
+        TInt count( aXdmNode.NodeCount() );
+        for ( TInt i(0); i < count; i++ )
+            {
+            // ruleset should not contain any other type elements
+            // than <rule>
+            if ( !Match( aXdmNode.ChileNode(i)->NodeName(), KXdmRule ) ) 
+                {
+                LeaveWithErrorL( KXcapErrorSchemaViolation );
+                }
+            }
+        found = ETrue;
+        }
+    // <rule> 
+    else if ( Match( element, KXdmRule ) )
+        {
+        // required attribute id
+        if ( !aXdmNode.HasAttribute( KXdmId ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+            }
+        found = ETrue;
+        }
+    // <conditions> 
+    else if ( Match( element, KXdmConditions ) )
+        {
+        found = ETrue;
+        }
+    // <actions> 
+    else if ( Match( element, KXdmActions ) )
+        {
+        found = ETrue;
+        }
+    // <transformations> 
+    else if ( Match( element, KXdmTransformations ) )
+        {
+        found = ETrue;
+        }
+    // <validity> 
+    else if ( Match( element, KXdmValidity ) )
+        {
+            // <validity> should contain <from> and <until>
+            TBool from( EFalse );
+            TBool until( EFalse );
+            TInt count( aXdmNode.NodeCount() );
+            for ( TInt i(0); i < count; i++ )
+                {
+                TPtrC childName = aXdmNode.ChileNode(i)->NodeName();
+                if ( Match( childName, KXdmFrom ) ) 
+                    {
+                    from = ETrue;
+                    }
+                else if ( Match( childName, KXdmUntil ) ) 
+                    {
+                    until = ETrue;
+                    }
+                }
+            if ( !from || !until ) 
+                {
+                LeaveWithErrorL( KXcapErrorMissingRequiredElement );    
+                }    
+        found = ETrue;
+        }
+    // <from> 
+    else if ( Match( element, KXdmFrom ) )
+        {
+        dataType = EDataTypeDateTime;
+        found = ETrue;
+        }
+    // <to> 
+    else if ( Match( element, KXdmTo ) )
+        {
+        dataType = EDataTypeDateTime;
+        found = ETrue;
+        }
+    // <identity> 
+    else if ( Match( element, KXdmIdentity ) )
+        {
+        // <identity> should contain either <one> or <many>
+        // elements, not both
+        TBool one( EFalse );
+        TBool many( EFalse );
+        TInt count( aXdmNode.NodeCount() );
+        for ( TInt i(0); i < count; i++ )
+            {
+            TPtrC childName = aXdmNode.ChileNode(i)->NodeName();
+            if ( Match( childName, KXdmOne ) ) 
+                {
+                one = ETrue;
+        }
+            else if ( Match( childName, KXdmMany ) ) 
+                {
+                many = ETrue;
+                }    
+            }
+        if ( one && many )
+            {
+            LeaveWithErrorL( KXcapErrorSchemaViolation );
+            }
+        found = ETrue;
+        }
+    // <id> 
+    else if ( Match( element, KXdmId ) )
+        {
+        // required attribute entity
+        if ( !aXdmNode.HasAttribute( KXdmEntity ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+            }
+        found = ETrue;
+        }
+    // <any-identity> 
+    else if ( Match( element, KXdmAnyIdentity ) )
+        {
+        found = ETrue;
+        }
+    // <except> 
+    else if ( Match( element, KXdmExcept ) )
+        {
+        found = ETrue;
+        }   
+    // <sphere> 
+    else if ( Match( element, KXdmSphere ) )
+        {
+        // required attribute value
+        if ( !aXdmNode.HasAttribute( KXdmValue ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+            }
+        found = ETrue;
+        }
+    // <one> 
+    else if ( Match( element, KXdmOne ) )
+        {
+        // required attribute id
+        if ( !aXdmNode.HasAttribute( KXdmId ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+            }
+        found = ETrue;
+        }
+    // <many> 
+    else if ( Match( element, KXdmMany) )
+        {
+        found = ETrue;
+        }
+    // <until> 
+    else if ( Match( element, KXdmUntil ) )
+        {
+        dataType = EDataTypeDateTime;
+        found = ETrue;
+        }        
+
+    // if the node is some of the basic types,
+    // pass it to the base class for data validation
+    if ( dataType != EDataTypeUndefined )
+        {
+        ValidateDataL( dataType, aXdmNode );
+        }
+    return found;   
+    }
+                            
+// ----------------------------------------------------
+// CXcapIetfCommonPolicyUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapIetfCommonPolicyUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+        
+    TDataType dataType ( EDataTypeUndefined );
+    TPtrC attribute = aXdmNodeAttr.NodeName();
+
+    // id 
+    if ( Match( attribute, KXdmId ) )
+        {
+        dataType = EDataTypeString;
+        }
+        // domain 
+    else if ( Match( attribute, KXdmDomain ) )
+        {
+        dataType = EDataTypeString;
+        }
+    // value 
+    else if ( Match( attribute, KXdmValue ) )
+        {
+        dataType = EDataTypeString;
+        }
+
+    // pass to base class for data validation
+    ValidateDataL( dataType, aXdmNodeAttr );
+    }
+                            
+// ----------------------------------------------------
+// CXcapIetfCommonPolicyUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapIetfCommonPolicyUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+	{
+    aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KNullDesC8 );
+	}
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XCapCommonPolicyCapsUsage/src/XcapOmaCPUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,184 @@
+/*
+* 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:  CXcapOmaCommonPolicyUsage
+*
+*/
+
+
+
+
+// Used specifications
+// OMA-TS-XDM_Core-V1_0-20060612, 12 June 2006
+
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include "XcapOmaCommonPolicyUsage.h"
+
+// ----------------------------------------------------
+// CXcapOmaCommonPolicyUsage::CXcapOmaCommonPolicyUsage
+// 
+// ----------------------------------------------------
+//
+CXcapOmaCommonPolicyUsage::CXcapOmaCommonPolicyUsage( const CXdmEngine& aXdmEngine ) :
+CXcapAppUsage( aXdmEngine )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapOmaCommonPolicyUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapOmaCommonPolicyUsage* CXcapOmaCommonPolicyUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapOmaCommonPolicyUsage* self = new ( ELeave ) CXcapOmaCommonPolicyUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );    // << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapOmaCommonPolicyUsage::~CXcapOmaCommonPolicyUsage
+// 
+// ----------------------------------------------------
+//
+CXcapOmaCommonPolicyUsage::~CXcapOmaCommonPolicyUsage()
+    {
+    }
+        
+// ----------------------------------------------------
+// CXcapOmaCommonPolicyUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapOmaCommonPolicyUsage::ConstructL()
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapOmaCommonPolicyUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapOmaCommonPolicyUsage::AUID() const
+    {
+    return TPtrC8( KXdmOmaCommonPolicyUsageAUID );
+    }
+                
+// ----------------------------------------------------
+// CXcapOmaCommonPolicyUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapOmaCommonPolicyUsage::ContentType() const
+    {
+    return TPtrC8( KXdmOmaCommonPolicyUsageContType );
+    }
+
+// ----------------------------------------------------
+// CXcapOmaCommonPolicyUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapOmaCommonPolicyUsage::DefaultNamespace() const
+    {
+    return TPtrC8( KXdmOmaCommonPolicyNamespace );
+    }   
+    
+// ----------------------------------------------------
+// CXcapOmaCommonPolicyUsage::ValidateNodeL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapOmaCommonPolicyUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
+    {
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+    
+    TBool found( EFalse );
+    TDataType dataType ( EDataTypeUndefined );
+    TPtrC element = aXdmNode.NodeName();
+            
+    // <other-identity> 
+    if ( Match( element, KXdmOtherIdentity ) )
+        {
+        dataType = EDataTypeEmpty;
+        found = ETrue;
+        }
+    // <external-list>
+    else if ( Match( element, KXdmExternalList ) )
+        {
+        found = ETrue;
+        }
+    // <entry> 
+    else if ( Match( element, KXdmEntry ) )
+        {
+        // should we check the parent's namespace here
+        found = ETrue;
+        }
+    // <anonymous-request> 
+    else if ( Match( element, KXdmAnonymousRequest ) )
+        {
+        dataType = EDataTypeEmpty;
+        found = ETrue;
+        }
+        
+    // if the node is some of the basic types,
+    // pass it to the base class for data validation
+    if ( dataType != EDataTypeUndefined )
+        {
+        ValidateDataL( dataType, aXdmNode );
+        }
+    return found;   
+    }
+    
+// ----------------------------------------------------
+// CXcapOmaCommonPolicyUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapOmaCommonPolicyUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+
+    // anc 
+    if ( Match( aXdmNodeAttr.NodeName(), KXdmAnc ) )
+        {
+        // pass to base class for data validation
+        ValidateDataL( EDataTypeAnyURI, aXdmNodeAttr );
+        }   
+    }
+                            
+// ----------------------------------------------------
+// CXcapOmaCommonPolicyUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapOmaCommonPolicyUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+    aXdmDocument.AppendNamespaceL( KXdmOmaCommonPolicyNamespace, KNullDesC8 );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XCapPocUserAccessUsage/inc/XcapPocUserAccessUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,107 @@
+/*
+* 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:  CXcapPocUserAccessUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPPOCUSERACCESSUSAGE__
+#define __XCAPPOCUSERACCESSUSAGE__
+
+#include "XcapAppUsage.h"
+
+
+// CLASS DECLARATION
+class CXcapPocUserAccessUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapPocUserAccessUsage*
+        */
+        static CXcapPocUserAccessUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapPocUserAccessUsage();
+        
+    public:  // From CXcapAppUsage
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;
+        
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+                        
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+                        
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */        
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+        
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapPocUserAccessUsage( const CXdmEngine& aXdmEngine );    
+    
+    private:    // Data
+           
+        CXcapAppUsage*      iIetfCommonPolicies;   
+        CXcapAppUsage*      iOmaCommonPolicies; 
+    };
+
+#endif    //__XCAPPOCGROUPUSAGE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XCapPocUserAccessUsage/src/XcapPocUserAccessUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  CXcapPocUserAccessUsage
+*
+*/
+
+
+
+
+#include <XdmErrors.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include "XcapPocUserAccessUsage.h"
+
+// Used specification
+// OMA-TS-PoC_XDM-V1_0-20050317-C, 17 March 2005
+// OMA-TS-PoC_XDM-V1_0-20060127-C, 27 January 2006
+
+// ----------------------------------------------------
+// CXcapPocUserAccessUsage::CXcapPocUserAccessUsage
+// 
+// ----------------------------------------------------
+//
+CXcapPocUserAccessUsage::CXcapPocUserAccessUsage( const CXdmEngine& aXdmEngine ) :
+CXcapAppUsage( aXdmEngine ),
+iIetfCommonPolicies( NULL ),
+iOmaCommonPolicies( NULL )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapPocUserAccessUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapPocUserAccessUsage* CXcapPocUserAccessUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapPocUserAccessUsage* self = new ( ELeave ) CXcapPocUserAccessUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );	// << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapPocUserAccessUsage::~CXcapPocUserAccessUsage
+// 
+// ----------------------------------------------------
+//
+CXcapPocUserAccessUsage::~CXcapPocUserAccessUsage()
+    {
+    delete iIetfCommonPolicies;
+    delete iOmaCommonPolicies;
+    }
+        
+// ----------------------------------------------------
+// CXcapPocUserAccessUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapPocUserAccessUsage::ConstructL()
+    {
+    iIetfCommonPolicies = CXcapAppUsage::NewL( iXdmEngine, EXdmIetfCommonPolicy );
+    iOmaCommonPolicies = CXcapAppUsage::NewL( iXdmEngine, EXdmOmaCommonPolicy );
+    }
+
+// ----------------------------------------------------
+// CXcapPocUserAccessUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapPocUserAccessUsage::AUID() const
+    {
+    return TPtrC8( KXdmPocUserAccessUsageAUID );
+    }
+
+// ----------------------------------------------------
+// CXcapPocUserAccessUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapPocUserAccessUsage::ContentType() const
+    {
+    return TPtrC8( KXdmPocUserAccessUsageContType );
+    }
+
+// ----------------------------------------------------
+// CXcapPocUserAccessUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapPocUserAccessUsage::DefaultNamespace() const
+    {
+//    return TPtrC8( KXdmPocUserAccessNamespace );
+    // NOTE the default namespace is IetfCommonPolicy
+    return TPtrC8( KXdmIetfCommonPolicyNamespace );
+    }   
+    
+// ----------------------------------------------------
+// CXcapPocUserAccessUsage::ValidateNodeL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapPocUserAccessUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
+    {    
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+
+    TBool found ( EFalse );
+    TPtrC element = aXdmNode.NodeName();
+    
+    // there is restriction for the value 
+    // of <allow-invite>
+    // check that value is either "reject", "accept" or "pass"
+    // 0 (reject), 1 (pass), 2 (accept)
+    if ( Match( element, KXdmAllowInvite ) )
+        {
+        TPtrC8 data = aXdmNode.LeafNodeContent();
+        if ( data.CompareF( KXdmReject )
+             && data.CompareF( KXdmAccept )
+             && data.CompareF( KXdmPass ) )
+            {
+            LeaveWithErrorL( KXcapErrorEnumerationRule );
+            }
+        found = ETrue;
+        // NOTE the default namespace is IetfCommonPolicy
+        SetPrefixL( aXdmNode, KXdmPocUserAccessNsPrefix ); 
+        }
+    // urn:ietf:params:xml:ns:common-policy
+    if ( !found )
+        {
+        found = iIetfCommonPolicies->ValidateNodeL( aXdmNode );
+        // NOTE the default namespace is IetfCommonPolicy
+        /*if ( found )
+            {
+            SetPrefixL( aXdmNode, KXdmIetfCommonPolicyNsPrefix );  
+            }*/
+        }
+    // urn:oma:params:xml:ns:common-policy
+    if ( !found )
+        {
+        found = iOmaCommonPolicies->ValidateNodeL( aXdmNode );
+                if ( found )
+            {
+            SetPrefixL( aXdmNode, KXdmOmaCommonPolicyNsPrefix );   
+            }
+        }
+    return found;
+    }
+        
+// ----------------------------------------------------
+// CXcapPocUserAccessUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapPocUserAccessUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr)
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+    
+    // there aren't any attributes, all attributes are
+    // either from urn:ietf:params:xml:ns:common-policy
+    // or from urn:oma:params:xml:ns:common-policy
+    
+    // add parent element namespace checking when available,
+    // now we don't know the attribute's namespace
+    iIetfCommonPolicies->ValidateAttributeL( aXdmNodeAttr );
+    iOmaCommonPolicies->ValidateAttributeL( aXdmNodeAttr ); 
+    }
+        
+
+ // ----------------------------------------------------
+// CXcapPocUserAccessUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapPocUserAccessUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+    aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KNullDesC8 );
+    aXdmDocument.AppendNamespaceL( KXdmPocUserAccessNamespace, KXdmPocUserAccessNsPrefix );
+    aXdmDocument.AppendNamespaceL( KXdmOmaCommonPolicyNamespace, KXdmOmaCommonPolicyNsPrefix );
+/*    aXdmDocument.AppendNamespaceL( KXdmPocUserAccessNamespace, KNullDesC8 );
+    aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KXdmIetfCommonPolicyNsPrefix );
+    aXdmDocument.AppendNamespaceL( KXdmOmaCommonPolicyNamespace, KXdmOmaCommonPolicyNsPrefix );*/
+    }                           
+                           
+                           
+// End of File
+  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapC4/inc/XcapC4.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CXcapC4
+*
+*/
+
+#ifndef __XCAPRESCONTENT__
+#define __XCAPRESCONTENT__
+
+#include "XcapAppUsage.h"
+
+// CONSTANTS
+#define KC4SettingsCenRepUID     0x20021391
+
+
+// CLASS DECLARATION
+class CXcapC4 : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapC4*
+        */
+        static CXcapC4* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapC4();
+        
+    public:  // From CXcapAppUsage
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;
+
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+                        
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+                        
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */        
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapC4( const CXdmEngine& aXdmEngine );  
+        
+    private: // member data
+        /// RCS Global: Old content type setting
+        TInt iRCSGlobalOldContentType;
+    };
+
+#endif    //__XCAPPRESCONTENT__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapC4/src/XcapC4.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,201 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CXcapC4
+*
+*/
+
+#include <XdmErrors.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include <centralrepository.h>
+#ifdef _DEBUG
+#include <flogger.h>
+#endif
+
+#include "XcapC4.h"
+//#include "pasvariation.hrh"
+
+
+// Used specification
+// Presence Content XDM Specification, draft 1.0
+
+// ----------------------------------------------------
+// CXcapC4::CXcapC4
+// 
+// ----------------------------------------------------
+//
+CXcapC4::CXcapC4( const CXdmEngine& aXdmEngine ) :
+	CXcapAppUsage( aXdmEngine )
+    {
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapC4 initialized!" ) );
+#endif
+    }
+
+// ----------------------------------------------------
+// CXcapC4::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapC4* CXcapC4::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapC4* self = new ( ELeave ) CXcapC4( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );	// << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapC4::~CXcapC4
+// 
+// ----------------------------------------------------
+//
+CXcapC4::~CXcapC4()
+    {
+    }
+        
+// ----------------------------------------------------
+// CXcapC4::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapC4::ConstructL()
+    {
+    CRepository* cenRepRCSGlobal;
+    cenRepRCSGlobal = CRepository::NewL( TUid::Uid( KC4SettingsCenRepUID ) );
+	CleanupStack::PushL( cenRepRCSGlobal );
+
+    // 0x06 is the index in central repository for content type setting
+    User::LeaveIfError( cenRepRCSGlobal->Get( 0x06, iRCSGlobalOldContentType ) );
+    CleanupStack::PopAndDestroy( ); // cenRepRCSGlobal
+    }
+
+// ----------------------------------------------------
+// CXcapC4::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapC4::AUID() const
+    {
+    return TPtrC8( KXdmPresContentAUID );
+    }
+                
+// ----------------------------------------------------
+// CXcapC4::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapC4::ContentType() const
+    {
+    if ( iRCSGlobalOldContentType )
+    	{
+	return TPtrC8( KXdmPresContentContTypeOld );
+    	}
+    else
+    	{
+	return TPtrC8( KXdmPresContentContType );
+    	}
+    }
+
+// ----------------------------------------------------
+// CXcapC4::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapC4::DefaultNamespace() const
+    {
+    return TPtrC8( KXdmPresContentNamespace );
+    }   
+    
+// ----------------------------------------------------
+// CXcapC4::ValidateL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapC4::ValidateNodeL( CXdmDocumentNode& aXdmNode )
+    {
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapC4::ValidateNodeL" ) );
+#endif
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+     
+    TBool found ( EFalse );   
+    TPtrC element = aXdmNode.NodeName();
+
+	// mime-type
+	if ( Match( element, KXdmMimeType ) )
+		{
+		found = ETrue;
+		}
+	else if ( Match( element, KXdmEncoding ) )
+		{
+		found = ETrue;
+		}
+	else if ( Match( element, KXdmDescription ) )
+		{
+		found = ETrue;
+		}
+	else if ( Match( element, KXdmData ) )
+		{
+		found = ETrue;
+		}
+
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapC4::ValidateNodeL - found: %d" ), found );
+#endif
+    return found;
+    }
+
+// ----------------------------------------------------
+// CXcapC4::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapC4::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+    
+	// there should not be any attributes in pres-content document
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapC4::ValidateAttributeL" ) );
+#endif
+//	User::Leave( KErrNotSupported );
+    }   
+                         
+// ----------------------------------------------------
+// CXcapC4::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapC4::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapC4::AddNamespaceInformationL" ) );
+#endif
+    aXdmDocument.AppendNamespaceL( KXdmPresContentNamespace, KNullDesC8 );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapCapabilityUsage/inc/XcapCapabilityUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,102 @@
+/*
+* 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:  CXcapCapabilityUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPCAPABILITYUSAGE__
+#define __XCAPCAPABILITYUSAGE__
+
+#include "XcapAppUsage.h"
+
+
+// CLASS DECLARATION
+class CXcapCapabilityUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapCapabilityUsage*
+        */
+        static CXcapCapabilityUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapCapabilityUsage();
+        
+    public:  // From CXcapAppUsage
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;
+        
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+        
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+                        
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+        
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapCapabilityUsage( const CXdmEngine& aXdmEngine );    
+    };
+
+#endif    //__XCAPCAPABILITYUSAGE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapCapabilityUsage/src/XcapCapabilityUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,188 @@
+/*
+* 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:  CXcapCapabilityUsage
+*
+*/
+
+
+
+
+#include <XdmDocumentNode.h>
+#include "XcapCapabilityUsage.h"
+
+// Used specification
+// OMA-TS-XDM_Core-V1_0-20051103-C, 03 November 2005
+
+// ----------------------------------------------------
+// CXcapCapabilityUsage::CXcapCapabilityUsage
+// 
+// ----------------------------------------------------
+//
+CXcapCapabilityUsage::CXcapCapabilityUsage( const CXdmEngine& aXdmEngine ) :
+                                            CXcapAppUsage( aXdmEngine )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapCapabilityUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapCapabilityUsage* CXcapCapabilityUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapCapabilityUsage* self = new ( ELeave ) CXcapCapabilityUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );    // << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapCapabilityUsage::~CXcapCapabilityUsage
+// 
+// ----------------------------------------------------
+//
+CXcapCapabilityUsage::~CXcapCapabilityUsage()
+    {
+    }
+        
+// ----------------------------------------------------
+// CXcapCapabilityUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapCapabilityUsage::ConstructL()
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapCapabilityUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapCapabilityUsage::AUID() const
+    {
+    return TPtrC8( KXdmCapabilityUsageAUID );
+    }
+
+// ----------------------------------------------------
+// CXcapCapabilityUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapCapabilityUsage::ContentType() const
+    {
+    return TPtrC8( KXdmCapabilityUsageContType );
+    }
+
+// ----------------------------------------------------
+// CXcapCapabilityUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapCapabilityUsage::DefaultNamespace() const
+    {
+    return TPtrC8( KXdmCapabilityNamespace );
+    }    
+
+// ----------------------------------------------------
+// CXcapCapabilityUsage::ValidateNodeL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapCapabilityUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
+    {
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+    
+    TBool found ( EFalse );
+    TDataType dataType ( EDataTypeUndefined );
+    TPtrC element = aXdmNode.NodeName();
+    
+    // <auids>
+    if ( Match( element, KXdmAuids ) )
+        {
+        found = ETrue;
+        } 
+    // <auid>
+    else if ( Match( element, KXdmAuid ) )
+        {
+        dataType = EDataTypeString;
+        found = ETrue;
+        }
+    // <extensions>
+    else if ( Match( element, KXdmExtensions ) )
+        {
+        found = ETrue;
+        }
+    // <extension>
+    else if ( Match( element, KXdmExtension ) )
+        {
+        dataType = EDataTypeString;
+        found = ETrue;
+        }
+    // <namespaces>
+    else if ( Match( element, KXdmNamespace ) )
+        {
+        found = ETrue;
+        }
+    // <namespace>
+    else if ( Match( element, KXdmNamespace ) )
+        {
+        dataType = EDataTypeAnyURI;
+        found = ETrue;
+        }
+        
+    if ( dataType != EDataTypeUndefined )
+        {
+        // pass to the base class for data validation
+        ValidateDataL( dataType, aXdmNode );
+        }
+    return found;
+    }
+
+// ----------------------------------------------------
+// CXcapCapabilityUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapCapabilityUsage::ValidateAttributeL( const CXdmNodeAttribute& /*aXdmNodeAttr*/ )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+    
+    // There aren't any attributes in
+    // capability usage schema.
+    }
+    
+// ----------------------------------------------------
+// CXcapCapabilityUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapCapabilityUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+    aXdmDocument.AppendNamespaceL( KXdmCapabilityNamespace, KNullDesC8 );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapDirectoryUsage/inc/XcapDirectoryUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,102 @@
+/*
+* 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: CXcapDirectoryUsage 
+*
+*/
+
+
+
+
+#ifndef __XCAPDIRECTORYUSAGE__
+#define __XCAPDIRECTORYUSAGE__
+
+#include "XcapAppUsage.h"
+
+
+// CLASS DECLARATION
+class CXcapDirectoryUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapDirectoryUsage*
+        */
+        static CXcapDirectoryUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapDirectoryUsage();
+    
+    public:
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;
+        
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+                        
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+                        
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */        
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+        
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapDirectoryUsage( const CXdmEngine& aXdmEngine );    
+    };
+
+#endif    //__XCAPDIRECTORYUSAGE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapDirectoryUsage/src/XcapDirectoryUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,234 @@
+/*
+* 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:  CXcapDirectoryUsage
+*
+*/
+
+
+
+
+#include <XdmErrors.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include "XcapDirectoryUsage.h"
+
+
+// Used specification
+// OMA-TS-XDM_Core-V1_0-20051103-C, 03 November 2005
+
+// ----------------------------------------------------
+// CXcapDirectoryUsage::CXcapDirectoryUsage
+// 
+// ----------------------------------------------------
+//
+CXcapDirectoryUsage::CXcapDirectoryUsage( const CXdmEngine& aXdmEngine ) :
+                                          CXcapAppUsage( aXdmEngine )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapDirectoryUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapDirectoryUsage* CXcapDirectoryUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapDirectoryUsage* self = new ( ELeave ) CXcapDirectoryUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );    // << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapDirectoryUsage::~CXcapDirectoryUsage
+// 
+// ----------------------------------------------------
+//
+CXcapDirectoryUsage::~CXcapDirectoryUsage()
+    {
+    }
+        
+// ----------------------------------------------------
+// CXcapDirectoryUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapDirectoryUsage::ConstructL()
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapDirectoryUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapDirectoryUsage::AUID() const
+    {
+    return TPtrC8( KXdmDirectoryUsageAUID );
+    }
+                 
+// ----------------------------------------------------
+// CXcapDirectoryUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapDirectoryUsage::ContentType() const
+    {
+    return TPtrC8( KXdmDirectoryUsageContType );
+    }
+
+// ----------------------------------------------------
+// CXcapDirectoryUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapDirectoryUsage::DefaultNamespace() const
+    {
+    return TPtrC8( KXdmDirectoryNamespace );
+    }   
+    
+// ----------------------------------------------------
+// CXcapDirectoryUsage::ValidateNodeL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapDirectoryUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode ) 
+    {
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+
+    TBool found( EFalse );
+    TPtrC element = aXdmNode.NodeName();
+        
+    // <xcap-directory>
+    if ( Match( element, KXdmXcapDirectory ) ) 
+        {
+        found = ETrue;  
+        }
+    // <folder>
+    else if ( Match( element, KXdmFolder ) )
+        {
+        // required attribute auid
+        if ( !aXdmNode.HasAttribute( KXdmAuid ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+            }
+        // there should be either <entry> or <error-code>
+        // element, not both
+        TBool entry( EFalse );
+        TBool errorcode( EFalse ) ;
+        TInt count( aXdmNode.NodeCount() );
+        for ( TInt i(0); i < count; i++ )
+            {
+            TPtrC childName = aXdmNode.ChileNode(i)->NodeName();            
+            if ( childName.CompareF( KXdmEntry ) ) 
+                {
+                entry = ETrue;
+                }
+            else if ( childName.CompareF( KXdmErrorCode ) ) 
+                {
+                errorcode = ETrue;
+                }
+            }
+        if ( entry && errorcode )   
+            {
+            LeaveWithErrorL( KXcapErrorSchemaViolation );   
+            }
+        found = ETrue;  
+        }
+    // <entry>
+    else if ( Match( element, KXdmEntry ) )
+        {
+        // required attributes uri and etag
+        if ( !aXdmNode.HasAttribute( KXdmUri ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+            }
+        if ( !aXdmNode.HasAttribute( KXdmEtag ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute);
+            }
+        found = ETrue;  
+        }
+    // <error-code>
+    else if ( Match( element, KXdmErrorCode ) ) 
+        {
+        ValidateDataL( EDataTypeString, aXdmNode );
+        found = ETrue;  
+        }
+    return found;
+    }
+        
+// ----------------------------------------------------
+// CXcapDirectoryUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapDirectoryUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+    
+    TDataType dataType ( EDataTypeUndefined );
+    TPtrC attribute = aXdmNodeAttr.NodeName();
+    // uri
+    if ( Match( attribute, KXdmUri ) )
+        {
+        dataType = EDataTypeAnyURI;
+        }
+    // etag
+    else if ( Match( attribute, KXdmEtag ) )
+        {
+        dataType = EDataTypeString;
+        }
+    // last-modified
+    else if ( Match( attribute, KXdmLastModified ) )
+        {
+        dataType = EDataTypeDateTime;
+        }
+    // size
+    else if ( Match( attribute, KXdmSize ) )
+        {
+        dataType = EDataTypeNonNegativeInteger;
+        }
+    // auid
+    else if ( Match( attribute, KXdmAuid ) )
+        {
+        dataType = EDataTypeString;
+        }
+    // pass to base class for data validation
+    ValidateDataL( dataType, aXdmNodeAttr );
+    }
+
+// ----------------------------------------------------
+// CXcapDirectoryUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapDirectoryUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+    aXdmDocument.AppendNamespaceL( KXdmDirectoryNamespace, KNullDesC8 );
+    }
+    
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapPocGroupUsage/inc/XcapPocGroupUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,108 @@
+/*
+* 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:  CXcapPocGroupUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPPOCGROUPUSAGE__
+#define __XCAPPOCGROUPUSAGE__
+
+#include "XcapAppUsage.h"
+
+
+// CLASS DECLARATION
+class CXcapPocGroupUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapPocGroupUsage*
+        */
+        static CXcapPocGroupUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapPocGroupUsage();
+        
+    public:  // From CXcapAppUsage
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;
+        
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+                        
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+        
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapPocGroupUsage( const CXdmEngine& aXdmEngine );    
+
+    private:    // Data
+            
+        CXcapAppUsage*      iIetfCommonPolicies; 
+        CXcapAppUsage*      iOmaCommonPolicies; 
+        CXcapAppUsage*      iResourceLists;
+    };
+
+#endif    //__XCAPPOCGROUPUSAGE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapPocGroupUsage/src/XcapPocGroupUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,330 @@
+/*
+* 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:  CXcapPocGroupUsage
+*
+*/
+
+
+
+
+#include <XdmErrors.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include "XcapPocGroupUsage.h"
+
+
+
+// Used specification
+// OMA-TS-PoC_XDM-V1_0-20060609-A, 09 June 2006
+// ----------------------------------------------------
+// CXcapPocGroupUsage::CXcapPocGroupUsage
+// 
+// ----------------------------------------------------
+//
+CXcapPocGroupUsage::CXcapPocGroupUsage( const CXdmEngine& aXdmEngine ) :
+CXcapAppUsage( aXdmEngine ),
+iIetfCommonPolicies( NULL ),
+iOmaCommonPolicies( NULL ),
+iResourceLists( NULL )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapPocGroupUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapPocGroupUsage* CXcapPocGroupUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapPocGroupUsage* self = new ( ELeave ) CXcapPocGroupUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );    // << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapPocGroupUsage::~CXcapPocGroupUsage
+// 
+// ----------------------------------------------------
+//
+CXcapPocGroupUsage::~CXcapPocGroupUsage()
+    {
+    delete iIetfCommonPolicies;
+    delete iOmaCommonPolicies;
+    delete iResourceLists;
+    }
+        
+// ----------------------------------------------------
+// CXcapPocGroupUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapPocGroupUsage::ConstructL()
+    {
+    iIetfCommonPolicies = CXcapAppUsage::NewL( iXdmEngine, EXdmIetfCommonPolicy );
+    iOmaCommonPolicies = CXcapAppUsage::NewL( iXdmEngine, EXdmOmaCommonPolicy );
+    iResourceLists = CXcapAppUsage::NewL( iXdmEngine, EXdmResourceLists );
+    }
+
+// ----------------------------------------------------
+// CXcapPocGroupUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapPocGroupUsage::AUID() const
+    {
+    return TPtrC8( KXdmPocGroupUsageAUID );
+    }
+
+// ----------------------------------------------------
+// CXcapPocGroupUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapPocGroupUsage::ContentType() const
+    {
+    return TPtrC8( KXdmPocGroupUsageContType );
+    }
+
+// ----------------------------------------------------
+// CXcapPocGroupUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapPocGroupUsage::DefaultNamespace() const
+    {
+    return TPtrC8( KXdmPocGroupNamespace );
+    }   
+    
+// ----------------------------------------------------
+// CXcapPocGroupUsage::ValidateNodeL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapPocGroupUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
+    {
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+
+    TBool found( EFalse );
+    TDataType dataType ( EDataTypeUndefined );
+    TPtrC element = aXdmNode.NodeName();
+            
+    // <group> 
+    if ( Match( element, KXdmGroup ) )
+        {
+        // no other elements than <list-service>
+        TInt count( aXdmNode.NodeCount() );
+        for ( TInt i(0); i < count; i++ )
+            {
+            if ( !Match( aXdmNode.ChileNode(i)->NodeName(), KXdmListService ) )
+                {
+                LeaveWithErrorL( KXcapErrorSchemaViolation );   
+                }
+            }
+        found = ETrue;
+        }           
+    // <list-service>
+    else if ( Match( element, KXdmListService ) )
+        {
+        // required attribute uri
+        if ( !aXdmNode.HasAttribute( KXdmUri ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+            }
+        found = ETrue;
+        }
+    // <display-name>   
+    else if ( Match( element, KXdmDisplayName ) )
+        {
+        CXdmDocumentNode* parent = aXdmNode.Parent();
+        if ( parent && !parent->NodeName().CompareF( KXdmEntry ) )
+            {
+            found = iResourceLists->ValidateNodeL( aXdmNode );	
+            if ( found )
+            	{
+            	SetPrefixL( aXdmNode, KXdmResourceListsNsPrefix );  
+            	}
+            }
+        else
+            {
+        dataType = EDataTypeString;
+        found = ETrue;
+        }
+        }
+    // <invite-members>     
+    else if ( Match( element, KXdmInviteMembers ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <max-participant-count>
+    else if ( Match( element, KXdmMaxParticipantCount ) )
+        {
+        dataType = EDataTypeNonNegativeInteger;
+        found = ETrue;
+        }
+    // <is-list-member>
+    else if ( Match( element, KXdmIsListMember ) )
+        {
+        // dataType = EDataTypeBoolean; // OMA-TS-PoC_XDM-V1_0-20050317-C, 17 March 2005
+        // changed 4-Nov-2005 PoC XDM
+        dataType = EDataTypeEmpty;
+        found = ETrue;
+        }   
+    // <allow-conference-state> 
+    else if ( Match( element, KXdmAllowConfState ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <allow-invite-users-dynamically>
+    else if ( Match( element, KXdmAllowInvUsersDyn ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <join-handling> 
+    else if ( Match( element, KXdmJoinHandling ) )
+        {
+        // OMA-TS-PoC_XDM-V1_0-20050317-C, 17 March 2005
+        // the value must be "allow" or "block"
+        // 0 (block) and 1 (allow)
+        /* TPtrC8 data = aXdmNode.LeafNodeContent();
+        if ( data.CompareF( KXdmAllow )
+             && data.CompareF( KXdmBlock ) )
+            {
+            LeaveWithErrorL( KXcapErrorEnumerationRule );
+            }
+        */
+        // changed OMA-TS-PoC_XDM-V1_0-20060127-C, 27 January 2006
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <allow-initiate-conference>
+    else if ( Match( element, KXdmAllowInitiateConf ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <allow-anonymity>
+    else if ( Match( element, KXdmAllowAnonymity ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <is-key-participant>
+    else if ( Match( element, KXdmIsKeyParticipant ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <external> 
+    // type = rl:externalType from urn:ietf:params:xml:ns:resource-lists 
+    // pass to the appropriate usage for validation
+    // but use default namespace
+    else if ( Match( element, KXdmExternal ) )
+        {
+        found = iResourceLists->ValidateNodeL( aXdmNode );
+        }
+    // <entry> 
+    // type = rl:entryType from urn:ietf:params:xml:ns:resource-lists 
+    // pass to the appropriate usage for validation
+    // but use default namespace
+    else if ( Match( element, KXdmEntry ) )    
+        {
+        found = iResourceLists->ValidateNodeL( aXdmNode );
+        }
+
+    // urn:ietf:params:xml:ns:common-policy
+    if ( !found )
+        {
+        found = iIetfCommonPolicies->ValidateNodeL( aXdmNode );
+        if ( found )
+            {
+            SetPrefixL( aXdmNode, KXdmIetfCommonPolicyNsPrefix );  
+            }
+        }
+    // urn:oma:params:xml:ns:common-policy
+    if ( !found )
+        {
+        found = iOmaCommonPolicies->ValidateNodeL( aXdmNode );
+        if ( found )
+            {
+            SetPrefixL( aXdmNode, KXdmOmaCommonPolicyNsPrefix );   
+            }
+        }
+        
+    // if the node is some of the basic types,
+    // pass it to the base class for data validation
+    if ( dataType != EDataTypeUndefined )
+        {
+        ValidateDataL( dataType, aXdmNode );
+        }
+    return found;   
+    }
+
+// ----------------------------------------------------
+// CXcapPocGroupUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapPocGroupUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+
+    TPtrC attribute = aXdmNodeAttr.NodeName();
+    
+    // uri
+    if ( Match( attribute, KXdmUri ) ) 
+        {
+        // pass to base class for data validation
+        // check if this should be SIP uri
+        ValidateDataL( EDataTypeAnyURI, aXdmNodeAttr ); 
+        }
+    else
+        {
+        // add parent element namespace checking when available,
+        // now we don't know the attribute's namespace
+        iIetfCommonPolicies->ValidateAttributeL( aXdmNodeAttr );
+        iOmaCommonPolicies->ValidateAttributeL( aXdmNodeAttr ); 
+        }
+    }
+                            
+// ----------------------------------------------------
+// CXcapPocGroupUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapPocGroupUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+    aXdmDocument.AppendNamespaceL( KXdmPocGroupNamespace, KNullDesC8 );
+    aXdmDocument.AppendNamespaceL( KXdmResourceListsNamespace, KXdmResourceListsNsPrefix );
+    aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KXdmIetfCommonPolicyNsPrefix );
+    aXdmDocument.AppendNamespaceL( KXdmOmaCommonPolicyNamespace, KXdmOmaCommonPolicyNsPrefix );
+    }
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapPresenceRulesUsage/inc/XcapIetfPresRulesUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* 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:  CXcapIetfPresRulesUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPIETFPRESRULESUSAGE__
+#define __XCAPIETFPRESRULESUSAGE__
+
+#include "XcapAppUsage.h"
+
+
+
+// CLASS DECLARATION
+class CXcapIetfPresRulesUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapIetfPresRulesUsage*
+        */
+        static CXcapIetfPresRulesUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapIetfPresRulesUsage();
+        
+    public:  // From CXcapAppUsage
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;                        
+        
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+        
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        */
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+        
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapIetfPresRulesUsage( const CXdmEngine& aXdmEngine );   
+        
+    private:    // Data
+    
+        CXcapAppUsage* iIetfCommonPolicy;
+    };
+
+#endif    //__XCAPIETFPRESRULESUSAGE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapPresenceRulesUsage/inc/XcapOmaPresRulesUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,108 @@
+/*
+* 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:  CXcapOmaPresRulesUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPOMAPRESRULESUSAGE__
+#define __XCAPOMAPRESRULESUSAGE__
+
+#include "XcapAppUsage.h"
+
+
+// CLASS DECLARATION
+class CXcapOmaPresRulesUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapOmaPresRulesUsage*
+        */
+        static CXcapOmaPresRulesUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapOmaPresRulesUsage();
+        
+    public:  // From CXcapAppUsage
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;                        
+        
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+        
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+                        
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapOmaPresRulesUsage( const CXdmEngine& aXdmEngine );  
+
+    private:    // Data 
+            
+        CXcapAppUsage*  iIetfPresRules;
+        CXcapAppUsage*  iIetfCommonPolicy;
+        CXcapAppUsage*  iOmaCommonPolicy;
+    };
+
+#endif    //__XCAPOMAPRESRULESUSAGE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapPresenceRulesUsage/src/XcapIetfPresRulesUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,520 @@
+/*
+* 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:  CXcapIetfPresRulesUsage
+*
+*/
+
+
+
+
+#include "XcapIetfPresRulesUsage.h"
+#include "XdmDocumentNode.h"
+#include "XdmNodeAttribute.h"
+#include "XdmErrors.h"
+
+// Used specification
+// draft-ietf-simple-presence-rules-03, 18 July 2005
+// expires 19 January, 2006
+// draft-ietf-simple-presence-rules-05, 06 March 2006
+// expires 07 September, 2006
+
+// ----------------------------------------------------
+// CXcapIetfPresRulesUsage::CXcapIetfPresRulesUsage
+// 
+// ----------------------------------------------------
+//
+CXcapIetfPresRulesUsage::CXcapIetfPresRulesUsage( const CXdmEngine& aXdmEngine ) :
+CXcapAppUsage( aXdmEngine ),
+iIetfCommonPolicy( NULL )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapIetfPresRulesUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapIetfPresRulesUsage* CXcapIetfPresRulesUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapIetfPresRulesUsage* self = new ( ELeave ) CXcapIetfPresRulesUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );	// << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapIetfPresRulesUsage::~CXcapIetfPresRulesUsage
+// 
+// ----------------------------------------------------
+//
+CXcapIetfPresRulesUsage::~CXcapIetfPresRulesUsage()
+    {
+    delete iIetfCommonPolicy;
+    }
+        
+// ----------------------------------------------------
+// CXcapIetfPresRulesUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapIetfPresRulesUsage::ConstructL()
+    {
+    iIetfCommonPolicy = CXcapAppUsage::NewL( iXdmEngine, KXdmIetfCommonPolicyUsageUid );
+    }
+
+// ----------------------------------------------------
+// CXcapIetfPresRulesUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapIetfPresRulesUsage::AUID() const
+    {
+    return TPtrC8( KXdmIetfPresRulesUsageAUID );
+    }
+                
+// ----------------------------------------------------
+// CXcapIetfPresRulesUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapIetfPresRulesUsage::ContentType() const
+    {
+    return TPtrC8( KXdmIetfPresRulesUsageContType );
+    }
+    
+// ----------------------------------------------------
+// CXcapIetfPresRulesUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapIetfPresRulesUsage::DefaultNamespace() const
+    {
+    return TPtrC8( KXdmIetfPresRulesNamespace );
+    }    
+
+// ----------------------------------------------------
+// CXcapIetfPresRulesUsage::ValidateL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapIetfPresRulesUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
+    {
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+
+    TBool found ( EFalse );    
+    TDataType dataType ( EDataTypeUndefined );
+    TPtrC element = aXdmNode.NodeName();
+    
+    // <service-uri-scheme>       
+    if ( Match( element, KXdmServiceUriScheme ) )
+        {
+        dataType = EDataTypeToken;  
+        found = ETrue;
+        }
+    // <class>
+    else if ( Match( element, KXdmClass ) )
+        {
+        dataType = EDataTypeToken;
+        found = ETrue;  
+        }
+    // <occurence-id>
+    else if ( Match( element, KXdmOccurenceId ) ) 
+        {
+        dataType = EDataTypeToken;  
+        found = ETrue;      
+        }
+    // <service-uri>
+    else if ( Match( element, KXdmServiceUri ) )
+        {
+        dataType = EDataTypeAnyURI; 
+        found = ETrue;      
+        }
+    // <all-services>
+    else if ( Match( element, KXdmAllServices ) ) 
+        {
+        found = ETrue;
+        }
+    // <provide-services>
+    else if ( Match( element, KXdmProvideServices ) )
+        {
+        // type = provideServicePermissions
+        // here we should have either <all-services>
+        // or sequence of other elements
+        TBool allServices( EFalse );
+        TBool sequence( EFalse );
+        TBool serviceUri( EFalse );
+        TBool serviceUriScheme( EFalse );
+        TBool occurenceId( EFalse );
+        TBool prclass( EFalse );
+        TInt count( aXdmNode.NodeCount() );
+        for ( TInt i(0); i < count; i++ )
+            {
+            TPtrC childName = aXdmNode.ChileNode(i)->NodeName();
+            if ( Match( childName, KXdmAllServices ) ) 
+                {
+                allServices = ETrue;
+                }
+            else
+                {
+                sequence = ETrue;
+                // in sequence should be either <service-uri>, 
+                // <service-uri-scheme>, <occurence-id> or <class>
+                if ( Match( childName, KXdmServiceUri ) ) 
+                    {
+                    serviceUri = ETrue;
+                    }
+                else if ( Match( childName, KXdmServiceUriScheme ) ) 
+                    {
+                    serviceUriScheme = ETrue;
+                    }
+                else if ( Match( childName, KXdmOccurenceId ) ) 
+                    {
+                    occurenceId = ETrue;
+                    }
+                else if ( Match( childName, KXdmClass ) ) 
+                    {
+                    prclass = ETrue;
+                    }
+                }
+            }
+        if ( allServices && sequence )
+            {
+            LeaveWithErrorL( KXcapErrorSchemaViolation );
+            }
+        if ( sequence ) 
+            {
+            if ( serviceUri && ( serviceUriScheme || occurenceId || prclass ) )
+                {
+                LeaveWithErrorL( KXcapErrorSchemaViolation );
+                }
+            if ( serviceUriScheme && ( occurenceId || prclass ) )
+                {
+                LeaveWithErrorL( KXcapErrorSchemaViolation );
+                }
+            if ( occurenceId && prclass )
+                {
+                LeaveWithErrorL( KXcapErrorSchemaViolation );
+                }       
+            }
+        found = ETrue;
+        }
+    // used in presence-rules-03
+    // <device-id>
+    else if ( Match( element, KXdmDeviceId ) )
+        {
+        dataType = EDataTypeAnyURI; 
+        found = ETrue;          
+        }
+    // used in presence-rules-05
+    // <deviceID>
+    else if ( Match( element, KXdmDeviceID ) )
+        {
+        dataType = EDataTypeAnyURI; 
+        found = ETrue;          
+        }
+    // <all-devices>
+    else if ( Match( element, KXdmAllDevices ) )
+        {
+        found = ETrue;
+        }
+    // <provide-devices>
+    else if ( Match( element, KXdmProvideDevices ) )
+        {
+        // type = provideDevicePermissions
+        // here we should have either <all-devices>
+        // or sequence of other elements
+        TBool allDevices( EFalse );
+        TBool sequence( EFalse );
+        TBool deviceId( EFalse );
+        TBool occurenceId( EFalse );
+        TBool prclass( EFalse );
+        TInt count( aXdmNode.NodeCount() );
+        for ( TInt i(0); i < count; i++ )
+            {
+            TPtrC childName = aXdmNode.ChileNode(i)->NodeName();
+            if ( Match( childName, KXdmAllDevices ) ) 
+                {
+                allDevices = ETrue;
+                }
+            else
+                {
+                sequence = ETrue;
+                // in sequence should be either pres-rules-03 <device-id> pres-rules-05 <deviceID>, 
+                // <occurence-id> or <class>
+                if ( Match( childName, KXdmDeviceId ) 
+                    || Match( childName, KXdmDeviceID ) ) 
+                    {
+                    deviceId = ETrue;
+                    }
+                else if ( Match( childName, KXdmOccurenceId ) ) 
+                    {
+                    occurenceId = ETrue;
+                    }
+                else if ( Match( childName, KXdmClass ) ) 
+                    {
+                    prclass = ETrue;
+                    }
+                }
+            }
+            if ( allDevices && sequence )
+                {
+                LeaveWithErrorL( KXcapErrorSchemaViolation );
+                }
+            if ( sequence ) 
+                {
+                if ( deviceId && ( occurenceId || prclass ) )
+                    {
+                    LeaveWithErrorL( KXcapErrorSchemaViolation );
+                    }
+                if ( occurenceId && prclass )
+                    {
+                    LeaveWithErrorL( KXcapErrorSchemaViolation );
+                    }
+                }
+        found = ETrue;
+        }
+    // <all-persons>
+    else if ( Match( element, KXdmAllPersons ) )
+        {
+        found = ETrue;
+        }
+    //  <provide-persons>
+    else if ( !element.CompareF( KXdmProvidePersons ) )
+        {
+        // type = providePersonPermissions
+        // here we should have either <all-devices>
+        // or sequence of other elements
+        TBool allPersons( EFalse );
+        TBool sequence( EFalse );
+        TBool occurenceId( EFalse );
+        TBool prclass( EFalse );
+        TInt count( aXdmNode.NodeCount() );
+        for ( TInt i(0); i < count; i++ )
+            {
+            TPtrC childName = aXdmNode.ChileNode(i)->NodeName();
+            if ( Match( childName, KXdmAllPersons ) ) 
+                {
+                allPersons = ETrue;
+                }
+            else
+                {
+                sequence = ETrue;
+                // in sequence should be either 
+                // <occurence-id> or <class>
+                if ( Match( childName, KXdmOccurenceId ) ) 
+                    {
+                    occurenceId = ETrue;
+                    }
+                else if ( Match( childName, KXdmClass ) ) 
+                    {
+                    prclass = ETrue;
+                    }
+                }
+            }
+            if ( allPersons && sequence )
+                {
+                LeaveWithErrorL( KXcapErrorSchemaViolation );
+                }
+            if ( sequence ) 
+                {
+                if ( occurenceId && prclass )
+                    {
+                    LeaveWithErrorL( KXcapErrorSchemaViolation );
+                    }
+                }
+        found = ETrue;              
+        }
+    // <provide-activities>
+    else if ( Match( element, KXdmProvideActivities ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;              
+        }
+    // <provide-class>
+    else if ( Match( element, KXdmProvideClass ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;          
+        }
+    // <provide-device-id>
+    else if ( Match( element, KXdmProvideDeviceId ) )
+        {
+        dataType = EDataTypeBoolean;            
+        found = ETrue;
+        }
+    // <provide-mood>
+    else if ( Match( element, KXdmProvideMood ) )
+        {
+        dataType = EDataTypeBoolean;            
+        found = ETrue;
+        }
+    // <provide-place-is>
+    else if ( Match( element, KXdmProvidePlaceIs ) )
+        {
+        dataType = EDataTypeBoolean;            
+        found = ETrue;
+        }
+    // <provide-place-type>
+    else if ( Match( element, KXdmProvidePlaceType ) )
+        {
+        dataType = EDataTypeBoolean;            
+        found = ETrue;
+        }
+    // <provide-privacy>
+    else if ( Match( element, KXdmProvidePrivacy ) )
+        {
+        dataType = EDataTypeBoolean;            
+        found = ETrue;
+        }
+    // <provide-relationship>
+    else if ( Match( element, KXdmProvideRelationship ) )
+        {
+        dataType = EDataTypeBoolean;            
+        found = ETrue;
+        }
+    // <provide-status-icon>
+    else if ( Match( element, KXdmProvideStatusIcon ) )
+        {
+        dataType = EDataTypeBoolean;            
+        found = ETrue;
+        }
+    // <provide-sphere>
+    else if ( Match( element, KXdmProvideSphere ) )
+        {
+        dataType = EDataTypeBoolean;            
+        found = ETrue;
+        }
+    // <provide-time-offset>
+    else if ( Match( element, KXdmProvideTimeOffset ) )
+        {
+        dataType = EDataTypeBoolean;            
+        found = ETrue;
+        }
+    // <provide-user-input>
+    else if ( Match( element, KXdmProvideUserInput ) )
+        {
+        // value is restricted, allowed values
+        // are "false", "bare", "thresholds" and "full" 
+        TPtrC8 data = aXdmNode.LeafNodeContent();
+        if ( data.CompareF( KXdmFalse )
+             && data.CompareF( KXdmBare )
+             && data.CompareF( KXdmThresholds )
+             && data.CompareF( KXdmFull ) )
+            {
+            LeaveWithErrorL( KXcapErrorEnumerationRule );
+            }
+        found = ETrue;
+        }
+    // <provide-note>
+    else if ( Match( element, KXdmProvideNote ) )
+        {
+        dataType = EDataTypeBoolean;            
+        found = ETrue;
+        }
+    // <provide-unknown-attribute>
+    else if ( Match( element, KXdmProvideUnknownAttribute ) )
+        {
+        // required attribute name
+        if ( !aXdmNode.HasAttribute( KXdmName ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+            }   
+        found = ETrue;
+        }
+    // <provide-all-attributes>
+    else if ( Match( element, KXdmProvideAllAttributes ) )
+        {
+        found = ETrue;
+        }
+    // <sub-handling>
+    else if ( Match( element, KXdmSubHandling ) )
+        {
+        found = ETrue;
+        // value is restricted, allowed values
+        // are "block", "confirm", "polite-block" and "allow" 
+        TPtrC8 data = aXdmNode.LeafNodeContent();
+        if ( data.CompareF( KXdmBlock )
+             && data.CompareF( KXdmConfirm )
+             && data.CompareF( KXdmPoliteBlock )
+             && data.CompareF( KXdmAllow ) )
+            {
+            LeaveWithErrorL( KXcapErrorEnumerationRule );
+            }
+        }
+    // urn:ietf:params:xml:ns:common-policy
+    if ( !found )
+        {
+        found = iIetfCommonPolicy->ValidateNodeL( aXdmNode );
+        if ( found )
+            {
+            SetPrefixL( aXdmNode, KXdmIetfCommonPolicyNsPrefix );  
+            }
+        }
+        
+    if ( dataType != EDataTypeUndefined )
+        {
+        // pass to the base class for data validation
+        ValidateDataL( dataType, aXdmNode );
+        }
+    return found;
+    }
+
+// ----------------------------------------------------
+// CXcapIetfPresRulesUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapIetfPresRulesUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+    
+    // name 
+    if ( Match( aXdmNodeAttr.NodeName(), KXdmName ) )
+        {       
+        // pass to base class for data validation
+        ValidateDataL( EDataTypeString, aXdmNodeAttr );    
+        }
+    // the rest are from urn:ietf:params:xml:ns:common-policy
+    else
+        {
+        iIetfCommonPolicy->ValidateAttributeL( aXdmNodeAttr );  
+        }
+     }   
+                         
+// ----------------------------------------------------
+// CXcapIetfPresRulesUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapIetfPresRulesUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+    aXdmDocument.AppendNamespaceL( KXdmIetfPresRulesNamespace, KNullDesC8 );
+    aXdmDocument.AppendNamespaceL( KXdmIetfPresRulesNamespace, KXdmIetfPresRulesNsPrefix ); // ESTI-7AY95P 
+    aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KXdmIetfCommonPolicyNsPrefix ); // ESTI-7AY95P 
+    }
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapPresenceRulesUsage/src/XcapOmaPresRulesUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,267 @@
+/*
+* 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:  CXcapOmaPresRulesUsage
+*
+*/
+
+
+
+
+#include <XdmErrors.h>
+#include <XdmDocumentNode.h>
+#include "XcapOmaPresRulesUsage.h"
+
+// Used specification
+// OMA-TS-Presence_SIMPLE_XDM-V1_0-20060110-C, 10 January 2006
+// OMA-TS-Presence_SIMPLE_XDM-V1_0-20060418-C, 18 April 2006
+
+// ----------------------------------------------------
+// CXcapOmaPresRulesUsage::CXcapOmaPresRulesUsage
+// 
+// ----------------------------------------------------
+//
+CXcapOmaPresRulesUsage::CXcapOmaPresRulesUsage( const CXdmEngine& aXdmEngine ) :
+CXcapAppUsage( aXdmEngine ),
+iIetfPresRules( NULL ),
+iIetfCommonPolicy( NULL ),
+iOmaCommonPolicy( NULL )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapOmaPresRulesUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapOmaPresRulesUsage* CXcapOmaPresRulesUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapOmaPresRulesUsage* self = new ( ELeave ) CXcapOmaPresRulesUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );	// << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapOmaPresRulesUsage::~CXcapOmaPresRulesUsage
+// 
+// ----------------------------------------------------
+//
+CXcapOmaPresRulesUsage::~CXcapOmaPresRulesUsage()
+    {
+    delete iIetfPresRules;
+    delete iIetfCommonPolicy;
+    delete iOmaCommonPolicy;
+    }
+        
+// ----------------------------------------------------
+// CXcapOmaPresRulesUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapOmaPresRulesUsage::ConstructL()
+    {
+    iIetfPresRules = CXcapAppUsage::NewL( iXdmEngine, KXdmIetfPresRulesUsageUid );
+    iIetfCommonPolicy = CXcapAppUsage::NewL( iXdmEngine, KXdmIetfCommonPolicyUsageUid );
+    iOmaCommonPolicy = CXcapAppUsage::NewL( iXdmEngine, KXdmOmaCommonPolicyUsageUid );
+    }
+
+// ----------------------------------------------------
+// CXcapOmaPresRulesUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapOmaPresRulesUsage::AUID() const
+    {
+    return TPtrC8( KXdmOmaPresRulesUsageAUID );
+    }
+                
+// ----------------------------------------------------
+// CXcapOmaPresRulesUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapOmaPresRulesUsage::ContentType() const
+    {
+    return TPtrC8( KXdmOmaPresRulesUsageContType );
+    }
+    
+// ----------------------------------------------------
+// CXcapOmaPresRulesUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapOmaPresRulesUsage::DefaultNamespace() const
+    {
+    //return TPtrC8( KXdmOmaPresRulesNamespace );
+    // NOTE the default namespace is IetfCommonPolicy
+    return TPtrC8( KXdmIetfCommonPolicyNamespace );
+    }    
+
+// ----------------------------------------------------
+// CXcapOmaPresRulesUsage::ValidateL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapOmaPresRulesUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
+    {
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+
+    TBool found ( EFalse );   
+    TDataType dataType ( EDataTypeUndefined );
+    TPtrC element = aXdmNode.NodeName();
+     
+    // <provide-willigness>
+    if ( Match( element, KXdmProvideWillingness ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <provide-network-availability>
+    else if ( Match( element, KXdmProvideNetworkAvailability ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <provide-session-participation>
+    else if ( Match( element, KXdmProvideSessionParticipation ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <provide-registration-state>
+    else if ( Match( element, KXdmProvideRegistrationState ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <provide-barring-state>
+    else if ( Match( element, KXdmProvideBarringState ) )
+        {
+        dataType = EDataTypeBoolean;
+        found = ETrue;
+        }
+    // <provide-geopriv>
+    else if ( Match( element, KXdmProvideGeopriv ) )
+        {
+        // value must be "false" or "full"
+        // 0 (false), 1 (full)
+        TPtrC8 data = aXdmNode.LeafNodeContent();
+        if ( data.CompareF( KXdmFalse )
+             && data.CompareF( KXdmFull ) )
+            {
+            LeaveWithErrorL( KXcapErrorEnumerationRule );
+            }
+        found = ETrue;
+        }
+    // <service-id>
+    else if ( Match( element, KXdmServiceId ) )
+        {
+        dataType = EDataTypeString;
+        found = ETrue;
+        }
+        
+    // NOTE the default namespace is IetfCommonPolicy
+    if ( found )
+        {
+        SetPrefixL( aXdmNode, KXdmOmaPresRulesNsPrefix );
+        }
+
+    // urn:ietf:params:xml:ns:pres-rules
+    // urn:ietf:params:xml:ns:common-policy
+    // urn:oma:xml:xdm:common-policy
+    else
+        {
+        // urn:ietf:params:xml:ns:common-policy
+        found = iIetfCommonPolicy->ValidateNodeL( aXdmNode );
+        if ( found )
+            {
+            // this means that this belongs to urn:ietf:params:xml:ns:common-policy,
+            // there may be the prefix already
+            // NOTE the default namespace is IetfCommonPolicy
+                SetPrefixL( aXdmNode, KNullDesC8 );
+                }
+        else
+            {
+            // urn:ietf:params:xml:ns:pres-rules
+            found = iIetfPresRules->ValidateNodeL( aXdmNode );
+            if ( found )
+                {
+                SetPrefixL( aXdmNode, KXdmIetfPresRulesNsPrefix );
+                }
+            else
+                {
+                // urn:oma:xml:xdm:common-policy
+                found = iOmaCommonPolicy->ValidateNodeL( aXdmNode );
+                if ( found )
+                    {
+                    SetPrefixL( aXdmNode, KXdmOmaCommonPolicyNsPrefix );
+                    }
+                }
+            }
+        }
+        
+    if ( dataType != EDataTypeUndefined )
+        {
+        // pass to the base class for data validation
+        ValidateDataL( dataType, aXdmNode );
+        }
+    return found;
+    }
+
+// ----------------------------------------------------
+// CXcapOmaPresRulesUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapOmaPresRulesUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+    
+    // there aren't any attributes in
+    // oma presence rules usage schema
+    // urn:ietf:params:xml:ns:pres-rules
+    // urn:ietf:params:xml:ns:common-policy
+    iIetfPresRules->ValidateAttributeL( aXdmNodeAttr );
+    }   
+                         
+// ----------------------------------------------------
+// CXcapOmaPresRulesUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapOmaPresRulesUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+    // NOTE the default namespace is IetfCommonPolicy
+    aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KNullDesC8 );
+    aXdmDocument.AppendNamespaceL( KXdmOmaCommonPolicyNamespace, KXdmOmaCommonPolicyNsPrefix );
+    aXdmDocument.AppendNamespaceL( KXdmOmaPresRulesNamespace, KXdmOmaPresRulesNsPrefix );
+    aXdmDocument.AppendNamespaceL( KXdmIetfPresRulesNamespace, KXdmIetfPresRulesNsPrefix );
+/*    aXdmDocument.AppendNamespaceL( KXdmOmaPresRulesNamespace, KNullDesC8 );
+    aXdmDocument.AppendNamespaceL( KXdmIetfPresRulesNamespace, KXdmIetfPresRulesNsPrefix );
+    aXdmDocument.AppendNamespaceL( KXdmIetfCommonPolicyNamespace, KXdmIetfCommonPolicyNsPrefix );*/
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapResourceListsUsage/inc/XcapResourceListsUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,102 @@
+/*
+* 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:   CXcapResourceListsUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPRESOURCELISTSUSAGE__
+#define __XCAPRESOURCELISTSUSAGE__
+
+#include "XcapAppUsage.h"
+
+
+// CLASS DECLARATION
+class CXcapResourceListsUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapResourceListsUsage*
+        */
+        static CXcapResourceListsUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapResourceListsUsage();
+        
+    public:  // From CXcapAppUsage
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;
+
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+                        
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+                        
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */        
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapResourceListsUsage( const CXdmEngine& aXdmEngine );    
+    };
+
+#endif    //__XCAPRESOURCELISTSUSAGE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapResourceListsUsage/src/XcapResourceListsUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,229 @@
+/*
+* 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:   CXcapResourceListsUsage
+*
+*/
+
+
+
+
+#include <XdmErrors.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include "XcapResourceListsUsage.h"
+
+// Used specification
+// draft-ietf-simple-xcap-list-usage-05, 7 February 2005
+// expires 8 August 2005
+
+// ----------------------------------------------------
+// CXcapResourceListsUsage::CXcapResourceListsUsage
+// 
+// ----------------------------------------------------
+//
+CXcapResourceListsUsage::CXcapResourceListsUsage( const CXdmEngine& aXdmEngine ) :
+                                            CXcapAppUsage( aXdmEngine )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapResourceListsUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapResourceListsUsage* CXcapResourceListsUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapResourceListsUsage* self = new ( ELeave ) CXcapResourceListsUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );	// << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapResourceListsUsage::~CXcapResourceListsUsage
+// 
+// ----------------------------------------------------
+//
+CXcapResourceListsUsage::~CXcapResourceListsUsage()
+    {
+    }
+        
+// ----------------------------------------------------
+// CXcapResourceListsUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapResourceListsUsage::ConstructL()
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapResourceListsUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapResourceListsUsage::AUID() const
+    {
+    return TPtrC8( KXdmResourceListsUsageAUID );
+    }
+                
+// ----------------------------------------------------
+// CXcapResourceListsUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapResourceListsUsage::ContentType() const
+    {
+    return TPtrC8( KXdmResourceListsUsageContType );
+    }
+
+// ----------------------------------------------------
+// CXcapResourceListsUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapResourceListsUsage::DefaultNamespace() const
+    {
+    return TPtrC8( KXdmResourceListsNamespace );
+    }   
+    
+// ----------------------------------------------------
+// CXcapResourceListsUsage::ValidateL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapResourceListsUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
+    {
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+     
+    TBool found ( EFalse );   
+    TDataType dataType ( EDataTypeUndefined );
+    TPtrC element = aXdmNode.NodeName();
+
+    // <resource-lists> 
+    if ( Match( element, KXdmResourceLists) )    
+        {
+        TInt count( aXdmNode.NodeCount() );
+        for ( TInt i(0); i < count; i++ )
+            {
+            // there should not be any other elements than <list>
+            if ( !Match( aXdmNode.ChileNode(i)->NodeName(), KXdmList ) )
+                {
+                LeaveWithErrorL( KXcapErrorSchemaViolation );
+                }
+            }
+        found = ETrue;
+        }
+    // <list> 
+    else if ( Match( element, KXdmList ) )    
+        {
+        found = ETrue;
+        }
+    // <entry> 
+    else if ( Match( element, KXdmEntry ) )    
+        {
+        // required attribute uri
+        if ( !aXdmNode.HasAttribute( KXdmUri ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+            }
+        found = ETrue;
+        }
+    // <entry-ref> 
+    else if ( Match( element, KXdmEntryRef ) )    
+        {
+        if ( !aXdmNode.HasAttribute( KXdmRef ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+            }
+        found = ETrue;
+        }
+    // <display-name> 
+    else if ( Match( element, KXdmDisplayName ) )    
+        {
+        dataType = EDataTypeString;
+        found = ETrue;
+        }
+        
+    if ( dataType != EDataTypeUndefined )
+        {
+        // pass to the base class for data validation
+        ValidateDataL( dataType, aXdmNode );
+        }
+    return found;
+    }
+
+// ----------------------------------------------------
+// CXcapResourceListsUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapResourceListsUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+    
+    TDataType dataType ( EDataTypeUndefined );
+    TPtrC attribute = aXdmNodeAttr.NodeName();
+        
+    // name 
+    if ( Match( attribute, KXdmName ) )
+        {
+        dataType = EDataTypeString;
+        }
+    // uri 
+    else if ( Match( attribute, KXdmUri ) )
+        {
+        dataType = EDataTypeString;
+        }
+    // ref 
+    else if ( Match( attribute, KXdmRef ) )
+        {
+        dataType = EDataTypeAnyURI;
+        }
+    // anchor
+    else if ( Match( attribute, KXdmAnchor ) )
+        {
+        dataType = EDataTypeAnyURI;
+        }   
+        
+    if ( dataType != EDataTypeUndefined )
+        {
+        // pass to base class for data validation
+        ValidateDataL( dataType, aXdmNodeAttr );
+        }   
+    }   
+                         
+// ----------------------------------------------------
+// CXcapResourceListsUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapResourceListsUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+    aXdmDocument.AppendNamespaceL( KXdmResourceListsNamespace, KNullDesC8 );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapRlsServicesUsage/inc/XcapRlsServicesUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,106 @@
+/*
+* 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:  CXcapRlsServicesUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPRLSSERVICESUSAGE__
+#define __XCAPRLSSERVICESUSAGE__
+
+#include "XcapAppUsage.h"
+
+
+// CLASS DECLARATION
+class CXcapRlsServicesUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapRlsServicesUsage*
+        */
+        static CXcapRlsServicesUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapRlsServicesUsage();
+        
+    public:  // From CXcapAppUsage
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;
+
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+        
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapRlsServicesUsage( const CXdmEngine& aXdmEngine );  
+ 
+    private:    // Data
+           
+        CXcapAppUsage*      iResourceLists;  
+    };
+
+#endif    //__XCAPRLSSERVICESUSAGE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapRlsServicesUsage/src/XcapRlsServicesUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,271 @@
+/*
+* 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:  CXcapRlsServicesUsage
+*
+*/
+
+
+
+
+#include <XdmErrors.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include "XcapRlsServicesUsage.h"
+
+// Used specification
+// OMA-RLS_XDM_Specification-V1_0-20060214-C, 14 February 2006
+
+// ----------------------------------------------------
+// CXcapRlsServicesUsage::CXcapRlsServicesUsage
+// 
+// ----------------------------------------------------
+//
+CXcapRlsServicesUsage::CXcapRlsServicesUsage( const CXdmEngine& aXdmEngine ) :
+CXcapAppUsage( aXdmEngine ),
+iResourceLists( NULL )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapRlsServicesUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapRlsServicesUsage* CXcapRlsServicesUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapRlsServicesUsage* self = new ( ELeave ) CXcapRlsServicesUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );	// << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapRlsServicesUsage::~CXcapRlsServicesUsage
+// 
+// ----------------------------------------------------
+//
+CXcapRlsServicesUsage::~CXcapRlsServicesUsage()
+    {
+    delete iResourceLists;
+    }
+        
+// ----------------------------------------------------
+// CXcapRlsServicesUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapRlsServicesUsage::ConstructL()
+    {
+    iResourceLists = CXcapAppUsage::NewL( iXdmEngine, KXdmResourceListsUsageUid );
+    }
+
+// ----------------------------------------------------
+// CXcapRlsServicesUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapRlsServicesUsage::AUID() const
+    {
+    return TPtrC8( KXdmRlsServicesUsageAUID );
+    }
+                
+// ----------------------------------------------------
+// CXcapRlsServicesUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapRlsServicesUsage::ContentType() const
+    {
+    return TPtrC8( KXdmRlsServicesUsageContType );
+    }
+
+// ----------------------------------------------------
+// CXcapRlsServicesUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapRlsServicesUsage::DefaultNamespace() const
+    {
+    return TPtrC8( KXdmRlsServicesNamespace );
+    }   
+    
+// ----------------------------------------------------
+// CXcapRlsServicesUsage::ValidateNodeL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapRlsServicesUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
+    {
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+
+    
+    TBool found( EFalse );    
+    TDataType dataType ( EDataTypeUndefined );
+    TPtrC element = aXdmNode.NodeName();
+    // <rls-services>
+    if ( Match( element, KXdmRlsServices ) )   
+        {
+        found = ETrue;
+        }
+     // <service>
+    else if ( Match( element, KXdmService ) )    
+        {
+        // required attribute uri
+        if ( !aXdmNode.HasAttribute( KXdmUri ) )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+            }
+            
+        // there should be either <resource-list> or
+        // <list> element and mandatory <packages> element
+        TBool resourcelist( EFalse );
+        TBool list( EFalse );
+        TBool packages( EFalse );
+        // go through all childs
+        TInt count( aXdmNode.NodeCount() );
+        for ( TInt i(0); i < count; i++ )
+            {
+            TPtrC childName = aXdmNode.ChileNode(i)->NodeName();
+            if ( Match( childName, KXdmResourceList ) )  
+                {
+                resourcelist = ETrue;
+                }
+            else if ( Match( childName, KXdmList ) ) 
+                {
+                list = ETrue;
+                }
+            else if ( Match( childName, KXdmPackages ) ) 
+                {
+                packages = ETrue;
+                }
+            }
+        // <resource-list> or <list>, not both
+        if ( resourcelist && list )
+            {
+            LeaveWithErrorL( KXcapErrorSchemaViolation );   
+            }
+        // each <service> must have at least one <packages> element
+        if ( !packages )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredElement );    
+            }
+        found = ETrue;
+        }
+    // <resource-list>
+    else if ( Match( element, KXdmResourceList ) )   
+        {
+        dataType = EDataTypeAnyURI;
+        found = ETrue;
+        }
+    // <packages>
+    else if ( Match( element, KXdmPackages ) )   
+        {
+        // each <packages> shall specify at least presence event package,
+        // go through all childs
+        TBool presence ( EFalse );
+        TInt count( aXdmNode.NodeCount() );
+        for ( TInt i(0); i < count; i++ )
+            {   
+            if ( Match( aXdmNode.ChileNode(i)->NodeName(), KXdmPackage ) ) 
+                {
+                TPtrC8 data = aXdmNode.ChileNode(i)->LeafNodeContent();
+                if ( !data.CompareF( KXdmPresence ) )
+                    {
+                    presence = ETrue;
+                    }
+                }
+            }
+        // check that the <package>presence<package> exists
+        if ( !presence )
+            {
+            LeaveWithErrorL( KXcapErrorMissingRequiredElementValue );   
+            }
+        found = ETrue;
+        }
+    // <package>
+    else if ( Match( element, KXdmPackage ) )   
+        {
+        dataType = EDataTypeString;
+        found = ETrue;
+        }
+    // <list> type=rl:listType from urn:ietf:params:xml:ns:resource-lists
+    // however belongs to the default namespace
+    // ( btw, there is mistake in specification example )
+    else if ( Match( element, KXdmList ) ) 
+        {
+        found = iResourceLists->ValidateNodeL( aXdmNode );
+        }
+    // <entry>,<display-name> from urn:ietf:params:xml:ns:resource-lists
+    if ( !found ) 
+        {
+        found = iResourceLists->ValidateNodeL( aXdmNode );
+        if ( found )
+            {
+            SetPrefixL( aXdmNode, KXdmResourceListsNsPrefix );   
+            }
+        }
+    if ( dataType != EDataTypeUndefined )
+        {
+        // pass to the base class for data validation
+        ValidateDataL( dataType, aXdmNode );
+        }
+    return found;
+    }
+
+// ----------------------------------------------------
+// CXcapRlsServicesUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapRlsServicesUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+    
+    // uri 
+    if ( Match( aXdmNodeAttr.NodeName(), KXdmUri ) )
+        {
+        ValidateDataL( EDataTypeAnyURI, aXdmNodeAttr );
+        }
+    // the rest are rom urn:ietf:params:xml:ns:resource-lists
+    else
+        {
+        iResourceLists->ValidateAttributeL( aXdmNodeAttr ); 
+        }
+    }   
+                         
+// ----------------------------------------------------
+// CXcapRlsServicesUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapRlsServicesUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+    aXdmDocument.AppendNamespaceL( KXdmRlsServicesNamespace, KNullDesC8 );
+    aXdmDocument.AppendNamespaceL( KXdmResourceListsNamespace, KXdmResourceListsNsPrefix );
+    }
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapSharedXDMUsage/inc/XcapSharedXDMUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,107 @@
+/*
+* 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:   CXcapSharedXDMUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPSHAREDXDMUSAGE__
+#define __XCAPSHAREDXDMUSAGE__
+
+#include "XcapAppUsage.h"
+
+
+// CLASS DECLARATION
+class CXcapSharedXDMUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapSharedXDMUsage*
+        */
+        static CXcapSharedXDMUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapSharedXDMUsage();
+        
+    public:  // From CXcapAppUsage
+       
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;
+
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+                        
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+                        
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapSharedXDMUsage( const CXdmEngine& aXdmEngine );  
+ 
+    private:    // Data
+           
+        CXcapAppUsage*      iResListUsage;  
+
+    };
+
+#endif    //__XCAPSHAREDXDMUSAGE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapSharedXDMUsage/src/XcapSharedXDMUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,180 @@
+/*
+* 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:   CXcapSharedXDMUsage
+*
+*/
+
+
+
+
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include "XcapSharedXDMUsage.h"
+
+// Used spesifications
+// OMA-TS-XDM_Core-V1_0-20051103-C, 03 November 2005
+// OMA-TS-XDM_Shared-V1_0-20051006-C, 12 June 2006
+
+// ----------------------------------------------------
+// CXcapSharedXDMUsage::CXcapSharedXDMUsage
+// 
+// ----------------------------------------------------
+//
+CXcapSharedXDMUsage::CXcapSharedXDMUsage( 
+const CXdmEngine& aXdmEngine ) : CXcapAppUsage( aXdmEngine ),
+iResListUsage( NULL )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapSharedXDMUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapSharedXDMUsage* CXcapSharedXDMUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapSharedXDMUsage* self = new ( ELeave ) CXcapSharedXDMUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );	// << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapSharedXDMUsage::~CXcapSharedXDMUsage
+// 
+// ----------------------------------------------------
+//
+CXcapSharedXDMUsage::~CXcapSharedXDMUsage()
+    {
+	delete iResListUsage;
+    }
+        
+// ----------------------------------------------------
+// CXcapSharedXDMUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapSharedXDMUsage::ConstructL()
+    {
+    iResListUsage = CXcapAppUsage::NewL( iXdmEngine, KXdmResourceListsUsageUid );
+    }
+
+// ----------------------------------------------------
+// CXcapSharedXDMUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapSharedXDMUsage::AUID() const
+    {
+    return TPtrC8( KXdmSharedXDMUsageAUID );
+    }
+                
+// ----------------------------------------------------
+// CXcapSharedXDMUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapSharedXDMUsage::ContentType() const
+    {
+    return TPtrC8( KXdmSharedXDMUsageContType );
+    }
+
+// ----------------------------------------------------
+// CXcapSharedXDMUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapSharedXDMUsage::DefaultNamespace() const
+    {
+    // we use urn:ietf:params:xml:ns:resource-lists 
+    // as a default namespace
+    return TPtrC8( KXdmResourceListsNamespace );
+    }   
+    
+// ----------------------------------------------------
+// CXcapSharedXDMUsage::ValidateNodeL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapSharedXDMUsage::ValidateNodeL( CXdmDocumentNode& aXdmNode )
+    {
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+
+    TBool found ( EFalse );    
+    TPtrC element = aXdmNode.NodeName();
+  
+    // <uriusages>
+    if ( Match( element, KXdmUriUsages ) )    
+        {
+        SetPrefixL( aXdmNode, KXdmSharedXDMUriUsageNsPrefix );
+        found = ETrue;
+        }
+    // <uriusage>
+    else if ( Match( element, KXdmUriUsage ) )    
+        {
+        SetPrefixL( aXdmNode, KXdmSharedXDMUriUsageNsPrefix );
+        found = ETrue;
+        }
+    // the rest are from urn:ietf:params:xml:ns:resource-lists
+    else
+        {
+        // do not append the namespace prefix here,
+        // since the used default namespace is
+        // urn:ietf:params:xml:ns:resource-lists
+        found = iResListUsage->ValidateNodeL( aXdmNode );
+        }
+    return found;
+    }
+
+// ----------------------------------------------------
+// CXcapSharedXDMUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapSharedXDMUsage::ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.
+
+    // this usage doesn't have any attributes,
+    // all attributes are from urn:ietf:params:xml:ns:resource-lists
+    iResListUsage->ValidateAttributeL( aXdmNodeAttr );
+   
+    }   
+                         
+// ----------------------------------------------------
+// CXcapSharedXDMUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapSharedXDMUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+    // we use urn:ietf:params:xml:ns:resource-lists 
+    // as a default namespace
+    aXdmDocument.AppendNamespaceL( KXdmResourceListsNamespace, KNullDesC8 );
+    aXdmDocument.AppendNamespaceL( KXdmSharedXDMUriUsageNamespace, KXdmSharedXDMUriUsageNsPrefix );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapTestAppUsage/inc/XcapTestAppUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,114 @@
+/*
+* 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:   CXcapTestAppUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPTESTAPPUSAGE__
+#define __XCAPTESTAPPUSAGE__
+
+#include "XcapAppUsage.h"
+
+// CONSTANTS
+// Define here literals for element names if they
+// aren't already defined in AppUsageDef.h
+// _LIT( KExample,                     "example" );
+// _LIT( KExampleElement,              "example-element" );
+// _LIT( KExampleElement2,             "example-element2" );
+// _LIT( KExampleElement3,             "example-element3" );
+// _LIT( KExampleAttr1,                "exampleAttr1" );
+// _LIT( KExampleAttr2,                "exampleAttr2" );
+
+// CLASS DECLARATION
+class CXcapTestAppUsage : public CXcapAppUsage
+    {
+    public:
+        
+        /**
+        * Symbian OS constructor
+        * @param TXcapAppUsageParams Parameters
+        * @return CXcapTestAppUsage*
+        */
+        static CXcapTestAppUsage* NewL( const TXcapAppUsageParams& aParameters );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapTestAppUsage();
+        
+    public:  //From CXcapAppUsage
+    
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        TPtrC8 AUID() const;
+        
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        TPtrC8 ContentType() const;
+        
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        TPtrC8 DefaultNamespace() const;
+                        
+        /**
+        * Validate the node in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmDocumentNode& reference to the node
+        * @return ETrue, if the node belongs to the appusage's namespace
+        */
+        TBool ValidateNodeL( CXdmDocumentNode& aXdmNode );
+                        
+        /**
+        * Validate the attribute in the parameter
+        * Leaves with system wide error codes or
+        * with error defined in XdmErrors.h
+        * @param CXdmNodeAttribute& reference to the attribute
+        */
+        void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param CXdmDocument& reference to the document        
+        */
+        void AddNamespaceInformationL( CXdmDocument& aXdmDocument );
+        
+    private:
+        
+        /**
+        * Second phase construction
+        */
+        void ConstructL();
+        
+        /**
+        * Prohibit copy costructor
+        */      
+        CXcapTestAppUsage( const CXdmEngine& aXdmEngine ); 
+     
+    private:    // Data
+       
+    };
+
+#endif    //__XCAPTESTAPPUSAGE__
+            
+   // End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/XcapTestAppUsage/src/XcapTestAppUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,203 @@
+/*
+* 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:   CXcapTestAppUsage
+*
+*/
+
+
+
+
+#include "XcapTestAppUsage.h"
+
+// ----------------------------------------------------
+// CXcapTestAppUsage::CXcapTestAppUsage
+// 
+// ----------------------------------------------------
+//
+CXcapTestAppUsage::CXcapTestAppUsage( const CXdmEngine& aXdmEngine ) :
+                                      CXcapAppUsage( aXdmEngine )
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapTestAppUsage::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapTestAppUsage* CXcapTestAppUsage::NewL( const TXcapAppUsageParams& aParameters )
+    {
+    CXcapTestAppUsage* self = new ( ELeave ) CXcapTestAppUsage( aParameters.iXdmEngine );
+    CleanupStack::PushL( self );    // << self
+    self->ConstructL();
+    CleanupStack::Pop( self );      // >> self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapTestAppUsage::~CXcapTestAppUsage
+// 
+// ----------------------------------------------------
+//
+CXcapTestAppUsage::~CXcapTestAppUsage()
+    {
+    }
+        
+// ----------------------------------------------------
+// CXcapTestAppUsage::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapTestAppUsage::ConstructL()
+    {
+    }
+            
+// ----------------------------------------------------
+// CXcapTestAppUsage::AUID
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapTestAppUsage::AUID() const
+    {
+    return TPtrC8( KXdmTestAppUsageAUID );
+    }
+
+// ----------------------------------------------------
+// CXcapTestAppUsage::ContentType
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapTestAppUsage::ContentType() const
+    {
+    return TPtrC8( KXdmTestAppUsageContType );
+    }
+
+// ----------------------------------------------------
+// CXcapTestAppUsage::DefaultNamespace
+// 
+// ----------------------------------------------------
+//
+TPtrC8 CXcapTestAppUsage::DefaultNamespace() const
+    {
+    return TPtrC8( KXdmTestAppUsageDefaultNamespace );
+    }   
+    
+// ----------------------------------------------------
+// CXcapTestAppUsage::ValidateNodeL
+// 
+// ----------------------------------------------------
+//
+TBool CXcapTestAppUsage::ValidateNodeL( CXdmDocumentNode& /*aXdmNode*/ )
+    {
+    // This method is called by base class for each element
+    // in document, here we have to declare every element, check element 
+    // datatype, restrictions for values and also do all checking that concerns  
+    // the structure of the element. If the datatype is some of
+    // the common datatypes defined in xcapappusage.h, the node
+    // can pe passed to the base class for value validation.
+    // If the node belongs to this namespace, the return value
+    // should be true, false otherwise.
+
+
+    // TBool found ( EFalse );   
+    // TDataType dataType ( EDataTypeUndefined );
+    // TPtrC element = aXdmNode.NodeName();
+     
+    // <example-element>
+    // if ( Match( element, KExampleElement ) )
+        // {
+        // supported data types are defined in AppUsageDef
+        // dataType = EDataTypeBoolean;
+        // found = ETrue;
+        // }
+    // <example-element2>
+    // else if ( Match( element, KExampleElement2 ) )
+        // {
+           // required attribute attribute
+           // if ( !aXdmNode.HasAttribute( KAttribute ) )
+           // {
+           // LeaveWithErrorL( KXcapErrorMissingRequiredAttribute );
+           // }
+        // found = ETrue;
+        // }   
+    // <example-element3>     
+    // else if ( Match( element, KExampleElement3 ) )
+        // {
+        // TInt count( aXdmNode.NodeCount() );
+        // for ( TInt i(0); i < count; i++ )
+           // {
+            // there should not be any other elements than <example>
+           // if ( !Match( aXdmNode.ChileNode(i)->NodeName(), KExample ) )
+               // {
+               // LeaveWithErrorL( KXcapErrorSchemaViolation );
+               // }
+            // }
+        // found = ETrue; 
+        //  }
+        
+   // if ( dataType != EDataTypeUndefined )
+        // {
+        // pass to the base class for data validation
+        // ValidateDataL( dataType, aXdmNode );
+        // }
+    // return found;
+     
+    return EFalse;
+    }
+
+// ----------------------------------------------------
+// CXcapTestAppUsage::ValidateAttributeL
+// 
+// ----------------------------------------------------
+//
+void CXcapTestAppUsage::ValidateAttributeL( const CXdmNodeAttribute& /*aXdmNodeAttr*/ )
+    {
+    // This method is called by base class for each attribute
+    // in document, here we have to define data types
+    // for attributes, and pass them to the base class
+    // for the actual data checking.   
+    
+    // TDataType dataType ( EDataTypeUndefined );
+    // TPtrC attribute = aXdmNodeAttr.NodeName();
+        
+    // exampleAttr1 
+    // if ( Match( attribute, KExampleAttr1 ) )
+        // {
+        // dataType = EDataTypeString;
+        // }
+    // exampleAttr2 
+    // else if ( Match( attribute, KExampleAttr2 ) )
+        // {
+        // dataType = EDataTypeString;
+        // }
+        
+    // if ( dataType != EDataTypeUndefined )
+        // {
+        // pass to base class for data validation
+        // ValidateDataL( dataType, aXdmNodeAttr );
+        // }   
+    }
+    
+// ----------------------------------------------------
+// CXcapTestAppUsage::AddNamespaceInformationL
+// 
+// ----------------------------------------------------
+//
+void CXcapTestAppUsage::AddNamespaceInformationL( CXdmDocument& aXdmDocument )
+    {
+    // default namespace prefix should be empty
+    aXdmDocument.AppendNamespaceL( KXdmTestAppUsageDefaultNamespace, KNullDesC8 );
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/eabi/XcapAppUsageU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,32 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+	_ZN13CXcapAppUsage4NewLERK10CXdmEnginei @ 2 NONAME
+	_ZN13CXcapAppUsage8ValidateER12CXdmDocumenti @ 3 NONAME
+	_ZN13CXcapAppUsage8ValidateER16CXdmDocumentNodeP17MXcapUriInterfacei @ 4 NONAME
+	_ZTI13CXcapAppUsage @ 5 NONAME
+	_ZTI18CXcapPocGroupUsage @ 6 NONAME
+	_ZTI19CXcapDirectoryUsage @ 7 NONAME
+	_ZTI19CXcapSharedXDMUsage @ 8 NONAME
+	_ZTI20CXcapCapabilityUsage @ 9 NONAME
+	_ZTI21CXcapRlsServicesUsage @ 10 NONAME
+	_ZTI22CXcapOmaPresRulesUsage @ 11 NONAME
+	_ZTI23CXcapIetfPresRulesUsage @ 12 NONAME
+	_ZTI23CXcapPocUserAccessUsage @ 13 NONAME
+	_ZTI23CXcapResourceListsUsage @ 14 NONAME
+	_ZTI25CXcapOmaCommonPolicyUsage @ 15 NONAME
+	_ZTI26CXcapIetfCommonPolicyUsage @ 16 NONAME
+	_ZTI7CXcapC4 @ 17 NONAME
+	_ZTV13CXcapAppUsage @ 18 NONAME
+	_ZTV18CXcapPocGroupUsage @ 19 NONAME
+	_ZTV19CXcapDirectoryUsage @ 20 NONAME
+	_ZTV19CXcapSharedXDMUsage @ 21 NONAME
+	_ZTV20CXcapCapabilityUsage @ 22 NONAME
+	_ZTV21CXcapRlsServicesUsage @ 23 NONAME
+	_ZTV22CXcapOmaPresRulesUsage @ 24 NONAME
+	_ZTV23CXcapIetfPresRulesUsage @ 25 NONAME
+	_ZTV23CXcapPocUserAccessUsage @ 26 NONAME
+	_ZTV23CXcapResourceListsUsage @ 27 NONAME
+	_ZTV25CXcapOmaCommonPolicyUsage @ 28 NONAME
+	_ZTV26CXcapIetfCommonPolicyUsage @ 29 NONAME
+	_ZTV7CXcapC4 @ 30 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/group/XcapAppUsage.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  XcapAppUsage.mmp
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                                  xcapappusage.dll
+TARGETTYPE                              PLUGIN
+UID                                     0x10009D8D 0x10207416
+CAPABILITY                              CAP_ECOM_PLUGIN
+VENDORID                                VID_DEFAULT
+
+SOURCEPATH                              ../src
+SOURCE                                  XcapAppUsage.cpp
+
+START RESOURCE                          10207416.rss
+    TARGET                              xcapappusage.rsc                                                                
+END
+
+//Capability application usage
+SOURCEPATH                              ../XcapCapabilityUsage/src
+SOURCE                                  XcapCapabilityUsage.cpp
+
+//Directory application usage
+SOURCEPATH                              ../XcapDirectoryUsage/src
+SOURCE                                  XcapDirectoryUsage.cpp
+
+//PocGroup application usage
+SOURCEPATH                              ../XcapPocGroupUsage/src
+SOURCE                                  XcapPocGroupUsage.cpp
+
+//PocUserAccessPolicy application usage
+SOURCEPATH                              ../XCapPocUserAccessUsage/src
+SOURCE                                  XcapPocUserAccessUsage.cpp
+
+// SharedXDM application usage
+SOURCEPATH                              ../XcapSharedXDMUsage/src
+SOURCE                                  XcapSharedXDMUsage.cpp
+
+//RlsServices application usage
+SOURCEPATH                              ../XcapRlsServicesUsage/src
+SOURCE                                  XcapRlsServicesUsage.cpp
+
+//ResourceLists application usage
+SOURCEPATH                              ../XcapResourceListsUsage/src
+SOURCE                                  XcapResourceListsUsage.cpp
+
+//CommonPolicyCaps application usage
+SOURCEPATH                              ../XCapCommonPolicyCapsUsage/src
+SOURCE                                  XcapOmaCPUsage.cpp
+SOURCE                                  XcapIetfCPUsage.cpp
+
+// PresenceRules application usage
+SOURCEPATH                              ../XcapPresenceRulesUsage/src
+SOURCE                                  XcapIetfPresRulesUsage.cpp
+SOURCE                                  XcapOmaPresRulesUsage.cpp
+
+// Example application usage
+// SOURCEPATH                              ../XcapTestAppUsage/src
+// SOURCE                                  XcapTestAppUsage.cpp
+
+// PRES-CONTENT STARTS
+SOURCEPATH                              ../XcapC4/src
+SOURCE                                  XcapC4.cpp
+// PRES-CONTENT ENDS
+USERINCLUDE                             ../inc
+USERINCLUDE                             ../../inc
+USERINCLUDE                             ../XcapCapabilityUsage/inc
+USERINCLUDE                             ../XcapDirectoryUsage/inc
+USERINCLUDE                             ../XcapPocGroupUsage/inc
+USERINCLUDE                             ../XCapPocUserAccessUsage/inc
+USERINCLUDE                             ../XcapSharedXDMUsage/inc
+USERINCLUDE                             ../XcapRlsServicesUsage/inc
+USERINCLUDE                             ../XcapResourceListsUsage/inc
+USERINCLUDE                             ../XCapCommonPolicyCapsUsage/inc
+USERINCLUDE                             ../XcapPresenceRulesUsage/inc
+// USERINCLUDE                             ../XcapTestAppUsage/inc
+
+USERINCLUDE                             ../../../../inc
+// PRES-CONTENT STARTS
+USERINCLUDE                             ../XcapC4/inc
+// PRES-CONTENT ENDS
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE                           /epoc32/include/ecom
+SYSTEMINCLUDE                           ../../../../inc
+
+LIBRARY                                 ecom.lib
+LIBRARY                                 euser.lib
+LIBRARY                                 XdmEngine.lib
+LIBRARY                                 centralrepository.lib
+
+DEBUGLIBRARY                            efsrv.lib
+DEBUGLIBRARY                            flogger.lib
+
+
+
+#if defined( ARMCC )
+    DEFFILE ../eabi/ 
+#elif defined ( WINSCW )
+    deffile ../BWINSCW/ 
+#elif defined (WINS )
+    deffile ../BWINS/ 
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  XcapAppUsage bld.inf
+*
+*/
+
+
+
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_EXPORTS
+//--------------------
+
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+
+XcapAppUsage.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/inc/XcapAppUsage.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,498 @@
+/*
+* 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:  CXcapAppUsage
+*
+*/
+
+
+
+
+#ifndef __XCAPAPPUSAGE__
+#define __XCAPAPPUSAGE__
+
+// INCLUDES
+#include <ecom.h>
+
+#include <XdmEngine.h>
+#include <XdmProtocolUidList.h>
+#include "XcapAppUsageDef.h"
+
+// CONSTANTS
+#ifdef _DEBUG
+_LIT( KXdmAppUsageLogDir,                          "Xdm" );
+_LIT( KXdmAppUsageLogFile,                         "XcapAppUsage.txt" );
+const TInt KAppUsageLogBufferMaxSize                = 2000;
+#endif
+
+_LIT( KXdmDefaultNsAttrName, "xmlns");
+_LIT( KXdmNonDefaultNsAttrName, "xmlns:");
+const TInt KXdmMaxPrefixLength = 10;
+
+// FORWARD DECLARATIONS
+class CXdmDocument;
+class MXcapUriInterface;
+
+// NOTE
+// If _NAMESPACES_TO_NODE_SELECTOR flag is defined, used namespaces will be added to the node selector
+// when updating partial documents.
+// The default namespace of the usage will not be added.
+#define _NAMESPACES_TO_NODE_SELECTOR
+
+// If _ADD_NAMESPACE_ATTRIBUTES flag is defined, namespace information is
+// added as an node atttribute when updating partial documents.
+// The default namespace of the usage will not be added.
+#define _ADD_NAMESPACE_ATTRIBUTES
+
+/**
+* A helper class for  parameter passing from
+* the XCAP protocol to the application usage
+*
+* NOTE: There will most probably be more than one parameter!
+*
+*/
+class TXcapAppUsageParams
+    {
+    public:
+        
+        /**
+        * @param CXdmEngine& XDM Engine
+        * @return TXcapAppUsageParams
+        */
+        TXcapAppUsageParams( const CXdmEngine& aXdmEngine ) :
+                             iXdmEngine( aXdmEngine ){}
+    
+    public:
+    
+        const CXdmEngine&    iXdmEngine;
+    };
+
+// CLASS DECLARATION
+/**
+* Application usage base class
+*/
+class CXcapAppUsage : public CBase
+    {
+    public:
+
+        /**
+        * Symbian OS constructor
+        * @param aXdmEngine XdmEngine reference
+        * @param aDocumentType Type of the document
+        * @return CXcapAppUsage*
+        * REMOVE THIS WHEN USAGE IN ENGINE CHANGED!!!
+        */
+        static CXcapAppUsage* NewL( const CXdmEngine& aXdmEngine,
+                                    const TXdmDocType aDocumentType );
+                                    
+        /**
+        * Symbian OS constructor
+        * @param aXdmEngine XdmEngine reference
+        * @param aDocumentType Type of the document
+        * @return CXcapAppUsage*
+        */
+        IMPORT_C CXcapAppUsage* NewL( const CXdmEngine& aXdmEngine,
+                                    const TInt aDocumentType );
+        
+        /**
+        * Destructor
+        */
+        virtual ~CXcapAppUsage();
+    
+        /**
+        * Validate the document in the parameter.
+        * Calls ValidateNodeL( aXdmNode ) method from derived class
+        * for each node in document and ValidateAttributeL( aXdmNodeAttr )
+        * for each attribute in document. If the document is outgoing, 
+        * calls also AddNamespaceInformationL method from derived class.
+        * @param aXdmDocument document reference
+        * @param aAddNamespaces if true, the namespaces will be added
+        * @return KErrNone or error code.
+        */
+        IMPORT_C TInt Validate( CXdmDocument& aXdmDocument, TBool aAddNamespaces ) ;
+                                 
+        /**
+        * Validate the node in the parameter.
+        * Calls ValidateNodeL( aXdmNode ) method from derived class for 
+        * current node and it's descendants and ValidateAttributeL( aXdmNodeAttr )
+        * for each attribute. Stores the uri of the node.
+        * @param aXdmNode node reference
+        * @param TBool aIsGetOrDelete indication of http get or delete
+        * @return KErrNone or error code.
+        */
+        IMPORT_C TInt Validate( CXdmDocumentNode& aXdmNode, 
+                                MXcapUriInterface* aUriInterface,
+                                TBool aIsGetOrDelete ) ;
+                                                     
+    
+    
+    public:  // Application Usage API
+        
+        /**
+        * AUID for this usage
+        * @return AUID
+        */
+        virtual TPtrC8 AUID() const = 0;
+           
+        /**
+        * MIME type for this usage
+        * @return MIME type
+        */
+        virtual TPtrC8 ContentType() const = 0;
+        
+        /**
+        * Default namespace for this usage
+        * @return Default namespace definition
+        */
+        virtual TPtrC8 DefaultNamespace() const = 0;
+        
+        /**
+        * Validate the node in the parameter
+        * This method is called by base class for each node
+        * in document, here we have to check element datatype,
+        * restrictions for values and also do all checking that concerns  
+        * the structure of the element. If the datatype is some of
+        * the common datatypes defined in xcapappusage.h, the node
+        * can pe passed to the base class for value validation.
+        * @param CXdmDocumentNode& node reference
+        * @return True, if the node belongs to the current namespace
+        */
+        virtual TBool ValidateNodeL( CXdmDocumentNode& aXdmNode ) = 0;
+        
+        /**
+        * Validate the attribute in the parameter
+        * This method is called by base class for each attribute
+        * in document, here we have to define data types
+        * for attributes, and pass them to the base class
+        * for the actual data checking.
+        * @param aXdmNodeAttr attribute reference
+        */
+        virtual void ValidateAttributeL( const CXdmNodeAttribute& aXdmNodeAttr ) = 0;
+          
+        /**
+        * Add namespaces and namespace prefixes used in document
+        * @param aXdmDocument document reference
+        */
+        virtual void AddNamespaceInformationL( CXdmDocument& aXdmDocument ) = 0;
+                              
+                              
+    protected:
+        
+        /**
+        * C++ constructor
+        */
+        CXcapAppUsage( const CXdmEngine& aXdmEngine );
+    
+        /**
+        * Validates basic data types
+        * @param aDataType type of the data
+        * @param aXdmNode node reference
+        */
+        void ValidateDataL ( TDataType aDataType, CXdmDocumentNode& aXdmNode );
+       
+       /**
+        * Validates basic data types
+        * @param aDataType type of the data
+        * @param aXdmNodeAttr attribute reference
+        */
+        void ValidateDataL ( TDataType aDataType, const CXdmNodeAttribute& aXdmNodeAttr );
+        
+        /**
+        * If outgoing document, adds namespacePrefix 
+        * to the node in parameter
+        * @param aXdmNode node reference
+        * @param aPrefix namespace prefix
+        */
+        void SetPrefixL( CXdmDocumentNode& aXdmNode, const TDesC8& aPrefix );
+        
+        /**
+        * Helper method for string comparison
+        * @param aLeft first string
+        * @param aRight second string
+        * @return ETrue, if the strings are equal
+        */
+        TBool Match( const TDesC& aLeft, const TDesC& aRight );
+        
+        /**
+        * Helper method for string comparison
+        * @param aLeft first string
+        * @param aRight second string
+        * @return ETrue, if the strings are equal
+        */
+        TBool Match( const TDesC8& aLeft, const TDesC8& aRight );
+        
+        /**
+        * To be used when an error occurs, however if the node is
+        * for http get or delete request, this do not leave
+        * @param aErrorCode function will leave with this error code
+        */
+        void LeaveWithErrorL( TInt aErrorCode );
+        
+#ifdef _DEBUG        
+        /**
+        * Writes logs to file.
+        */
+        void WriteToLog( TRefByValue<const TDesC8> aFmt,... );
+#endif
+    
+    private:
+        
+        /**
+        * Validate the document in the parameter.
+        * @param aXdmDocument document reference
+        */
+        void DoValidateL( CXdmDocument& aXdmDocument ) ;
+        
+        /**
+        * Validate the node in the parameter. 
+        * @param aXdmNode node reference
+        */
+        void DoValidateL( CXdmDocumentNode& aXdmNode ) ;
+        
+        /**
+        * Validates basic data types
+        * @param aDataType type of the data
+        * @param aData validated data
+        */
+        void ValidateDataL ( TDataType aDataType, TDesC8& aData );
+        
+        /**
+        * Updates member variables for used namespaces
+        * @param aPrefix prefix of the namespace
+        */        
+        void AddUsedNamespace( const TDesC8& aPrefix ) ;
+
+        /**
+        * Resets member variables for used namespaces
+        */
+        void ResetUsedNamespaces( ); 
+        
+        /**
+        * Appends namespace information to the node's uri interface. 
+        * Called if _NAMESPACES_TO_NODE_SELECTOR defined.
+        * @param aUriInterface interface for storing the uri
+        */
+        void AppendUsedNamespacesL( MXcapUriInterface* aUriInterface ); 
+        
+        /**
+        * Creates namespace attribute for the node. 
+        * Called if _ADD_NAMESPACE_ATTRIBUTES is defined
+        * and validating partial document.
+        * @param aXdmNode node for storing the uri
+        */
+        void CreateNamespaceAttributesL( CXdmDocumentNode& aXdmNode, MXcapUriInterface* aUriInterface );
+           
+        /**
+        * Removes namespace attributes from the node
+        * and it's child nodes
+        * @param aXdmNode 
+        */
+        void RemoveNamespaceAttributesL( CXdmDocumentNode& aXdmNode ); 
+        
+        /**
+        * Adds namespace attributes that are used in 
+        * partial document
+        * @param aXdmNode 
+        */
+        void AppendNamespaceAttributesL( CXdmDocumentNode& aXdmNode ) ;
+        
+        /**
+        * Creates namespace attribute for node
+        * @param aXdmNode 
+        * @param aPrefix prefix of the namespace
+        * @param aNamespace namespace definition
+        */
+        void CreateNamespaceAttributeL( CXdmDocumentNode& aXdmNode, const TDesC8& aPrefix, const TDesC8& aNamespace );
+        
+        
+        /**
+        * Goes through all nodes and checks if 
+        * default namespace is used in document fragment
+        * the namespace given in parameter
+        * @param aXdmNode 
+        * @return ETrue or EFalse
+        */
+        TBool DefaultNamespaceUsed( CXdmDocumentNode& aXdmNode );
+        
+    protected:  // Data
+    
+        CXdmEngine&                 iXdmEngine;
+       
+    private:  // Data
+    
+        TBool                       iAddNamespaces;
+        TBool                       iNsToNodeSelector;
+        TBool                       iAddNsAttributes;
+        TBool                       iIsGetOrDelete;
+        TUid                        iDestructorKey;
+		// Variables for used namespaces
+		// Add new one here if needed
+        TBool iRL;
+        TBool iCR;
+        TBool iCP ;
+        TBool iPR;
+        TBool iLS;
+        TBool iPOC;
+        TBool iOPR;
+        TBool iRLS;
+        TBool iOU;
+    // add new prefix definitions here 
+
+
+    };
+
+
+// ----------------------------------------------------
+// CXcapAppUsage::NewL
+// Create a new application usage implementation
+// REMOVE THIS WHEN USAGE IN ENGINE CHANGED!!!
+// ----------------------------------------------------
+//
+inline CXcapAppUsage* CXcapAppUsage::NewL( const CXdmEngine& aXdmEngine,
+                                           const TXdmDocType aDocumentType )
+    {
+    TAny* ptr = NULL;
+    TXcapAppUsageParams params( aXdmEngine );
+    switch( aDocumentType )
+        {
+        case EXdmCapabilities:
+            {
+            TUid KDefaultImplementationUid = { 0x10207418 };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+        case EXdmDirectory:
+            {
+            TUid KDefaultImplementationUid = { 0x10207419 };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+        case EXdmTestDocType:
+            {
+            TUid KDefaultImplementationUid = { 0x1020741A };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+        case EXdmPoCGroup:
+            {
+            TUid KDefaultImplementationUid = { 0x1020741B };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+        case EXdmPoCUserAccessPolicy:
+            {
+            TUid KDefaultImplementationUid = { 0x1020741C };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+        case EXdmSharedXdm:
+            {
+            TUid KDefaultImplementationUid = { 0x1020741D };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+       case EXdmRlsServices:
+            {
+            TUid KDefaultImplementationUid = { 0x1020741E };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+      case EXdmResourceLists:
+            {
+            TUid KDefaultImplementationUid = { 0x10275080 };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+      case EXdmIetfCommonPolicy:
+            {
+            TUid KDefaultImplementationUid = { 0x10275081 };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+      case EXdmOmaCommonPolicy:
+            {
+            TUid KDefaultImplementationUid = { 0x10275082 };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+      case EXdmIetfPresenceRules:
+            {
+            TUid KDefaultImplementationUid = { 0x10275083 };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+      case EXdmOmaPresenceRules:
+            {
+            TUid KDefaultImplementationUid = { 0x102750AB };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                   KDefaultImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params ) );
+            }
+            break;
+// PRES-CONTENT STARTS
+      case EXdmPresContent:
+            {
+            TUid KDefaultImplementationUid = { 0x20028701 };
+            TRAPD( error, ptr = REComSession::CreateImplementationL( 
+                KDefaultImplementationUid,
+                _FOFF( CXcapAppUsage, iDestructorKey ),
+               ( TAny* )&params ) );
+            }
+            break;
+// PRES-CONTENT ENDS
+        default:
+            User::Leave( KErrNotSupported );
+        }
+    return reinterpret_cast<CXcapAppUsage*>( ptr );
+    }
+    
+    
+#endif          //__XCAPAPPUSAGE__
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/inc/XcapAppUsageDef.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,254 @@
+/*
+* 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:  XcapAppUsage enumerations
+*
+*/
+
+
+
+
+#ifndef __XCAPAPPUSAGEDEF__
+#define __XCAPAPPUSAGEDEF__
+
+// Supported data types    
+enum TDataType
+    {
+    EDataTypeUndefined = 0,
+    EDataTypeString,
+    EDataTypeNonNegativeInteger,
+    EDataTypeAnyURI,
+    EDataTypeDateTime,
+    EDataTypeBoolean,
+    EDataTypeToken,
+    EDataTypeEmpty
+    };
+    
+// AUIDs
+_LIT8( KXdmResourceListsUsageAUID,         "/resource-lists/" );
+_LIT8( KXdmCapabilityUsageAUID,            "/xcap-caps/" );
+_LIT8( KXdmDirectoryUsageAUID,             "/org.openmobilealliance.xcap-directory/" );
+_LIT8( KXdmIetfCommonPolicyUsageAUID,      "/policy-capabilities/" );
+_LIT8( KXdmOmaCommonPolicyUsageAUID,       "/org.openmobilealliance.policy-capabilities/" );
+_LIT8( KXdmPocUserAccessUsageAUID,         "/org.openmobilealliance.poc-rules/" );
+_LIT8( KXdmIetfPresRulesUsageAUID,         "/pres-rules/" );
+_LIT8( KXdmRlsServicesUsageAUID,           "/rls-services/" );
+_LIT8( KXdmSharedXDMUsageAUID,             "/resource-lists/" );
+_LIT8( KXdmOmaPresRulesUsageAUID,          "/org.openmobilealliance.pres-rules/" );
+_LIT8( KXdmPocGroupUsageAUID,              "/org.openmobilealliance.poc-groups/" );
+// add new AUID definitions here
+//_LIT8( KXdmTestAppUsageAUID,               "/org.foo.bar/" );
+// PRES-CONTENT starts
+_LIT8( KXdmPresContentAUID,                "/org.openmobilealliance.pres-content/" );
+// PRES-CONTENT ends
+
+// ContentTypes
+_LIT8( KXdmResourceListsUsageContType,     "application/resource-lists+xml" );
+_LIT8( KXdmCapabilityUsageContType,        "application/xcap-caps+xml" );
+_LIT8( KXdmDirectoryUsageContType,         "application/oma-directory+xml" );
+_LIT8( KXdmIetfCommonPolicyUsageContType,  "application/policy-caps+xml" );
+_LIT8( KXdmOmaCommonPolicyUsageContType,   "application/policy-caps+xml" );
+_LIT8( KXdmSharedXDMUsageContType,         "application/resource-lists+xml" );
+_LIT8( KXdmIetfPresRulesUsageContType,     "application/auth-policy+xml" );
+_LIT8( KXdmPocUserAccessUsageContType,     "application/auth-policy+xml" );
+_LIT8( KXdmOmaPresRulesUsageContType,      "application/auth-policy+xml" );
+_LIT8( KXdmRlsServicesUsageContType,       "application/rls-services+xml" );
+_LIT8( KXdmPocGroupUsageContType,          "application/vnd.oma.poc.groups+xml" );
+// add new content types here
+//_LIT8( KXdmTestAppUsageContType,           "application/test-type+xml" );
+// PRES-CONTENT starts
+_LIT8( KXdmPresContentContType,            "application/vnd.oma.pres-content+xml" );
+_LIT8( KXdmPresContentContTypeOld,         "application/vnd.oma.content+xml" );
+// PRES-CONTENT ends
+
+// Namespaces
+_LIT8( KXdmResourceListsNamespace,         "urn:ietf:params:xml:ns:resource-lists" );
+_LIT8( KXdmCapabilityNamespace,            "urn:ietf:params:xml:ns:xcap-caps" );
+_LIT8( KXdmDirectoryNamespace,             "urn:oma:params:xml:ns:xcap-directory" );
+_LIT8( KXdmIetfCommonPolicyNamespace,      "urn:ietf:params:xml:ns:common-policy" );
+_LIT8( KXdmOmaCommonPolicyNamespace,       "urn:oma:xml:xdm:common-policy" );
+_LIT8( KXdmOmaPresRulesNamespace,          "urn:oma:xml:prs:pres-rules" );
+_LIT8( KXdmIetfPresRulesNamespace,         "urn:ietf:params:xml:ns:pres-rules" );
+_LIT8( KXdmRlsServicesNamespace,           "urn:ietf:params:xml:ns:rls-services" );
+_LIT8( KXdmSharedXDMUriUsageNamespace,     "urn:oma:params:xml:ns:resource-list:oma-uriusage" );
+_LIT8( KXdmPocUserAccessNamespace,         "urn:oma:xml:poc:poc-rules" );
+_LIT8( KXdmPocGroupNamespace,              "urn:oma:xml:poc:list-service" );
+// add new namespace definitions here
+// PRES-CONTENT starts
+_LIT8( KXdmPresContentNamespace,           "urn:oma:xml:prs:pres-content" );
+// PRES-CONTENT ends
+
+// Namespace prefixes
+_LIT8( KXdmSharedXDMUriUsageNsPrefix,       "ou" );
+_LIT8( KXdmResourceListsNsPrefix,           "rl" );
+_LIT8( KXdmIetfCommonPolicyNsPrefix,        "cr" );
+_LIT8( KXdmOmaCommonPolicyNsPrefix,         "ocp" );
+_LIT8( KXdmIetfPresRulesNsPrefix,           "pr" );
+_LIT8( KXdmTestAppUsageDefaultNamespace,    "ta" );
+_LIT8( KXdmPocUserAccessNsPrefix,           "poc" );
+_LIT8( KXdmOmaPresRulesNsPrefix,            "opr" );
+_LIT8( KXdmRlsServicesNsPrefix,             "rls" );
+_LIT8( KXdmPocGroupNsPrefix,                "ls" );
+// add new namespace prefix definitions here
+
+// Common literals
+_LIT( KXdmAuid,                             "auid" );
+_LIT( KXdmUri,                              "uri" );
+_LIT( KXdmEtag,                             "etag" );
+_LIT( KXdmName,                             "name" );
+_LIT( KXdmRef,                              "ref" );
+_LIT( KXdmUse,                              "use" );
+_LIT( KXdmRuleset,                          "ruleset" );
+_LIT( KXdmEntry,                            "entry" );
+_LIT( KXdmEntity,                           "entity" );
+_LIT( KXdmId,                               "id" );
+_LIT( KXdmAnyIdentity,                      "any-identity" );
+_LIT( KXdmIdentity,                         "identity" );
+_LIT( KXdmDomain,                           "domain" );
+_LIT( KXdmAnc,                              "anc" );
+_LIT( KXdmDisplayName,                      "display-name" );
+_LIT( KXdmAnchor,                           "anchor" );
+_LIT( KXdmExternal,                         "external" );
+_LIT(  KXdmList,                            "list" );
+_LIT(  KXdmServiceId,                       "service-id" );
+_LIT8( KXdmZero,                            "0" );
+_LIT8( KXdmOneNbr,                          "1" );
+_LIT8( KXdmTrue,                            "true" );
+_LIT8( KXdmFalse,                           "false");
+_LIT8( KXdmFull,                            "full" );
+_LIT8( KXdmAllow,                           "allow" );
+_LIT8( KXdmBlock,                           "block" );
+
+// Literals for capability
+_LIT( KXdmExtensions,                       "extensions" );
+_LIT( KXdmExtension,                        "extension" );
+_LIT( KXdmAuids,                            "auids" );
+_LIT( KXdmNamespaces,                       "namespaces" );
+_LIT( KXdmNamespace,                        "namespace");
+
+// Literals for directory
+_LIT( KXdmXcapDirectory,                    "xcap-directory" );
+_LIT( KXdmFolder,                           "folder" );
+_LIT( KXdmErrorCode,                        "error-code" );
+_LIT( KXdmLastModified,                     "last-modified" );
+_LIT( KXdmSize,                             "size" );
+
+// Literals for presence
+_LIT( KXdmServiceUriScheme,                "service-uri-scheme" );
+_LIT( KXdmClass,                           "class" );
+_LIT( KXdmOccurenceId,                     "occurence-id" );
+_LIT( KXdmServiceUri,                      "service-uri" );
+_LIT( KXdmAllServices,                     "all-services" );
+_LIT( KXdmProvideServices,                 "provide-services" );
+// pres-rules-03
+_LIT( KXdmDeviceId,                        "device-id" );
+// pres-rules-05
+_LIT( KXdmDeviceID,                        "deviceID" );
+_LIT( KXdmAllDevices,                      "all-devices" );
+_LIT( KXdmProvideDevices,                  "provide-devices" );
+_LIT( KXdmAllPersons,                      "all-persons" );
+_LIT( KXdmProvidePersons,                  "provide-persons" );
+_LIT( KXdmProvideActivities,               "provide-activities" );
+_LIT( KXdmProvideClass,                    "provide-class" );
+_LIT( KXdmProvideDeviceId,                 "provide-device-id" );
+_LIT( KXdmProvideMood,                     "provide-mood" );
+_LIT( KXdmProvidePlaceIs,                  "provide-place-is" );
+_LIT( KXdmProvidePlaceType,                "provide-place-type" );
+_LIT( KXdmProvidePrivacy,                  "provide-privacy" );
+_LIT( KXdmProvideRelationship,             "provide-relationship" );
+_LIT( KXdmProvideStatusIcon,               "provide-status-icon" );
+_LIT( KXdmProvideSphere,                   "provide-sphere" );
+_LIT( KXdmProvideTimeOffset,               "provide-time-offset" );
+_LIT( KXdmProvideUserInput,                "provide-user-input" );
+_LIT( KXdmProvideNote,                     "provide-note" );
+_LIT( KXdmProvideUnknownAttribute,         "provide-unknown-attribute" );
+_LIT( KXdmProvideAllAttributes,            "provide-all-attributes" );
+_LIT( KXdmSubHandling,                     "sub-handling" );
+_LIT( KXdmProvideWillingness,              "provide-willingness" );
+_LIT( KXdmProvideNetworkAvailability,      "provide-network-availability" );
+_LIT( KXdmProvideSessionParticipation,     "provide-session-participation" );
+_LIT( KXdmProvideGeopriv,                  "provide-geopriv" );
+_LIT( KXdmProvideRegistrationState,        "provide-registration-state" );
+_LIT( KXdmProvideBarringState,             "provide-barring-state" );
+_LIT8( KXdmBare,                           "bare" );
+_LIT8( KXdmThresholds,                     "thresholds" );
+_LIT8( KXdmRandomize,                      "randomize" );
+_LIT8( KXdmObfuscate,                      "obfuscate" );
+_LIT8( KXdmConfirm,                        "confirm" );
+_LIT8( KXdmPoliteBlock,                    "polite-block" );
+
+// Literals for commonpolicy
+_LIT( KXdmOtherIdentity,                    "other-identity" );
+_LIT( KXdmExternalList,                     "external-list" );
+_LIT( KXdmAnonymousRequest,                 "anonymous-request" );
+_LIT( KXdmRule,                             "rule" );
+_LIT( KXdmExceptDomain,                     "except-domain" );
+_LIT( KXdmExcept,                           "except" );
+_LIT( KXdmFrom,                             "from" );
+_LIT( KXdmTo,                               "to" );
+_LIT( KXdmValue,                            "value" );
+_LIT( KXdmSphere,                           "sphere" );
+_LIT( KXdmValidity,                         "validity" );
+_LIT( KXdmConditions,                       "conditions" );
+_LIT( KXdmActions,                          "actions" );
+_LIT( KXdmTransformations,                  "transformations" );
+_LIT( KXdmMany,                             "many" );
+_LIT( KXdmUntil,                            "until" );
+_LIT( KXdmOne,                              "one" );
+_LIT( KXdmScheme,                           "scheme" );
+
+// Literals for poc
+_LIT(  KXdmGroup,                           "group");
+_LIT(  KXdmListService,                     "list-service" );
+_LIT(  KXdmInviteMembers,                   "invite-members" );
+_LIT(  KXdmMaxParticipantCount,             "max-participant-count" );
+_LIT(  KXdmIsListMember,                    "is-list-member" );
+_LIT(  KXdmAllowConfState,                  "allow-conference-state" );
+_LIT(  KXdmAllowInvUsersDyn,                "allow-invite-users-dynamically" );
+_LIT(  KXdmJoinHandling,                    "join-handling" );
+_LIT(  KXdmAllowInitiateConf,               "allow-initiate-conference" );
+_LIT(  KXdmAllowAnonymity,                  "allow-anonymity");
+_LIT(  KXdmIsKeyParticipant,                "list-service" );
+_LIT(  KXdmAllowInvite,                     "allow-invite" );
+_LIT8( KXdmReject,                          "reject" );
+_LIT8( KXdmAccept,                          "accept" );
+_LIT8( KXdmPass,                            "pass" );
+
+// Literals for resource list
+_LIT(  KXdmEntryRef,                        "entry-ref");
+_LIT(  KXdmResourceLists,                   "resource-lists");
+
+// Literals for shared
+_LIT(  KXdmUriUsages,                       "uriusages");
+_LIT(  KXdmUriUsage,                        "uriusage");
+
+// Literals for rls
+_LIT(  KXdmRlsServices,                     "rls-services" );
+_LIT(  KXdmService,                         "service");
+_LIT(  KXdmResourceList,                    "resource-list" );
+_LIT(  KXdmPackages,                        "packages" );
+_LIT(  KXdmPackage,                         "package" );
+_LIT8( KXdmPresence,                        "presence" );
+
+// PRES-CONTENT starts
+_LIT( KXdmMimeType,                         "mime-type");
+_LIT( KXdmEncoding,                         "encoding");
+_LIT( KXdmDescription,                      "description");
+_LIT( KXdmData,                             "data");
+_LIT( KXdmSvg,                              "svg");
+_LIT( KXdmRect,                             "rect");
+// PRES-CONTENT ends
+
+#endif      //__XCAPAPPUSAGEDEF__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/src/10207416.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,144 @@
+/*
+* 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:  Part of XCAP Protocol Application Usage API
+*
+*/
+
+
+
+
+#include "registryinfo.rh"
+
+//Declares the interface implementations provided
+RESOURCE REGISTRY_INFO XcapAppUsageInfo
+	{
+	dll_uid = 0x10207416;
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x10207417;
+			implementations = 
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10207418;
+					version_no = 1;
+					display_name = "XCAP Capability Application Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					},
+			    	IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10207419;
+					version_no = 1;
+					display_name = "XCAP Directory Application Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					},
+			    	IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x1020741A;
+					version_no = 1;
+					display_name = "XCAP Test Application Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					},
+			    	IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x1020741B;
+					version_no = 1;
+					display_name = "XCAP PocGroup Application Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					},
+			    	IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x1020741C;
+					version_no = 1;
+					display_name = "XCAP PocUserAccessPolicy Application Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					},
+			    	IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x1020741D;
+					version_no = 1;
+					display_name = "XCAP SharedXDM Application Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					},
+			    	IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x1020741E;
+					version_no = 1;
+					display_name = "XCAP RlsServicesApplication Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					},
+			    	IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10275080;
+					version_no = 1;
+					display_name = "XCAP ResourceLists Application Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					},
+			    	IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10275081;
+					version_no = 1;
+					display_name = "XCAP IetfCommonPolicy Application Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					},
+			    	IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10275082;
+					version_no = 1;
+					display_name = "XCAP OmaCommonPolicy Application Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					},
+			    	IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10275083;
+					version_no = 1;
+					display_name = "XCAP IetfPresenceRules Application Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					},
+			    	IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x102750AB;
+					version_no = 1;
+					display_name = "XCAP OmaPresenceRules Application Usage||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data ="";
+					},
+					// PRES-CONTENT STARTS
+				IMPLEMENTATION_INFO
+				    {
+					implementation_uid = 0x20028701;
+					version_no = 1;
+					display_name = "XCAP Pres-Content Application Usage||Copyright © 2008 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data ="";
+					}
+					// PRES-CONTENT ENDS
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapAppUsage/src/XcapAppUsage.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,756 @@
+/*
+* 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: CXcapAppUsage
+*
+*/
+
+
+
+
+
+// INCLUDE FILES
+#ifdef _DEBUG
+#include <flogger.h>
+#endif
+
+#include <implementationproxy.h>
+
+#include "XcapAppUsageDef.h"
+
+#include "XcapDirectoryUsage.h"
+#include "XcapCapabilityUsage.h"
+#include "XcapPocGroupUsage.h"
+#include "XcapPocUserAccessUsage.h"
+#include "XcapSharedXDMUsage.h"
+#include "XcapRlsServicesUsage.h"
+#include "XcapResourceListsUsage.h"
+#include "XcapIetfCommonPolicyUsage.h"
+#include "XcapOmaCommonPolicyUsage.h"
+#include "XcapIetfPresRulesUsage.h"
+#include "XcapOmaPresRulesUsage.h"
+// Add the header of the new app usage here
+// #include "XcapTestAppUsage.h"
+// PRES-CONTENT STARTS
+#include "XcapC4.h"
+// PRES-CONTENT ENDS
+
+#include <XdmErrors.h>
+#include <XdmProtocolUidList.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include "XcapUriInterface.h"
+
+
+    
+// CONSTANTS
+// Map the interface UIDs to implementation factory functions
+const TImplementationProxy ImplementationTable[] = 
+	{
+#ifdef __EABI__  
+	IMPLEMENTATION_PROXY_ENTRY( KXdmCapabilityUsageUid, CXcapCapabilityUsage::NewL ),
+	IMPLEMENTATION_PROXY_ENTRY( KXdmDirectoryUsageUid,  CXcapDirectoryUsage::NewL ),
+	IMPLEMENTATION_PROXY_ENTRY( KXdmPocGroupUsageUid,   CXcapPocGroupUsage::NewL ),
+	IMPLEMENTATION_PROXY_ENTRY( KXdmPocUserAccessUsageUid,  CXcapPocUserAccessUsage::NewL ),
+	IMPLEMENTATION_PROXY_ENTRY( KXdmSharedXDMUsageUid,  CXcapSharedXDMUsage::NewL ),
+	IMPLEMENTATION_PROXY_ENTRY( KXdmRlsServicesUsageUid,    CXcapRlsServicesUsage::NewL ),
+	IMPLEMENTATION_PROXY_ENTRY( KXdmResourceListsUsageUid,  CXcapResourceListsUsage::NewL ),
+	IMPLEMENTATION_PROXY_ENTRY( KXdmIetfCommonPolicyUsageUid,   CXcapIetfCommonPolicyUsage::NewL ),
+	IMPLEMENTATION_PROXY_ENTRY( KXdmOmaCommonPolicyUsageUid,    CXcapOmaCommonPolicyUsage::NewL ),
+	IMPLEMENTATION_PROXY_ENTRY( KXdmIetfPresRulesUsageUid,  CXcapIetfPresRulesUsage::NewL ),
+	IMPLEMENTATION_PROXY_ENTRY( KXdmOmaPresRulesUsageUid,   CXcapOmaPresRulesUsage::NewL ),
+    // add new usages here
+    // IMPLEMENTATION_PROXY_ENTRY( KXdmTestAppUsageUid,    CXcapTestAppUsage::NewL ),
+// PRES-CONTENT STARTS
+	IMPLEMENTATION_PROXY_ENTRY( KXdmUsageUid, CXcapC4::NewL )
+// PRES-CONTENT ENDS
+#else  
+    { { KXdmCapabilityUsageUid }, CXcapCapabilityUsage::NewL },
+    { { KXdmDirectoryUsageUid }, CXcapDirectoryUsage::NewL },
+    { { KXdmPocGroupUsageUid }, CXcapPocGroupUsage::NewL },
+    { { KXdmPocUserAccessUsageUid }, CXcapPocUserAccessUsage::NewL },
+    { { KXdmSharedXDMUsageUid }, CXcapSharedXDMUsage::NewL },
+    { { KXdmRlsServicesUsageUid }, CXcapRlsServicesUsage::NewL },
+    { { KXdmResourceListsUsageUid }, CXcapResourceListsUsage::NewL },
+    { { KXdmIetfCommonPolicyUsageUid }, CXcapIetfCommonPolicyUsage::NewL },
+    { { KXdmOmaCommonPolicyUsageUid }, CXcapOmaCommonPolicyUsage::NewL },
+    { { KXdmIetfPresRulesUsageUid }, CXcapIetfPresRulesUsage::NewL },
+    { { KXdmOmaPresRulesUsageUid }, CXcapOmaPresRulesUsage::NewL }, 
+    // add new usages here
+    // { { KXdmTestAppUsageUid }, CXcapTestAppUsage::NewL }, 
+// PRES-CONTENT STARTS
+    { { KXdmUsageUid }, CXcapC4::NewL }
+// PRES-CONTENT ENDS
+#endif
+    };
+
+// ----------------------------------------------------
+// ImplementationGroupProxy
+//
+// ----------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+    return ImplementationTable;
+    }
+
+
+// ----------------------------------------------------
+// CXcapAppUsage::CXcapAppUsage
+// 
+// ----------------------------------------------------
+//
+CXcapAppUsage::CXcapAppUsage( const CXdmEngine& aXdmEngine ) :
+iXdmEngine( CONST_CAST( CXdmEngine&, aXdmEngine ) ),
+iAddNamespaces( EFalse ),
+iNsToNodeSelector( EFalse ),
+iAddNsAttributes( EFalse ),
+iIsGetOrDelete( EFalse )
+    {
+#ifdef _NAMESPACES_TO_NODE_SELECTOR
+    iNsToNodeSelector = ETrue;
+#endif   
+
+#ifdef _ADD_NAMESPACE_ATTRIBUTES
+	iAddNsAttributes = ETrue;
+#endif  
+    }
+
+// ----------------------------------------------------
+// CXcapAppUsage::~CXcapAppUsage
+// 
+// ----------------------------------------------------
+//
+CXcapAppUsage::~CXcapAppUsage()
+    {
+    REComSession::DestroyedImplementation( iDestructorKey );
+    }
+
+// ----------------------------------------------------
+// CXcapAppUsage::NewL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXcapAppUsage* CXcapAppUsage::NewL( const CXdmEngine& aXdmEngine,
+                                           const TInt aDocumentType )
+    {
+    TAny* ptr = NULL;
+    TXcapAppUsageParams params( aXdmEngine );
+    switch( aDocumentType )
+        {
+        case KXdmCapabilityUsageUid:
+        case KXdmDirectoryUsageUid:
+        case KXdmTestAppUsageUid:    
+        case KXdmPocGroupUsageUid:   
+        case KXdmPocUserAccessUsageUid:   
+        case KXdmSharedXDMUsageUid:
+        case KXdmRlsServicesUsageUid:   
+        case KXdmResourceListsUsageUid:  
+        case KXdmIetfCommonPolicyUsageUid:
+        case KXdmOmaCommonPolicyUsageUid:     
+        case KXdmIetfPresRulesUsageUid:     
+        case KXdmOmaPresRulesUsageUid:
+        case KXdmUsageUid:
+            {
+            TUid KImplementationUid = { aDocumentType };
+            ptr = REComSession::CreateImplementationL( 
+                   KImplementationUid,
+                   _FOFF( CXcapAppUsage, iDestructorKey ),
+                   ( TAny* )&params );
+            }
+            break;
+     
+        default:
+            User::Leave( KErrNotSupported );
+        }
+    return reinterpret_cast<CXcapAppUsage*>( ptr );
+    }
+
+// ----------------------------------------------------
+// CXcapAppUsage::Validate
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TInt CXcapAppUsage::Validate( CXdmDocument& aXdmDocument, TBool aAddNamespaces ) 
+    {    
+    iAddNamespaces = aAddNamespaces;
+    iIsGetOrDelete = EFalse;
+    // catch leaves here and return the error code
+    TInt error ( KErrNone );
+    TRAP( error, DoValidateL( aXdmDocument ) );
+    // add namespace information for outgoing document
+    if ( error == KErrNone && iAddNamespaces )
+        {
+	    aXdmDocument.ResetNamespaces();
+	    TRAP( error, AddNamespaceInformationL( aXdmDocument ) );	
+	    }
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::Validate document returns %d" ), error );
+#endif
+    return error;
+    }
+
+// ----------------------------------------------------
+// CXcapAppUsage::Validate
+//
+// ----------------------------------------------------
+//	
+EXPORT_C TInt CXcapAppUsage::Validate( CXdmDocumentNode& aXdmNode, 
+                                       MXcapUriInterface* aUriInterface,
+                                       TBool aIsGetOrDelete ) 
+    {
+    iAddNamespaces = ETrue;  
+    iIsGetOrDelete = aIsGetOrDelete;
+    ResetUsedNamespaces();
+    // catch leaves here and return the error code
+    TInt error( KErrNone );
+    TRAP( error, DoValidateL( aXdmNode ) );
+
+    // add namespace if defined 
+    if ( error == KErrNone && iAddNsAttributes )
+    	{
+    	TRAP( error, CreateNamespaceAttributesL( aXdmNode, aUriInterface ) );
+    	}
+    
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::Validate node returns %d" ), error );
+#endif    
+    return error;
+    }
+	    
+			
+// ----------------------------------------------------
+// CXcapAppUsage::DoValidateL
+//
+// ----------------------------------------------------
+//
+void CXcapAppUsage::DoValidateL( CXdmDocumentNode& aXdmNode ) 
+    {
+    // call method from derived class
+    ValidateNodeL( aXdmNode );
+    
+    // go through all attributes
+    TInt attrCount( aXdmNode.AttributeCount() );
+    for ( TInt i( 0 ); i < attrCount; i++ )
+        {   
+        CXdmNodeAttribute* attr = aXdmNode.Attribute( i );
+        ValidateAttributeL( *attr ); 
+        }
+		   
+    // go through all descendants
+    TInt count( aXdmNode.NodeCount( ) );
+    for ( TInt i = 0; i < count; i++ )
+        {
+        DoValidateL ( *aXdmNode.ChileNode( i ) );
+        }
+    }
+	
+// ----------------------------------------------------
+// CXcapAppUsage::DoValidateL 
+// 
+// ----------------------------------------------------
+//  
+void CXcapAppUsage::DoValidateL ( CXdmDocument& aXdmDocument ) 
+    {
+    DoValidateL( *aXdmDocument.DocumentRoot() );
+    }
+
+// ----------------------------------------------------
+// CXcapAppUsage::ValidateDataL
+// 
+// ----------------------------------------------------
+//
+void CXcapAppUsage::ValidateDataL ( TDataType aDataType, TDesC8& aData )
+    {
+    if ( iIsGetOrDelete )
+        {
+        return;
+        }
+    switch ( aDataType )
+        {
+        case EDataTypeString:
+            {
+            // TODO 
+            }
+        break;
+        case EDataTypeNonNegativeInteger:
+            {
+            TInt value( 0 );
+            TLex8 lex( aData );
+            lex.Val( value );   
+            if ( value < 0 )
+                {
+                User::Leave( KXcapErrorIllegalDataValue );
+                }
+            }
+            break;
+        case EDataTypeAnyURI:
+            {
+            // TODO 
+            }
+            break;
+        case EDataTypeDateTime:
+            {
+            // TODO 
+            }
+            break;
+        case EDataTypeBoolean:
+            {
+            if ( aData.CompareF( KXdmTrue )
+                && aData.CompareF( KXdmFalse )
+                && aData.CompareF( KXdmZero )
+                && aData.CompareF( KXdmOneNbr )  )
+                {
+                User::Leave( KXcapErrorIllegalDataValue );  
+                }
+            }
+            break;
+        case EDataTypeToken:
+            {
+            // elements that are using datatype token
+            // scheme, class, occurence-id 
+            }
+            break;
+        case EDataTypeEmpty:
+            {
+            if ( aData.Length() > 0 )
+                {
+                User::Leave( KXcapErrorIllegalDataValue );
+                } 
+            }
+            break;      
+        default:    
+        break;
+        }
+    }
+    
+// ----------------------------------------------------
+// CXcapAppUsage::ValidateDataL
+// 
+// ----------------------------------------------------
+//
+void CXcapAppUsage::ValidateDataL ( TDataType aDataType, CXdmDocumentNode& aXdmNode )
+    { 
+    TPtrC8 data = aXdmNode.LeafNodeContent();
+    ValidateDataL( aDataType, data );
+    }
+    
+// ----------------------------------------------------
+// CXcapAppUsage::ValidateDataL
+// 
+// ----------------------------------------------------
+//  
+void CXcapAppUsage::ValidateDataL ( TDataType aDataType, const CXdmNodeAttribute& aXdmNodeAttr )
+    {
+    HBufC8* dataBuf = aXdmNodeAttr.EightBitValueLC();   // << dataBuf
+    TPtrC8 data = dataBuf->Des();
+    ValidateDataL( aDataType, data );
+    CleanupStack::PopAndDestroy( dataBuf );            // >>> dataBuf 
+    }
+
+// ----------------------------------------------------
+// CXcapAppUsage::SetPrefixL
+// 
+// ----------------------------------------------------
+//
+void CXcapAppUsage::SetPrefixL( CXdmDocumentNode& aXdmNode, const TDesC8& aPrefix )
+    {
+    if ( iAddNamespaces )
+        {
+        aXdmNode.SetPrefixL( aPrefix ); 
+        AddUsedNamespace( aPrefix );
+        }
+    }
+    
+// ----------------------------------------------------
+// CXcapAppUsage::AddUsedNamespace
+// 
+// ----------------------------------------------------
+//
+void CXcapAppUsage::AddUsedNamespace( const TDesC8& aPrefix ) 
+    {
+    // rl
+    if ( Match( aPrefix, KXdmResourceListsNsPrefix ) )
+        {
+        iRL = ETrue;
+        }
+    // cr
+    else if ( Match( aPrefix, KXdmIetfCommonPolicyNsPrefix ) )
+        {
+        iCR = ETrue;
+        }
+    // cp
+    else if ( Match( aPrefix, KXdmOmaCommonPolicyNsPrefix ) )
+        {
+        iCP = ETrue;
+        }
+    // pr
+    else if ( Match( aPrefix, KXdmIetfPresRulesNsPrefix ) )
+        {
+        iPR = ETrue;
+        }
+    // ls
+    else if ( Match( aPrefix, KXdmPocGroupNsPrefix ) )
+        {
+        iLS = ETrue;
+        }
+    // poc
+    else if ( Match( aPrefix, KXdmPocUserAccessNsPrefix ) )
+        {
+        iPOC = ETrue;
+        }
+    // opr
+    else if ( Match( aPrefix, KXdmOmaPresRulesNsPrefix ) )
+        {
+        iOPR = ETrue;
+        }
+    // rls
+    else if ( Match( aPrefix, KXdmRlsServicesNsPrefix ) )
+        {
+        iRLS = ETrue;
+        }
+    // ou
+    else if ( Match( aPrefix, KXdmSharedXDMUriUsageNsPrefix ) )
+        {
+        iOU = ETrue;
+        }
+    // add new prefix definitions here 
+    }
+    
+// ----------------------------------------------------
+// CXcapAppUsage::ResetUsedNamespaces
+// 
+// ----------------------------------------------------
+//
+void CXcapAppUsage::ResetUsedNamespaces() 
+    {
+    iRL = EFalse;
+    iCR = EFalse;
+    iCP = EFalse;
+    iPR = EFalse;
+    iLS = EFalse;
+    iPOC = EFalse;
+    iOPR = EFalse;
+    iRLS = EFalse;
+    iOU = EFalse;
+    // add new prefix definitions here 
+    }
+    
+// ----------------------------------------------------
+// CXcapAppUsage::AppendUsedNamespacesL
+// 
+// ----------------------------------------------------
+//
+void CXcapAppUsage::AppendUsedNamespacesL( MXcapUriInterface* aUriInterface ) 
+    {
+    if( iRL )
+        {
+        aUriInterface->AddNamespaceMappingL( KXdmResourceListsNamespace, KXdmResourceListsNsPrefix );
+        }
+    if( iCR )
+        {
+        aUriInterface->AddNamespaceMappingL( KXdmIetfCommonPolicyNamespace, KXdmIetfCommonPolicyNsPrefix );
+        }
+    if( iCP )
+        {
+        aUriInterface->AddNamespaceMappingL( KXdmOmaCommonPolicyNamespace, KXdmOmaCommonPolicyNsPrefix );        
+        }
+    if( iPR )
+        {
+        aUriInterface->AddNamespaceMappingL( KXdmIetfPresRulesNamespace, KXdmIetfPresRulesNsPrefix );        
+        }
+    if( iLS )
+        {
+         aUriInterface->AddNamespaceMappingL( KXdmPocGroupNamespace, KXdmPocGroupNsPrefix );       
+        }
+    if( iPOC )
+        {
+        aUriInterface->AddNamespaceMappingL( KXdmPocUserAccessNamespace, KXdmPocUserAccessNsPrefix );       
+        }
+    if( iOPR )
+        {
+        aUriInterface->AddNamespaceMappingL( KXdmOmaPresRulesNamespace, KXdmOmaPresRulesNsPrefix );       
+        }
+    if( iRLS )
+        {
+        aUriInterface->AddNamespaceMappingL( KXdmRlsServicesNamespace, KXdmRlsServicesNsPrefix );        
+        }
+    if( iOU )
+        {
+        aUriInterface->AddNamespaceMappingL( KXdmSharedXDMUriUsageNamespace, KXdmSharedXDMUriUsageNsPrefix );
+        }
+    // add new prefix definitions here 
+    }
+    
+// ----------------------------------------------------
+// CXcapAppUsage::CreateNamespaceAttributesL
+// 
+// ----------------------------------------------------
+// 
+void CXcapAppUsage::CreateNamespaceAttributesL( CXdmDocumentNode& aXdmNode, MXcapUriInterface* aUriInterface )
+	{
+	// First remove all existing xmlns attributes
+	RemoveNamespaceAttributesL( aXdmNode );
+	
+	TPtrC8 nameSpace;
+	TPtrC8 prefix = aXdmNode.Prefix();
+	
+    // if the root node belongs to the default namespace,
+    // it's enough that we add attribute for it and also
+    // attributes for all other used namespaces
+    if ( Match( prefix, KNullDesC8 ) )
+			{
+       	CXdmNodeAttribute* ns = aXdmNode.CreateAttributeL( KXdmDefaultNsAttrName );
+        ns->SetAttributeValueL( DefaultNamespace() );
+        AppendNamespaceAttributesL( aXdmNode ); 
+        
+        if ( iNsToNodeSelector )
+            {
+            //aUriInterface->AddNamespaceMappingL( DefaultNamespace(), KNullDesC8 );
+            CXdmDocumentNode* parent = aXdmNode.Parent();
+            while ( parent )
+                {
+                AddUsedNamespace ( parent->Prefix() );
+                parent = parent->Parent();
+                }
+            AppendUsedNamespacesL( aUriInterface );   
+            } 
+        // we are done
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::CreateNamespaceAttributesL root belongs to default" ) );
+#endif
+        return;        
+        }
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::CreateNamespaceAttributesL root doesn't belong to default" ) );
+#endif   
+    // if the default namespace is used in fragment,
+    // the attribute for it has to be added
+    if ( DefaultNamespaceUsed( aXdmNode ) )
+        {
+      	CXdmNodeAttribute* ns = aXdmNode.CreateAttributeL( KXdmDefaultNsAttrName );
+        ns->SetAttributeValueL( DefaultNamespace() );
+        }
+	// finally, create new xmlns attributes
+    AppendNamespaceAttributesL( aXdmNode );
+    if ( iNsToNodeSelector )
+        {
+        //aUriInterface->AddNamespaceMappingL( DefaultNamespace(), KNullDesC8 );
+        CXdmDocumentNode* parent = aXdmNode.Parent();
+        while ( parent )
+            {
+            AddUsedNamespace ( parent->Prefix() );
+            parent = parent->Parent();
+            }
+        AppendUsedNamespacesL( aUriInterface );   
+        } 
+	}	
+
+// ----------------------------------------------------
+// CXcapAppUsage::RemoveNamespaceAttributesL
+// 
+// ----------------------------------------------------
+// 
+void CXcapAppUsage::RemoveNamespaceAttributesL( CXdmDocumentNode& aXdmNode )
+	{
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::RemoveNamespaceAttributesL begin" ) );
+#endif	
+	// go through all attributes
+    for ( TInt i( aXdmNode.AttributeCount() - 1 ); i > KErrNotFound; i-- )
+        {   
+        CXdmNodeAttribute* attr = aXdmNode.Attribute( i );
+       	if ( attr->NodeName().FindF( KXdmDefaultNsAttrName ) != KErrNotFound )
+			{
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::RemoveNamespaceAttributesL AttrCount=%d i=%d" ), aXdmNode.AttributeCount(), i );
+#endif
+			aXdmNode.RemoveChileNodeL( attr );
+			}
+        }
+		   
+    // go through all descendants
+    TInt count( aXdmNode.NodeCount( ) );
+    for ( TInt i(0); i < count; i++ )
+        {
+        RemoveNamespaceAttributesL ( *aXdmNode.ChileNode( i ) );
+        }
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::RemoveNamespaceAttributesL done" ) );
+#endif	
+	}
+	
+// ----------------------------------------------------
+// CXcapAppUsage::DefaultNamespaceUsed
+// 
+// ----------------------------------------------------
+// 
+TBool CXcapAppUsage::DefaultNamespaceUsed( CXdmDocumentNode& aXdmNode )
+	{
+	if ( Match( aXdmNode.Prefix(), KNullDesC8 ) )
+		{
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::DefaultNamespaceUsed returns true" ) );
+#endif
+		return ETrue;	
+		}
+    // go through all descendants
+    TInt count( aXdmNode.NodeCount( ) );
+    for ( TInt i = 0; i < count; i++ )
+        {
+        if ( DefaultNamespaceUsed ( *aXdmNode.ChileNode( i ) ) )
+            {
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::DefaultNamespaceUsed returns true" ) );
+#endif
+            return ETrue;
+            }
+        }
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::DefaultNamespaceUsed returns false" ) );
+#endif
+    return EFalse;	
+	}
+// ----------------------------------------------------
+// CXcapAppUsage::AppendNamespaceAttributesL
+// 
+// ----------------------------------------------------
+//
+void CXcapAppUsage::AppendNamespaceAttributesL( CXdmDocumentNode& aXdmNode ) 
+    {
+    if( iRL )
+        {
+		CreateNamespaceAttributeL( aXdmNode, KXdmResourceListsNsPrefix, KXdmResourceListsNamespace );
+        }
+    if( iCR )
+        {
+        CreateNamespaceAttributeL( aXdmNode, KXdmIetfCommonPolicyNsPrefix, KXdmIetfCommonPolicyNamespace );
+        }
+    if( iCP )
+        {
+       	CreateNamespaceAttributeL( aXdmNode, KXdmOmaCommonPolicyNsPrefix, KXdmOmaCommonPolicyNamespace );        
+        }
+    if( iPR )
+        {
+        CreateNamespaceAttributeL( aXdmNode, KXdmIetfPresRulesNsPrefix, KXdmIetfPresRulesNamespace );        
+        }
+    if( iLS )
+        {
+       	CreateNamespaceAttributeL( aXdmNode, KXdmPocGroupNsPrefix, KXdmPocGroupNamespace );      
+        }
+    if( iPOC )
+        {
+       	CreateNamespaceAttributeL( aXdmNode, KXdmPocUserAccessNsPrefix, KXdmPocUserAccessNamespace );   
+        }
+    if( iOPR )
+        {
+       	CreateNamespaceAttributeL( aXdmNode, KXdmOmaPresRulesNsPrefix, KXdmOmaPresRulesNamespace );       
+        }
+    if( iRLS )
+        {
+        CreateNamespaceAttributeL( aXdmNode, KXdmRlsServicesNsPrefix, KXdmRlsServicesNamespace );  
+        }
+    if( iOU )
+        {
+       	CreateNamespaceAttributeL( aXdmNode, KXdmSharedXDMUriUsageNsPrefix, KXdmSharedXDMUriUsageNamespace );
+        }
+    // add new prefix definitions here 
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::AppendNamespaceAttributesL done" ) );
+#endif
+    }
+    
+// ----------------------------------------------------
+// CXcapAppUsage::CreateNamespaceAttributeL
+// 
+// ----------------------------------------------------
+// 
+void CXcapAppUsage::CreateNamespaceAttributeL( CXdmDocumentNode& aXdmNode, const TDesC8& aPrefix, const TDesC8& aNamespace )
+    {
+	TBuf8<KXdmMaxPrefixLength> name;
+    name.Copy( KXdmNonDefaultNsAttrName );
+    name.Append( aPrefix );
+    HBufC8* attrName = name.AllocLC();	// << attrName
+    CXdmNodeAttribute* ns = aXdmNode.CreateAttributeL(  );
+    CleanupStack::PushL( ns );	// << ns
+    ns->SetNameL( *attrName );
+    ns->SetAttributeValueL( aNamespace );
+    CleanupStack::Pop( ns );	// >> ns
+    CleanupStack::PopAndDestroy();	// >>> attrName
+#ifdef _DEBUG 
+    WriteToLog( _L8( "CXcapAppUsage::CreateNamespaceAttributeL done" ) );
+#endif
+	}
+    
+// ----------------------------------------------------
+// CXcapAppUsage::Match
+// 
+// ----------------------------------------------------
+// 
+TBool CXcapAppUsage::Match( const TDesC& aLeft, const TDesC& aRight )
+    {
+    if ( !aLeft.CompareF( aRight ) )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+    
+// ----------------------------------------------------
+// CXcapAppUsage::Match
+// 
+// ----------------------------------------------------
+// 
+TBool CXcapAppUsage::Match( const TDesC8& aLeft, const TDesC8& aRight )
+    {
+    if ( !aLeft.CompareF( aRight ) )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }    
+    
+// ----------------------------------------------------
+// CXcapAppUsage::LeaveWithErrorL
+// 
+// ----------------------------------------------------
+//
+void CXcapAppUsage::LeaveWithErrorL( TInt aErrorCode )
+    {
+    if ( !iIsGetOrDelete )
+        {
+        User::Leave( aErrorCode );
+        }
+    }    
+    
+
+// ----------------------------------------------------
+// CXcapAppUsage::WriteToLog
+// _DEBUG only
+// ----------------------------------------------------
+//
+#ifdef _DEBUG
+void CXcapAppUsage::WriteToLog( TRefByValue<const TDesC8> aFmt,... )                                 
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf8<KAppUsageLogBufferMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    RFileLogger::Write( KXdmAppUsageLogDir, KXdmAppUsageLogFile, EFileLoggingModeAppend, buf );
+    }
+#endif
+    
+//  End of File  
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Client/BWINSCW/XcapCacheClientU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,12 @@
+EXPORTS
+	??0RXcapCache@@QAE@XZ @ 1 NONAME ; RXcapCache::RXcapCache(void)
+	??1RXcapCache@@QAE@XZ @ 2 NONAME ; RXcapCache::~RXcapCache(void)
+	?Connect@RXcapCache@@QAEHXZ @ 3 NONAME ; int RXcapCache::Connect(void)
+	?Delete@RXcapCache@@QAEHABVTDesC16@@ABVTDesC8@@@Z @ 4 NONAME ; int RXcapCache::Delete(class TDesC16 const &, class TDesC8 const &)
+	?FetchDocumentContent@RXcapCache@@QAEXAAVTDes8@@ABVTDesC16@@ABVTDesC8@@@Z @ 5 NONAME ; void RXcapCache::FetchDocumentContent(class TDes8 &, class TDesC16 const &, class TDesC8 const &)
+	?FetchDocumentInfo@RXcapCache@@QAEHAAVTDes8@@ABVTDesC16@@ABVTDesC8@@AAVTCacheEntryInfo@@@Z @ 6 NONAME ; int RXcapCache::FetchDocumentInfo(class TDes8 &, class TDesC16 const &, class TDesC8 const &, class TCacheEntryInfo &)
+	?Flush@RXcapCache@@QAEXXZ @ 7 NONAME ; void RXcapCache::Flush(void)
+	?IsCurrent@RXcapCache@@QAEHABVTDesC8@@ABVTDesC16@@0@Z @ 8 NONAME ; int RXcapCache::IsCurrent(class TDesC8 const &, class TDesC16 const &, class TDesC8 const &)
+	?Store@RXcapCache@@QAEXABVTDesC8@@ABVTDesC16@@00@Z @ 9 NONAME ; void RXcapCache::Store(class TDesC8 const &, class TDesC16 const &, class TDesC8 const &, class TDesC8 const &)
+	?Version@RXcapCache@@QBE?AVTVersion@@XZ @ 10 NONAME ; class TVersion RXcapCache::Version(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Client/eabi/XcapCacheClientU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,14 @@
+EXPORTS
+	_ZN10RXcapCache17FetchDocumentInfoER5TDes8RK7TDesC16RK6TDesC8R15TCacheEntryInfo @ 1 NONAME
+	_ZN10RXcapCache20FetchDocumentContentER5TDes8RK7TDesC16RK6TDesC8 @ 2 NONAME
+	_ZN10RXcapCache5FlushEv @ 3 NONAME
+	_ZN10RXcapCache5StoreERK6TDesC8RK7TDesC16S2_S2_ @ 4 NONAME
+	_ZN10RXcapCache6DeleteERK7TDesC16RK6TDesC8 @ 5 NONAME
+	_ZN10RXcapCache7ConnectEv @ 6 NONAME
+	_ZN10RXcapCache9IsCurrentERK6TDesC8RK7TDesC16S2_ @ 7 NONAME
+	_ZN10RXcapCacheC1Ev @ 8 NONAME
+	_ZN10RXcapCacheC2Ev @ 9 NONAME
+	_ZN10RXcapCacheD1Ev @ 10 NONAME
+	_ZN10RXcapCacheD2Ev @ 11 NONAME
+	_ZNK10RXcapCache7VersionEv @ 12 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Client/group/XcapCacheClient.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* 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:  XcapCacheClient.mmp
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                  xcapcacheclient.dll
+TARGETTYPE              dll
+UID                     0x1000008d 0x10207413
+VENDORID                VID_DEFAULT
+CAPABILITY              CAP_CLIENT_DLL
+
+SOURCEPATH              ../src
+USERINCLUDE             ../../inc
+
+SOURCE                  XcapCache.cpp
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY             	euser.lib
+LIBRARY             	efsrv.lib
+DEBUGLIBRARY            flogger.lib
+
+#if defined( ARMCC )
+    DEFFILE ../eabi/ 
+#elif defined ( WINSCW )
+deffile ../BWINSCW/ 
+#elif defined (WINS )
+    deffile ../bwins/ 
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Client/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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:  XcapCacheClient bld.inf
+*
+*/
+
+
+
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+XcapCacheClient.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Client/src/XcapCache.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,188 @@
+/*
+* 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:   RXcapCache
+*
+*/
+
+
+
+#include "XcapCache.h"
+#include "CommonDefines.h"
+
+
+//CLASS DECLARATION
+EXPORT_C RXcapCache::RXcapCache() : iConnected( EFalse )
+    {
+    }
+
+// ----------------------------------------------------
+// RXcapCache::Store
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void RXcapCache::Store( const TDesC8& aETag, 
+                                 const TDesC& aDocumentName,
+                                 const TDesC8& aRootLocation,
+                                 const TDesC8& aResponseData )
+    {
+    SendReceive( EXcapCacheStore, TIpcArgs( &aDocumentName, &aRootLocation, &aETag, &aResponseData ) );
+    }
+
+// ----------------------------------------------------
+// RXcapCache::Delete
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TInt RXcapCache::Delete( const TDesC& aDocumentName,
+                                  const TDesC8& aRootLocation )
+    {
+    TCacheEntryInfo entryInfo;
+    entryInfo.iRootUri = CONST_CAST( TDesC8*, &aRootLocation );
+    entryInfo.iDocumentUri = CONST_CAST( TDesC*, &aDocumentName );
+    TPckgC<TCacheEntryInfo> package( entryInfo );
+    return SendReceive( EXcapCacheDelete, TIpcArgs( &package ) );
+    }
+                                  
+// ----------------------------------------------------
+// RXcapCache::FetchDocumentInfo
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TInt RXcapCache::FetchDocumentInfo( TDes8& aETagDescriptor,
+                                             const TDesC& aDocumentName,
+                                             const TDesC8& aRootLocation,
+                                             TCacheEntryInfo& aEntryInfo )
+    {
+    TPckg<TCacheEntryInfo> package( aEntryInfo );
+    return SendReceive( EXcapCacheFetchInfo, TIpcArgs( &package, &aETagDescriptor,
+                                                       &aDocumentName, &aRootLocation ) );
+    }
+
+// ----------------------------------------------------
+// RXcapCache::FetchDocumentContent
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void RXcapCache::FetchDocumentContent( TDes8& aContentDescriptor,
+                                                const TDesC& aDocumentName,
+                                                const TDesC8& aRootLocation )
+    {
+    SendReceive( EXcapCacheFetchData, TIpcArgs(
+                 &aDocumentName, &aRootLocation, &aContentDescriptor ) );
+    }
+
+// ----------------------------------------------------
+// RXcapCache::IsCurrent
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TInt RXcapCache::IsCurrent( const TDesC8& aETag, 
+                                     const TDesC& aDocumentName,
+                                     const TDesC8& aRootLocation )
+    {
+    return SendReceive( EXcapCacheCheckValidity, TIpcArgs(
+                        &aETag, &aDocumentName, &aRootLocation ) );
+    }
+                                 
+// ----------------------------------------------------
+// RXcapCache::Flush
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void RXcapCache::Flush()
+    {
+    SendReceive( EXcapCacheFlush );
+    }
+        
+// ----------------------------------------------------
+// RXcapCache::Version
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TVersion RXcapCache::Version() const
+	{
+	return TVersion( KCacheServerMajorVersionNumber,
+					 KCacheServerMinorVersionNumber,
+					 KCacheServerBuildVersionNumber );
+	}
+
+// ----------------------------------------------------
+// RXcapCache::~RXcapCache
+// 
+// ----------------------------------------------------
+//
+EXPORT_C RXcapCache::~RXcapCache()
+    {
+    }
+
+// ----------------------------------------------------
+// RXcapCache::Connect()
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TInt RXcapCache::Connect()
+    {
+    TInt ret = KErrNone;
+    if( !iConnected )
+        {
+        ret = StartServer();
+        if( ret == KErrNone || ret == KErrAlreadyExists )
+            {
+            ret = CreateSession( KXcapCacheServerLib, Version(), KTTDefaultMessageSlots );
+            iConnected = ( ret == KErrNone );
+            }
+        }
+    return ret; 
+    }
+
+// ----------------------------------------------------
+// RXcapCache::StartServer
+//
+// ----------------------------------------------------
+//
+TInt RXcapCache::StartServer()
+    {
+    TInt ret = KErrNone;
+    TRequestStatus status = KRequestPending; 
+    if ( !IsRunning() )
+        {
+        RProcess server;
+        ret = server.Create( KXcapCacheServerExe, KNullDesC );       
+        if( ret != KErrNone )
+            return ret;     
+        server.Rendezvous( status );    	
+        status != KRequestPending ? server.Kill( 0 ) : server.Resume();
+        //Wait for start or death 
+        User::WaitForRequest( status );	
+        ret = server.ExitType() == EExitPanic ? KErrGeneral : status.Int();
+        server.Close();	
+        }
+    return ret;
+    }
+
+// ----------------------------------------------------
+// RXcapCache::IsRunning
+//
+// ----------------------------------------------------
+//
+TBool RXcapCache::IsRunning()
+    {
+    TFindServer findServer( KXcapCacheServerName );
+    TFullName name;
+    return ( findServer.Next( name ) == KErrNone );
+    } 
+  
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Client/src/XcapCacheClient.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,79 @@
+/*
+* 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:   CXcapCacheClient
+*
+*/
+
+
+
+#include <e32std.h>
+#include "XcapCache.h"
+#include "CommonDefines.h"
+#include "XcapCacheClient.h"
+
+//CLASS DECLARATION
+CXcapCacheClient::CXcapCacheClient( RXcapCache& aCacheMain ) :
+                                    CActive( EPriorityStandard ),
+                                    iClientMain( aCacheMain )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------
+// CXcapCacheClient::Store
+// 
+// ----------------------------------------------------
+//
+void CXcapCacheClient::Reset()
+    {
+    #ifdef _DEBUG
+        RXcapCache::WriteToLog( _L8( "CXcapCacheClient::Reset()" ) );
+    #endif
+    }
+
+// ----------------------------------------------------
+// CXcapCacheClient::SendMessageL
+// 
+// ----------------------------------------------------
+//
+void CXcapCacheClient::ReceiveAsync( TRequestStatus& aStatus )   
+    {
+    iClientStatus = &aStatus;
+    aStatus = KRequestPending;
+    SetActive();
+    }
+
+// ----------------------------------------------------
+// CXcapCacheClient::RunL
+// 
+// ----------------------------------------------------
+//
+void CXcapCacheClient::RunL()
+    {
+    
+    }
+
+// ----------------------------------------------------
+// CXcapCacheClient::DoCancel
+// 
+// ----------------------------------------------------
+//
+void CXcapCacheClient::DoCancel()
+    {
+    
+    }
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/BWINSCW/XcapCacheServerU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,4 @@
+EXPORTS
+	?StartThread@CXcapCacheServer@@SAHXZ @ 1 NONAME ; int CXcapCacheServer::StartThread(void)
+	?WriteToLog@CXcapCacheServer@@SAXV?$TRefByValue@$$CBVTDesC8@@@@ZZ @ 2 NONAME ; void CXcapCacheServer::WriteToLog(class TRefByValue<class TDesC8 const >, ...)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/eabi/XcapCacheServerU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,6 @@
+EXPORTS
+	_ZN16CXcapCacheServer10WriteToLogE11TRefByValueIK6TDesC8Ez @ 1 NONAME
+	_ZN16CXcapCacheServer11StartThreadEv @ 2 NONAME
+	_ZTI16CXcapCacheServer @ 3 NONAME ; #<TI>#
+	_ZTV16CXcapCacheServer @ 4 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/group/XcapCache.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,52 @@
+/*
+* 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:   XcapCache.mmp
+*		 	XcapCache.exe from XcapCache.mmp
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                          xcapcache.exe
+TARGETTYPE                      exe
+UID                             0 0x10207421
+CAPABILITY                      CAP_SERVER
+VENDORID                        VID_DEFAULT
+
+SOURCEPATH                      ../src
+
+SOURCE                          XcapCacheIndex.cpp
+SOURCE                          XcapCacheServer.cpp
+SOURCE                          XcapCacheSession.cpp
+SOURCE                          XcapShutdownTimer.cpp
+SOURCE                          XcapCacheIndexAdmin.cpp
+SOURCE                          XcapCacheIndexEntry.cpp
+SOURCE                          XcapCacheServerMain.cpp
+SOURCE                          XcapCacheEntryProperty.cpp
+SOURCE                          XcapCacheIndexTableEntry.cpp
+
+USERINCLUDE                     ../inc
+USERINCLUDE                     ../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY                         bafl.lib
+LIBRARY             	        euser.lib
+LIBRARY                     	efsrv.lib
+LIBRARY                         flogger.lib
+LIBRARY                         centralrepository.lib 
+
+EPOCSTACKSIZE                   0x8000
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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:  XcapCache bld.inf
+*
+*/
+
+
+
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+XcapCache.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/inc/ServerDefines.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,57 @@
+/*
+* 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:   XCapServerDefines
+*
+*/
+
+
+
+
+#ifndef __SERVERDEFINES_H__
+#define __SERVERDEFINES_H__
+
+#include <e32base.h>
+
+const TInt KPageFilePosSeparator            = 32;
+_LIT8( KPageFileSeparator,                  " " );
+_LIT8( KIndexFileEndOfLine,                 "\r\n" );
+_LIT8( KIndexFileEndOfEntry,                "\r\n\r\n" );
+_LIT8( KValuePropertySeparator,             "=" );
+_LIT8( KValueFieldSeparator,                ";" );
+
+//Array of characters available for random string creation
+const TInt KRandomStringCharArray[]     = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+                                            0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
+                                            0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
+                                            0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x30, 0x31,
+                                            0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
+                                            0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C,
+                                            0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74,
+                                            0x75, 0x76, 0x77, 0x78, 0x79, 0x7A };
+                                            
+const TReal KDefaultCompression             = 0.75;                                 
+const TInt KRandStringLength                = 20;
+const TInt KDateMaxSize                     = 100;
+const TInt KDateTimeMaxSize                 = 200;
+_LIT( KDateFormatFileName,                  "%1%2%3");
+_LIT( KTimeFormatFileName,                  "%H%T%S");
+_LIT( KCacheDateFormat,                     "%1-%2-%3");
+_LIT( KCacheTimeFormat,                     "%H:%T:%S");
+_LIT( KDateTimeFormat,                      "%D%M%Y%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S");
+
+
+
+#endif // #ifndef __SERVERDEFINES_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheEntryProperty.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,101 @@
+/*
+* 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:   CXcapCacheEntryProperty
+*
+*/
+
+
+
+
+#ifndef __XCAPCACHEINDEXPROPERTY_H__
+#define __XCAPCACHEINDEXPROPERTY_H__
+
+// INCLUDES
+#include <e32std.h>
+#include "CommonDefines.h"
+
+//FORWARD DECLARATIONs
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapCacheEntryProperty ) : public CBase                         
+    {
+    public:             // Constructors and destructor
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        static CXcapCacheEntryProperty* NewL( TInt aPropertyName,
+                                              const TDesC8& aPropertyValue );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TInt IntValue() const;
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TTime TimeValue() const;
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TPtrC DesValue16() const;
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TPtrC8 DesValue8() const;
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TInt Name() const;
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        ~CXcapCacheEntryProperty();
+
+    private:
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void ConstructL( const TDesC8& aPropertyValue );
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        CXcapCacheEntryProperty( TInt aPropertyName );
+
+    private:            // Data
+        
+        HBufC*                             	iPropertyValue16;
+        HBufC8*                             iPropertyValue8;
+        const TInt                          iPropertyName;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheIndex.h	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  CXcapCacheIndex 
+*
+*/
+
+
+
+
+#ifndef __XCAPCACHEINDEX_H__
+#define __XCAPCACHEINDEX_H__
+
+// INCLUDES
+#include <s32file.h>
+#include <e32std.h>
+#include "CommonDefines.h"
+
+//FORWARD DECLARATIONs
+class CXcapCacheIndexEntry;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapCacheIndex ) : public CBase                         
+    {
+    public:             // Constructors and destructor
+        
+        /**
+        * Returns Cache Index
+        * @return Created Cache Index
+        */
+        static CXcapCacheIndex* NewL();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        static TInt Compare( const CXcapCacheIndexEntry& aFirst,
+                             const CXcapCacheIndexEntry& aSecond );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TInt UpdateIndexL( const CXcapCacheIndexEntry* aEntry );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        CXcapCacheIndexEntry* Entry( TInt aIndex ) const;
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TInt EntryCount() const;
+         
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void SortEntriesL();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void RemoveEntry( TInt aIndex );
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void StoreCacheDataL();
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        ~CXcapCacheIndex();
+
+    private:
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        CXcapCacheIndex();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void ConstructL();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        RFile InitialiseIndexL();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void ReadEntriesL( TPtr8& aIndexData );
+
+    private:            // Data
+        
+        RPointerArray<CXcapCacheIndexEntry>         iEntryList;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheIndexAdmin.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,122 @@
+/*
+* 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:   CXcapCacheIndexAdmin
+*
+*/
+
+
+
+
+#ifndef __XCAPCACHEINDEXADMIN_H__
+#define __XCAPCACHEINDEXADMIN_H__
+
+// INCLUDES
+#include <e32std.h>
+#include <s32file.h>
+#include "CommonDefines.h"
+
+//CONSTANTS
+
+//FORWARD DECLARATIONs
+class CXcapCacheIndexTableEntry;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapCacheIndexAdmin ) : public CBase                         
+    {
+    public:             // Constructors and destructor
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        static CXcapCacheIndexAdmin* NewL();
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void UpdateIndexTableL( TInt aIndex, const TCacheEntryInfo* aStorageHeader );
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        CXcapCacheIndexTableEntry* FindL( TInt& aTableIndex,
+                                          const TDesC8& aRootUri,
+                                          const TDesC& aDocumentUri );
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TInt ReadIndexL( const CXcapCacheIndexTableEntry& aEntry );
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void RemoveTableIndex( TInt aIndex );
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void StoreIndexTableL();
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        ~CXcapCacheIndexAdmin();
+
+    private:
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void ConstructL();
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        CXcapCacheIndexAdmin();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        RFile InitialisePageFileL();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void ReadEntriesL( TPtr8& aDataDesc );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        CXcapCacheIndexTableEntry* ParseOneEntryL( const TDesC8& aEntryData );
+
+    private:            // Data
+        
+        RPointerArray<CXcapCacheIndexTableEntry>        iEntryList;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheIndexEntry.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,197 @@
+/*
+* 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:   CXcapCacheIndexEntry
+*
+*/
+
+
+
+
+#ifndef __XCAPCACHEINDEXENTRY_H__
+#define __XCAPCACHEINDEXENTRY_H__
+
+// INCLUDES
+#include <e32std.h>
+#include <s32file.h>
+//#include "XcapCacheClient.h"
+
+//CONSTANTS
+const TUint KCacheEntryETag                               = 0;
+const TUint KCacheXmlSize                                 = 1;
+const TUint KCacheXmlFile                                 = 2;
+const TUint KCacheLastAccess                              = 3;
+const TUint KCacheLastModified                            = 4;
+ 
+//ENUMS
+enum TCacheIndexEntry
+    {
+    EEntryETag                                            = KCacheEntryETag,
+    EEntryXmlSize                                         = KCacheXmlSize,
+    EEntryXmlFile                                         = KCacheXmlFile,
+    EEntryLastAccess                                      = KCacheLastAccess,
+    EEntryLastModified                                    = KCacheLastModified
+    };
+
+//Specifies the cache file "protocol"
+const TText8* const KCacheEntryArray[] = {                _S8( "etag" ),
+                                                          _S8( "size" ),
+                                                          _S8( "file" ),
+                                                          _S8( "access" ),
+                                                          _S8( "modify" )
+                                         };
+
+//FORWARD DECLARATIONs
+class CXcapCacheEntryProperty;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapCacheIndexEntry ) : public CBase                         
+    {
+    public:             // Constructors and destructor
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        static CXcapCacheIndexEntry* NewL( const TCacheEntryInfo* aHeader );
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        static CXcapCacheIndexEntry* NewL( TPtr8& aEntryData );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void UpdateEntryL( const TCacheEntryInfo* aHeader );
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TTime LastAccess() const;
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TTime LastModified() const;
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TInt XmlSize() const;
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TPtrC8 ETag() const;
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TPtrC8 FileNameL() const;
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TPtrC FileName16L() const;
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        HBufC8* PrintLC() const;
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        ~CXcapCacheIndexEntry();
+
+    private:
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void ConstructL( const TCacheEntryInfo* aHeader );
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void ConstructL( TPtr8& aEntryData );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        CXcapCacheIndexEntry();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        CXcapCacheEntryProperty* CreatePropertyL( const TInt aPropertyName,
+                                                  const TDesC8& aPropertyValue );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void CreateFromHeaderL( const TCacheEntryInfo* aHeader );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        const CXcapCacheEntryProperty& FindProperty( const TInt aPropId ) const;
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TInt FindPropNameId( const TDesC8& aNameString ) const;
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        HBufC8* HourStringLC();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void DeleteFileL( const TDesC8& aFileName );
+
+        /**
+        * Second-phase constructor.
+        */ 
+        HBufC8* StoreXmlFileLC( const TDesC8& aXmlData );
+
+    private:            // Data
+        
+        RPointerArray<CXcapCacheEntryProperty>          iPropertyList;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheIndexTableEntry.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,139 @@
+/*
+* 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:   CXcapCacheIndexTableEntry
+*
+*/
+
+
+
+
+#ifndef __XCAPCACHEINDEXTABLEENTRY_H__
+#define __XCAPCACHEINDEXTABLEENTRY_H__
+
+// INCLUDES
+#include <e32std.h>
+#include "CommonDefines.h"
+
+//CONSTANTS
+
+//FORWARD DECLARATIONs
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapCacheIndexTableEntry ) : public CBase                         
+    {
+    public:             // Constructors and destructor
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        static CXcapCacheIndexTableEntry* NewL( const TInt aEntryIndex,
+                                                const TDesC8& aRootUri,
+                                                const TDesC& aDocumentUri );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        static CXcapCacheIndexTableEntry* NewL( const TInt aEntryIndex,
+                                                const TDesC8& aRootUri,
+                                                const TDesC8& aDocumentUri );
+                                                
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        static CXcapCacheIndexTableEntry* NewL( const TDesC8& aRootUri,
+                                                const TDesC& aDocumentUri );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TPtrC8 RootUri() const;
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TPtrC8 DocumentUri() const;
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void Increase();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void Decrease();
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TBool operator==( const CXcapCacheIndexTableEntry& aEntry ) const;
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TInt Index() const;
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        ~CXcapCacheIndexTableEntry();
+
+    private:
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */       
+        CXcapCacheIndexTableEntry();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void ConstructL( const TDesC8& aRootUri,
+                         const TDesC& aDocumentUri );
+                         
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void ConstructL( const TDesC8& aRootUri,
+                         const TDesC8& aDocumentUri );                         
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        CXcapCacheIndexTableEntry( const TInt aEntryIndex );
+
+    private:            // Data
+        
+        TInt                                    iEntryIndex;
+        HBufC8*                                 iRootUri;
+        HBufC8*                                 iDocumentUri;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheServer.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,206 @@
+/*
+* 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:   CXcapCacheServer
+*
+*/
+
+
+
+
+#ifndef __XCAPCACHESERVER_H__
+#define __XCAPCACHESERVER_H__
+
+// INCLUDES
+#include <e32std.h>
+#include <s32file.h>
+#include "ServerDefines.h"
+#include "CommonDefines.h"
+#include "XcapShutdownTimer.h"
+
+//CONSTANTS
+_LIT( KCacheServerRoot,                             "C:\\private\\10207421\\" );
+_LIT( KCacheServerIndex,                            "C:\\private\\10207421\\index.ch" );
+_LIT( KCacheServerPageFile,                         "C:\\private\\10207421\\pagefile.ch" );
+_LIT( KCacheServerIndexF,                        	"index.ch" );
+_LIT( KCacheServerPageFileF,                     	"pagefile.ch" );
+
+_LIT( KCacheServerLogDir,                           "XDM" );
+_LIT( KCacheServerLogFile,                          "CacheServer.txt" );
+const TUint KAppDefaultHeapSize                     = 0x10000;
+
+//FORWARD DECLARATIONs
+class CXcapCacheIndex;
+class CXcapCacheIndexAdmin;
+
+// CLASS DECLARATION
+class CXcapCacheServer : public CServer2                         
+    {
+    public:             // Constructors and destructor
+        
+        /**
+        * Returns KErrNone
+        * @return TInt System wide error code
+        */
+        IMPORT_C static TInt StartThreadL();
+        
+        /**
+        * A global logging function for 8 bit data.
+        * @param aCommand command to be handled
+        */
+        IMPORT_C static void WriteToLog( TRefByValue<const TDesC8> aFmt,... ); 
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        static CServer2* NewLC( void );
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        virtual CSession2* NewSessionL( const TVersion& aVersion,
+        								const RMessage2& /*aMessage*/ ) const;
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        RFs* Session();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TInt CacheSize( TInt& aEntryCount );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        TInt MaxCacheSize() const;
+
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        ~CXcapCacheServer();
+
+    public:  //static
+
+        /**
+        * A global logging function for 8 bit data.
+        * @param aCommand command to be handled
+        */
+        static RFs& FileSession();
+        
+        /**
+        * A global logging function for 8 bit data.
+        * @param aCommand command to be handled
+        */
+        static CXcapCacheIndex* Index();
+
+        /**
+        * A global logging function for 8 bit data.
+        * @param aCommand command to be handled
+        */
+        static CXcapCacheIndexAdmin* IndexAdmin();
+        
+        /**
+        * A global logging function for 8 bit data.
+        * @param aCommand command to be handled
+        */
+        static TInt ConvertDesc( const TDesC8& aNumberDesc );
+        
+        /**
+        * A function to handle descriptor data.
+        * @return Date in heap descriptor
+        */
+        static HBufC* DateL();
+                
+        /**
+        * A function to handle descriptor data.
+        * @return Time in heap descriptor
+        */
+        static HBufC* TimeL();
+
+        /**
+        * A function to handle descriptor data.
+        * @return Random string heap descriptor
+        */
+        static HBufC* RandomStringL();
+                
+        /**
+        * A function to handle descriptor data.
+        * @return Date and time heap descriptor
+        */
+        static HBufC* DateTimeL();
+                
+        /**
+        * A function to handle descriptor data.
+        * @return Date and time heap descriptor
+        */
+        static HBufC* DateTimeL( const TTime& aTime );
+                
+        /**
+        * A function to handle descriptor data.
+        * @param aCommand command to be handled
+        */
+        static TPtr8 DescriptorCast( const TDesC8& aConstData );
+
+    private:
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        CXcapCacheServer( TInt aPriority );
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void ConstructL();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void ReadMaxCacheSizeL();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void AddSession();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        void DropSession();
+
+    private:            // Data
+        
+        RFs                                     iFileSession;
+        TInt                                    iMaxCacheSize;
+        TUint                                   iSessionCount;
+        CDir*                                   iCacheDirectory;
+        CXcapShutdownTimer                      iShutdownTimer;
+        friend class                            CXcapCacheSession;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheServerMain.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,37 @@
+/*
+* 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:   XcapCacheServerMain
+*
+*/
+
+
+
+
+#ifndef __XCAPCACHESERVERMAIN_H__
+#define __XCAPCACHESERVERMAIN_H__
+
+// INCLUDES
+#include <e32std.h>
+#include <f32file.h>
+
+class CXcapCacheIndex;
+class CXcapCacheIndexAdmin;
+
+RFs                         FsSession; 
+CXcapCacheIndex*            CacheIndex = NULL;
+CXcapCacheIndexAdmin*       CacheIndexAdmin = NULL;
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapCacheSession.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,227 @@
+/*
+* 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:   CXcapCacheSession
+*
+*/
+
+
+
+
+#ifndef __XCAPCACHESESSION_H__
+#define __XCAPCACHESESSION_H__
+
+// INCLUDES
+#include <e32std.h>
+#include <e32cons.h>
+#include <s32file.h>
+#include <e32base.h>
+#include "XcapCacheServer.h"
+
+class MDesC16Array;
+class CXcapCacheIndex;
+class CXcapCacheIndexAdmin;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapCacheSession ) : public CSession2
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor
+        *
+        * @param CXcapCacheServer Pointer to the server object
+        * @return CXcapCacheSession* New session object
+        */ 
+        static CXcapCacheSession* NewL( CXcapCacheServer* aServer );
+
+        /**
+        * Service a request
+        *
+        * @param RMessage& Kernel message
+        * @return void
+        */ 
+        virtual void ServiceL ( const RMessage2& aMessage );
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapCacheSession();
+
+    private:
+        
+        /**
+        * Second-phase constructor
+        *
+        * @return void
+        */  
+        void ConstructL();
+
+        /**
+        * C++ default constructor is private.
+        *
+        * @param CXcapCacheServer Pointer to the server object
+        * @return CXcapCacheSession New session object
+        */ 
+        CXcapCacheSession( CXcapCacheServer* aServer );
+        
+        /**
+        * Check the capabilities of the connecting client
+        *
+        * @param RMessage2& Kernel message
+        * @return TBool Does the client have proper capabilities
+        */
+        TBool Capabilities( const RMessage2& aMessage );
+        
+        /**
+        * Panic the client
+        *
+        * @param TInt Panic code
+        * @return void
+        */
+        void PanicClient( TInt aPanic );
+        
+        /**
+        * Dispatch the client's request
+        *
+        * @param RMessage2& Kernel message
+        * @return void
+        */ 
+        void DispatchMessageL( const RMessage2& aMessage );
+        
+        /**
+        * Fetch the meta information for a document
+        *
+        * @param RMessage2& Kernel message
+        * @return void
+        */ 
+        void FetchDocumentInfoL( const RMessage2& aMessage );
+        
+        /**
+        * Fetch the contents of a document
+        *
+        * @param RMessage2& Kernel message
+        * @return void
+        */  
+        void FetchDocumentContentsL( const RMessage2& aMessage );
+        
+        /**
+        * Store a document
+        *
+        * @param RMessage2& Kernel message
+        * @return void
+        */  
+        void CacheXcapDataL( const RMessage2& aMessage );
+        
+        /**
+        * Delete a document from the cache
+        *
+        * @param RMessage2& Kernel message
+        * @return void
+        */  
+        void DeleteCacheDataL( const RMessage2& aMessage );
+        
+        /**
+        * Check the currency of a document 
+        *
+        * @param RMessage2& Kernel message
+        * @return void
+        */  
+        void CheckValidityL( const RMessage2& aMessage );
+        
+        /**
+        * Externalize the meta information
+        *
+        * @return void
+        */ 
+        void FlushCacheDataL();
+        
+        /**
+        * Delete unindexed documents from the cache
+        *
+        * @param MDesC16Array Indexed documents
+        * @return void
+        */
+        void DeleteExcessL( const MDesC16Array& aIndexedEntries );
+        
+        /**
+        * Check for unindexed entries in the cache
+        *
+        * @param TInt Total number of documents in the cache
+        * @return void
+        */
+        void CheckUnindexedEntriesL( TInt aTotalCount );
+
+        /**
+        * Check whether the "aFileName" document is indexed
+        *
+        * @param MDesC16Array& The indexed entries
+        * @param TDesC& Name of the dile to be checked
+        * @return TBool Is the document indexed
+        */
+        TBool IsIndexed( const MDesC16Array& aIndexedEntries, const TDesC& aFileName );
+        
+        /**
+        * Read the specified parameter from the kernel message
+        *
+        * @param TInt The parameter to be read
+        * @param RMessage2& Kernel message
+        * @return HBufC* The parameter data (16-bit)
+        */
+        HBufC* ReadMsgParam16LC( TInt aMsgIndex, const RMessage2& aMessage );
+        
+        /**
+        * Read the specified parameter from the kernel message
+        *
+        * @param TInt The parameter to be read
+        * @param RMessage2& Kernel message
+        * @return HBufC8* The parameter data (8-bit)
+        */
+        HBufC8* ReadMsgParam8LC( TInt aMsgIndex, const RMessage2& aMessage );
+        
+        /**
+        * Check the temporary buffer for data
+        *
+        * @return void
+        */ 
+        void CheckTempBuffer();
+        
+        /**
+        * Delete a named document from the store
+        *
+        * @param TDesC& Name of the document to be deleted
+        * @return TInt Error code
+        */ 
+        TInt DeleteFromStorageL( const TDesC& aFileName );
+        
+        /**
+        * Read a named document from the store
+        *
+        * @param TDesC& Name of the document to be deleted
+        * @return HBufC* The contents of the document
+        */ 
+        HBufC8* ReadFromStorageL( const TDesC& aFileName );
+
+    private: //Data
+        
+        HBufC8*                                 iTempBuffer;
+        CFileMan*                               iFileManager;
+        CXcapCacheServer*                       iCacheServer;
+        CXcapCacheIndex&                        iCacheIndex;
+        CXcapCacheIndexAdmin&                   iCacheIndexAdmin;
+    };
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/inc/XcapShutdownTimer.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* 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:   CXcapShutdownTimer
+*
+*/
+
+
+
+
+#ifndef __XCAPSHUTDOWNTIMER__
+#define __XCAPSHUTDOWNTIMER__
+
+NONSHARABLE_CLASS( CXcapShutdownTimer ) : public CTimer
+	{	
+    public:
+    
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    CXcapShutdownTimer();
+	
+	    /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    void ConstructL();
+	
+	    /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    void Start();
+	
+    private:
+    
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    void RunL();
+	    
+	private:
+	
+		enum { KXcapCacheShutdownDelay = 0x200000 };	
+	};
+	
+#endif	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheEntryProperty.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -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: CXcapCacheEntryPropertyProperty from XcapCacheIndexProperty.cpp
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XcapCacheServer.h"
+#include "XcapCacheEntryProperty.h"
+
+// ----------------------------------------------------------
+// CXcapCacheEntryProperty::CXcapCacheEntryProperty
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheEntryProperty::CXcapCacheEntryProperty( TInt aPropertyName ) :
+                                                  iPropertyName( aPropertyName )
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheEntryProperty::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheEntryProperty* CXcapCacheEntryProperty::NewL( TInt aPropertyName,
+                                                        const TDesC8& aPropertyValue )
+    {
+    CXcapCacheEntryProperty* self = new( ELeave ) CXcapCacheEntryProperty( aPropertyName );
+    CleanupStack::PushL( self );
+    self->ConstructL( aPropertyValue );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheEntryProperty::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheEntryProperty::ConstructL( const TDesC8& aPropertyValue )
+    {
+    iPropertyValue8 = aPropertyValue.AllocL();
+    iPropertyValue16 = HBufC::NewL( aPropertyValue.Length() );
+    iPropertyValue16->Des().Copy( aPropertyValue );
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheEntryProperty::~CXcapCacheEntryProperty
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheEntryProperty::~CXcapCacheEntryProperty()
+    {
+    delete iPropertyValue8;
+    delete iPropertyValue16;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheEntryProperty::ConstructL
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapCacheEntryProperty::Name() const
+    {
+    return iPropertyName;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheEntryProperty::ConstructL
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapCacheEntryProperty::IntValue() const
+    {
+    return CXcapCacheServer::ConvertDesc( iPropertyValue8->Des() );
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheEntryProperty::ConstructL
+// 
+// ----------------------------------------------------------
+//
+TTime CXcapCacheEntryProperty::TimeValue() const
+    {
+    TTime ret;
+    ret.Parse( iPropertyValue16->Des() );
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheEntryProperty::ConstructL
+// 
+// ----------------------------------------------------------
+//
+TPtrC CXcapCacheEntryProperty::DesValue16() const
+    {
+    return iPropertyValue16 != NULL ? iPropertyValue16->Des() : TPtrC();
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheEntryProperty::ConstructL
+// 
+// ----------------------------------------------------------
+//
+TPtrC8 CXcapCacheEntryProperty::DesValue8() const
+    {
+    return iPropertyValue8 != NULL ? iPropertyValue8->Des() : TPtrC8();
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheIndex.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,268 @@
+/*
+* 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:   CXcapCacheIndex
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "ServerDefines.h"
+#include "XcapCacheIndex.h"
+#include "XcapCacheServer.h"
+#include "XcapCacheIndexEntry.h"
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::CXcapCacheIndex
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndex::CXcapCacheIndex()
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndex* CXcapCacheIndex::NewL()
+    {
+    CXcapCacheIndex* self = new( ELeave ) CXcapCacheIndex();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndex::ConstructL()
+    {
+    TInt length = 0;   
+    RFile index = InitialiseIndexL();                                    
+    CleanupClosePushL( index );
+    User::LeaveIfError( index.Size( length ) );
+    if( length > 0 )
+        {
+        HBufC8* data = HBufC8::NewLC( length );
+        TPtr8 pointer( data->Des() );
+        User::LeaveIfError( index.Read( pointer ) );
+        ReadEntriesL( pointer );
+        CleanupStack::PopAndDestroy(); //data
+        }
+    CleanupStack::PopAndDestroy(); //index
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::InitialiseIndexL
+// 
+// ----------------------------------------------------------
+//
+RFile CXcapCacheIndex::InitialiseIndexL()
+    {
+    RFile ret;
+    TUid process = RProcess().Identity();
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheIndex::InitialiseIndexL() - Process: %x" ), process ) ;
+    #endif
+    TInt error = ret.Open( CXcapCacheServer::FileSession(), KCacheServerIndex,
+                           EFileShareExclusive | EFileRead | EFileWrite );
+    if( error != KErrNone )
+        {
+        if( error == KErrPathNotFound )
+            User::LeaveIfError( CXcapCacheServer::FileSession().MkDirAll( KCacheServerRoot ) );
+        User::LeaveIfError( ret.Create( CXcapCacheServer::FileSession(), KCacheServerIndex,
+                            EFileShareExclusive | EFileRead | EFileWrite ) );
+        }
+    return ret;
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheIndex::~CXcapCacheIndex
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndex::~CXcapCacheIndex()
+    {
+    iEntryList.ResetAndDestroy();
+    iEntryList.Close();
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::ConstructL
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapCacheIndex::UpdateIndexL( const CXcapCacheIndexEntry* aEntry )
+    {
+    if( aEntry != NULL )
+        {
+        User::LeaveIfError( iEntryList.Append( aEntry ) );
+        return iEntryList.Find( aEntry );
+        }
+    else return KErrNotFound;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::Entry
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexEntry* CXcapCacheIndex::Entry( TInt aIndex ) const
+    {
+    TInt count = iEntryList.Count();
+    CXcapCacheIndexEntry* entry = NULL;
+    if( count > 0 && aIndex >= 0 && aIndex < count )
+        entry = iEntryList[aIndex];
+    return entry;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::EntryCount
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapCacheIndex::EntryCount() const
+	{
+	return iEntryList.Count();
+	}
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::Compare
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapCacheIndex::Compare( const CXcapCacheIndexEntry& aFirst,
+                               const CXcapCacheIndexEntry& aSecond )
+    {
+    if( aFirst.LastModified() == aSecond.LastModified() )
+        return 0;
+    else if( aFirst.LastModified() > aSecond.LastModified() )
+        return 1;
+    else return -1;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::SortEntries
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndex::SortEntriesL()
+    {
+    TLinearOrder<CXcapCacheIndexEntry> order( CXcapCacheIndex::Compare );
+    iEntryList.Sort( order );
+    #ifdef _DEBUG
+        TPtrC8 entryDesc;
+        TInt count = iEntryList.Count();
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheIndex::SortEntriesL()" ) );
+        CXcapCacheServer::WriteToLog( _L8( "------------------------------------------" ) );
+        CXcapCacheServer::WriteToLog( _L8( " Sorted list:" ) );
+        for( TInt i = 0;i < count;i++ )
+            {
+            HBufC* buffer = NULL;
+            buffer = CXcapCacheServer::DateTimeL( iEntryList[i]->LastModified() );
+            TBuf8<KDateTimeMaxSize> printBuffer( _L8( "  " ) );
+            printBuffer.AppendFormat( _L8( "%d: " ), i );
+            printBuffer.Append( *buffer );
+            CXcapCacheServer::WriteToLog( printBuffer );
+            }
+        CXcapCacheServer::WriteToLog( _L8( "------------------------------------------" ) );
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::RemoveEntry
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndex::RemoveEntry( TInt aIndex )
+    {
+    TInt count = iEntryList.Count();
+    if( count > 0 && aIndex >= 0 && aIndex < count )
+        {
+        CXcapCacheIndexEntry* entry = iEntryList[aIndex];
+        iEntryList.Remove( aIndex );
+        delete entry;
+        entry = NULL;
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::ReadEntriesL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndex::ReadEntriesL( TPtr8& aIndexData )
+    {
+    TBool finished = EFalse;
+    while( !finished && aIndexData.Length() > 0 )
+        {
+        //If we find that there is still more data, but no \r\n
+        //to denote the end of an entry, simply quit. The data
+        //format has most probably been corrupted at some point.
+        TInt entryIndex = aIndexData.FindF( KIndexFileEndOfLine );
+        if( entryIndex > 0 )
+            {
+            TPtr8 entryData = CXcapCacheServer::DescriptorCast( 
+                              aIndexData.Left( entryIndex ) );
+            CXcapCacheIndexEntry* entry = CXcapCacheIndexEntry::NewL( entryData );
+            CleanupStack::PushL( entry );
+            User::LeaveIfError( iEntryList.Append( entry ) );
+            CleanupStack::Pop();
+            aIndexData.Delete( 0, entryIndex + 2 );
+            }
+        else finished = ETrue;
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndex::StoreCacheDataL()
+    {
+    RFile index;
+    TInt count = iEntryList.Count();
+    if( count > 0 )
+        {
+        User::LeaveIfError( index.Replace( CXcapCacheServer::FileSession(),
+                            KCacheServerIndex, EFileWrite ) );
+        CleanupClosePushL( index );
+        for( TInt i = 0;i < count;i++ )
+            {
+            CXcapCacheIndexEntry* entry = iEntryList[i];
+            HBufC8* entryData = entry->PrintLC();
+            if( entryData )
+                {
+                User::LeaveIfError( index.Write( entryData->Des() ) );
+                CleanupStack::PopAndDestroy();  //entryData
+                }
+            }
+        CleanupStack::PopAndDestroy();  //index
+        }
+    else
+        {
+        CFileMan* manager = CFileMan::NewL( CXcapCacheServer::FileSession() );
+        manager->Delete( KCacheServerIndex );
+        delete manager;
+        manager = NULL;
+        }
+    }
+        
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheIndexAdmin.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,284 @@
+/*
+* 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:   CXcapCacheIndexAdmin
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "ServerDefines.h"
+#include "XcapCacheServer.h"
+#include "XcapCacheIndexAdmin.h"
+#include "XcapCacheIndexTableEntry.h"
+
+// ----------------------------------------------------------
+// CXcapCacheIndexAdmin::CXcapCacheIndexAdmin
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexAdmin::CXcapCacheIndexAdmin()
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexAdmin::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexAdmin* CXcapCacheIndexAdmin::NewL()
+    {
+    CXcapCacheIndexAdmin* self = new( ELeave ) CXcapCacheIndexAdmin();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexAdmin::~CXcapCacheIndexAdmin
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexAdmin::~CXcapCacheIndexAdmin()
+    {
+    iEntryList.ResetAndDestroy();
+    iEntryList.Close();
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexAdmin::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexAdmin::ConstructL()
+    {
+    TInt length = 0;
+    RFile indexTable = InitialisePageFileL();                                         
+    CleanupClosePushL( indexTable );
+    User::LeaveIfError( indexTable.Size( length ) );
+    if( length > 0 )
+        {
+        HBufC8* data = HBufC8::NewLC( length );
+        TPtr8 pointer( data->Des() );
+        User::LeaveIfError( indexTable.Read( pointer ) );
+        ReadEntriesL( pointer );
+        CleanupStack::PopAndDestroy(); //data
+        }
+    CleanupStack::PopAndDestroy(); //index
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndex::InitialisePageFileL
+// 
+// ----------------------------------------------------------
+//
+RFile CXcapCacheIndexAdmin::InitialisePageFileL()
+    {
+    RFile ret;
+    TInt error = ret.Open( CXcapCacheServer::FileSession(), KCacheServerPageFile,
+                           EFileShareExclusive | EFileRead | EFileWrite );
+    //No need to check the path at this time, because needed
+    //directories have already been created by the CacheIndex
+    //object if they didn't exist before the server was launched                           
+    if( error != KErrNone )
+        User::LeaveIfError( ret.Create( CXcapCacheServer::FileSession(), KCacheServerPageFile,
+                                        EFileShareExclusive | EFileRead | EFileWrite ) );                           
+    return ret;
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheIndexAdmin::UpdateIndexTableL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexAdmin::UpdateIndexTableL( TInt aIndex, const TCacheEntryInfo* aHeader )
+    {
+    CXcapCacheIndexTableEntry* entry =
+        CXcapCacheIndexTableEntry::NewL( aIndex, *aHeader->iRootUri,
+                                         *aHeader->iDocumentUri );
+    CleanupStack::PushL( entry );
+    User::LeaveIfError( iEntryList.Append( entry ) );
+    CleanupStack::Pop();  //entry
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::ReadIndexL
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapCacheIndexAdmin::ReadIndexL( const CXcapCacheIndexTableEntry& aEntry )
+    {
+    TBool found = EFalse;
+    TInt ret = KErrNotFound;
+    TInt count = iEntryList.Count();
+    CXcapCacheIndexTableEntry* entry = NULL;
+    for( TInt i = 0;!found && i < count;i++ )
+        {
+        entry = iEntryList[i];
+        if( *entry == aEntry )
+            { 
+            ret = entry->Index();
+            found = ETrue;
+            }
+        }
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::FindL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexTableEntry* CXcapCacheIndexAdmin::FindL( TInt& aTableIndex,
+                                                        const TDesC8& aRootUri,
+                                                        const TDesC& aDocumentUri )
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheIndexAdmin::FindL()" ) );
+    #endif
+    TBool found = EFalse;
+    TInt count = iEntryList.Count();
+    CXcapCacheIndexTableEntry* entry = NULL;
+    if( count > 0 )
+        {
+        CXcapCacheIndexTableEntry* newEntry = CXcapCacheIndexTableEntry::NewL(
+                                              aRootUri, aDocumentUri );
+        for( TInt i = 0;!found && i < count;i++ )
+            {
+            CXcapCacheIndexTableEntry* listEntry = iEntryList[i];
+            if( *newEntry == *listEntry )
+                {
+                aTableIndex = i;
+                entry = iEntryList[i];
+                found = ETrue;
+                }
+            }
+        delete newEntry;
+        newEntry = NULL;
+        }
+    return entry;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::RemoveTableIndexL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexAdmin::RemoveTableIndex( TInt aIndex )
+    {
+    TInt count = iEntryList.Count();
+    if( count > 0 && aIndex >= 0 && aIndex < count )
+        {
+        CXcapCacheIndexTableEntry* entry = iEntryList[aIndex];
+        iEntryList.Remove( aIndex );
+        delete entry;
+        entry = NULL;
+        for( TInt i = aIndex;i < count - 1;i++ )
+            {
+            CXcapCacheIndexTableEntry* z = iEntryList[i];
+            z->Decrease();
+            }   
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::StoreIndexTableL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexAdmin::StoreIndexTableL()
+    {
+    RFile indexTable;
+    TInt count = iEntryList.Count();
+    if( count > 0 )
+        {
+        TBuf8<7> numBuf;
+        User::LeaveIfError( indexTable.Replace( CXcapCacheServer::FileSession(),
+                                                KCacheServerPageFile, EFileWrite ) );
+        CleanupClosePushL( indexTable );
+        for( TInt i = 0;i < count;i++ )
+            {
+            numBuf.AppendNum( iEntryList[i]->Index() );
+            indexTable.Write( iEntryList[i]->RootUri() );
+            indexTable.Write( KValueFieldSeparator );
+            indexTable.Write( iEntryList[i]->DocumentUri() );
+            indexTable.Write( KPageFileSeparator );
+            indexTable.Write( numBuf );
+            indexTable.Write( KIndexFileEndOfLine );
+            numBuf.Zero();
+            }
+        CleanupStack::PopAndDestroy();  //indexTable
+        }
+    else
+        {
+        CFileMan* manager = CFileMan::NewL( CXcapCacheServer::FileSession() );
+        manager->Delete( KCacheServerPageFile );
+        delete manager;
+        manager = NULL;
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::UpdatePageFileL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexAdmin::ReadEntriesL( TPtr8& aDataDesc )
+    {
+    TBool finished = EFalse;
+    while( !finished && aDataDesc.Length() > 0 )
+        {
+        //If we find that there is still more data, but no \r\n
+        //to denote the end of an entry, simply quit. The data
+        //format has most probably been corrupted at some point.
+        TInt entryIndex = aDataDesc.FindF( KIndexFileEndOfLine );
+        if( entryIndex > 0 )
+            {
+            TPtrC8 one = aDataDesc.Left( entryIndex );
+            CXcapCacheIndexTableEntry* entry = ParseOneEntryL( one );
+            CleanupStack::PushL( entry );
+            User::LeaveIfError( iEntryList.Append( entry ) );
+            CleanupStack::Pop();
+            aDataDesc.Delete( 0, entryIndex + 2 );
+            }
+        else finished = ETrue;
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::ParseOneEntryL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexTableEntry* CXcapCacheIndexAdmin::ParseOneEntryL( const TDesC8& aEntryData )
+    {
+    CXcapCacheIndexTableEntry* ret = NULL;
+    TInt rootIndex = aEntryData.FindF( KValueFieldSeparator );
+    if( rootIndex > 0 )
+        {
+        TPtrC8 root( aEntryData.Left( rootIndex ) );
+        TInt docIndex = aEntryData.FindF( KPageFileSeparator );
+        TPtrC8 doc( aEntryData.Mid( rootIndex + 1, docIndex - ( rootIndex + 1 ) ) );
+        TPtrC8 pos( aEntryData.Mid( docIndex + 1, aEntryData.Length() - ( docIndex + 1 ) ) );
+        TInt index( CXcapCacheServer::ConvertDesc( pos ) );
+        ret = CXcapCacheIndexTableEntry::NewL( index, root, doc );
+        }
+    return ret;
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheIndexEntry.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,410 @@
+/*
+* 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:   CXcapCacheIndexEntry
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "ServerDefines.h"
+#include "XcapCacheServer.h"
+#include "XcapCacheIndexEntry.h"
+#include "XcapCacheEntryProperty.h"
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::CXcapCacheIndexEntry
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexEntry::CXcapCacheIndexEntry()
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexEntry* CXcapCacheIndexEntry::NewL( const TCacheEntryInfo* aHeader )
+    {
+    CXcapCacheIndexEntry* self = new( ELeave ) CXcapCacheIndexEntry();
+    CleanupStack::PushL( self );
+    self->ConstructL( aHeader );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexEntry* CXcapCacheIndexEntry::NewL( TPtr8& aEntryData )
+    {
+    CXcapCacheIndexEntry* self = new( ELeave ) CXcapCacheIndexEntry();
+    CleanupStack::PushL( self );
+    self->ConstructL( aEntryData );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::~CXcapCacheIndexEntry
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexEntry::~CXcapCacheIndexEntry()
+    {
+    iPropertyList.ResetAndDestroy();
+    iPropertyList.Close();
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexEntry::ConstructL( TPtr8& aEntryData )
+    {
+    while( aEntryData.Length() > 0 )
+        {
+        CXcapCacheEntryProperty* prop = NULL;
+        TInt index = aEntryData.FindF( KValueFieldSeparator );
+        if( index > 0 )
+            {
+            TPtrC8 propData = aEntryData.Left( index );
+            TInt separator = propData.FindF( KValuePropertySeparator );
+            if( separator > 0 )
+                {
+                TPtrC8 name = propData.Left( separator );
+                TPtrC8 value = propData.Right( propData.Length() - separator - 1 );
+                const TInt nameId = FindPropNameId( name );
+                __ASSERT_DEBUG( nameId != KErrNotFound, User::Leave( KErrCorrupt ) );
+                prop = CreatePropertyL( nameId, value );
+                CleanupStack::PushL( prop );
+                User::LeaveIfError( iPropertyList.Append( prop ) );
+                CleanupStack::Pop();  //prop
+                }
+            aEntryData.Delete( 0, index + 1 );
+            }
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexEntry::ConstructL( const TCacheEntryInfo* aHeader )
+    {
+    CreateFromHeaderL( aHeader );
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::FindPropNameId
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapCacheIndexEntry::FindPropNameId( const TDesC8& aNameString ) const
+    {
+    TBool found = EFalse;
+    TInt ret = KErrNotFound;
+    TInt arrayLength = sizeof( KCacheEntryArray ) /
+                       sizeof( KCacheEntryArray[0] );
+    for( TInt i = 0;!found && i < arrayLength;i++ )
+        {
+        if( aNameString.CompareF( TPtrC8( KCacheEntryArray[i] ) ) == 0 )
+            {
+            ret = i;
+            found = ETrue;
+            }
+        }
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::UpdateEntryL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexEntry::UpdateEntryL( const TCacheEntryInfo* aHeader )
+    {
+    TTime access = LastAccess();
+    DeleteFileL( FileNameL() );
+    iPropertyList.ResetAndDestroy();
+    CreateFromHeaderL( aHeader );
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::DeleteFileL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexEntry::DeleteFileL( const TDesC8& aFileName )
+    {
+    HBufC* buf = HBufC::NewLC( aFileName.Length() );
+    buf->Des().Copy( aFileName );
+    CFileMan* manager = CFileMan::NewL( CXcapCacheServer::FileSession() );
+    CleanupStack::PushL( manager );
+    TInt error = manager->Delete( buf->Des() );
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheServer::DeleteFileL() - Error: %d" ), error );
+    #endif
+    CleanupStack::PopAndDestroy( 2 );  //manager, buf
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::CreatePropertyL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheEntryProperty* CXcapCacheIndexEntry::CreatePropertyL( const TInt aPropertyName,
+                                                                const TDesC8& aPropertyValue )
+    {
+    return CXcapCacheEntryProperty::NewL( aPropertyName, aPropertyValue );
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::FindProperty
+// 
+// ---------------------------------------------------------
+//  
+const CXcapCacheEntryProperty& CXcapCacheIndexEntry::FindProperty( const TInt aPropId ) const
+    {
+    TBool found = EFalse;
+    TInt count = iPropertyList.Count();
+    CXcapCacheEntryProperty* property = NULL;
+    for( TInt i = 0;!found && i < count;i++ )
+        {
+        property = iPropertyList[i];
+        if( property->Name() == aPropId )
+            found = ETrue;
+        }
+    return *property;
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::LastAccess
+// 
+// ---------------------------------------------------------
+//  
+TTime CXcapCacheIndexEntry::LastAccess() const
+    {
+    const CXcapCacheEntryProperty& property = FindProperty( KCacheLastAccess );
+    return property.TimeValue();
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::LastModified
+// 
+// ---------------------------------------------------------
+//  
+TTime CXcapCacheIndexEntry::LastModified() const
+    {
+    const CXcapCacheEntryProperty& property = FindProperty( KCacheLastModified );
+    return property.TimeValue();
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::XmlSize
+// 
+// ---------------------------------------------------------
+//  
+TInt CXcapCacheIndexEntry::XmlSize() const
+    {
+    const CXcapCacheEntryProperty& property = FindProperty( KCacheXmlSize );
+    return property.IntValue();
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::FileNameL
+// 
+// ---------------------------------------------------------
+//  
+TPtrC8 CXcapCacheIndexEntry::FileNameL() const
+    {
+    const CXcapCacheEntryProperty& property = FindProperty( KCacheXmlFile );
+    return property.DesValue8();
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::FileName16L
+// 
+// ---------------------------------------------------------
+//
+TPtrC CXcapCacheIndexEntry::FileName16L() const
+	{
+	const CXcapCacheEntryProperty& property = FindProperty( KCacheXmlFile );
+	return property.DesValue16();
+	}
+
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::ETag
+// 
+// ---------------------------------------------------------
+//  
+TPtrC8 CXcapCacheIndexEntry::ETag() const
+    {
+    const CXcapCacheEntryProperty& property = FindProperty( KCacheEntryETag );
+    return property.DesValue8();
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::CreateFromHeaderL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexEntry::CreateFromHeaderL( const TCacheEntryInfo* aHeader )
+    {
+    TInt arrayLength = sizeof( KCacheEntryArray ) /
+                       sizeof( KCacheEntryArray[0] );
+    HBufC8* hour = HourStringLC();
+    for( TInt i = 0;i < arrayLength;i++ )
+        {
+        CXcapCacheEntryProperty* prop = NULL;
+        switch( i )
+            {
+            case KCacheEntryETag:
+                prop = CreatePropertyL( KCacheEntryETag, *aHeader->iEtag );
+                break;
+            case KCacheXmlSize:
+                {
+                TBuf8<10> sizeBuf;
+                sizeBuf.AppendNum( aHeader->iDataLength );
+                prop = CreatePropertyL( KCacheXmlSize, sizeBuf );
+                }
+                break;
+            case KCacheXmlFile:
+                {
+                HBufC8* fileName = StoreXmlFileLC( *aHeader->iRespData );
+                prop = CreatePropertyL( KCacheXmlFile, fileName->Des() );
+                CleanupStack::PopAndDestroy();  //fileName
+                }
+                break;
+            case KCacheLastAccess:
+                prop = CreatePropertyL( KCacheLastAccess, hour->Des() );
+                break;
+            case KCacheLastModified:
+                prop = CreatePropertyL( KCacheLastModified, hour->Des() );
+                break;
+            default:
+                break;
+            }
+        if( prop != NULL )
+            User::LeaveIfError( iPropertyList.Append( prop ) );
+        }
+    CleanupStack::PopAndDestroy();  //hour
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::HourStringLC
+// 
+// ----------------------------------------------------------
+//
+HBufC8* CXcapCacheIndexEntry::HourStringLC()
+    {
+    HBufC8* hourString = NULL;
+    HBufC* date = CXcapCacheServer::DateL();
+    HBufC* time = CXcapCacheServer::TimeL();
+    hourString = HBufC8::NewLC( date->Length() + time->Length() + 1 );
+    TPtr8 pointer( hourString->Des() );
+    pointer.Copy( *date );
+    pointer.Append( KPageFileSeparator );
+    pointer.Append( *time );
+    delete date;
+    date = NULL;
+    delete time;
+    time = NULL;
+    return hourString;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::StoreXmlFileLC
+// 
+// ----------------------------------------------------------
+//
+HBufC8* CXcapCacheIndexEntry::StoreXmlFileLC( const TDesC8& aXmlData )
+    {
+    RFile file;
+    HBufC* nameBuf = NULL;
+    HBufC* randomString = NULL;
+    TPtrC randomName( _L( "" ) );
+    TInt error = KErrAlreadyExists;
+    //It is extremely unlikely that the random string generator
+    //creates two exact same patterns, but let's check for it, anyway.
+    while( error == KErrAlreadyExists )
+        {
+        randomString = CXcapCacheServer::RandomStringL();
+        randomName.Set( *randomString );
+        nameBuf = HBufC::NewLC( KCacheServerRoot().Length() + randomName.Length() );
+        nameBuf->Des().Copy( KCacheServerRoot );
+        nameBuf->Des().Append( randomName );
+        error = file.Create( CXcapCacheServer::FileSession(),
+                             nameBuf->Des(), EFileWrite );
+        if( error != KErrNone )
+            CleanupStack::PopAndDestroy();  //nameBuf
+        }
+    file.Write( aXmlData );
+    file.Close();
+    __ASSERT_ALWAYS( nameBuf != NULL, User::Leave( KErrCorrupt ) );
+    HBufC8* ret = HBufC8::NewLC( nameBuf->Des().Length() );
+    ret->Des().Copy( nameBuf->Des() );
+    CleanupStack::Pop();  //ret
+    CleanupStack::PopAndDestroy();  //nameBuf
+    CleanupStack::PushL( ret );
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexEntry::PrintLC
+// 
+// ----------------------------------------------------------
+//
+HBufC8* CXcapCacheIndexEntry::PrintLC() const
+    {
+    TInt position = 0;
+    CBufFlat* buffer = NULL;
+    HBufC8* entryString = NULL;
+    TInt count = iPropertyList.Count();
+    if( count > 0 )
+        {
+        buffer = CBufFlat::NewL( 50 );
+        CleanupStack::PushL( buffer );
+        for( TInt i = 0;i < count;i++ )
+            {
+            TPtrC8 name = TPtrC8( KCacheEntryArray[iPropertyList[i]->Name()] );
+            TPtrC8 value = iPropertyList[i]->DesValue8();
+            buffer->InsertL( position, name );
+            position = position + name.Length();
+            buffer->InsertL( position, KValuePropertySeparator );
+            position = position + KValuePropertySeparator().Length();
+            buffer->InsertL( position, value );
+            position = position + value.Length();
+            buffer->InsertL( position, KValueFieldSeparator );
+            position = position + KValueFieldSeparator().Length();
+            }
+        buffer->InsertL( position, KIndexFileEndOfLine );
+        TPtr8 pointer( buffer->Ptr( 0 ) );
+        entryString = HBufC8::NewL( pointer.Length() );
+        entryString->Des().Copy( pointer );
+        CleanupStack::PopAndDestroy();  //buffer
+        CleanupStack::PushL( entryString );
+        }
+    return entryString;
+    }
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheIndexTableEntry.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,210 @@
+/*
+* 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: CXcapCacheIndexTableEntry  
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "ServerDefines.h"
+#include "XcapCacheServer.h"
+#include "XcapCacheIndexTableEntry.h"
+
+// ----------------------------------------------------------
+// CXcapCacheIndexTableEntry::CXcapCacheIndexTableEntry
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexTableEntry::CXcapCacheIndexTableEntry() : iEntryIndex( KErrNotFound ) 
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexTableEntry::CXcapCacheIndexTableEntry
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexTableEntry::CXcapCacheIndexTableEntry( const TInt aEntryIndex ) :
+                                                      iEntryIndex( aEntryIndex ) 
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexTableEntry::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexTableEntry* CXcapCacheIndexTableEntry::NewL( const TInt aEntryIndex,
+                                                            const TDesC8& aRootUri,
+                                                            const TDesC& aDocumentUri )
+    {
+    CXcapCacheIndexTableEntry* self = new( ELeave ) CXcapCacheIndexTableEntry( aEntryIndex );
+    CleanupStack::PushL( self );
+    self->ConstructL( aRootUri, aDocumentUri );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexTableEntry::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexTableEntry* CXcapCacheIndexTableEntry::NewL( const TInt aEntryIndex,
+                                                            const TDesC8& aRootUri,
+                                                            const TDesC8& aDocumentUri )
+    {
+    CXcapCacheIndexTableEntry* self = new( ELeave ) CXcapCacheIndexTableEntry( aEntryIndex );
+    CleanupStack::PushL( self );
+    self->ConstructL( aRootUri, aDocumentUri );
+    CleanupStack::Pop();
+    return self;
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheIndexTableEntry::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexTableEntry* CXcapCacheIndexTableEntry::NewL( const TDesC8& aRootUri,
+                                                            const TDesC& aDocumentUri )
+    {
+    CXcapCacheIndexTableEntry* self = new( ELeave ) CXcapCacheIndexTableEntry();
+    CleanupStack::PushL( self );
+    self->ConstructL( aRootUri, aDocumentUri );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexTableEntry::~CXcapCacheIndexTableEntry
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheIndexTableEntry::~CXcapCacheIndexTableEntry()
+    {
+    delete iRootUri;
+    delete iDocumentUri;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexTableEntry::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexTableEntry::ConstructL( const TDesC8& aRootUri,
+                                            const TDesC& aDocumentUri )
+    {
+    #ifdef _DEBUG
+        HBufC8* eightBuffer = HBufC8::NewLC( aDocumentUri.Length() );
+        TPtr8 desc( eightBuffer->Des() );
+        desc.Copy( aDocumentUri );
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheIndexTableEntry::ConstructL" ) );
+        CXcapCacheServer::WriteToLog( _L8( "  Root:     %S" ), &aRootUri );
+        CXcapCacheServer::WriteToLog( _L8( "  Document: %S" ), &desc );
+        CleanupStack::PopAndDestroy();  //eightBuffer
+    #endif
+    iRootUri = aRootUri.AllocL();
+    iDocumentUri = HBufC8::NewL( aDocumentUri.Length() );
+    iDocumentUri->Des().Copy( aDocumentUri );
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheIndexTableEntry::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheIndexTableEntry::ConstructL( const TDesC8& aRootUri,
+                                            const TDesC8& aDocumentUri )
+    {
+    #ifdef _DEBUG
+        HBufC8* eightBuffer = HBufC8::NewLC( aDocumentUri.Length() );
+        TPtr8 desc( eightBuffer->Des() );
+        desc.Copy( aDocumentUri );
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheIndexTableEntry::ConstructL" ) );
+        CXcapCacheServer::WriteToLog( _L8( "  Root:     %S" ), &aRootUri );
+        CXcapCacheServer::WriteToLog( _L8( "  Document: %S" ), &desc );
+        CleanupStack::PopAndDestroy();  //eightBuffer
+    #endif
+    iRootUri = aRootUri.AllocL();
+    iDocumentUri = HBufC8::NewL( aDocumentUri.Length() );
+    iDocumentUri->Des().Copy( aDocumentUri );
+    }
+    
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::EntryData
+// 
+// ---------------------------------------------------------
+//  
+TPtrC8 CXcapCacheIndexTableEntry::RootUri() const
+  {
+  return iRootUri != NULL ? iRootUri->Des() : TPtrC8();
+  }
+
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::EntryData
+// 
+// ---------------------------------------------------------
+//  
+TPtrC8 CXcapCacheIndexTableEntry::DocumentUri() const
+  {
+  return iDocumentUri != NULL ? iDocumentUri->Des() : TPtrC8();
+  }
+
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::EntryData
+// 
+// ---------------------------------------------------------
+//  
+void CXcapCacheIndexTableEntry::Increase()
+  {
+  iEntryIndex++;
+  }
+  
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::EntryData
+// 
+// ---------------------------------------------------------
+//  
+void CXcapCacheIndexTableEntry::Decrease()
+  {
+  iEntryIndex--;
+  }
+  
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::operator++
+// 
+// ---------------------------------------------------------
+//  
+TBool CXcapCacheIndexTableEntry::operator==( const CXcapCacheIndexTableEntry& aEntry ) const
+    {
+    return ( iRootUri != NULL && iDocumentUri != NULL ) &&
+           ( iRootUri->Des().CompareF( aEntry.RootUri() ) == 0  ) &&
+           ( iDocumentUri->Des().CompareF( aEntry.DocumentUri() ) == 0 );
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheIndexTableEntry::operator++
+// 
+// ---------------------------------------------------------
+//  
+TInt CXcapCacheIndexTableEntry::Index() const
+    {
+    return iEntryIndex;
+    }
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheServer.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,387 @@
+/*
+* 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:   CXcapCacheServer
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32math.h>
+#include <flogger.h>
+#include <centralrepository.h>
+#include <XdmEngineDomainCRKeys.h>
+#include "XcapCacheIndex.h"
+#include "XcapCacheServer.h"
+#include "XcapCacheSession.h"
+#include "XcapCacheIndexAdmin.h"
+#include "XcapCacheServerMain.h"
+
+GLDEF_C void PanicServer( TXcapCacheServerPanic aPanic )
+    {
+    _LIT( KCacheServerPanic, "XcapCacheServer");
+    User::Panic( KCacheServerPanic, aPanic );
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheServer::New
+// 
+// ----------------------------------------------------------
+//
+CServer2* CXcapCacheServer::NewLC()
+    {
+    CXcapCacheServer* self = new CXcapCacheServer( EPriorityHigh );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheServer::New
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheServer::ConstructL()
+    {
+    ReadMaxCacheSizeL();
+    User::LeaveIfError( iFileSession.Connect() );
+    StartL( KXcapCacheServerLib );
+    iShutdownTimer.ConstructL();
+    iShutdownTimer.Start();
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheServer::NewSessionL
+// 
+// ----------------------------------------------------------
+//
+CSession2* CXcapCacheServer::NewSessionL( const TVersion& aVersion,
+        								  const RMessage2& /*aMessage*/ ) const
+    {
+    // Check version number of API against our known version number.
+    TVersion thisVersion( KCacheServerMajorVersionNumber,
+                          KCacheServerMinorVersionNumber,
+                          KCacheServerBuildVersionNumber );
+    if( !User::QueryVersionSupported( thisVersion, aVersion ) ) 
+        User::Leave( KErrNotSupported );
+    return CXcapCacheSession::NewL( ( CXcapCacheServer* )this );
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheServer::CXcapCacheServer
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheServer::~CXcapCacheServer()
+    {
+    iFileSession.Close();
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheServer::ReadMaxCacheSizeL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheServer::ReadMaxCacheSizeL()
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheServer::ReadMaxCacheSizeL()" ) );
+    #endif
+    CRepository* repository = CRepository::NewL( KCRUIDXDMEngineXcapLocal );
+    CleanupStack::PushL( repository );
+    TInt error = repository->Get( KXDMXcapCacheSize, iMaxCacheSize );
+    //If something went wrong, just use 30 KB as a default value
+    if( error != KErrNone )
+        {
+        #ifdef _DEBUG
+            CXcapCacheServer::WriteToLog( _L8( "Reading from CenRep failed: %d => Default to 30 KB" ), error );
+        #endif
+        iMaxCacheSize = 30000;
+        }
+    else
+        {
+        #ifdef _DEBUG
+            CXcapCacheServer::WriteToLog( _L8( "  Max cache size is %d KB" ), iMaxCacheSize );
+        #endif  
+        iMaxCacheSize = iMaxCacheSize * 1000;
+        }
+    CleanupStack::PopAndDestroy();  //repository
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheServer::CXcapCacheServer
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheServer::CXcapCacheServer( TInt aPriority ) : CServer2( aPriority )
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheServer::AddSession
+//
+// ----------------------------------------------------------
+//
+void CXcapCacheServer::AddSession()
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheServer::AddSession()" ) );
+    #endif
+	++iSessionCount;
+	iShutdownTimer.Cancel();
+    }
+        
+// ----------------------------------------------------------
+// CXcapCacheServer::DropSession
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheServer::DropSession()
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheServer::DropSession()" ) );
+    #endif
+	if( --iSessionCount == 0 )
+		CActiveScheduler::Stop();
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheServer::ConvertDesc
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapCacheServer::ConvertDesc( const TDesC8& aNumberDesc )
+    {
+    TInt ret = 0;
+    TLex8 lex( aNumberDesc );
+    TInt error = lex.Val( ret );
+    return error == KErrNone ? ret : error;
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheServer::DateL
+// 
+// ---------------------------------------------------------
+//
+HBufC* CXcapCacheServer::DateL()
+    {
+    TTime time;
+    TBuf<KDateMaxSize> dateBuffer;
+    dateBuffer.SetLength( 0 );
+    time.HomeTime();
+    time.FormatL( dateBuffer, KCacheDateFormat );
+    HBufC* heapDate = dateBuffer.AllocL();
+    return heapDate;
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheServer::DateTimeL
+// 
+// ---------------------------------------------------------
+//
+HBufC* CXcapCacheServer::DateTimeL()
+    {
+    TTime time;
+    TBuf<KDateMaxSize> dateBuffer;
+    time.HomeTime();
+    time.FormatL( dateBuffer, KDateFormatFileName );
+    TBuf<KDateMaxSize> timeBuffer;
+    time.HomeTime();
+    time.FormatL( timeBuffer, KTimeFormatFileName );
+    TBuf<KDateTimeMaxSize> buffer;
+    buffer.SetLength( 0 );
+    buffer.Copy( dateBuffer );
+    buffer.Append( timeBuffer );
+    HBufC* ret = HBufC::NewL( buffer.Length() );
+    ret->Des().Copy( buffer );
+    return ret;
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheServer::DateTimeL
+// 
+// ---------------------------------------------------------
+//
+HBufC* CXcapCacheServer::DateTimeL( const TTime& aTime )
+    {
+    TBuf<KDateTimeMaxSize> dateTimeBuffer;
+    aTime.FormatL( dateTimeBuffer, KDateTimeFormat );
+    HBufC* heapDateTime = dateTimeBuffer.AllocL();
+    return heapDateTime;
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheServer::MaxCacheSize
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapCacheServer::MaxCacheSize() const
+    {
+    return iMaxCacheSize;
+    }
+    
+// ---------------------------------------------------------
+// CXcapCacheServer::CacheSize
+// 
+// ---------------------------------------------------------
+//
+TInt CXcapCacheServer::CacheSize( TInt& aEntryCount )
+    {
+    #ifdef _DEBUG
+	    CXcapCacheServer::WriteToLog( _L8( "CXcapCacheServer::CacheSize()" ) );
+	#endif
+    TInt total = 0;
+    TInt entryCount = 0;
+    CDir* directory = NULL;
+    User::LeaveIfError( iFileSession.GetDir( KCacheServerRoot, KEntryAttNormal,
+                                             ESortNone, directory ) );
+    CleanupStack::PushL( directory );
+    entryCount = directory->Count();
+    for( TInt i = 0;i < entryCount;i++ )
+        total = total + ( *directory )[i].iSize;
+    #ifdef _DEBUG
+	    CXcapCacheServer::WriteToLog( _L8( " Entries:    %d " ), entryCount );
+	    CXcapCacheServer::WriteToLog( _L8( " Total size: %d bytes" ), total );
+	#endif
+	CleanupStack::PopAndDestroy();
+	aEntryCount = entryCount;
+	return total;
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheServer::RandomStringL
+// 
+// ---------------------------------------------------------
+//
+HBufC* CXcapCacheServer::RandomStringL()
+    {
+    const TInt charCount( sizeof( KRandomStringCharArray ) / sizeof( TInt ) );
+    TBuf<KRandStringLength> buffer;
+    buffer.Zero();
+    for( TInt i = 0; i < KRandStringLength;i++ )
+        {
+        TInt index = Math::Random() % charCount;
+        buffer.Append( ( TChar )KRandomStringCharArray[index] );
+        }
+    HBufC* randomHeapBuffer = buffer.AllocL();
+    return randomHeapBuffer;
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheServer::TimeL
+// 
+// ---------------------------------------------------------
+//
+HBufC* CXcapCacheServer::TimeL()
+    {
+    TTime time;
+    TBuf<KDateMaxSize> timeBuffer;
+    timeBuffer.SetLength( 0 );
+    time.HomeTime();
+    time.FormatL( timeBuffer, KCacheTimeFormat );
+    HBufC* heapTime = timeBuffer.AllocL();
+    return heapTime;
+    }
+
+// ---------------------------------------------------------
+// CXcapCacheServer::DescriptorCast
+//
+// ---------------------------------------------------------
+//
+TPtr8 CXcapCacheServer::DescriptorCast( const TDesC8& aConstData )
+	{
+    TInt length = aConstData.Length();
+    TPtr8 constCast( CONST_CAST( TUint8*, aConstData.Ptr() ), length, length );
+    constCast.TrimAll();
+    return constCast;
+	}
+
+// ----------------------------------------------------
+// CXcapCacheServer::FileSession
+// 
+// ----------------------------------------------------
+//
+RFs& CXcapCacheServer::FileSession()
+    {
+    return FsSession;
+    }
+
+// ----------------------------------------------------
+// CXcapCacheServer::FileSession
+// 
+// ----------------------------------------------------
+//
+CXcapCacheIndex* CXcapCacheServer::Index()
+    {
+    return CacheIndex;
+    }
+
+// ----------------------------------------------------
+// CXcapCacheServer::FileSession
+// 
+// ----------------------------------------------------
+//
+CXcapCacheIndexAdmin* CXcapCacheServer::IndexAdmin()
+    {
+    return CacheIndexAdmin;
+    }
+
+// ----------------------------------------------------
+// CXcapCacheServer::StartThreadL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TInt CXcapCacheServer::StartThreadL()
+    {
+    User::LeaveIfError( User::RenameThread( KXcapCacheServerName ) );
+    CActiveScheduler* scheduler = new ( ELeave ) CActiveScheduler;
+    CleanupStack::PushL( scheduler );
+    CActiveScheduler::Install( scheduler );
+    User::LeaveIfError( FsSession.Connect() );
+    CleanupClosePushL( FsSession );
+    CXcapCacheServer::NewLC();
+    CacheIndex = CXcapCacheIndex::NewL();
+    CleanupStack::PushL( CacheIndex );
+    CacheIndexAdmin = CXcapCacheIndexAdmin::NewL();
+    CleanupStack::PushL( CacheIndexAdmin );
+    RProcess::Rendezvous( KErrNone );
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "XcapCacheServer fully running" ) );
+    #endif
+    CActiveScheduler::Start();
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "XcapCacheServer closing..." ) );
+    #endif
+    CleanupStack::PopAndDestroy( 5 );  //CacheIndexAdmin, CacheIndex, server, FsSession, scheduler
+    return KErrNone;
+    }
+
+// ----------------------------------------------------
+// CXcapCacheServer::WriteToLog
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXcapCacheServer::WriteToLog( TRefByValue<const TDesC8> aFmt,... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf8<KServerLogBufferMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    RFileLogger::Write( KCacheServerLogDir, KCacheServerLogFile, EFileLoggingModeAppend, buf );
+    RDebug::RawPrint( buf );
+    }
+    
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheServerMain.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -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:   XcapCacheServerMain.cpp
+*
+*/
+
+
+
+#include "XcapCacheServer.h"
+
+// ----------------------------------------------------------
+// DeleteLogFiles
+// 
+// ----------------------------------------------------------
+//
+TInt DeleteLogFileL()
+    {
+    RFs session;
+    TInt error = session.Connect();
+    if( error == KErrNone )
+        {
+        CFileMan* manager = CFileMan::NewL( session );
+        error = manager->Delete( _L( "C:\\logs\\XDM\\CacheServer.txt" ) );
+        session.Close();
+        delete manager;
+        manager = NULL;
+        }
+    return error;
+    }
+
+// ----------------------------------------------------------
+// E32Main
+// 
+// ----------------------------------------------------------
+//     
+GLDEF_C TInt E32Main()
+	{
+	__UHEAP_MARK;
+    TInt error = KErrNoMemory;
+    CTrapCleanup* cleanup = CTrapCleanup::New();
+    #ifdef _DEBUG
+        TRAPD( logErr, DeleteLogFileL() );
+        TBuf8<KMaxFileName> exe;
+        TFileName name( RProcess().FileName() );
+        exe.Copy( name );
+        CXcapCacheServer::WriteToLog( _L8( "*** E32Main(): Exe loaded from %S - Log deletion: %d"),
+                                      &exe, logErr );
+    #endif
+	if( cleanup )
+		{
+		TRAP( error, CXcapCacheServer::StartThreadL() );
+		delete cleanup;
+		}
+	__UHEAP_MARKEND; 
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "*** E32Main() completes: %d" ), error );
+    #endif  
+	return error;
+	}
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapCacheSession.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,588 @@
+/*
+* 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:   CXcapCacheSession
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <f32file.h>
+#include <badesca.h>
+#include "XcapCacheIndex.h"
+#include "XcapCacheSession.h"
+#include "XcapCacheIndexAdmin.h"
+#include "XcapCacheIndexEntry.h"
+#include "XcapCacheIndexTableEntry.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+// ----------------------------------------------------------
+// CXcapCacheSession::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheSession* CXcapCacheSession::NewL( CXcapCacheServer* aServer )
+    {
+    CXcapCacheSession* self = new( ELeave ) CXcapCacheSession( aServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::~CXcapCacheSession
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheSession::~CXcapCacheSession()
+    {
+    delete iFileManager;
+    //Reduce number of active clients within server
+    if( iCacheServer )
+        iCacheServer->DropSession();
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::ServiceL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::ServiceL( const RMessage2& aMessage )
+    {
+    TInt ret = KErrNone;
+    if( Capabilities( aMessage ) )
+        {
+        CheckTempBuffer();
+        TRAPD( err, DispatchMessageL( aMessage ) );
+        if( err != KErrNone )
+            ret = err;
+        }
+    else ret = KErrPermissionDenied;
+    aMessage.Complete( ret );
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "** Message completed - Error: %d" ), ret );
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::Capabilities
+// 
+// ----------------------------------------------------------
+//
+TBool CXcapCacheSession::Capabilities( const RMessage2& aMessage )
+    {
+    return aMessage.HasCapability( ECapabilityReadUserData ) &&
+           aMessage.HasCapability( ECapabilityWriteUserData );
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheSession::CheckTempBuffer
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::CheckTempBuffer()
+    {
+    if( iTempBuffer )
+        {
+        delete iTempBuffer;
+        iTempBuffer = NULL;
+        }
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheSession::CXcapCacheSession
+// 
+// ----------------------------------------------------------
+//
+CXcapCacheSession::CXcapCacheSession( CXcapCacheServer* aServer ) :
+                                      iCacheServer( aServer ),
+                                      iCacheIndex( *CXcapCacheServer::Index() ),
+                                      iCacheIndexAdmin( *CXcapCacheServer::IndexAdmin() )
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::ConstructL()
+    {
+    iCacheServer->AddSession();
+    iFileManager = CFileMan::NewL( iCacheServer->FileSession() );
+    #ifdef _DEBUG
+        TInt count = 0;
+        iCacheServer->CacheSize( count );
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::PanicClient
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::PanicClient( TInt aPanic )
+    {
+    _LIT( KTxtSessionPanic,"Test Server Session panic");
+    User::Panic( KTxtSessionPanic, aPanic );
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::DispatchMessageL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::DispatchMessageL( const RMessage2& aMessage )
+    {
+    switch( aMessage.Function() )
+        {
+        case EXcapCacheFetchInfo:
+            FetchDocumentInfoL( aMessage );
+            break;
+        case EXcapCacheFetchData:
+            FetchDocumentContentsL( aMessage );
+            break;
+        case EXcapCacheStore:
+            {
+            TInt entryCount = 0;
+            CacheXcapDataL( aMessage );
+            TInt size = iCacheServer->CacheSize( entryCount );
+            CheckUnindexedEntriesL( entryCount );
+            //Recheck the size
+            size = iCacheServer->CacheSize( entryCount );
+            const TInt maxSize = iCacheServer->MaxCacheSize();
+            //If there's only one document filling the
+            //whole data area, there's not much to be done
+            //NOTE: Index & pagefile are always there => 3
+            if( size >= maxSize && entryCount > 3 )
+                {
+                #ifdef _DEBUG
+                    CXcapCacheServer::WriteToLog( _L8( " Cache too large: %d bytes" ), size );
+                #endif
+                iCacheIndex.SortEntriesL();
+                const TInt compression( iCacheServer->MaxCacheSize() * KDefaultCompression );
+                //NOTE: Index & pagefile are always there -> 3
+                TBool ready = EFalse;
+                while( entryCount > 3 && size > compression && !ready )
+                    {
+                    //The entries have been sorted => FIFO
+                    CXcapCacheIndexEntry* entry = iCacheIndex.Entry( 0 );
+                    if( entry )
+                    	{
+                        DeleteFromStorageL( entry->FileName16L() );
+                        iCacheIndex.RemoveEntry( 0 );
+                        iCacheIndexAdmin.RemoveTableIndex( 0 );
+                        FlushCacheDataL();
+                        size = iCacheServer->CacheSize( entryCount );
+                    	}
+                    else ready = ETrue;
+                    }
+                } 
+            }  
+            break;
+        case EXcapCacheDelete:
+            DeleteCacheDataL( aMessage );
+            break;
+        case EXcapCacheCheckValidity:
+            CheckValidityL( aMessage );
+            break;
+        case EXcapCacheFlush:
+            FlushCacheDataL();
+            break;
+        default:
+            PanicClient( EBadRequest );
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::CheckUnindexedEntriesL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::CheckUnindexedEntriesL( TInt aTotalCount )
+    {
+    #ifdef _DEBUG
+    	CXcapCacheServer::WriteToLog( _L8( "CXcapCacheSession::CheckUnindexedEntriesL()" ) );
+        CXcapCacheServer::WriteToLog( _L8( "  Total count: %d" ), aTotalCount );
+	#endif
+    const TInt indexed = iCacheIndex.EntryCount();
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "  Indexed entries: %d" ), indexed );
+	#endif
+    if( aTotalCount > indexed + 2 )  //index + pagefile = 2
+        {
+        CDesC16ArraySeg* array = new ( ELeave ) CDesC16ArraySeg( indexed );
+        CleanupStack::PushL( array );
+        array->AppendL( KCacheServerIndexF() );
+        array->AppendL( KCacheServerPageFileF() );
+        for( TInt i = 0;i < indexed;i++ )
+            {
+            const TChar delimiter = 92;
+            TPtrC temp( iCacheIndex.Entry( i )->FileName16L() );
+            TPtrC entry( temp.Right( temp.LocateReverse( delimiter ) + 1 ) );
+            array->AppendL( entry );
+            }
+        DeleteExcessL( *array );
+        array->Reset();
+        CleanupStack::PopAndDestroy();  //array
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::DeleteExcessL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::DeleteExcessL( const MDesC16Array& aIndexedEntries )
+	{
+	#ifdef _DEBUG
+    	CXcapCacheServer::WriteToLog( _L8( "CXcapCacheSession::DeleteExcessL()" ) );
+	#endif
+    CDir* directory = NULL;
+    RFs& session = CXcapCacheServer::FileSession();
+    User::LeaveIfError( session.GetDir( KCacheServerRoot, KEntryAttNormal,
+    					ESortNone, directory ) );
+    CleanupStack::PushL( directory );
+    const TInt count = directory->Count();
+    for( TInt i = 0;i < count;i++ )
+    	{
+    	TPtrC targetName( ( *directory )[i].iName );
+    	if( !IsIndexed( aIndexedEntries, targetName ) )
+    		{
+        	HBufC* fileName = HBufC::NewLC( targetName.Length() + 
+    						  KCacheServerRoot().Length() );
+    		fileName->Des().Copy( KCacheServerRoot );
+    		fileName->Des().Append( targetName );
+    		TPtrC name( fileName->Des() );
+    		User::LeaveIfError( iFileManager->Delete( name ) );
+    		CleanupStack::PopAndDestroy();  //fileName
+    		}
+    	}
+    CleanupStack::PopAndDestroy();  //directory
+	}
+
+// ----------------------------------------------------------
+// CXcapCacheSession::IsIndexed
+// 
+// ----------------------------------------------------------
+//
+TBool CXcapCacheSession::IsIndexed( const MDesC16Array& aIndexedEntries, const TDesC& aFileName )
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheSession::IsIndexed()" ) );
+    #endif
+    TBool indexed = EFalse;
+    const TInt count = aIndexedEntries.MdcaCount();
+    for( TInt i = 0;!indexed && i < count;i++ )
+    	{
+    	if( aIndexedEntries.MdcaPoint( i ).Compare( aFileName ) == 0 )
+    		{
+    		indexed = ETrue;
+    		}
+    	}
+    return indexed;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::ReadMsgParamLC
+// 
+// ----------------------------------------------------------
+//
+HBufC* CXcapCacheSession::ReadMsgParam16LC( TInt aMsgIndex, const RMessage2& aMessage )
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheServer::ReadMsgParam16LC()" ) );
+    #endif
+    TInt length = aMessage.GetDesLength( aMsgIndex );
+    HBufC* buffer = HBufC::NewLC( length );
+    TPtr descriptor( buffer->Des() );
+    aMessage.ReadL( aMsgIndex, descriptor );
+    return buffer;
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::ReadMsgParam8LC
+// 
+// ----------------------------------------------------------
+//
+HBufC8* CXcapCacheSession::ReadMsgParam8LC( TInt aMsgIndex, const RMessage2& aMessage )
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheServer::ReadMsgParam8LC()" ) );
+    #endif
+    TInt length = aMessage.GetDesLength( aMsgIndex );
+    HBufC8* buffer = HBufC8::NewLC( length );
+    TPtr8 descriptor( buffer->Des() );
+    aMessage.ReadL( aMsgIndex, descriptor );
+    return buffer;
+    }
+       
+// ----------------------------------------------------------
+// CXcapCacheSession::CheckValidityL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::CheckValidityL( const RMessage2& aMessage )
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "** CXcapCacheServer::CheckValidityL()" ) );
+    #endif
+    TPtrC8 etag( ReadMsgParam8LC( 0, aMessage )->Des() );
+    TPtrC name( ReadMsgParam16LC( 1, aMessage )->Des() );
+    TPtrC8 root( ReadMsgParam8LC( 2, aMessage )->Des() );
+    TInt tableIndex = KErrNotFound;
+    CXcapCacheIndexTableEntry* tableEntry = iCacheIndexAdmin.FindL( tableIndex, root, name );
+    if( tableEntry != NULL )
+        {
+        CXcapCacheIndexEntry* entry = iCacheIndex.Entry( tableEntry->Index() );
+        User::Leave( entry->ETag().Compare( etag ) == 0 ? KErrNone : KErrGeneral );
+        }
+    else User::Leave( KErrNotFound );
+    CleanupStack::PopAndDestroy( 3 );  //root, name, etag
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheSession::DeleteCacheDataL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::DeleteCacheDataL( const RMessage2& aMessage )
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "** CXcapCacheServer::DeleteCacheDataL()" ) );
+    #endif
+    TCacheEntryInfo header;
+    TPckg<TCacheEntryInfo> pack( header );
+    aMessage.ReadL( 0, pack );
+    TInt tableIndex = KErrNotFound;
+    CXcapCacheIndexTableEntry* tableEntry =
+        iCacheIndexAdmin.FindL( tableIndex, *header.iRootUri, *header.iDocumentUri );
+    if( tableEntry )
+        {
+        TInt error = KErrNone;
+        TInt index( tableEntry->Index() );
+        CXcapCacheIndexEntry* entry = iCacheIndex.Entry( index );
+        error = DeleteFromStorageL( entry->FileName16L() );
+        #ifdef _DEBUG
+            CXcapCacheServer::WriteToLog(
+                    _L8( "CXcapCacheSession::DeleteCacheDataL() - error: %d"), error  );
+        #endif
+        iCacheIndex.RemoveEntry( index );
+        iCacheIndexAdmin.RemoveTableIndex( tableIndex );
+        FlushCacheDataL();
+        }
+    else User::Leave( KErrNotFound );
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheSession::FetchDocumentInfoL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::FetchDocumentInfoL( const RMessage2& aMessage )
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "** CXcapCacheServer::FetchDocumentInfoL()" ) );
+    #endif
+    TInt error = KErrNone;
+    //Read info header
+    TCacheEntryInfo header;
+    TPckg<TCacheEntryInfo> pack( header );
+    aMessage.ReadL( 0, pack );
+    TPtrC name( ReadMsgParam16LC( 2, aMessage )->Des() );
+    TPtrC8 root( ReadMsgParam8LC( 3, aMessage )->Des() );
+    TInt tableIndex = KErrNotFound;
+    #ifdef _DEBUG
+        HBufC8* temp = HBufC8::NewLC( name.Length() );
+        TPtr8 tempDesc( temp->Des() );
+        tempDesc.Copy( name );
+        CXcapCacheServer::WriteToLog( _L8( "   Root:     %S" ), &root );
+        CXcapCacheServer::WriteToLog( _L8( "   Document: %S" ), &tempDesc );
+        CleanupStack::PopAndDestroy();  //temp
+    #endif
+    CXcapCacheIndexTableEntry* tableEntry = iCacheIndexAdmin.FindL( tableIndex, root, name );
+    if( tableEntry != NULL )
+        {
+        TInt index = tableEntry->Index();
+        CXcapCacheIndexEntry* entry = iCacheIndex.Entry( index );
+        TPtrC8 eTag = entry->ETag();
+        header.iDataLength = entry->XmlSize();
+        header.iLastAccess = entry->LastAccess();
+        header.iLastUpdate = entry->LastModified();
+        TPckgC<TCacheEntryInfo> package( header );
+        TRAP( error, aMessage.WriteL( 0, package ) );
+        #ifdef _DEBUG
+            CXcapCacheServer::WriteToLog( _L8( "  Write header: %d" ), error );
+        #endif
+        TRAP( error, aMessage.WriteL( 1, eTag ) );
+        #ifdef _DEBUG
+            CXcapCacheServer::WriteToLog( _L8( "  Write ETag:   %d" ), error );
+        #endif
+        }
+    else User::Leave( KErrNotFound );
+    CleanupStack::PopAndDestroy( 2 );  //root, name
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheSession::FetchDocumentContentsL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::FetchDocumentContentsL( const RMessage2& aMessage )
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "** CXcapCacheServer::FetchDocumentContentsL()" ) );
+    #endif
+    TPtrC name( ReadMsgParam16LC( 0, aMessage )->Des() );
+    TPtrC8 root( ReadMsgParam8LC( 1, aMessage )->Des() );
+    #ifdef _DEBUG
+        HBufC8* document = HBufC8::NewLC( name.Length() );
+        TPtr8 docDesc( document->Des() );
+        docDesc.Copy( name );
+        CXcapCacheServer::WriteToLog( _L8( "  Document:    %S" ), &docDesc );
+        CXcapCacheServer::WriteToLog( _L8( "  Root URI:    %S" ), &root );
+        CleanupStack::PopAndDestroy();  //document
+    #endif
+    TInt tableIndex = KErrNotFound;
+    CXcapCacheIndexTableEntry* tableEntry = iCacheIndexAdmin.FindL( tableIndex, root, name );
+    if( tableEntry != NULL )
+        {
+        CXcapCacheIndexEntry* entry = iCacheIndex.Entry( tableEntry->Index() );
+        iTempBuffer = ReadFromStorageL( entry->FileName16L() );
+        TPtrC8 dataDesc = iTempBuffer->Des();
+        aMessage.Write( 2, dataDesc );
+        }
+    else User::Leave( KErrNotFound );
+    CleanupStack::PopAndDestroy( 2 );  //name, root
+    }
+    
+// ----------------------------------------------------------
+// CXcapCacheSession::CacheXcapData
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::CacheXcapDataL( const RMessage2& aMessage )
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "** CXcapCacheServer::CacheXcapDataL()" ) );
+    #endif
+    TPtrC doc( ReadMsgParam16LC( 0, aMessage )->Des() );
+    TPtrC8 root( ReadMsgParam8LC( 1, aMessage )->Des() );
+    TPtrC8 etag( ReadMsgParam8LC( 2, aMessage )->Des() );
+    TPtrC8 data( ReadMsgParam8LC( 3, aMessage )->Des() );
+    #ifdef _DEBUG
+        HBufC8* document = HBufC8::NewLC( doc.Length() );
+        TPtr8 docDesc( document->Des() );
+        docDesc.Copy( doc );
+        CXcapCacheServer::WriteToLog( _L8( "  Document:    %S" ), &docDesc );
+        CXcapCacheServer::WriteToLog( _L8( "  ETag:        %S" ), &etag );
+        CXcapCacheServer::WriteToLog( _L8( "  Root URI:    %S" ), &root );
+        CXcapCacheServer::WriteToLog( _L8( "  Data:        %d bytes" ), data.Length() );
+        CleanupStack::PopAndDestroy();  //document
+    #endif
+    TInt tableIndex = KErrNotFound;
+    TCacheEntryInfo header;
+    header.iEtag = &etag;
+    header.iRootUri = &root;
+    header.iRespData = &data;
+    header.iDocumentUri = &doc;
+    header.iDataLength = data.Length();
+    CXcapCacheIndexTableEntry* tableEntry = iCacheIndexAdmin.FindL( tableIndex, root, doc );
+    CXcapCacheIndexEntry* entry = NULL;
+    if( tableEntry != NULL )
+        {
+        entry = iCacheIndex.Entry( tableEntry->Index() );
+        entry->UpdateEntryL( &header );
+        }
+    else
+        {
+        entry = CXcapCacheIndexEntry::NewL( &header );
+        CleanupStack::PushL( entry );
+        TInt index = iCacheIndex.UpdateIndexL( entry );
+        CleanupStack::Pop();  //entry
+        iCacheIndexAdmin.UpdateIndexTableL( index, &header );
+        }
+    CleanupStack::PopAndDestroy( 4 );  //data, etag, root, name
+    FlushCacheDataL();
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::FlushCacheDataL
+// 
+// ----------------------------------------------------------
+//
+void CXcapCacheSession::FlushCacheDataL()
+    {
+    #ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheServer::FlushCacheDataL()" ) );
+    #endif
+    iCacheIndex.StoreCacheDataL();
+    iCacheIndexAdmin.StoreIndexTableL();
+    }
+
+// ----------------------------------------------------------
+// CXcapCacheSession::DeleteFromStorageL
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapCacheSession::DeleteFromStorageL( const TDesC& aFileName )
+    {
+    #ifdef _DEBUG
+        HBufC8* name = HBufC8::NewLC( aFileName.Length() );
+        TPtr8 nameDesc( name->Des() );
+        nameDesc.Copy( aFileName );
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheServer::DeleteFromStorageL() - Filename: %S" ), &nameDesc );
+        CleanupStack::PopAndDestroy();  //name
+    #endif
+    TInt error = iFileManager->Delete( aFileName );
+    return error;
+    }
+            
+// ----------------------------------------------------------
+// CXcapCacheSession::FlushCacheDataL
+// 
+// ----------------------------------------------------------
+//
+HBufC8* CXcapCacheSession::ReadFromStorageL( const TDesC& aFileName )
+    {
+    #ifdef _DEBUG
+        HBufC8* name = HBufC8::NewLC( aFileName.Length() );
+        TPtr8 nameDesc( name->Des() );
+        nameDesc.Copy( aFileName );
+        CXcapCacheServer::WriteToLog( _L8( "CXcapCacheServer::ReadFromStorageL() - Filename: %S" ), &nameDesc );
+        CleanupStack::PopAndDestroy();  //name
+    #endif
+    RFile file;
+    HBufC8* data = NULL;
+    User::LeaveIfError( file.Open( CXcapCacheServer::FileSession(), aFileName, EFileRead ) );
+    CleanupClosePushL( file );
+    TInt size = 0;
+    User::LeaveIfError( file.Size( size ) );
+    data = HBufC8::NewL( size );
+    TPtr8 pointer( data->Des() );
+    file.Read( pointer );
+    CleanupStack::PopAndDestroy();  //file
+    return data;
+    }
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/Server/src/XcapShutdownTimer.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,75 @@
+/*
+* 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:   CXcapShutdownTimer
+*
+*/
+
+
+
+#include "XcapCacheServer.h"
+#include "XcapShutdownTimer.h"
+
+// ----------------------------------------------------
+// CXcapShutdownTimer::CXcapShutdownTimer
+// 
+// ----------------------------------------------------
+//
+CXcapShutdownTimer::CXcapShutdownTimer() : CTimer( -1 )
+  {
+  /*#ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapShutdownTimer::CXcapShutdownTimer()" ) );
+    #endif*/
+  CActiveScheduler::Add(this);
+  }
+
+// ----------------------------------------------------
+// CXcapShutdownTimer::ConstructL
+// 
+// ----------------------------------------------------
+//  
+void CXcapShutdownTimer::ConstructL()
+  {
+  /*#ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapShutdownTimer::ConstructL()" ) );
+    #endif*/
+  CTimer::ConstructL();
+  }
+
+// ----------------------------------------------------
+// CXcapShutdownTimer::Start
+// 
+// ----------------------------------------------------
+//
+void CXcapShutdownTimer::Start()
+  {
+  /*#ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapShutdownTimer::Start()" ) );
+    #endif*/
+  After( KXcapCacheShutdownDelay );
+  }
+
+// ----------------------------------------------------
+// CXcapShutdownTimer::RunL
+// 
+// ----------------------------------------------------
+//  
+void CXcapShutdownTimer::RunL()
+  {
+  /*#ifdef _DEBUG
+        CXcapCacheServer::WriteToLog( _L8( "CXcapShutdownTimer::RunL() - Closing down server" ) );
+    #endif*/
+  CActiveScheduler::Stop();
+  }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/inc/CommonDefines.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,88 @@
+/*
+* 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:   XcapCache common defines
+*
+*/
+
+
+
+
+#ifndef __COMMONDEFINES_H__
+#define __COMMONDEFINES_H__
+
+#include <e32base.h>
+
+//Information about the data in the cache
+class TCacheEntryInfo
+    {
+    public:    
+        
+        TTime                         iLastUpdate;
+        TTime                         iLastAccess;
+        TInt32                        iDataLength;
+        const TDesC*                  iDocumentUri;
+        const TDesC8*                 iEtag;
+        const TDesC8*                 iRootUri;
+        const TDesC8*                 iRespData;
+    };
+    
+// server name
+_LIT( KXcapCacheServerName,                          "!CXcapCacheServer" );
+_LIT( KXcapCacheServerLib,                           "XcapCacheServer" );
+_LIT( KXcapCacheServerExe,                           "XcapCache.exe");
+
+// A version must be specifyed when creating a session with the server
+const TUint KCacheServerMajorVersionNumber           = 0;
+const TUint KCacheServerMinorVersionNumber           = 1;
+const TUint KCacheServerBuildVersionNumber           = 1;
+
+// Server panic codes
+enum TXcapCacheServerPanic
+    {
+    ECacheCreateServer = 0,
+    ECacheStartServer,
+    ECacheFileServerConnect,
+    ECacheIndexFileOpen,
+    ECachePageFileOpen,
+    EMainSchedulerError,
+    EBadRequest
+    };
+    
+//Opcodes used in message passing between client and server
+enum TTransportServerRequest
+	{
+	EXcapCacheFetchInfo = 0,
+	EXcapCacheFetchData,
+    EXcapCacheStore,
+    EXcapCacheDelete,
+    EXcapCacheCheckValidity,
+    EXcapCacheFlush
+	};	
+
+//Number of asynchronous requests
+const TUint KTTMaxAsyncRequests                     = 4;
+
+//Number of data transfer requests
+const TUint KTTDataTransferRequests                 = 3;
+
+//Default number of message slots per session
+const TUint KTTDefaultMessageSlots	                = KTTMaxAsyncRequests + 2;
+
+const TInt KServerLogBufferMaxSize                  = 2000;
+
+const TInt KMaxCacheSize                            = 30000;
+
+#endif // #ifndef __COMMONDEFINES_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapCache/inc/XcapCache.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,159 @@
+/*
+* 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:   RXcapCache
+*
+*/
+
+
+
+
+#ifndef __XCAPCACHE_H__
+#define __XCAPCACHE_H__
+
+// INCLUDES
+#include <e32std.h>
+#include <f32file.h>
+
+//Constants
+#ifdef _DEBUG
+    _LIT( KCacheClientLogDir,                       "XDM" );
+    _LIT( KCacheClientLogFile,                      "CacheClient.txt" );
+#endif
+
+//FORWARD DECLARATIONS
+class TCacheEntryInfo;
+class CXcapCacheClient;
+
+//CLASS DECLARATION
+class RXcapCache : public RSessionBase
+    {
+    public:  // New functions
+        
+        /**
+        * C++ Constructor.
+        */
+        IMPORT_C RXcapCache();
+        
+        /**
+        * Return the version of this component
+        *
+        * @return TVersion The version number
+        */
+        IMPORT_C TVersion Version() const;
+        
+        /**
+        * Connect to the server side session object
+        *
+        * @return TInt Error code
+        */
+        IMPORT_C TInt Connect();
+        
+        /**
+        * Destructor
+        */
+        IMPORT_C ~RXcapCache();
+        
+        /**
+        * Store a new document
+        *
+        * @param TDesC8& ETag of the new document
+        * @param TDesC& Name of the document
+        * @param TDesC8& Root location of the document
+        * @param TDesC8& The document content
+        * @return void
+        */
+        IMPORT_C void Store( const TDesC8& aETag, 
+                             const TDesC& aDocumentName,
+                             const TDesC8& aRootLocation,
+                             const TDesC8& aResponseData );
+        
+        /**
+        * Remove a named document from the cache
+        *
+        * @param TDesC& Name of the document
+        * @param TDesC8& Root location of the document
+        * @return TInt Error code
+        */
+        IMPORT_C TInt Delete( const TDesC& aDocumentName,
+                              const TDesC8& aRootLocation );
+        
+        /**
+        * Fetch information on a named document
+        *
+        * @param TDes8& Contains the ETag string on completion
+        * @param TCacheEntryInfo& Encapsulates root & name 
+        * @return TInt Error code
+        */
+        IMPORT_C TInt FetchDocumentInfo( TDes8& aETagDescriptor,
+                                         const TDesC& aDocumentName,
+                                         const TDesC8& aRootLocation,
+                                         TCacheEntryInfo& aEntryInfo );
+        
+        /**
+        * Fetch content for the named document
+        *
+        * @param TRequestStatus& Request status of the client
+        * @param TDes8& Contains the document contents on completion
+        * @param TCacheEntryInfo& Encapsulates root & name 
+        * @return TInt Error code
+        */                             
+        IMPORT_C void FetchDocumentContent( TDes8& aContentDescriptor,
+                                            const TDesC& aDocumentName,
+                                            const TDesC8& aRootLocation );
+        
+        /**
+        * Check validity of the named document
+        *
+        * @param TDesC8& ETag of the document
+        * @param TDesC& Name of the document
+        * @param TDesC8& Root location of the document
+        * @return TInt Error code
+        */                            
+        IMPORT_C TInt IsCurrent( const TDesC8& aETag, 
+                                 const TDesC& aDocumentName,
+                                 const TDesC8& aRootLocation );
+                                                                                                                            
+        /**
+        * Flush (externalise) cache metadata to disk
+        *
+        * @return void
+        */
+        IMPORT_C void Flush();
+        
+    public:   //Not exported
+        
+        /**
+        * Start the server
+        *
+        * @return TInt Error code
+        */
+        TInt StartServer();
+        
+        /**
+        * Check whether the server is already running
+        *
+        * @return TBool Is the server running
+        */
+        TBool IsRunning();
+
+
+    private: //Data
+        
+       TBool                                            iConnected;
+    };
+
+#endif      //__XCAPCACHE_H__
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/BWINSCW/XcapHttpTransportU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,24 @@
+EXPORTS
+	??1CXcapHttpRequest@@UAE@XZ @ 1 NONAME ; CXcapHttpRequest::~CXcapHttpRequest(void)
+	??1CXcapHttpTransport@@UAE@XZ @ 2 NONAME ; CXcapHttpTransport::~CXcapHttpTransport(void)
+	?CancelRequest@CXcapHttpRequest@@QAEXXZ @ 3 NONAME ; void CXcapHttpRequest::CancelRequest(void)
+	?DeleteL@CXcapHttpTransport@@QAEPAVCXcapHttpReqDelete@@ABVTDesC16@@@Z @ 4 NONAME ; class CXcapHttpReqDelete * CXcapHttpTransport::DeleteL(class TDesC16 const &)
+	?DispatchRequestL@CXcapHttpRequest@@QAEXAAVTRequestStatus@@@Z @ 5 NONAME ; void CXcapHttpRequest::DispatchRequestL(class TRequestStatus &)
+	?GetL@CXcapHttpTransport@@QAEPAVCXcapHttpReqGet@@ABVTDesC16@@@Z @ 6 NONAME ; class CXcapHttpReqGet * CXcapHttpTransport::GetL(class TDesC16 const &)
+	?HeadL@CXcapHttpTransport@@QAEPAVCXcapHttpReqHead@@ABVTDesC16@@@Z @ 7 NONAME ; class CXcapHttpReqHead * CXcapHttpTransport::HeadL(class TDesC16 const &)
+	?HeaderValue@CXcapHttpRequest@@QBE?AVTPtrC8@@W4TStrings@HTTP@@@Z @ 8 NONAME ; class TPtrC8 CXcapHttpRequest::HeaderValue(enum HTTP::TStrings) const
+	?MkcolL@CXcapHttpTransport@@QAEPAVCXcapHttpReqMkcol@@ABVTDesC16@@@Z @ 9 NONAME ; class CXcapHttpReqMkcol * CXcapHttpTransport::MkcolL(class TDesC16 const &)
+	?NewL@CXcapHttpTransport@@SAPAV1@ABVTDesC16@@AAVMMsgConnManager@@ABVTXdmCredentials@@@Z @ 10 NONAME ; class CXcapHttpTransport * CXcapHttpTransport::NewL(class TDesC16 const &, class MMsgConnManager &, class TXdmCredentials const &)
+	?PutL@CXcapHttpTransport@@QAEPAVCXcapHttpReqPut@@ABVTDesC16@@@Z @ 11 NONAME ; class CXcapHttpReqPut * CXcapHttpTransport::PutL(class TDesC16 const &)
+	?ReleaseResponseData@CXcapHttpRequest@@QAEXXZ @ 12 NONAME ; void CXcapHttpRequest::ReleaseResponseData(void)
+	?RequestBody@CXcapHttpContSupplier@@QBE?AVTPtrC8@@XZ @ 13 NONAME ; class TPtrC8 CXcapHttpContSupplier::RequestBody(void) const
+	?RequestUriL@CXcapHttpRequest@@QBE?AVTPtrC8@@XZ @ 14 NONAME ; class TPtrC8 CXcapHttpRequest::RequestUriL(void) const
+	?ResetUriL@CXcapHttpRequest@@QAEXABVTDesC16@@@Z @ 15 NONAME ; void CXcapHttpRequest::ResetUriL(class TDesC16 const &)
+	?ResponseData@CXcapHttpRequest@@QAEPAVTXdmCompletionData@@XZ @ 16 NONAME ; class TXdmCompletionData * CXcapHttpRequest::ResponseData(void)
+	?RootUri@CXcapHttpTransport@@QAE?AVTPtrC8@@XZ @ 17 NONAME ; class TPtrC8 CXcapHttpTransport::RootUri(void)
+	?SetExpiryTimeL@CXcapHttpRequest@@QAEXPAVMXcapHttpRequestTimerCallback@@VTTimeIntervalMicroSeconds32@@@Z @ 18 NONAME ; void CXcapHttpRequest::SetExpiryTimeL(class MXcapHttpRequestTimerCallback *, class TTimeIntervalMicroSeconds32)
+	?SetHeaderL@CXcapHttpRequest@@QAEXABVTDesC8@@0@Z @ 19 NONAME ; void CXcapHttpRequest::SetHeaderL(class TDesC8 const &, class TDesC8 const &)
+	?SetRequestBodyL@CXcapHttpContSupplier@@QAEXABVTDesC8@@@Z @ 20 NONAME ; void CXcapHttpContSupplier::SetRequestBodyL(class TDesC8 const &)
+	?SetRootUriL@CXcapHttpTransport@@QAEXABVTDesC16@@@Z @ 21 NONAME ; void CXcapHttpTransport::SetRootUriL(class TDesC16 const &)
+	?UpdateRequestUriL@CXcapHttpRequest@@QAEXABVTDesC8@@@Z @ 22 NONAME ; void CXcapHttpRequest::UpdateRequestUriL(class TDesC8 const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/eabi/XcapHttpTransportU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,32 @@
+EXPORTS
+    _ZN16CXcapHttpRequest10SetHeaderLERK6TDesC8S2_ @ 1 NONAME
+	_ZN16CXcapHttpRequest12ResponseDataEv @ 2 NONAME
+	_ZN16CXcapHttpRequest13CancelRequestEv @ 3 NONAME
+	_ZN16CXcapHttpRequest14SetExpiryTimeLEP29MXcapHttpRequestTimerCallback27TTimeIntervalMicroSeconds32 @ 4 NONAME
+	_ZN16CXcapHttpRequest16DispatchRequestLER14TRequestStatus @ 5 NONAME
+	_ZN16CXcapHttpRequest17UpdateRequestUriLERK6TDesC8 @ 6 NONAME
+	_ZN16CXcapHttpRequest19ReleaseResponseDataEv @ 7 NONAME
+	_ZN16CXcapHttpRequest9ResetUriLERK7TDesC16 @ 8 NONAME
+	_ZN18CXcapHttpTransport11SetRootUriLERK7TDesC16 @ 9 NONAME
+	_ZN18CXcapHttpTransport4GetLERK7TDesC16 @ 10 NONAME
+	_ZN18CXcapHttpTransport4NewLERK7TDesC16R15MMsgConnManagerRK15TXdmCredentials @ 11 NONAME
+	_ZN18CXcapHttpTransport4PutLERK7TDesC16 @ 12 NONAME
+	_ZN18CXcapHttpTransport5HeadLERK7TDesC16 @ 13 NONAME
+	_ZN18CXcapHttpTransport6MkcolLERK7TDesC16 @ 14 NONAME
+	_ZN18CXcapHttpTransport7DeleteLERK7TDesC16 @ 15 NONAME
+	_ZN18CXcapHttpTransport7RootUriEv @ 16 NONAME
+	_ZN21CXcapHttpContSupplier15SetRequestBodyLERK6TDesC8 @ 17 NONAME
+	_ZNK16CXcapHttpRequest11HeaderValueEN4HTTP8TStringsE @ 18 NONAME
+	_ZNK16CXcapHttpRequest11RequestUriLEv @ 19 NONAME
+	_ZNK21CXcapHttpContSupplier11RequestBodyEv @ 20 NONAME
+	_ZTI16CXcapHttpRequest @ 21 NONAME ; #<TI>#
+	_ZTI18CXcapHttpTransport @ 22 NONAME ; #<TI>#
+	_ZTI20CXcapHttpAuthManager @ 23 NONAME ; #<TI>#
+	_ZTI21CXcapHttpContSupplier @ 24 NONAME ; #<TI>#
+	_ZTV16CXcapHttpRequest @ 25 NONAME ; #<VT>#
+	_ZTV18CXcapHttpTransport @ 26 NONAME ; #<VT>#
+	_ZTV20CXcapHttpAuthManager @ 27 NONAME ; #<VT>#
+	_ZTV21CXcapHttpContSupplier @ 28 NONAME ; #<VT>#
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/group/XcapHttpTransport.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,78 @@
+/*
+* 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: XcapHttpTransport.dll from XcapHttpTransport.mmp
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                  xcaphttptransport.dll
+TARGETTYPE              dll
+UID                     0x1000008d 0x10207411
+CAPABILITY              CAP_GENERAL_DLL
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+
+SOURCE                  XcapHttpTransport.cpp
+SOURCE                  XcapHttpReqGet.cpp
+SOURCE                  XcapHttpReqPut.cpp
+SOURCE                  XcapHttpRequest.cpp
+SOURCE                  XcapHttpResponse.cpp
+SOURCE                  XcapHttpReqDelete.cpp
+SOURCE                  XcapHttpHeaderModel.cpp
+SOURCE                  XcapHttpAuthManager.cpp
+SOURCE                  XcapHttpContSupplier.cpp
+SOURCE                  XcapHttpRequestTimer.cpp
+// SONERA SOLUTION
+SOURCE                  XcapHttpReqHead.cpp
+SOURCE                  XcapHttpReqMkcol.cpp
+
+//Internal
+USERINCLUDE             ../inc
+USERINCLUDE             ../../inc
+USERINCLUDE             ../../../inc
+USERINCLUDE             ../../XcapOperations/inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE           /epoc32/include/http
+SYSTEMINCLUDE           /epoc32/include/ecom
+SYSTEMINCLUDE           ../../../../inc
+
+
+LIBRARY                 hal.lib
+LIBRARY                 bafl.lib
+LIBRARY                 http.lib
+LIBRARY                 ecom.lib
+LIBRARY                 hash.lib
+LIBRARY                 efsrv.lib
+LIBRARY                 euser.lib
+LIBRARY                 xdmengine.lib
+LIBRARY                 inetprotutil.lib
+DEBUGLIBRARY            flogger.lib
+
+
+
+#if defined( ARMCC )
+    deffile ../eabi/ 
+#elif defined ( WINSCW )
+    deffile ../BWINSCW/ 
+#elif defined ( WINS )
+    deffile ../bwins/  
+#endif 
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  XcapHttpTransport bld.inf
+*
+*/
+
+
+
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+
+XcapHttpTransport.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpAuthManager.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,163 @@
+/*
+* 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:   CXcapHttpAuthManager
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPTAUTHMANAGER__
+#define __XCAPHTTPTAUTHMANAGER__
+
+// INCLUDES
+#include <XdmCredentials.h>
+#include <http/mhttpauthenticationcallback.h>
+#include "XcapHttpConsts.h"
+
+//FORWARD DECLARATION  
+class CMD5;
+
+//CLASS DECLARATION
+class CXcapHttpAuthManager : public CBase
+
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        */     
+        static CXcapHttpAuthManager* NewL( RHTTPSession& iHttpSession,
+                                           CXcapHttpTransport& aTransportMain,
+                                           const TXdmCredentials& aDigestCredentials );
+        
+        /**
+        * Symbian OS default constructor.
+        */   
+        void SetAuthorized( TBool aAuthorized );
+        
+        /**
+        * Symbian OS default constructor.
+        */   
+        TBool IsAuthorized() const;
+        
+        /**
+        * Symbian OS default constructor.
+        */                                      
+        TBool ParseHeaderL( RHTTPTransaction& aTransaction, TInt aAuthType );
+        
+        /**
+        * A global logging function for 8 bit data.
+        * @param aCommand command to be handled
+        */
+        HBufC8* AuthorizationL( CXcapHttpRequest& aHttpRequest );
+        
+        /**
+        * Symbian OS default constructor.
+        */                                      
+        TBool ConsumeAuthInfoParamL( TAuthInfoParam aName, const TDesC8& aValue );
+        
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapHttpAuthManager();
+                               
+    private:
+        
+        /**
+        * C++ default constructor.
+        */      
+        CXcapHttpAuthManager( RHTTPSession& iHttpSession,
+                              CXcapHttpTransport& aTransportMain );
+
+        /**
+        * Symbian OS default constructor.
+        * @param aMimeType MIME type of the messages
+        */     
+        void ConstructL( const TXdmCredentials& aDigestCredentials );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aMimeType MIME type of the messages
+        */   
+        void Unquote( TPtr8& aParamValue );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aMimeType MIME type of the messages
+        */    
+        void ConstructHA1L( TDes8& aResult );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aMimeType MIME type of the messages
+        */    
+        void ConstructHA2L( TDes8& aResult, CXcapHttpRequest& aHttpRequest );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aMimeType MIME type of the messages
+        */   
+        void Hash( const TDesC8& aMessage, TDes8& aHash );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aMimeType MIME type of the messages
+        */   
+        HBufC8* RequestDigestLC( CXcapHttpRequest& aHttpRequest );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aMimeType MIME type of the messages
+        */ 
+        void SetNextNonceL( const TDesC8& aNextnonce );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aMimeType MIME type of the messages
+        */   
+        void GenerateClientNonce();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param aMimeType MIME type of the messages
+        */     
+        void ParseQopL( const TDesC8& aQopString );
+
+    private: //Data
+        
+        TInt                                        iNonceCount;
+        TBool                                       iAuthorized;
+        TBool                                       iUnauthReceived;
+        TBool                                       iNextnonce;
+        CMD5*                                       iMD5;
+	    TInt64                                      iSeed;
+	    HBufC8*                                     iOpaque;
+        HBufC8*                                     iServerNonce;
+        HBufC8*                                     iRealm;
+        HBufC8*                                     iDomain;
+        HBufC8*                                     iAlgorithm;
+        HBufC8*                                     iQopString;
+        TXcapAuthQop                                iQop;
+        RHTTPSession                                iHttpSession;
+        CXcapHttpTransport&                         iTransportMain;
+        TBuf8<KXcapHashLength>                      iClientNonce;
+        TBuf8<KXdmMaxUserNameLength>                iUserName;
+        TBuf8<KXdmMaxPasswordLength>                iPassword;
+        RStringPool                                 iStringPool;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpConsts.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,72 @@
+/*
+* 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:   XcapHttpConsts
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPCONSTS__
+#define __XCAPHTTPCONSTS__
+
+#include <e32base.h>
+
+const TInt KXcapHashLength                                  = 32;
+const TInt KXcapRawHashLength                               = 16;
+
+_LIT8( KAuthHeaderParamEnd,                                 "," );
+_LIT8( KAuthHeaderParamEndQ,                                "\"," );
+_LIT8( KAuthHeaderParamQuote,                               "\"" );
+_LIT8( KAuthHeaderStart,                                    "Digest username=\"" );
+_LIT8( KAuthHeaderRealm,                                    "realm=\"" );
+_LIT8( KAuthHeaderNonce,                                    "nonce=\"" );
+_LIT8( KAuthHeaderUri,                                      "uri=\"" );
+_LIT8( KAuthHeaderResponse,                                 "response=\"" );
+_LIT8( KAuthHeaderCNonce,                                   "cnonce=\"" );
+_LIT8( KAuthHeaderOpaque,                                   "opaque=\"" );
+_LIT8( KAuthHeaderNonceCount,                               "nc=" );
+_LIT8( KAuthHeaderQop,                                      "qop=" );
+
+const TText8* const KAuthInfoParamArray[]                   = 
+                                                            {
+                                                            _S8( "Authentication-Info" ),
+                                                            _S8( "Proxy-Authentication-Info" ),
+                                                            _S8( "nextnonce" ),
+                                                            _S8( "rspauth" ),
+                                                            _S8( "cnonce" ),
+                                                            _S8( "nc" ),
+                                                            _S8( "qop" ),
+                                                            };
+                                                            
+enum TAuthInfoParam                                         
+                                                            {
+                                                            ENfoAuthInfo = 0,
+                                                            ENfoPrxAuthInfo,
+                                                            ENfoNextnonce,
+                                                            ENfoRspauth,
+                                                            ENfoCnonce,
+                                                            ENfoNc,
+                                                            ENfoQop,
+                                                            };
+enum TXcapAuthQop
+    {
+    EXcapAuth = 0,
+    EXcapAuthInt,
+    EXcapAuthNone
+    };
+    
+#endif      //__XCAPHTTPCONSTS__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpContSupplier.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXcapHttpContSupplier
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPCONTSUPPLIER__
+#define __XCAPHTTPCONTSUPPLIER__
+
+// INCLUDES
+#include "XcapHttpRequest.h"
+
+//FORWARD DECLARATIONS
+class CXdmHttpResponse;
+
+// CLASS DECLARATION
+class CXcapHttpContSupplier : public CXcapHttpRequest,
+                              public MHTTPDataSupplier
+    {
+    public:
+
+        /**
+        * C++ default constructor is private.
+        */      
+        IMPORT_C void SetRequestBodyL( const TDesC8& aRequestBody );
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        IMPORT_C TPtrC8 RequestBody() const;
+
+    protected:
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        CXcapHttpContSupplier( RHTTPSession& aHttpSession,
+                               CXcapHttpAuthManager& aAuthManager,
+                               CXcapHttpTransport& aTransportMain );
+        
+         /**
+        * Destructor.
+        */      
+        virtual ~CXcapHttpContSupplier();
+    
+    private:
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        TBool GetNextDataPart( TPtrC8& aDataPart );
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        void ReleaseData();
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        TInt Reset();
+
+	    /**
+        * Second-phase constructor.
+        */ 
+        TInt OverallDataSize();
+
+    protected: //Data
+
+    private: //Data
+        
+        HBufC8*                         iRequestBody;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpHeaderModel.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CXcapHttpHeaderModel 
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPHEADERMODEL__
+#define __XCAPHTTPHEADERMODEL__
+
+// INCLUDES
+#include "XcapHttpRequest.h"
+
+//FORWARD DECLARATIONS
+class CXcapHttpResponse;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapHttpHeaderModel ) : public CBase
+    {
+    public:
+
+        /**
+        * C++ default constructor is private.
+        */      
+        static CXcapHttpHeaderModel* NewL( const TDesC8& aHeaderName,
+                                           const TDesC8& aHeaderValue,
+                                           CXcapHttpTransport& aTransportMain );
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        TPtrC8 HeaderValue() const; 
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        TPtrC8 HeaderName() const; 
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapHttpHeaderModel();
+    
+    private:
+        
+        /**
+        * C++ default constructor is private.
+        */     
+        CXcapHttpHeaderModel( CXcapHttpTransport& aTransportMain );
+        
+        /**
+        * C++ default constructor is private.
+        */     
+        void ConstructL( const TDesC8& aHeaderName,
+                         const TDesC8& aHeaderValue );
+
+    protected: //Data
+
+    private: //Data
+        
+        HBufC8*                         iHeaderName;
+        HBufC8*                         iHeaderValue;
+        CXcapHttpTransport&             iTransportMain; 
+
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpReqDelete.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  CXcapHttpReqDelete 
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPREQDELETE__
+#define __XCAPHTTPREQDELETE__
+
+// INCLUDES
+#include "http.h"
+#include "XcapHttpRequest.h"
+
+//CONSTANTS
+
+//FORWARD DECLARATIONS
+class CXcapHttpResponse;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapHttpReqDelete ) : public CXcapHttpRequest
+    {
+    public:
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        static CXcapHttpReqDelete* NewL( const TDesC& aRequestUri, 
+                                         RHTTPSession& aHttpSession,
+                                         CXcapHttpAuthManager& aAuthManager,
+                                         CXcapHttpTransport& aTransportMain );
+
+         /**
+        * Destructor.
+        */      
+        virtual ~CXcapHttpReqDelete();
+
+    private:  // Constructors and destructor
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        CXcapHttpReqDelete( RHTTPSession& aHttpSession,
+                            CXcapHttpAuthManager& aAuthManager,
+                            CXcapHttpTransport& aTransportMain );
+
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        virtual void ConstructRequestL();
+
+        /**
+        * Append data to the response buffer.
+        */
+        virtual RStringF ConstructMethodStringL();
+
+    private:
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        void ConstructL();
+        
+    private: //Data
+        
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpReqGet.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXcapHttpReqGet
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPREQGET__
+#define __XCAPHTTPREQGET__
+
+// INCLUDES
+#include "http.h"
+#include "XcapHttpRequest.h"
+
+//CONSTANTS
+
+//FORWARD DECLARATIONS
+class CXdmHttpResponse;
+class CXcapHttpAuthManager;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapHttpReqGet ) : public CXcapHttpRequest
+    {
+    public:
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        static CXcapHttpReqGet* NewL( const TDesC& aRequestUri,         
+                                      RHTTPSession& aHttpSession,
+                                      CXcapHttpAuthManager& aAuthManager,
+                                      CXcapHttpTransport& aTransportMain );
+
+         /**
+        * Destructor.
+        */      
+        virtual ~CXcapHttpReqGet();
+
+    private:  // Constructors and destructor
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        CXcapHttpReqGet( RHTTPSession& aHttpSession,
+                         CXcapHttpAuthManager& aAuthManager,
+                         CXcapHttpTransport& aTransportMain );
+
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        virtual void ConstructRequestL();
+
+        /**
+        * Append data to the response buffer.
+        */
+        virtual RStringF ConstructMethodStringL();
+
+    private:
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        void ConstructL();
+        
+    private: //Data
+        
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpReqHead.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXcapHttpReqHead
+*
+*/
+
+#ifndef __XCAPHTTPREQHEAD__
+#define __XCAPHTTPREQHEAD__
+
+// INCLUDES
+#include "http.h"
+#include "XcapHttpRequest.h"
+
+//CONSTANTS
+_LIT8( KXcapRequestHead, "HEAD" );
+
+//FORWARD DECLARATIONS
+class CXdmHttpResponse;
+class CXcapHttpAuthManager;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapHttpReqHead ) : public CXcapHttpRequest
+    {
+    public:
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        static CXcapHttpReqHead* NewL( const TDesC& aRequestUri,         
+                                      RHTTPSession& aHttpSession,
+                                      CXcapHttpAuthManager& aAuthManager,
+                                      CXcapHttpTransport& aTransportMain );
+
+         /**
+        * Destructor.
+        */      
+        virtual ~CXcapHttpReqHead();
+
+    private:  // Constructors and destructor
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        CXcapHttpReqHead( RHTTPSession& aHttpSession,
+                         CXcapHttpAuthManager& aAuthManager,
+                         CXcapHttpTransport& aTransportMain );
+
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        virtual void ConstructRequestL();
+
+        /**
+        * Append data to the response buffer.
+        */
+        virtual RStringF ConstructMethodStringL();
+
+    private:
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        void ConstructL();
+        
+    private: //Data
+        
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpReqMkcol.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXcapHttpReqMkcol
+*
+*/
+
+#ifndef __XCAPHTTPREQMKCOL__
+#define __XCAPHTTPREQMKCOL__
+
+// INCLUDES
+#include "http.h"
+#include "XcapHttpContSupplier.h"
+
+//CONSTANTS
+_LIT8( KXcapRequestMkcol, "MKCOL" );
+
+//FORWARD DECLARATIONS
+class CXcapHttpResponse;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapHttpReqMkcol ) : public CXcapHttpContSupplier
+    {
+    public:
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        static CXcapHttpReqMkcol* NewL( const TDesC& aRequestUri, 
+                                      RHTTPSession& aHttpSession,
+                                      CXcapHttpAuthManager& aAuthManager,
+                                      CXcapHttpTransport& aTransportMain );
+
+         /**
+        * Destructor.
+        */      
+        virtual ~CXcapHttpReqMkcol();
+
+    private:  // Constructors and destructor
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        CXcapHttpReqMkcol( RHTTPSession& aHttpSession,
+                         CXcapHttpAuthManager& aAuthManager,
+                         CXcapHttpTransport& aTransportMain );
+
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        virtual void ConstructRequestL();
+
+        /**
+        * Append data to the response buffer.
+        */
+        virtual RStringF ConstructMethodStringL();
+
+    private:
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        void ConstructL();
+        
+    private: //Data
+        
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpReqPut.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXcapHttpReqPut
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPREQPUT__
+#define __XCAPHTTPREQPUT__
+
+// INCLUDES
+#include "http.h"
+#include "XcapHttpContSupplier.h"
+
+//CONSTANTS
+
+//FORWARD DECLARATIONS
+class CXcapHttpResponse;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapHttpReqPut ) : public CXcapHttpContSupplier
+    {
+    public:
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        static CXcapHttpReqPut* NewL( const TDesC& aRequestUri, 
+                                      RHTTPSession& aHttpSession,
+                                      CXcapHttpAuthManager& aAuthManager,
+                                      CXcapHttpTransport& aTransportMain );
+
+         /**
+        * Destructor.
+        */      
+        virtual ~CXcapHttpReqPut();
+
+    private:  // Constructors and destructor
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        CXcapHttpReqPut( RHTTPSession& aHttpSession,
+                         CXcapHttpAuthManager& aAuthManager,
+                         CXcapHttpTransport& aTransportMain );
+
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        virtual void ConstructRequestL();
+
+        /**
+        * Append data to the response buffer.
+        */
+        virtual RStringF ConstructMethodStringL();
+
+    private:
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        void ConstructL();
+        
+    private: //Data
+        
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpRequest.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,312 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXcapHttpRequest
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPREQUEST__
+#define __XCAPHTTPREQUEST__
+
+// INCLUDES
+#include <http.h>
+#include "XdmOperation.h"
+#include "XcapHttpRequestTimerCallback.h"
+
+//CONSTANTS
+//const TInt KMaxNumberOfRetries                    = 3;
+const TInt KAuthTypeProxy                           = 407;
+const TInt KAuthTypeNormal                          = 401;
+
+_LIT8( KXcapRequestPost,                            "POST" );
+_LIT8( KXcapRequestGet,                             "GET" );
+_LIT8( KXcapRequestPut,                             "PUT" );
+_LIT8( KXcapRequestDelete,                          "DELETE" );
+		
+_LIT8( KHttpHeaderAccept,                           "Accept" );
+_LIT8( KHttpHeaderIfMatch,                          "If-Match" );
+_LIT8( KHttpHeaderIfNoneMatch,                      "If-None-Match" );
+_LIT8( KHttpHeaderContentType,                      "Content-Type" );
+_LIT8( KHttpHeaderIntIdentity,                      "X-3GPP-Intended-Identity" );
+
+//FORWARD DECLARATIONS
+class TXdmCredentials;
+class CXcapHttpResponse;
+class CXcapHttpTransport;
+class CXcapHttpHeaderModel;
+class CXcapHttpAuthManager;
+class CXcapHttpRequestTimer;
+
+// CLASS DECLARATION
+class CXcapHttpRequest : public CBase,
+                         public MXcapHttpRequestTimerCallback
+
+    {
+    public:
+        
+        /**
+        * C++ default constructor is private.
+        */     
+        IMPORT_C void SetHeaderL( const TDesC8& aHeaderName,
+                                  const TDesC8& aHeaderValue );
+
+        /**
+        * Sets the expiry time of this transaction
+        * @param aExpiryTime Time period after which this transaction expires
+        * @param aCallback Handle to the receiver of the expiry event
+        */
+        IMPORT_C void SetExpiryTimeL( MXcapHttpRequestTimerCallback* aCallback,
+                                      const TTimeIntervalMicroSeconds32 aExpiryTime );
+        
+        /**
+        * Cancel this transaction
+        */
+        IMPORT_C void CancelRequest();
+        
+        /**
+        * C++ default constructor is private.
+        */     
+        IMPORT_C void DispatchRequestL( TRequestStatus& aClientStatus );
+        
+        /**
+        * Sets the expiry time of this transaction
+        * @param aExpiryTime Time period after which this transaction expires
+        * @param aCallback Handle to the receiver of the expiry event
+        */
+        IMPORT_C void ResetUriL( const TDesC& aNewUri );
+        
+        /**
+        * Sets the expiry time of this transaction
+        * @param aExpiryTime Time period after which this transaction expires
+        * @param aCallback Handle to the receiver of the expiry event
+        */
+        IMPORT_C void UpdateRequestUriL( const TDesC8& aUpdatedUri );
+        
+        /**
+        * Sets the expiry time of this transaction
+        * @param aExpiryTime Time period after which this transaction expires
+        * @param aCallback Handle to the receiver of the expiry event
+        */
+        IMPORT_C TPtrC8 RequestUriL() const;
+        
+        /**
+        * Sets the expiry time of this transaction
+        * @param aExpiryTime Time period after which this transaction expires
+        * @param aCallback Handle to the receiver of the expiry event
+        */
+        IMPORT_C TPtrC8 HeaderValue( const HTTP::TStrings aHeaderName ) const;
+
+        /**
+        * C++ default constructor is private.
+        */   
+        IMPORT_C TXdmCompletionData* ResponseData();
+        
+        /**
+        * C++ default constructor is private.
+        */   
+        IMPORT_C void ReleaseResponseData();
+        
+        /**
+        * Destructor.
+        */      
+        IMPORT_C virtual ~CXcapHttpRequest();
+
+    public:
+        
+        /**
+        * Try to resend this request
+        * @return TBool Resent or not
+        */
+        TPtrC8 RelativeUri() const;
+        
+        /**
+        * Try to resend this request
+        * @return TBool Resent or not
+        */
+        void ResendWithAuthL( TInt aAuthtype );
+                
+        /**
+        * Has this transaction been cancelled.
+        * @return TBool
+        */
+        CXcapHttpAuthManager& AuthManager();
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        RHTTPSession& Session();
+
+        /**
+        * Return the HTTP transaction associated with this transaction
+        * @return RHTTPTransaction
+        */
+        RHTTPTransaction& Transaction();
+        
+        /**
+        * C++ default constructor is private.
+        */     
+        void AppendDataL( const TPtrC8& aBodyPart );
+
+        /**
+        * Complete this request
+        * @param aErrorCode The completion code
+        */
+        void FinaliseRequestL( TInt aErrorCode );
+
+
+    protected:  // Constructors and destructor
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        CXcapHttpRequest( RHTTPSession& aHttpSession,
+                          CXcapHttpAuthManager& aAuthManager,
+                          CXcapHttpTransport& aTransportMain );
+
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        void BaseConstructL( const TDesC& aRequestUri );
+
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        virtual void ConstructRequestL();
+
+        /**
+        * Append data to the response buffer.
+        */
+        virtual RStringF ConstructMethodStringL() = 0;
+        
+        /**
+        * Sets the status of this transaction
+        * @param aSent Has this transaction been sent or not
+        */
+        void SetStatus( const TBool aSent );
+
+        /**
+        * Has this transaction been cancelled.
+        * @return TBool
+        */
+        TBool IsCancelled();
+
+        /**
+        * Has this transaction been sent
+        * @return TBool
+        */
+        TBool Status() const;
+
+        /**
+        * Return the time stamp of this transaction
+        * @return TInt 
+        */
+        const TInt SendTime() const;
+
+        /**
+        * Get the current time (System tick count)
+        */
+        TInt TimeL() const;
+
+    private:
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        void ConstructL( const TDesC8& aRequestBody );
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        void DoSetHeadersL();
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        void RemoveDuplicateAuth();
+        
+        /**
+        * Append authorization header
+        */ 
+        void AppendAuthorizationHeaderL( RHTTPHeaders& aHeaderCollection, TInt aAuthType );
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        void SetRequestUriL( const TDesC& aRequestUri );
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        void PrepareResponseBodyL();
+    
+    #ifdef _DEBUG
+       
+        /**
+        * Second-phase constructor.
+        */ 
+        void DumpResponseL( const TDesC8& aRespData, const TDesC& aDumpName );
+        
+    #endif
+    
+        /**
+        * Second-phase constructor.
+        */ 
+        void CompileResponseDataL( TInt aErrorCode );
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        TInt ReinterpretErrorCode( const TInt aHttpStatus ) const;
+        
+        /**
+        * Second-phase constructor.
+        */ 
+        virtual void HandleTimerEventL();
+    
+    protected: //Data
+        
+        RHTTPSession&                           iHttpSession;
+        RHTTPTransaction                        iHttpTransaction;
+        CXcapHttpTransport&                     iTransportMain;
+
+    private: //Data
+        
+        HBufC8*                                 iFlatResponse;
+        HBufC8*                                 iRequestUriBuf;
+        HBufC8*                                 iWholeUri;
+        CXcapHttpResponse*                      iHttpResponse;
+        CBufSeg*                                iResponseBuffer;
+        TRequestStatus*                         iClientStatus;
+        CXcapHttpRequestTimer*                  iExpiryTimer;
+        TUriParser8                             iRequestUri;
+        TInt                                    iCurrentDataLength;
+        TInt                                    iNumberOfRetries;
+        TInt                                    iSendTime;
+        TBool                                   iSent;
+        TBool                                   iActive;
+        TBool                                   iCancelled;
+        TBool                                   iConstructed;
+        TXdmCompletionData                      iRespData;
+        CXcapHttpAuthManager&                   iAuthManager;
+        TTimeIntervalMicroSeconds32             iExpiryTime;
+        RPointerArray<CXcapHttpHeaderModel>     iHeaderCollection;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpRequestTimer.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXcapHttpRequestTimer
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPREQUESTTIMER__
+#define __XCAPHTTPREQUESTTIMER__
+
+// INCLUDES
+#include <e32base.h>
+#include "XcapHttpRequestTimerCallback.h"
+
+class CXcapHttpTransport;
+
+NONSHARABLE_CLASS( CXcapHttpRequestTimer ) : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        * @param aCallback A pointer to MMmsViewerTimerCallback class
+        */
+        static CXcapHttpRequestTimer* NewL( CXcapHttpTransport& aTransportMain,
+                                            MXcapHttpRequestTimerCallback* aCallback );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CXcapHttpRequestTimer();
+
+    public: // New functions
+        
+        /**
+        * Request to activate timer
+        * @param aDelay Time in microsecoXcap after which
+        *               the callback function is called.
+        */
+        void ActivateTimer( TTimeIntervalMicroSeconds32 aDelay );
+        
+    private:
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * C++ constructor.
+        * @param aCallback A pointer to MImpsTransportTimerCallback class
+        * @param aRequester Who constructed and/or activated the timer
+        * @param aLogging Trace or not
+        */
+        CXcapHttpRequestTimer( CXcapHttpTransport& aTransportMain,
+                               MXcapHttpRequestTimerCallback* aCallback );
+
+        /**
+        * From CActive.
+        * @return void
+        */
+        void RunL();
+
+        /**
+        * From CActive.
+        * @return void
+        */
+        void DoCancel();
+
+    private:    // Data
+
+        RTimer                                  iTimer;
+        CXcapHttpTransport&                     iTransportMain;
+        MXcapHttpRequestTimerCallback*          iCallback;
+    };
+
+#endif      //__XcapHTTPREQUESTTIMER__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpRequestTimerCallback.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   MXcapHttpRequestTimerCallback
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPREQUESTTIMERCALLBACK__
+#define __XCAPHTTPREQUESTTIMERCALLBACK__
+
+// CLASS DECLARATION
+
+/**
+*  A callback class for the timer class of IMPS Transport layer
+*/
+NONSHARABLE_CLASS( MXcapHttpRequestTimerCallback )
+    {
+    public:
+
+        /**
+        * Pure virtual callback function to be implemented in the
+        * derived class. This function is called when timer has
+        * compeleted.
+        * @param aStatus The integer value of iStatus of the timer class
+        */
+        virtual void HandleTimerEventL() = 0;
+    };
+
+#endif      //__XCAPHTTPREQUESTTIMERCALLBACK__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpResponse.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,150 @@
+/*
+* 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:   CXcapHttpResponse
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPRESPONSE__
+#define __XCAPHTTPRESPONSE__
+
+// INCLUDES
+#include <http.h>
+#include "XcapHttpConsts.h"
+
+//FORWARD DECLARATIONs
+class CXcapHttpRequest;
+class CXcapHttpAuthManager;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapHttpResponse ) : public CBase,
+                                         public MHTTPTransactionCallback
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * A global logging function for 16 bit data.
+        * @param aCommand command to be handled
+        */
+        static CXcapHttpResponse* CXcapHttpResponse::NewL( CXcapHttpRequest* aHttpRequest,
+                                                           CXcapHttpTransport& aTransportMain );
+        
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapHttpResponse();
+
+    public:   //New functions   
+        
+        /**
+        * Stores the address of the proxy currently in use
+        * @param aProxy Address of the HTTP proxy server
+        */
+        TInt ContentLengthL() const;
+       
+    private:
+    
+        /**
+        * A global logging function for 16 bit data.
+        * @param aCommand command to be handled
+        */
+        CXcapHttpResponse( CXcapHttpRequest* aHttpRequest,
+                           CXcapHttpTransport& aTransportMain );
+        
+        /**
+        * A global logging function for 16 bit data.
+        * @param aCommand command to be handled
+        */
+        void ConstructL();
+   
+        /**
+        * Stores the address of the proxy currently in use
+        * @param aProxy Address of the HTTP proxy server
+        */
+        RHTTPHeaders ResponseHeaderCollection() const;
+        
+        /**
+        * Stores the address of the proxy currently in use
+        * @param aProxy Address of the HTTP proxy server
+        */
+        RHTTPHeaders RequestHeaderCollection() const;
+        
+        /**
+        * Stores the address of the proxy currently in use
+        * @param aProxy Address of the HTTP proxy server
+        */
+        TBool HandleReceivedBodyDataL( const RHTTPTransaction aTransaction );
+        
+        /**
+        * Stores the address of the proxy currently in use
+        * @param aProxy Address of the HTTP proxy server
+        */
+        TBool IsUnauthRequest( RHTTPTransaction aTransaction, TInt& aAuthType );
+        
+        /**
+        * Stores the address of the proxy currently in use
+        * @param aProxy Address of the HTTP proxy server
+        */
+        TBool ParseAuthInfoParam( TInt& aLength, TAuthInfoParam& aName,
+                                  TPtrC8& aValue, TPtr8& aParam );
+        
+        /**
+        * Stores the address of the proxy currently in use
+        * @param aProxy Address of the HTTP proxy server
+        */
+        TBool CheckAuthInfoHeaderL( RHTTPHeaders aHeaders );
+        
+    #ifdef _DEBUG
+        
+        /**
+        * Convert undefined HTTP stack errors
+        */
+        void DumpHeadersL( RHTTPHeaders aHeaders, TInt aId );
+            
+    #endif
+        
+    private:  //From MHTTPTransactionCallback
+    
+        /**
+        * Handles all responses
+        * coming from the remote host
+        * @param aTransaction The finished transaction
+        * @param aEvent Type of the event
+        */
+        void MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent& aEvent );
+        
+        /**
+        * From MHTTPTransactionCallback, called when the RunL() of a transaction leaves
+        * @param aInt The error the HTTP framework left with
+        * @param aTransaction The failed transaction
+        * @param aEvent The event that was being processed
+        * @return KErrNone (HTTP framework panics if client returns any other error)
+        */
+        TInt MHFRunError( TInt aInt, RHTTPTransaction aTransaction, const THTTPEvent& aEvent );
+
+    private: //Data
+        
+        TBool                                    iAuthPending;
+        CXcapHttpRequest*                        iHttpRequest;
+        CXcapHttpTransport&                      iTransportMain;
+        CXcapHttpAuthManager&                    iAuthManager;
+        TInt                                     iUnauthRequestCounter;
+    };
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpTransport.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,164 @@
+/*
+* 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:  CXcapHttpTransport 
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPTRANSPORT__
+#define __XCAPHTTPTRANSPORT__
+
+// INCLUDES
+#include <http.h>
+#include <XdmCredentials.h>
+
+//COMMON CONSTANTS
+_LIT( KTransportLogFile,                        "HttpTransport" );
+const TInt KTransportLogBufMaxSize              = 2000;
+_LIT( KTransportDateFormat,                     "%D%M%Y%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S.%C%:3");
+const TInt KMaxSubmitSize                       = 1024;
+const TInt KMaxHeaderNameLen                    = 32;
+const TInt KMaxHeaderValueLen                   = 128;
+const TInt KBufferMaxSize                       = 2048;
+
+//FORWARD DECLARATIONS
+class CXdmLogWriter;
+class MMsgConnManager;
+class CXcapHttpReqGet;
+class CXcapHttpReqPut;
+class CXcapHttpReqDelete;
+class CXcapHttpAuthManager;
+class CXcapHttpReqMkcol;
+class CXcapHttpReqHead;
+
+// CLASS DECLARATION
+class CXcapHttpTransport : public CBase
+
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        */     
+        IMPORT_C static CXcapHttpTransport* NewL( const TDesC& aRootUri,
+                                                  MMsgConnManager& aConnManager,
+                                                  const TXdmCredentials& aDigestCredentials );
+        
+        /**
+        * A global logging function for 8 bit data.
+        * @param aCommand command to be handled
+        */
+        IMPORT_C TPtrC8 RootUri();
+
+        /**
+        * Send one IMPS message.
+        */
+        IMPORT_C CXcapHttpReqGet* GetL( const TDesC& aUri );
+
+        /**
+        * Send one IMPS message.
+        */
+        IMPORT_C CXcapHttpReqPut* PutL( const TDesC& aUri );
+        
+        /**
+        * Send one IMPS message.
+        */
+        IMPORT_C CXcapHttpReqMkcol* MkcolL( const TDesC& aUri );
+
+        /**
+        * Send one IMPS message.
+        */
+        IMPORT_C CXcapHttpReqHead* HeadL( const TDesC& aUri );
+
+        /**
+        * Send one IMPS message.
+        */
+        IMPORT_C CXcapHttpReqDelete* DeleteL( const TDesC& aUri );
+        
+        /**
+        * Stores the address of the proxy currently in use
+        * @param aProxy Address of the HTTP proxy server
+        */
+        IMPORT_C void SetRootUriL( const TDesC& aRootUri );
+        
+        /**
+        * Destructor.
+        */      
+        IMPORT_C virtual ~CXcapHttpTransport();
+
+    public:   //New functions   
+        
+        /**
+        * A global logging function for 8 bit data.
+        * @param aCommand command to be handled
+        */
+        static TXdmCredentials& Credentials();
+    
+    #ifdef _DEBUG
+    
+        /**
+        * A global logging function for 8 bit data.
+        * @param aCommand command to be handled
+        */
+        void WriteToLog( TRefByValue<const TDesC8> aFmt,... ) const;
+        
+        /**
+        * A global logging function for 16 bit data.
+        * @param aCommand command to be handled
+        */
+        void WriteToLog( TRefByValue<const TDesC> aFmt,... ) const;
+    
+    #endif //_DEBUG
+         
+    private:
+        
+        /**
+        * C++ default constructor.
+        */      
+        CXcapHttpTransport( MMsgConnManager& aConnManager );
+
+        /**
+        * Symbian OS default constructor.
+        * @param aMimeType MIME type of the messages
+        */     
+        void ConstructL( const TDesC& aRootUri, const TXdmCredentials& aDigestCredentials );
+                              
+        /**
+        * Symbian OS default constructor.
+        * @param aMimeType MIME type of the messages
+        */     
+        HBufC8* ConstructRequestUriLC( const TDesC& aDocumentSelector );
+        
+        /**
+        * Initialises an HTTP session
+        */
+        void InitialiseSessionL();
+        
+    private: //Data
+        
+        TBool                                       iCredValidity;
+        TBool                                       iSessionClosed;
+        HBufC8*                                     iRootUri;
+        HBufC8*                                     iProxyBuffer;
+        RHTTPSession                                iHttpSession;
+        CXdmLogWriter*                              iLogWriter;
+        MMsgConnManager&                            iConnManager;
+        CXcapHttpAuthManager*                       iAuthManager;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpAuthManager.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,578 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXcapHttpAuthManager
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <hash.h>
+#include <e32math.h>
+#include "XcapHttpRequest.h"
+#include "XcapHttpTransport.h"
+#include "XcapHttpAuthManager.h"
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::CXcapHttpAuthManager
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpAuthManager::CXcapHttpAuthManager( RHTTPSession& aHttpSession,
+                                            CXcapHttpTransport& aTransportMain ) :
+                                            iNonceCount( 1 ),
+                                            iAuthorized( EFalse ),
+                                            iHttpSession( aHttpSession ),
+                                            iTransportMain( aTransportMain ),
+                                            iStringPool( aHttpSession.StringPool() )
+    { 
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpAuthManager* CXcapHttpAuthManager::NewL( RHTTPSession& aHttpSession,
+                                                  CXcapHttpTransport& aTransportMain,
+                                                  const TXdmCredentials& aDigestCredentials )
+    {
+    CXcapHttpAuthManager* self = new ( ELeave ) CXcapHttpAuthManager( aHttpSession, aTransportMain );
+    CleanupStack::PushL( self );
+    self->ConstructL( aDigestCredentials );
+    CleanupStack::Pop();  //self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapHttpAuthManager::~CXcapHttpAuthManager
+// 
+// ----------------------------------------------------
+//
+CXcapHttpAuthManager::~CXcapHttpAuthManager()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpAuthManager::~CXcapHttpAuthManager()" ) );
+    #endif
+    delete iMD5;
+    delete iRealm;
+    delete iOpaque;
+    delete iDomain;
+    delete iQopString;
+    delete iAlgorithm;
+    delete iServerNonce;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpAuthManager::ConstructL( const TXdmCredentials& aDigestCredentials )
+    {
+    iMD5 = CMD5::NewL();
+    iUserName.Copy( aDigestCredentials.iUserName );
+    iPassword.Copy( aDigestCredentials.iPassword );
+    } 
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::SetAuthorized
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpAuthManager::SetAuthorized( TBool aAuthorized )
+    {
+    iAuthorized = aAuthorized;
+    } 
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::IsAuthorized
+// 
+// ----------------------------------------------------------
+//
+TBool CXcapHttpAuthManager::IsAuthorized() const
+    {
+    return iAuthorized;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::AuthorizationL
+// 
+// ----------------------------------------------------------
+//
+HBufC8* CXcapHttpAuthManager::AuthorizationL( CXcapHttpRequest& aHttpRequest )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpAuthManager::AuthorizationL()" ) );
+    #endif
+    if( !iUnauthReceived )
+        return NULL;
+    TInt bufPtr = 0;
+    HBufC8* ret = NULL;
+    THTTPHdrVal requestUri;
+    //All these strings should have been defined - except for
+    //"opaque", maybe - in the WWW-Authentication header that
+    //the server sent. In case some of them were not, let's just
+    //keep going as if they were there, but were empty. The request
+    //will then fail & be completed in the next MHFRunL() call. 
+    TPtrC8 realm( iRealm ? iRealm->Des() : TPtrC8() );
+    TPtrC8 qop( iQopString ? iQopString->Des() : TPtrC8() );
+    TPtrC8 opaque( iOpaque ? iOpaque->Des() : TPtrC8() );
+    TPtrC8 nonce( iServerNonce ? iServerNonce->Des() : TPtrC8() );
+    TPtrC8 uri( aHttpRequest.RelativeUri() );
+    TBuf8<8> nonceCount;
+    nonceCount.AppendFormat( _L8( "%08x" ), iNonceCount );   
+    CBufFlat* buffer = CBufFlat::NewL( 128 );
+    CleanupStack::PushL( buffer ); 
+    buffer->InsertL( bufPtr, KAuthHeaderStart );
+    bufPtr = bufPtr + KAuthHeaderStart().Length();
+    buffer->InsertL( bufPtr, iUserName );
+    bufPtr = bufPtr + iUserName.Length();    
+    buffer->InsertL( bufPtr, KAuthHeaderParamEndQ );
+    bufPtr = bufPtr + KAuthHeaderParamEndQ().Length();    
+    buffer->InsertL( bufPtr, KAuthHeaderRealm );
+    bufPtr = bufPtr + KAuthHeaderRealm().Length();
+    buffer->InsertL( bufPtr, realm );
+    bufPtr = bufPtr + realm.Length();
+    buffer->InsertL( bufPtr, KAuthHeaderParamEndQ );
+    bufPtr = bufPtr + KAuthHeaderParamEndQ().Length();   
+    buffer->InsertL( bufPtr, KAuthHeaderNonce );
+    bufPtr = bufPtr + KAuthHeaderNonce().Length();
+    buffer->InsertL( bufPtr, nonce );
+    bufPtr = bufPtr + nonce.Length();
+    buffer->InsertL( bufPtr, KAuthHeaderParamEndQ );
+    bufPtr = bufPtr + KAuthHeaderParamEndQ().Length(); 
+    buffer->InsertL( bufPtr, KAuthHeaderUri );
+    bufPtr = bufPtr + KAuthHeaderUri().Length();
+    buffer->InsertL( bufPtr, uri );
+    bufPtr = bufPtr + uri.Length();
+    buffer->InsertL( bufPtr, KAuthHeaderParamEndQ );
+    bufPtr = bufPtr + KAuthHeaderParamEndQ().Length();
+    buffer->InsertL( bufPtr, KAuthHeaderQop );
+    bufPtr = bufPtr + KAuthHeaderQop().Length();
+    buffer->InsertL( bufPtr, qop );
+    bufPtr = bufPtr + qop.Length();
+    buffer->InsertL( bufPtr, KAuthHeaderParamEnd );
+    bufPtr = bufPtr + KAuthHeaderParamEnd().Length();
+    buffer->InsertL( bufPtr, KAuthHeaderNonceCount );
+    bufPtr = bufPtr + KAuthHeaderNonceCount().Length();
+    buffer->InsertL( bufPtr, nonceCount );
+    bufPtr = bufPtr + nonceCount.Length();
+    buffer->InsertL( bufPtr, KAuthHeaderParamEnd );
+    bufPtr = bufPtr + KAuthHeaderParamEnd().Length();
+    buffer->InsertL( bufPtr, KAuthHeaderCNonce );
+    bufPtr = bufPtr + KAuthHeaderCNonce().Length();
+    buffer->InsertL( bufPtr, iClientNonce );
+    bufPtr = bufPtr + iClientNonce.Length();
+    buffer->InsertL( bufPtr, KAuthHeaderParamEndQ );
+    bufPtr = bufPtr + KAuthHeaderParamEndQ().Length();    
+    buffer->InsertL( bufPtr, KAuthHeaderResponse );
+    bufPtr = bufPtr + KAuthHeaderResponse().Length();  
+    TPtrC8 respDigest( RequestDigestLC( aHttpRequest )->Des() );
+    buffer->InsertL( bufPtr, respDigest );
+    bufPtr = bufPtr + respDigest.Length(); 
+    CleanupStack::PopAndDestroy();  //RequestDigestLC()
+    buffer->InsertL( bufPtr, KAuthHeaderParamEndQ );
+    bufPtr = bufPtr + KAuthHeaderParamEndQ().Length();
+    if( opaque.Length() > 0 )
+        {
+        buffer->InsertL( bufPtr, KAuthHeaderOpaque );
+        bufPtr = bufPtr + KAuthHeaderOpaque().Length();
+        buffer->InsertL( bufPtr, opaque );
+        bufPtr = bufPtr + opaque.Length();
+        buffer->InsertL( bufPtr, KAuthHeaderParamQuote );
+        }
+    ret = HBufC8::NewL( buffer->Size() );
+    ret->Des().Copy( buffer->Ptr( 0 ) );
+    buffer->Reset();
+    iNonceCount++;
+    CleanupStack::PopAndDestroy();  //buffer
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::ConsumeAuthInfoParamL
+// 
+// ----------------------------------------------------------
+//
+TBool CXcapHttpAuthManager::ConsumeAuthInfoParamL( TAuthInfoParam aName, const TDesC8& aValue )
+    {
+    //For the time being, always return ETrue
+    TBool ret = ETrue;
+    TInt length = aValue.Length();
+    TPtr8 value( CONST_CAST( TUint8*, aValue.Ptr() ), length, length );
+    Unquote( value );
+    #ifdef _DEBUG
+        TPtrC8 name( KAuthInfoParamArray[aName] );
+        iTransportMain.WriteToLog( _L8( "CXcapHttpAuthManager::ConsumeAuthInfoParamL()" ) );
+        iTransportMain.WriteToLog( _L8( "  Name:   %S" ), &name );
+        iTransportMain.WriteToLog( _L8( "  Value:  %S" ), &value );
+    #endif
+    switch( aName )
+        {                                              
+        case ENfoNextnonce:
+            {
+            SetNextNonceL( value );
+            #ifdef _DEBUG
+                TPtrC8 nonce( iServerNonce->Des() );
+                iTransportMain.WriteToLog( _L8( "  -> Nonce set to %S" ), &nonce );
+            #endif
+            }
+            break;
+        case ENfoRspauth:
+            /* TODO */
+            break;
+        case ENfoCnonce:
+            #ifdef _DEBUG
+                iTransportMain.WriteToLog( _L8( "  -> Current cnonce %S" ), &iClientNonce );
+            #endif
+            break;
+            //ret = value.Compare( iClientNonce ) == 0;
+        case ENfoNc:
+            {
+            TBuf8<8> nonceCount;
+            nonceCount.AppendFormat( _L8( "%08x" ), iNonceCount );
+            #ifdef _DEBUG
+                iTransportMain.WriteToLog( _L8( "  -> Current nonce count %S" ), &nonceCount );
+            #endif
+            //ret = nonceCount.Compare( value ) == 0;
+            break;
+            }
+        case ENfoQop:
+            ret = ETrue;
+            break;
+        default:
+            ret = ETrue;
+            break;
+        }
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::GenerateClientNonce
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpAuthManager::SetNextNonceL( const TDesC8& aNextnonce )
+    {
+    delete iServerNonce;
+    iServerNonce = NULL;
+    iServerNonce = aNextnonce.AllocL();
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::Unquote
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpAuthManager::Unquote( TPtr8& aParamValue )
+    {
+    TInt index = aParamValue.Locate( '"' );
+    while( index >= 0 )
+        {
+        aParamValue.Delete( index, 1 );
+        index = aParamValue.Locate( '\"');
+        }
+    }
+       
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::RequestDigestLC
+// 
+// ----------------------------------------------------------
+//
+HBufC8* CXcapHttpAuthManager::RequestDigestLC( CXcapHttpRequest& aHttpRequest )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpAuthManager::RequestDigestLC()" ) );
+    #endif
+    HBufC8* ret = NULL;
+    if( iQop == EXcapAuth || iQop == EXcapAuthInt )
+        {
+        TBuf8<8> nonceCount;
+        TBuf8<KXcapHashLength> hashBush;
+        nonceCount.AppendFormat( _L8( "%08x" ), iNonceCount );
+        TPtrC8 nonce( iServerNonce ? iServerNonce->Des() : TPtrC8() );
+        TPtrC8 qop( iQop == EXcapAuth ? _L8( "auth" ) : _L8( "auth-int" ) );
+        HBufC8* stringToHash = HBufC8::NewLC( nonce.Length() + qop.Length() +
+                                              3 * KXcapHashLength + 8 + 5 );
+        TPtr8 desc( stringToHash->Des() );
+        ConstructHA1L( desc );
+        desc.Append( ':' );
+        desc.Append( nonce );
+        desc.Append( ':' );
+        desc.Append( nonceCount );
+        desc.Append( ':' );
+        desc.Append( iClientNonce );
+        desc.Append(':');
+        desc.Append( qop );
+        desc.Append(':');
+        ConstructHA2L( hashBush, aHttpRequest );
+        desc.Append( hashBush ); 
+        hashBush.Zero();
+        ret = HBufC8::NewL( KXcapHashLength );
+        Hash( *stringToHash, hashBush );
+        ret->Des().Copy( hashBush );
+        CleanupStack::PopAndDestroy();  //stringToHash
+        CleanupStack::PushL( ret );
+        }
+    else
+        {
+        /*
+        * This case is for compatibility with RFC 2069:
+        * request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
+        */
+        #ifdef _DEBUG
+            iTransportMain.WriteToLog( _L8( "  Qop not defined, ignore" ) );
+        #endif
+        }
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::GenerateClientNonce
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpAuthManager::GenerateClientNonce()
+    {
+    TTime time;
+    TBuf8<33> key;
+    time.UniversalTime();
+    TInt64 randomNumber = Math::Rand( iSeed );
+    randomNumber <<= 32;
+    randomNumber += Math::Rand( iSeed );
+    key.Zero();
+    key.AppendNum( time.Int64(), EHex );
+    key.Append( _L8( ":" ) );
+    key.AppendNum( randomNumber, EHex );
+    Hash( key, iClientNonce );
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::Hash
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpAuthManager::Hash( const TDesC8& aMessage, TDes8& aHash )
+    {
+    TBuf8<2> buf;
+    aHash.Zero();
+    iMD5->Reset();
+    TPtrC8 hash = iMD5->Hash( aMessage );
+    _LIT8( formatStr, "%02x" );
+    for( TInt i = 0;i < KXcapRawHashLength;i++ )
+        {
+        buf.Zero();
+        buf.Format( formatStr, hash[i] );
+        aHash.Append( buf );
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::ParseQopL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpAuthManager::ParseQopL( const TDesC8& aQopString )
+    {
+    _LIT8( KXcapAuthInt, "auth-int" );
+    iQop = aQopString.FindF( KXcapAuthInt ) == 0 ? EXcapAuthInt : EXcapAuth;
+    delete iQopString;
+    iQopString = NULL;
+    iQopString = HBufC8::NewL( 8 );
+    iQopString->Des().Copy( iQop == EXcapAuth ? _L8( "auth" ) : _L8( "auth-int" )  );
+    #ifdef _DEBUG
+        TPtrC8 qop( iQopString->Des() );
+        iTransportMain.WriteToLog( _L8( "  Qop:         %S" ), &qop );
+    #endif
+    GenerateClientNonce();
+    iNonceCount = 1;    
+    }
+       
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::ParseHeaderL
+// 
+// ----------------------------------------------------------
+//
+TBool CXcapHttpAuthManager::ParseHeaderL( RHTTPTransaction& aTransaction, TInt aAuthType )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpAuthManager::ParseHeaderL()" ) );
+    #endif
+    TBool ret = EFalse;
+    THTTPHdrVal fieldVal;
+    RHTTPHeaders headers = aTransaction.Response().GetHeaderCollection();
+    RStringF auth = aAuthType == KAuthTypeNormal ? 
+        iStringPool.StringF( HTTP::EWWWAuthenticate, RHTTPSession::GetTable() ) :
+        iStringPool.StringF( HTTP::EProxyAuthenticate, RHTTPSession::GetTable() );
+    headers.GetField( auth, 0, fieldVal );
+    if( fieldVal.StrF() == iStringPool.StringF( HTTP::EDigest, RHTTPSession::GetTable() ) )
+        {
+        ret = ETrue;
+        TInt error = headers.GetParam( auth, iStringPool.StringF( HTTP::ERealm, RHTTPSession::GetTable() ), fieldVal );
+        if( KErrNone == error )
+            {
+            delete iRealm;
+            iRealm = NULL;
+            iRealm = fieldVal.Str().DesC().AllocL();
+            #ifdef _DEBUG
+                TPtrC8 realm( fieldVal.Str().DesC() );
+                iTransportMain.WriteToLog( _L8( "  Realm:       %S" ), &realm );
+            #endif
+            }
+        //In a proper WWW-Authentication request there SHOULD have been 
+        //a qop value. In case there was not, call the whole thing off
+        error = headers.GetParam( auth, iStringPool.StringF( HTTP::EQop, RHTTPSession::GetTable() ), fieldVal );
+        if( KErrNone == error )
+            ParseQopL( fieldVal.Str().DesC() );
+        else
+            {
+            delete iQopString;
+            iQopString = NULL;
+            ret = EFalse;
+            }
+        error = headers.GetParam( auth, iStringPool.StringF( HTTP::ENonce, RHTTPSession::GetTable() ), fieldVal );
+        if( ret && KErrNone == error )
+            {
+            SetNextNonceL( fieldVal.Str().DesC() );
+            #ifdef _DEBUG
+                TPtrC8 nonce( iServerNonce->Des() );
+                iTransportMain.WriteToLog( _L8( "  Nonce:       %S" ), &nonce );
+            #endif
+            }
+        error = headers.GetParam( auth, iStringPool.StringF( HTTP::EOpaque, RHTTPSession::GetTable() ), fieldVal );
+        if( ret && KErrNone == error )
+            {
+            delete iOpaque;
+            iOpaque = NULL;
+            iOpaque = fieldVal.Str().DesC().AllocL();
+            #ifdef _DEBUG
+                TPtrC8 opaque( iOpaque->Des() );
+                iTransportMain.WriteToLog( _L8( "  Opaque:      %S" ), &opaque );
+            #endif
+            }
+        error = headers.GetParam( auth, iStringPool.StringF( HTTP::EStale, RHTTPSession::GetTable() ), fieldVal );
+        if( ret && KErrNone == error )
+            {
+            #ifdef _DEBUG
+                TPtrC8 stale( fieldVal.Str().DesC() );
+                iTransportMain.WriteToLog( _L8( "  Stale:       %S" ), &stale );
+            #endif
+            }
+        error = headers.GetParam( auth, iStringPool.StringF( HTTP::EDomain, RHTTPSession::GetTable() ), fieldVal );
+        if( ret && KErrNone == error )
+            {
+            delete iDomain;
+            iDomain = NULL;
+            iDomain = fieldVal.Str().DesC().AllocL();
+            #ifdef _DEBUG
+                TPtrC8 domain( iDomain->Des() );
+                iTransportMain.WriteToLog( _L8( "  Domain:       %S" ), &domain );
+            #endif
+            }
+        error = headers.GetParam( auth, iStringPool.StringF( HTTP::EAlgorithm, RHTTPSession::GetTable() ), fieldVal );
+        if( ret && KErrNone == error )
+            {
+            delete iAlgorithm;
+            iAlgorithm = NULL;
+            iAlgorithm = fieldVal.Str().DesC().AllocL();
+            #ifdef _DEBUG
+                TPtrC8 algorithm( iAlgorithm->Des() );
+                iTransportMain.WriteToLog( _L8( "  Algorithm:   %S" ), &algorithm );
+            #endif
+            }
+        }
+    iUnauthReceived = ETrue;
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::ConstructHA1L
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpAuthManager::ConstructHA1L( TDes8& aResult )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpAuthManager::ConstructHA1L()" ) );
+    #endif
+
+    TPtrC8 realm( iRealm ? iRealm->Des() : TPtrC8() );
+
+    HBufC8* buffer = HBufC8::NewLC( iUserName.Length() +
+                     iPassword.Length() + realm.Length() + 2 );
+    TPtr8 desc( buffer->Des() );
+    desc.Copy( iUserName );
+    desc.Append(':');
+    desc.Append( realm );
+    desc.Append(':');
+    desc.Append( iPassword );
+    Hash( *buffer, aResult );
+    CleanupStack::PopAndDestroy();  //buffer
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::ConstructHA2L
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpAuthManager::ConstructHA2L( TDes8& aResult, CXcapHttpRequest& aHttpRequest )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpAuthManager::ConstructHA2L()" ) );
+    #endif
+    TPtrC8 uri( aHttpRequest.RelativeUri() );
+    TPtrC8 method( aHttpRequest.Transaction().Request().Method().DesC() );
+    switch( iQop )
+        {
+        case EXcapAuth:
+        case EXcapAuthNone:
+            {
+            HBufC8* buffer = HBufC8::NewLC( uri.Length() + method.Length() + 1 );
+            TPtr8 desc( buffer->Des() );
+            desc.Copy( method );
+            desc.Append( ':' );
+            desc.Append( uri );
+            Hash( desc, aResult );
+            CleanupStack::PopAndDestroy();  //buffer
+            }
+            break;
+        case EXcapAuthInt:
+            {
+            TPtrC8 body( _L8( "" ) );
+            TBuf8<KXcapHashLength> bodyHash;
+            if( aHttpRequest.Transaction().Request().HasBody() )
+                aHttpRequest.Transaction().Request().Body()->GetNextDataPart( body );
+            bodyHash.Zero();
+            Hash( body, bodyHash );
+            HBufC8* buffer = HBufC8::NewLC( uri.Length() + method.Length() +
+                                            KXcapHashLength + 2  );
+            TPtr8 desc( buffer->Des() );
+            desc.Copy( method );
+            desc.Append( ':' );
+            desc.Append( uri );
+            desc.Append( ':' );
+            desc.Append( bodyHash );
+            Hash( desc, aResult );
+            CleanupStack::PopAndDestroy();  //buffer
+            }
+            break;
+        default:
+            break;
+        }
+   
+    }
+     
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpContSupplier.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,139 @@
+/*
+* 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:   CXcapHttpContSupplier
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XcapHttpTransport.h"
+#include "XcapHttpContSupplier.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+// ----------------------------------------------------------
+// CXcapHttpContSupplier::CXcapHttpContSupplier
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpContSupplier::CXcapHttpContSupplier( RHTTPSession& aHttpSession,
+                                              CXcapHttpAuthManager& aAuthManager,
+                                              CXcapHttpTransport& aTransportMain ) :
+                                              CXcapHttpRequest( aHttpSession, aAuthManager, aTransportMain )
+                                        
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpContSupplier::~CXcapHttpContSupplier
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpContSupplier::~CXcapHttpContSupplier()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpContSupplier::~CXcapHttpContSupplier()" ) );    
+    #endif
+    delete iRequestBody;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpContSupplier::SetRequestBodyL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXcapHttpContSupplier::SetRequestBodyL( const TDesC8& aRequestBody )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpContSupplier::SetRequestBodyL" ) );    
+    #endif
+    delete iRequestBody;
+    iRequestBody = NULL;
+    iRequestBody = HBufC8::NewL( aRequestBody.Length() );
+    iRequestBody->Des().Copy( aRequestBody );
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpContSupplier::RequestBody
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TPtrC8 CXcapHttpContSupplier::RequestBody() const
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpContSupplier::RequestBody" ) );    
+    #endif
+    return iRequestBody != NULL ? iRequestBody->Des() : TPtrC8();
+    }
+    
+// ----------------------------------------------------------
+// CXcapHttpContSupplier::GetNextDataPart
+// 
+// ----------------------------------------------------------
+//
+TBool CXcapHttpContSupplier::GetNextDataPart( TPtrC8& aDataPart )
+    {
+    aDataPart.Set( iRequestBody->Des() );
+    return ETrue;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpContSupplier::ReleaseData
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpContSupplier::ReleaseData()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpContSupplier::ReleaseData()" ) );    
+    #endif
+    //Not just yet, lets see if the server accepts the data.
+    //If it does, the data needs to be cached and this is
+    //probably  - and hopefully - the only copy of the raw 
+    //data still available at that point in time
+    //delete iRequestBody;
+    //iRequestBody = NULL;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpContSupplier::Reset
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapHttpContSupplier::Reset()
+	{
+	//This method is called when client Cancel()s a request.
+	//There's nothing to reset in our case, because all needed
+	//resources are destructed in the destructor.
+	//NOTE: Never EVER set this method to return anything but
+	//KErrNone, since values < 0 will result in practically
+	//untraceable errors thanks to Symbian's lack of proper
+	//documentation on the issue.
+	return KErrNone;
+	}
+
+// ----------------------------------------------------------
+// CXcapHttpContSupplier::GetNextDataPart
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapHttpContSupplier::OverallDataSize()
+	{
+    return iRequestBody != NULL ? iRequestBody->Length() : 0;
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpHeaderModel.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,105 @@
+/*
+* 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:   CXcapHttpHeaderModel
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XcapHttpTransport.h"
+#include "XcapHttpHeaderModel.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+// ----------------------------------------------------------
+// CXcapHttpHeaderModel::CXcapHttpHeaderModel
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpHeaderModel::CXcapHttpHeaderModel( CXcapHttpTransport& aTransportMain ) :
+                                            iTransportMain( aTransportMain)
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpHeaderModel::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpHeaderModel* CXcapHttpHeaderModel::NewL( const TDesC8& aHeaderName,
+                                                  const TDesC8& aHeaderValue,
+                                                  CXcapHttpTransport& aTransportMain )
+                                        
+    {
+    CXcapHttpHeaderModel* self = new ( ELeave ) CXcapHttpHeaderModel( aTransportMain );
+    CleanupStack::PushL( self );
+    self->ConstructL( aHeaderName, aHeaderValue );
+    CleanupStack::Pop();  //self
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpHeaderModel::HeaderValue
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpHeaderModel::ConstructL( const TDesC8& aHeaderName,
+                                       const TDesC8& aHeaderValue )
+    {
+    delete iHeaderName;
+    iHeaderName = NULL;
+    iHeaderName = aHeaderName.AllocL();
+    delete iHeaderValue;
+    iHeaderValue = NULL;
+    iHeaderValue = aHeaderValue.AllocL();
+    
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpHeaderModel::HeaderValue
+// 
+// ----------------------------------------------------------
+//
+TPtrC8 CXcapHttpHeaderModel::HeaderValue() const
+    {
+    return iHeaderValue != NULL ? iHeaderValue->Des() : TPtrC8();
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpHeaderModel::HeaderValue
+// 
+// ----------------------------------------------------------
+//
+TPtrC8 CXcapHttpHeaderModel::HeaderName() const
+    {
+    return iHeaderName != NULL ? iHeaderName->Des() : TPtrC8();
+    }
+     
+// ----------------------------------------------------------
+// CXcapHttpHeaderModel::~CXcapHttpHeaderModel
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpHeaderModel::~CXcapHttpHeaderModel()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpHeaderModel::~CXcapHttpHeaderModel()" ) );    
+    #endif
+    delete iHeaderName;
+    delete iHeaderValue;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpReqDelete.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,90 @@
+/*
+* 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:   CXcapHttpReqDelete
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XcapHttpReqDelete.h"
+#include "XcapHttpTransport.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+// ----------------------------------------------------------
+// CXcapHttpReqDelete::CXcapHttpReqDelete
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqDelete::CXcapHttpReqDelete( RHTTPSession& aHttpSession,
+                                        CXcapHttpAuthManager& aAuthManager,
+                                        CXcapHttpTransport& aTransportMain ) :
+                                        CXcapHttpRequest( aHttpSession, aAuthManager, aTransportMain )
+                                        
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqDelete::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqDelete* CXcapHttpReqDelete::NewL( const TDesC& aRequestUri, 
+                                              RHTTPSession& aHttpSession,
+                                              CXcapHttpAuthManager& aAuthManager,
+                                              CXcapHttpTransport& aTransportMain )
+                                        
+    {
+    CXcapHttpReqDelete* self = new ( ELeave ) CXcapHttpReqDelete( aHttpSession, aAuthManager, aTransportMain );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aRequestUri );
+    CleanupStack::Pop();  //self
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqDelete::~CXcapHttpReqDelete
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqDelete::~CXcapHttpReqDelete()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpReqDelete::~CXcapHttpReqDelete()" ) );    
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqDelete::ConstructRequestL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpReqDelete::ConstructRequestL()
+    {
+    CXcapHttpRequest::ConstructRequestL();
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqDelete::ConstructRequestL
+// 
+// ----------------------------------------------------------
+//
+RStringF CXcapHttpReqDelete::ConstructMethodStringL()
+    {
+    return iHttpSession.StringPool().OpenFStringL( KXcapRequestDelete );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpReqGet.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* 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:   CXcapHttpReqGet
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XcapHttpReqGet.h"
+#include "XcapHttpTransport.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+// ----------------------------------------------------------
+// CXcapHttpReqGet::CXcapHttpReqGet
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqGet::CXcapHttpReqGet( RHTTPSession& aHttpSession,
+                                  CXcapHttpAuthManager& aAuthManager,
+                                  CXcapHttpTransport& aTransportMain ) :
+                                  CXcapHttpRequest( aHttpSession, aAuthManager, aTransportMain )
+                                        
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqGet::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqGet* CXcapHttpReqGet::NewL( const TDesC& aRequestUri, 
+                                        RHTTPSession& aHttpSession,
+                                        CXcapHttpAuthManager& aAuthManager,
+                                        CXcapHttpTransport& aTransportMain )
+                                        
+    {
+    CXcapHttpReqGet* self = new ( ELeave ) CXcapHttpReqGet( aHttpSession, aAuthManager, aTransportMain );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aRequestUri );
+    CleanupStack::Pop();  //self
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqGet::~CXcapHttpReqGet
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqGet::~CXcapHttpReqGet()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpReqGet::~CXcapHttpReqGet()" ) );    
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqGet::ConstructRequestL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpReqGet::ConstructRequestL()
+    {
+    CXcapHttpRequest::ConstructRequestL();
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqGet::ConstructRequestL
+// 
+// ----------------------------------------------------------
+//
+RStringF CXcapHttpReqGet::ConstructMethodStringL()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpReqGet::ConstructMethodStringL()" ) );    
+    #endif
+    return iHttpSession.StringPool().OpenFStringL( KXcapRequestGet );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpReqHead.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,95 @@
+/*
+* ============================================================================
+*  Name     : CXcapHttpReqHead from XcapHttpReqHead.cpp
+*  Part of  : Transport Adapter of the Symbian OS WV Engine 
+*
+*  Description:
+/*
+* 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:   CXcapHttpReqHead
+*
+*/
+
+// INCLUDE FILES
+#include "XcapHttpReqHead.h"
+#include "XcapHttpTransport.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+// ----------------------------------------------------------
+// CXcapHttpReqHead::CXcapHttpReqHead
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqHead::CXcapHttpReqHead( RHTTPSession& aHttpSession,
+                                  CXcapHttpAuthManager& aAuthManager,
+                                  CXcapHttpTransport& aTransportMain ) :
+                                  CXcapHttpRequest( aHttpSession, aAuthManager, aTransportMain )
+                                        
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqHead::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqHead* CXcapHttpReqHead::NewL( const TDesC& aRequestUri, 
+                                        RHTTPSession& aHttpSession,
+                                        CXcapHttpAuthManager& aAuthManager,
+                                        CXcapHttpTransport& aTransportMain )
+                                        
+    {
+    CXcapHttpReqHead* self = new ( ELeave ) CXcapHttpReqHead( aHttpSession, aAuthManager, aTransportMain );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aRequestUri );
+    CleanupStack::Pop();  //self
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqHead::~CXcapHttpReqHead
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqHead::~CXcapHttpReqHead()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpReqHead::~CXcapHttpReqHead()" ) );    
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqHead::ConstructRequestL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpReqHead::ConstructRequestL()
+    {
+    CXcapHttpRequest::ConstructRequestL();
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqHead::ConstructRequestL
+// 
+// ----------------------------------------------------------
+//
+RStringF CXcapHttpReqHead::ConstructMethodStringL()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpReqHead::ConstructMethodStringL()" ) );    
+    #endif
+    return iHttpSession.StringPool().OpenFStringL( KXcapRequestHead );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpReqMkcol.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,94 @@
+/*
+* ============================================================================
+*  Name     : CXcapHttpReqHead from XcapHttpReqHead.cpp
+*  Part of  : Transport Adapter of the Symbian OS WV Engine 
+*
+*  Description:
+/*
+* 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:   CXcapHttpReqMkcol
+*
+*/
+
+// INCLUDE FILES
+#include "XcapHttpReqMkcol.h"
+#include "XcapHttpTransport.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+// ----------------------------------------------------------
+// CXcapHttpReqMkcol::CXcapHttpReqMkcol
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqMkcol::CXcapHttpReqMkcol( RHTTPSession& aHttpSession,
+                                  CXcapHttpAuthManager& aAuthManager,
+                                  CXcapHttpTransport& aTransportMain ) :
+                                  CXcapHttpContSupplier( aHttpSession, aAuthManager, aTransportMain )
+                                        
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqMkcol::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqMkcol* CXcapHttpReqMkcol::NewL( const TDesC& aRequestUri, 
+                                        RHTTPSession& aHttpSession,
+                                        CXcapHttpAuthManager& aAuthManager,
+                                        CXcapHttpTransport& aTransportMain )
+                                        
+    {
+    CXcapHttpReqMkcol* self = new ( ELeave ) CXcapHttpReqMkcol( aHttpSession, aAuthManager, aTransportMain );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aRequestUri );
+    CleanupStack::Pop();  //self
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqMkcol::~CXcapHttpReqMkcol
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqMkcol::~CXcapHttpReqMkcol()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpReqMkcol::~CXcapHttpReqMkcol()" ) );    
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqMkcol::ConstructRequestL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpReqMkcol::ConstructRequestL()
+    {
+    CXcapHttpRequest::ConstructRequestL();
+    iHttpTransaction.Request().SetBody( *this );
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqMkcol::ConstructRequestL
+// 
+// ----------------------------------------------------------
+//
+RStringF CXcapHttpReqMkcol::ConstructMethodStringL()
+    {
+    return iHttpSession.StringPool().OpenFStringL( KXcapRequestMkcol );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpReqPut.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,91 @@
+/*
+* 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:   CXcapHttpReqPut
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XcapHttpReqPut.h"
+#include "XcapHttpTransport.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+// ----------------------------------------------------------
+// CXcapHttpReqPut::CXcapHttpReqPut
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqPut::CXcapHttpReqPut( RHTTPSession& aHttpSession,
+                                  CXcapHttpAuthManager& aAuthManager,
+                                  CXcapHttpTransport& aTransportMain ) :
+                                  CXcapHttpContSupplier( aHttpSession, aAuthManager, aTransportMain )
+                                        
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqPut::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqPut* CXcapHttpReqPut::NewL( const TDesC& aRequestUri, 
+                                        RHTTPSession& aHttpSession,
+                                        CXcapHttpAuthManager& aAuthManager,
+                                        CXcapHttpTransport& aTransportMain )
+                                        
+    {
+    CXcapHttpReqPut* self = new ( ELeave ) CXcapHttpReqPut( aHttpSession, aAuthManager, aTransportMain );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aRequestUri );
+    CleanupStack::Pop();  //self
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqPut::~CXcapHttpReqPut
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpReqPut::~CXcapHttpReqPut()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpReqPut::~CXcapHttpReqPut()" ) );    
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqPut::ConstructRequestL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpReqPut::ConstructRequestL()
+    {
+    CXcapHttpRequest::ConstructRequestL();
+    iHttpTransaction.Request().SetBody( *this );
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpReqPut::ConstructRequestL
+// 
+// ----------------------------------------------------------
+//
+RStringF CXcapHttpReqPut::ConstructMethodStringL()
+    {
+    return iHttpSession.StringPool().OpenFStringL( KXcapRequestPut );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpRequest.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,681 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXcapHttpRequest
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <hal.h>
+#include <e32math.h>
+#include "XdmCredentials.h"
+#include "XcapHttpRequest.h"
+#include "XcapHttpResponse.h"
+#include "XcapHttpTransport.h"
+#include "XcapHttpHeaderModel.h"
+#include "XcapHttpAuthManager.h"
+#include "XcapHttpRequestTimer.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::CXcapHttpRequest
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpRequest::CXcapHttpRequest( RHTTPSession& aHttpSession,
+                                    CXcapHttpAuthManager& aAuthManager,
+                                    CXcapHttpTransport& aTransportMain ) :
+                                    iHttpSession( aHttpSession ),
+                                    iTransportMain( aTransportMain ),
+                                    iSent( EFalse ),
+                                    iActive( EFalse ),
+                                    iCancelled( EFalse ),
+                                    iConstructed( EFalse ),
+                                    iAuthManager( aAuthManager )
+                                        
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::BaseConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::BaseConstructL( const TDesC& aRequestUri )
+    {
+    SetRequestUriL( aRequestUri );
+    iHttpResponse = CXcapHttpResponse::NewL( this, iTransportMain );
+    iResponseBuffer = CBufSeg::NewL( 250 );
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::~CXcapHttpRequest
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpRequest::~CXcapHttpRequest()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::~CXcapHttpRequest()" ) );    
+    #endif
+    delete iExpiryTimer;
+    delete iHttpResponse;
+    delete iRequestUriBuf;
+    ReleaseResponseData();
+    delete iResponseBuffer;
+    delete iWholeUri;
+    iHeaderCollection.Close();
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::DispatchRequestL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXcapHttpRequest::DispatchRequestL( TRequestStatus& aClientStatus )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::DispatchMessageL()" ) );
+        iSendTime = TimeL();
+    #endif
+    ConstructRequestL();
+    DoSetHeadersL();
+    iCurrentDataLength = 0;
+    aClientStatus = KRequestPending;
+    iClientStatus = &aClientStatus;
+    iHttpTransaction.SubmitL();
+    SetStatus( ETrue );
+    iActive = ETrue;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::ConstructRequest
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::ConstructRequestL()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::ConstructRequestL() - Constructed: %d" ), iConstructed );
+    #endif
+    if( !iConstructed )
+        {    
+        RStringF method = ConstructMethodStringL();
+        CleanupClosePushL( method );
+        iHttpTransaction = iHttpSession.OpenTransactionL( iRequestUri, *iHttpResponse, method );
+        CleanupStack::PopAndDestroy();  //method
+        RHTTPHeaders hdrs = iHttpTransaction.Request().GetHeaderCollection();
+        iConstructed = ETrue;
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::UpdateRequestUriL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXcapHttpRequest::UpdateRequestUriL( const TDesC8& aUpdatedUri )
+    {
+    HBufC* temp = HBufC::NewLC( aUpdatedUri.Length() );
+    temp->Des().Copy( aUpdatedUri );
+    SetRequestUriL( temp->Des() );
+    CleanupStack::PopAndDestroy();
+    }
+    
+// ----------------------------------------------------------
+// CXcapHttpRequest::ResetUriL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXcapHttpRequest::ResetUriL( const TDesC& aNewUri )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::ResetUriL()" ) );
+    #endif
+    delete iRequestUriBuf;
+    iRequestUriBuf = NULL;
+    delete iWholeUri;
+    iWholeUri = NULL;
+    iWholeUri = HBufC8::NewL( aNewUri.Length() );
+    iWholeUri->Des().Copy( aNewUri );
+    iRequestUri.Parse( iWholeUri->Des() );
+    #ifdef _DEBUG
+        TPtrC8 address( iRequestUri.UriDes() );
+        iTransportMain.WriteToLog( _L8( "  New URI %S"), &address );
+    #endif
+    }
+    
+// ----------------------------------------------------------
+// CXcapHttpRequest::RequestUriL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TPtrC8 CXcapHttpRequest::RequestUriL() const
+    {
+    return iRequestUriBuf != NULL ? iRequestUriBuf->Des() : TPtrC8();
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::ResendL
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpAuthManager& CXcapHttpRequest::AuthManager()
+    {
+    return iAuthManager;
+    }
+   
+// ----------------------------------------------------------
+// CXcapHttpRequest::ResendWithAuthL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::ResendWithAuthL( TInt aAuthType )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::ResendWithAuthL() - Auth type: %d" ), aAuthType );
+    #endif
+    iHttpTransaction.Cancel();
+    if( iExpiryTimer != NULL && iExpiryTimer->IsActive() )
+    	iExpiryTimer->Cancel();
+    RHTTPHeaders hdrs = iHttpTransaction.Request().GetHeaderCollection();
+    AppendAuthorizationHeaderL( hdrs, aAuthType );
+    iHttpTransaction.SubmitL();
+    SetStatus( ETrue );
+    iActive = ETrue;
+    }
+        
+// ----------------------------------------------------------
+// CXcapHttpRequest::Transaction
+// 
+// ----------------------------------------------------------
+//
+RHTTPTransaction& CXcapHttpRequest::Transaction()
+    {
+    return iHttpTransaction;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::RelativeUri
+// 
+// ----------------------------------------------------------
+//
+TPtrC8 CXcapHttpRequest::RelativeUri() const
+    {
+    TPtrC8 absolute( iRequestUri.UriDes() );
+    TPtrC8 temp( absolute.Mid( absolute.FindF( _L8( "//" ) ) + 2 ) );
+    return temp.Mid( temp.LocateF( '/' ) );
+    }
+    
+// ----------------------------------------------------------
+// CXcapHttpRequest::SetStatus
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::SetRequestUriL( const TDesC& aRequestUri )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::SetRequestUriL()") );
+    #endif
+    delete iRequestUriBuf;
+    iRequestUriBuf = NULL;
+    iRequestUriBuf = HBufC8::NewL( aRequestUri.Length() );
+    iRequestUriBuf->Des().Copy( aRequestUri );
+    TPtrC8 document = iRequestUriBuf->Des();
+    TPtrC8 root = iTransportMain.RootUri();
+    delete iWholeUri;
+    iWholeUri = NULL;
+    iWholeUri = HBufC8::NewL( root.Length() + document.Length() );
+    iWholeUri->Des().Copy( root );
+    iWholeUri->Des().Append( document );
+    iRequestUri.Parse( iWholeUri->Des() );
+    #ifdef _DEBUG
+        TPtrC8 address( iRequestUri.UriDes() );
+        iTransportMain.WriteToLog( _L8( "  URI %S"), &address );
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::SetStatus
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::SetStatus( const TBool aSent )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::SetStatus()" ) );
+    #endif
+    iSent = aSent;
+    if( iSent )
+        {
+        if( iExpiryTimer != NULL && !iExpiryTimer->IsActive() )
+            iExpiryTimer->ActivateTimer( iExpiryTime );
+        }
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::SetStatus(): Status %d"), iSent );
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::SetHeaderL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXcapHttpRequest::SetHeaderL( const TDesC8& aHeaderName,
+                                            const TDesC8& aHeaderValue )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::SetHeaderL()" ) );
+        iTransportMain.WriteToLog( _L8( "  Header name:    %S" ), &aHeaderName );
+        iTransportMain.WriteToLog( _L8( "  Header value:   %S" ), &aHeaderValue );
+    #endif
+    CXcapHttpHeaderModel* model = CXcapHttpHeaderModel::NewL( aHeaderName, aHeaderValue, iTransportMain );
+    CleanupStack::PushL( model );
+    User::LeaveIfError( iHeaderCollection.Append( model ) );
+    CleanupStack::Pop();  //model
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::HeaderValue
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TPtrC8 CXcapHttpRequest::HeaderValue( const HTTP::TStrings aHeaderName ) const
+    {
+    THTTPHdrVal value;
+    RStringPool stringPool = iHttpSession.StringPool();
+    RHTTPHeaders headerCollection = iHttpTransaction.Response().GetHeaderCollection();
+    RStringF hdrName = stringPool.StringF( aHeaderName, RHTTPSession::GetTable() );
+    headerCollection.GetField( hdrName, 0, value );
+    hdrName.Close();
+    if( value.Type() == THTTPHdrVal::KStrVal )
+        return value.Str().DesC();
+    else if( value.Type() == THTTPHdrVal::KStrFVal )
+        return value.StrF().DesC();
+    else return TPtrC8();
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::DoSetHeadersL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::DoSetHeadersL()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::DoSetHeadersL()" ) );
+    #endif
+    TInt count = iHeaderCollection.Count();
+    RHTTPHeaders hdrs = iHttpTransaction.Request().GetHeaderCollection();
+    if( iAuthManager.IsAuthorized() )
+        AppendAuthorizationHeaderL( hdrs, KAuthTypeNormal );
+    if( iConstructed && count > 0 )
+        {
+        #ifdef _DEBUG
+            iTransportMain.WriteToLog( _L8( "--------------------" ) );
+            iTransportMain.WriteToLog( _L8( "User-set headers:" ) );
+        #endif
+        for( TInt i = 0;i < count;i++ )
+            {
+            TPtrC8 name = iHeaderCollection[i]->HeaderName();
+            TPtrC8 value = iHeaderCollection[i]->HeaderValue();
+            RStringF nameString = iHttpSession.StringPool().OpenFStringL( name );
+            CleanupClosePushL( nameString );
+            RStringF valueString = iHttpSession.StringPool().OpenFStringL( value );
+            CleanupClosePushL( valueString );
+            hdrs.SetFieldL( nameString, valueString );
+            #ifdef _DEBUG
+                iTransportMain.WriteToLog( _L8( "* %S: %S" ), &name, &value );
+            #endif
+            CleanupStack::PopAndDestroy( 2 );  //valueString, nameString
+            }
+        #ifdef _DEBUG
+            iTransportMain.WriteToLog( _L8( "--------------------" ) );
+        #endif
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::AppendAuthorizationHeaderL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::AppendAuthorizationHeaderL( RHTTPHeaders& aHeaderCollection, TInt aAuthType )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::AppendAuthorizationHeaderL()" ) );
+    #endif
+    HBufC8* authorization = iAuthManager.AuthorizationL( *this );
+    if( authorization != NULL )
+        {
+        RemoveDuplicateAuth();
+        CleanupStack::PushL( authorization );
+        RStringF valStr = iHttpSession.StringPool().OpenFStringL( *authorization );
+        CleanupClosePushL( valStr );
+        switch( aAuthType )
+            {
+            case KAuthTypeNormal:
+                aHeaderCollection.SetFieldL( iHttpSession.StringPool().StringF( 
+                    HTTP::EAuthorization, RHTTPSession::GetTable() ), valStr );
+                break;
+            case KAuthTypeProxy:
+                aHeaderCollection.SetFieldL( iHttpSession.StringPool().StringF( 
+                    HTTP::EProxyAuthorization, RHTTPSession::GetTable() ), valStr );
+                break;
+            default:
+                #ifdef _DEBUG
+                    iTransportMain.WriteToLog( _L8( "  Default case: %d" ), aAuthType );
+                #endif
+                break;
+            }
+        CleanupStack::PopAndDestroy( 2 );  //valStr, authorization
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::RemoveDuplicateAuth
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::RemoveDuplicateAuth()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::RemoveDuplicateAuth()" ) );
+    #endif
+    RStringPool spool = iHttpSession.StringPool();								  
+    RHTTPHeaders requestHeaders( iHttpTransaction.Request().GetHeaderCollection() );
+    //Check for existence of the header is not needed, remove both if they're there
+    requestHeaders.RemoveField( spool.StringF( HTTP::EAuthorization, RHTTPSession::GetTable() ) );
+    requestHeaders.RemoveField( spool.StringF( HTTP::EProxyAuthorization, RHTTPSession::GetTable() ) );
+    }
+               
+// ----------------------------------------------------------
+// CXcapHttpRequest::AppendDataL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::AppendDataL( const TPtrC8& aBodyPart )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::AppendDataL() - Current: %d" ),
+                                        iCurrentDataLength );
+    #endif
+    iResponseBuffer->ResizeL( iCurrentDataLength + aBodyPart.Length() );
+    iResponseBuffer->Write( iCurrentDataLength, aBodyPart );
+    iCurrentDataLength = iCurrentDataLength + aBodyPart.Length();
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "  Current: %d" ), iCurrentDataLength );
+        iTransportMain.WriteToLog( _L8( "  Buffer size: %d" ), iResponseBuffer->Size() );
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::SetStatus
+// 
+// ----------------------------------------------------------
+//
+RHTTPSession& CXcapHttpRequest::Session()
+    {
+    return iHttpSession;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::SetStatus
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TXdmCompletionData* CXcapHttpRequest::ResponseData()
+    {
+    return &iRespData;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::ReleaseResponseData
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXcapHttpRequest::ReleaseResponseData()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::ReleaseResponseData()" ) );
+    #endif
+    if( iRespData.iETag != NULL )
+        {
+        delete iRespData.iETag;
+        iRespData.iETag = NULL;
+        }
+    if( iRespData.iStatusText != NULL )
+        {
+        delete iRespData.iStatusText;
+        iRespData.iStatusText = NULL;
+        }
+    if( iRespData.iResponseData != NULL )
+        {
+        delete iRespData.iResponseData;
+        iRespData.iResponseData = NULL;
+        }
+    if( iConstructed )
+        {
+        iConstructed = EFalse;
+        iHttpTransaction.Close();
+        }
+    iHeaderCollection.ResetAndDestroy();
+    }
+    
+// ----------------------------------------------------------
+// CXcapHttpRequest::SetExpiryTimeL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXcapHttpRequest::SetExpiryTimeL( MXcapHttpRequestTimerCallback* /*aCallback*/,
+                                                const TTimeIntervalMicroSeconds32 aExpiryTime )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::SetExpiryTimeL()" ) );
+    #endif
+    if( iExpiryTimer == NULL )
+        iExpiryTimer = CXcapHttpRequestTimer::NewL( iTransportMain, this );
+    iExpiryTime = aExpiryTime;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::FinaliseRequestL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::FinaliseRequestL( TInt aErrorCode )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::FinaliseRequestL()" ) );
+        iTransportMain.WriteToLog( _L8( "  Error:  %d" ), aErrorCode );
+        iTransportMain.WriteToLog( _L8( "  Active: %d" ), iActive );
+    #endif
+    if( iActive )
+        {
+        iActive = EFalse;
+        if( iExpiryTimer )
+            iExpiryTimer->Cancel();
+        PrepareResponseBodyL();
+        CompileResponseDataL( aErrorCode );
+        User::RequestComplete( iClientStatus, aErrorCode );
+        delete iWholeUri;
+        iWholeUri = NULL;
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::CancelRequest
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXcapHttpRequest::CancelRequest()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::CancelRequest()" ) );
+    #endif
+    if( iActive )
+        {
+        #ifdef _DEBUG
+            iTransportMain.WriteToLog( _L8( " Request is active, cancelling..." ) );
+        #endif
+        if( iExpiryTimer )
+            iExpiryTimer->Cancel();
+        iActive = EFalse;
+        iConstructed = EFalse;
+        iHttpTransaction.Close();
+        iRespData.iETag = NULL;
+        iRespData.iStatusText = NULL;
+        iRespData.iResponseData = NULL;
+        iRespData.iCompletion = KErrCancel;
+        iRespData.iHttpStatus = KErrCancel;
+        User::RequestComplete( iClientStatus, KErrCancel );
+        #ifdef _DEBUG
+            iTransportMain.WriteToLog( _L8( " Request completed with KErrCancel" ) );
+        #endif
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::CompileResponseData
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::CompileResponseDataL( TInt aErrorCode )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L( "CXcapHttpRequest::CompileResponseData()" ) );
+    #endif
+    RHTTPResponse response = iHttpTransaction.Response();
+    TInt statusInt = response.StatusCode();
+    RStringF statusStr = response.StatusText();
+    HBufC8* statusBuf = statusStr.DesC().AllocLC();
+    TPtrC8 etagDesc( HeaderValue( HTTP::EETag ) );
+    HBufC8* eTag = etagDesc.Length() > 0 ? etagDesc.AllocL() : NULL;
+    iRespData.iETag = eTag;
+    iRespData.iHttpStatus = statusInt;
+    iRespData.iStatusText = statusBuf;
+    iRespData.iCompletion = aErrorCode;
+    iRespData.iResponseData = iFlatResponse;
+    CleanupStack::Pop();  //statusBuf
+    #ifdef _DEBUG
+        if( iRespData.iResponseData != NULL )
+            {
+            TBuf<32> response( _L( "response" ) );
+            response.AppendNum( iHttpTransaction.Id() );
+            response.Append( _L( ".xml" ) );
+            DumpResponseL( *iRespData.iResponseData, response );
+            }
+    #endif
+    }
+
+#ifdef _DEBUG
+// ---------------------------------------------------------
+// CXcapHttpRequest::DumpResponseL
+//
+// ---------------------------------------------------------
+//
+void CXcapHttpRequest::DumpResponseL( const TDesC8& aRespData, const TDesC& aDumpName ) 
+    {
+    RFile file;
+    RFs session;
+    TBuf<512> path( _L( "C:\\logs\\XDM\\"  ) ); 
+    path.Append( aDumpName );
+    User::LeaveIfError( session.Connect() );
+    TInt error( file.Replace( session, path, EFileWrite ) );
+    if( error == KErrNone )
+        {
+        file.Write( aRespData );
+        file.Close();
+        }
+    session.Close();
+    }
+#endif
+    
+// ----------------------------------------------------------
+// CXcapHttpRequest::PrepareResponseBodyL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::PrepareResponseBodyL()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::PrepareResponseBodyL()" ) );
+    #endif
+    iResponseBuffer->Compress();
+    TInt dataLength = iResponseBuffer->Size();
+    #ifdef _DEBUG
+        TInt contentLength = iHttpResponse->ContentLengthL();
+        if( contentLength >= 0 && contentLength < KMaxTInt )
+            {
+            TPtrC8 result;
+            contentLength == dataLength ? result.Set( _L8( "Correct" ) ) :
+                                          result.Set( _L8( "Values do not match!" ) );
+            iTransportMain.WriteToLog( _L8( "  Actual length: %d *** Content-Length: %d => %S" ),
+                                            dataLength, contentLength, &result );
+            }
+    #endif
+    if( dataLength > 0 )
+        {
+        iFlatResponse = HBufC8::NewL( dataLength );
+        TPtr8 pointer( iFlatResponse->Des() );
+        iResponseBuffer->Read( 0, pointer, dataLength );
+        //pointer.Copy( iResponseBuffer->Ptr( 0 ) );
+        iResponseBuffer->Reset();
+        iCurrentDataLength = 0;
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpRequest::HandleTimerEventL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpRequest::HandleTimerEventL()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequest::HandleTimerEventL()" ) );
+    #endif
+    iHttpTransaction.Close();
+    iActive = EFalse;
+    iConstructed = EFalse;
+    iRespData.iETag = NULL;
+    iRespData.iStatusText = NULL;
+    iRespData.iResponseData = NULL;
+    iRespData.iCompletion = KErrTimedOut;
+    iRespData.iHttpStatus = KErrTimedOut;
+    User::RequestComplete( iClientStatus, KErrTimedOut );
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( " Request completed with KErrTimedOut" ) );
+    #endif
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpRequest::TimeL
+// 
+// ---------------------------------------------------------
+//
+TInt CXcapHttpRequest::TimeL() const
+    {
+    TInt period = 0;
+    User::LeaveIfError( HAL::Get( HALData::ESystemTickPeriod, period ) );
+    TInt millisecsPerTick = period / 1000;
+    return User::TickCount() * millisecsPerTick;
+    }
+
+// End of file
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpRequestTimer.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -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:   CXcapHttpRequestTimer
+*
+*/
+
+
+
+
+// INCLUDES
+#include "XcapHttpTransport.h"
+#include "XcapHttpRequestTimer.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CXcapHttpRequestTimer::CXcapHttpRequestTimer( CXcapHttpTransport& aTransportMain,
+                                              MXcapHttpRequestTimerCallback* aCallback ) :
+                                              CActive( 0 ),
+                                              iTransportMain( aTransportMain ),
+                                              iCallback( aCallback )
+                                              
+                                          
+    {
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpRequestTimer::ConstructL()
+//
+// ---------------------------------------------------------
+//
+void CXcapHttpRequestTimer::ConstructL()
+    {
+    User::LeaveIfError( iTimer.CreateLocal() );
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpRequestTimer::NewL
+//
+// ---------------------------------------------------------
+//
+CXcapHttpRequestTimer* CXcapHttpRequestTimer::NewL( CXcapHttpTransport& aTransportMain,
+                                                    MXcapHttpRequestTimerCallback* aCallback )
+    {
+    CXcapHttpRequestTimer* self = new ( ELeave ) CXcapHttpRequestTimer( aTransportMain, aCallback );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpRequestTimer::~CXcapHttpRequestTimer()
+//
+// ---------------------------------------------------------
+//
+CXcapHttpRequestTimer::~CXcapHttpRequestTimer()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequestTimer::~CXcapHttpRequestTimer()" ) );  
+    #endif
+    Cancel();
+    iTimer.Close();
+    }
+
+
+// ---------------------------------------------------------
+// CXcapHttpRequestTimer::ActivateTimer
+//
+// ---------------------------------------------------------
+//
+void CXcapHttpRequestTimer::ActivateTimer( TTimeIntervalMicroSeconds32 aDelay )
+    {
+    __ASSERT_ALWAYS( !IsActive(), User::Panic( _L( "CXcapHttpRequestTimer" ), 1 ) );
+    iTimer.After( iStatus, aDelay );
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequestTimer activated." ) );
+    #endif
+    SetActive();
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpRequestTimer::RunL
+//
+// ---------------------------------------------------------
+//
+void CXcapHttpRequestTimer::RunL()
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequestTimer::RunL()." ) );
+    #endif
+    iCallback->HandleTimerEventL();
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpRequestTimer::DoCancel
+//
+// ---------------------------------------------------------
+//
+void CXcapHttpRequestTimer::DoCancel()
+    {
+    iTimer.Cancel();
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpRequestTimer cancelled." ) );
+    #endif
+    }
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpResponse.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,442 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXcapHttpResponse
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <XdmErrors.h>
+#include "XdmCredentials.h"
+#include "XcapHttpRequest.h"
+#include "XcapHttpResponse.h"
+#include "XcapHttpTransport.h"
+#include "XcapHttpAuthManager.h"
+
+const TUint KMaxRetryCount = 3;
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+
+// ----------------------------------------------------------
+// CXcapHttpResponse::CXcapHttpResponse
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpResponse::CXcapHttpResponse( CXcapHttpRequest* aHttpRequest,
+                                      CXcapHttpTransport& aTransportMain ) :
+                                      iAuthPending( EFalse ),
+                                      iHttpRequest( aHttpRequest ),
+                                      iTransportMain( aTransportMain ),
+                                      iAuthManager( iHttpRequest->AuthManager() )                                       
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapHttpResponse::NewL
+// 
+// ----------------------------------------------------
+//
+CXcapHttpResponse* CXcapHttpResponse::NewL( CXcapHttpRequest* aHttpRequest,
+                                            CXcapHttpTransport& aTransportMain )
+    {
+    CXcapHttpResponse* self = new ( ELeave ) CXcapHttpResponse( aHttpRequest, aTransportMain );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();  //self
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CXcapHttpResponse::ConstructL
+// 
+// ----------------------------------------------------
+//
+void CXcapHttpResponse::ConstructL()
+    {
+    }
+    
+// ----------------------------------------------------
+// CXcapHttpResponse::~CXcapHttpResponse()
+// Destructor
+// ----------------------------------------------------
+//
+CXcapHttpResponse::~CXcapHttpResponse()
+    {
+    }
+
+// ----------------------------------------------------
+// CXcapHttpResponse::MHFRunL
+// 
+// ----------------------------------------------------
+//
+void CXcapHttpResponse::MHFRunL( RHTTPTransaction aTransaction, const THTTPEvent& aEvent )
+    {
+    TInt status = aTransaction.Response().StatusCode();
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpResponse::MHFRunL()" ) );
+        iTransportMain.WriteToLog( _L8( "  HTTP status:  %d" ), status );
+		iTransportMain.WriteToLog( _L8( "  Event status: %d" ), aEvent.iStatus );
+        iTransportMain.WriteToLog( _L8( "  TransID:      %d " ), aTransaction.Id() );
+    #endif
+    switch( aEvent.iStatus )
+        {
+        case THTTPEvent::EGotResponseHeaders:
+            #ifdef _DEBUG
+                DumpHeadersL( aTransaction.Response().GetHeaderCollection(), aTransaction.Id() );
+                //DumpHeadersL( aTransaction.Request().GetHeaderCollection(), aTransaction.Id() );
+            #endif
+            TInt authType;
+            if( IsUnauthRequest( aTransaction, authType ) )
+                {
+                // If server keeps on sending 401 resposenses. Will stop
+                // sending new requests after 3 trys.
+                if ( KMaxRetryCount == iUnauthRequestCounter )
+                    {
+                    #ifdef _DEBUG
+                        iTransportMain.WriteToLog(
+                        _L8( "  Max retry count. Stop sending auth requests to server." ) );
+                    #endif   
+                    iHttpRequest->FinaliseRequestL( KErrCancel );
+                    aTransaction.Cancel();                   
+                    }                
+                //We only support Digest => If Basic is defined, stop.
+                else if( iAuthManager.ParseHeaderL( aTransaction, authType ) )
+                    {
+                    iHttpRequest->ResendWithAuthL( authType );
+                    iAuthPending = ETrue;
+                    }
+                else
+                    {
+                    #ifdef _DEBUG
+                        iTransportMain.WriteToLog( _L8( " Basic authentication not supported" ) );
+                    #endif
+                    iHttpRequest->FinaliseRequestL( KXcapErrorAuthentication );
+                    aTransaction.Cancel();
+                    }
+                }
+            else if( iAuthPending && ( status != 401 && status != 403 ) )
+                {
+                iAuthPending = EFalse;
+                iAuthManager.SetAuthorized( ETrue );
+                }
+            else if( !CheckAuthInfoHeaderL( aTransaction.Response().GetHeaderCollection() ) )
+                {
+                //This means that something was wrong with the Authentication-Info header
+                //the server returned. Do not take any chances here, but stop.
+                #ifdef _DEBUG
+                    iTransportMain.WriteToLog( _L8( " Something's wrong with Authentication-Info => STOP" ) );
+                #endif
+                iHttpRequest->FinaliseRequestL( KXcapErrorAuthentication );
+                aTransaction.Cancel();
+                }
+            break;
+        case THTTPEvent::EGotResponseBodyData:
+            #ifdef _DEBUG
+                iTransportMain.WriteToLog( _L8( "MHFRunL() - A body part received" ) );
+            #endif
+            HandleReceivedBodyDataL( aTransaction );
+            break;
+        case THTTPEvent::EResponseComplete:
+            #ifdef _DEBUG
+                iTransportMain.WriteToLog( _L8( " * Transaction complete") );
+            #endif
+            break;
+        case THTTPEvent::ESucceeded:
+            #ifdef _DEBUG
+                iTransportMain.WriteToLog( _L8( " * Transaction succeeded") );
+            #endif
+            iHttpRequest->FinaliseRequestL( KErrNone );
+            break;
+        case THTTPEvent::EFailed:
+            {
+            TInt completion = aEvent.iStatus < 0 ? aEvent.iStatus : KErrNone;
+            #ifdef _DEBUG
+                iTransportMain.WriteToLog( _L8( " * Transaction failed - Completion: %d"), completion );
+            #endif
+            iHttpRequest->FinaliseRequestL( completion );
+            }
+            break;
+        case THTTPEvent::ERedirectedPermanently:
+            break;
+        case THTTPEvent::ERedirectedTemporarily:
+            break;
+        default:
+            {
+            if( aEvent.iStatus < KErrNone )
+                {
+                #ifdef _DEBUG
+                    iTransportMain.WriteToLog( _L8( "  * Transaction failed, stop" ) );
+                #endif
+                iHttpRequest->FinaliseRequestL( aEvent.iStatus );
+                }
+            else
+                {
+                #ifdef _DEBUG
+                    iTransportMain.WriteToLog( _L8( "  * Unknown status, stop" ) );
+                #endif
+                iHttpRequest->FinaliseRequestL( KErrUnknown );
+                }
+            }
+            break;
+        }  
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::CheckAuthInfoHeaderL
+// 
+// ----------------------------------------------------------
+//
+TBool CXcapHttpResponse::CheckAuthInfoHeaderL( RHTTPHeaders aHeaders )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpResponse::CheckAuthInfoHeaderL()" ) );
+    #endif
+    THTTPHdrVal fieldVal;
+    TBool authOk = ETrue;
+    TPtrC8 rawData( _L8( "" ) );
+    RStringPool spool = iHttpRequest->Session().StringPool();
+    RStringF authInfo = spool.OpenFStringL( TPtrC8( KAuthInfoParamArray[ENfoAuthInfo] ) );
+    CleanupClosePushL( authInfo );
+    RStringF prxAuthInfo = spool.OpenFStringL( TPtrC8( KAuthInfoParamArray[ENfoPrxAuthInfo] ) );
+    CleanupClosePushL( prxAuthInfo );
+    if( aHeaders.GetRawField( authInfo, rawData ) == KErrNone ||
+        aHeaders.GetRawField( prxAuthInfo, rawData ) == KErrNone )
+        {
+        TInt length = 0;
+        HBufC8* tempCopy = rawData.AllocLC();
+        TPtr8 modDesc( tempCopy->Des() );
+        while( authOk && modDesc.Length() > 0 )
+            {
+            TPtrC8 value;
+            TAuthInfoParam name = ( TAuthInfoParam )-1;
+            if( ParseAuthInfoParam( length, name, value, modDesc ) )
+                authOk = iAuthManager.ConsumeAuthInfoParamL( name, value );
+            modDesc.Delete( 0, length );
+            modDesc.TrimLeft();
+            }
+        CleanupStack::PopAndDestroy();  //tempCopy
+        }
+    CleanupStack::PopAndDestroy( 2 );  //prxAuthInfo, authInfo
+    return authOk;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpAuthManager::ParseAuthInfoParam
+// 
+// ----------------------------------------------------------
+//
+TBool CXcapHttpResponse::ParseAuthInfoParam( TInt& aLength, TAuthInfoParam& aName, TPtrC8& aValue, TPtr8& aParam )
+    {
+    TBool found = EFalse;
+    TInt delim = aParam.Locate( ',' );
+    TPtrC8 param( delim > 0 ? aParam.Left( delim ) : aParam );
+    TInt index = param.Locate( '=' );
+    if( index > 0 )
+        {
+        TPtrC8 name( param.Left( index ) );
+        TPtrC8 value( param.Mid( index + 1 ) );
+        const TInt count = sizeof( KAuthInfoParamArray ) / sizeof( KAuthInfoParamArray[0] );
+        for( TInt i = 0;!found && i < count;i++ )
+            {
+            if( name.CompareF( TPtrC8( KAuthInfoParamArray[i] ) ) == 0 )
+                {
+                aValue.Set( value );
+                aName = ( TAuthInfoParam )i;
+                found = ETrue;
+                }
+            }
+        }
+    aLength = delim > 0 ? delim + 1 : aParam.Length();
+    return found;
+    }
+
+               
+// ----------------------------------------------------------
+// CXcapHttpResponse::IsUnauthRequest
+// 
+// ----------------------------------------------------------
+//
+TBool CXcapHttpResponse::IsUnauthRequest( RHTTPTransaction aTransaction, TInt& aAuthType )
+    {
+    iUnauthRequestCounter++;
+    TInt status = aTransaction.Response().StatusCode();
+    switch( status )
+        {
+        case 401:  //Normal authentication
+            aAuthType = 401;
+            return ETrue;
+        case 407:  //Proxy authentication
+            aAuthType = 407;
+            return ETrue;
+        default:
+            return EFalse;
+        }
+    }
+       
+// ----------------------------------------------------------
+// CXcapHttpResponse::HandleReceivedBodyDataL
+// 
+// ----------------------------------------------------------
+//
+TBool CXcapHttpResponse::HandleReceivedBodyDataL( const RHTTPTransaction aTransaction )
+    {
+    #ifdef _DEBUG
+        iTransportMain.WriteToLog( _L8( "CXcapHttpResponse::HandleReceivedBodyDataL()") );
+    #endif
+    TPtrC8 bodyData;
+    MHTTPDataSupplier* respBody = aTransaction.Response().Body();
+    TBool lastChunk = respBody->GetNextDataPart( bodyData );
+    iHttpRequest->AppendDataL( bodyData );
+    respBody->ReleaseData();
+    return lastChunk;
+    }
+
+// ----------------------------------------------------------
+// CImpsHttpTransactionSender::ContentLengthL
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapHttpResponse::ContentLengthL() const
+    {
+    TInt retVal = KMaxTInt;
+    THTTPHdrVal fieldValue;
+    _LIT8( KContentLength, "Content-Length" );
+    RHTTPHeaders headers = ResponseHeaderCollection();
+    RStringPool stringPool = iHttpRequest->Session().StringPool();
+    RStringF lengthString = stringPool.OpenFStringL( KContentLength );
+    headers.GetField( lengthString, 0, fieldValue );
+    lengthString.Close();
+    if( fieldValue.Type() == THTTPHdrVal::KTIntVal )
+        retVal = fieldValue.Int();
+    return retVal;
+    }
+    
+// ----------------------------------------------------
+// CXcapHttpResponse::HeaderCollection
+// 
+// ----------------------------------------------------
+//
+RHTTPHeaders CXcapHttpResponse::ResponseHeaderCollection() const
+    {
+    return iHttpRequest->Transaction().Response().GetHeaderCollection();
+    }
+
+// ----------------------------------------------------
+// CXcapHttpResponse::HeaderCollection
+// 
+// ----------------------------------------------------
+//
+RHTTPHeaders CXcapHttpResponse::RequestHeaderCollection() const
+    {
+    return iHttpRequest->Transaction().Request().GetHeaderCollection();
+    }
+
+// ----------------------------------------------------
+// CXcapHttpResponse::MHFRunError
+// HTTP Stack callback interface
+// ----------------------------------------------------
+//
+TInt CXcapHttpResponse::MHFRunError( TInt /*aInt*/, RHTTPTransaction /*aTransaction*/,
+                                    const THTTPEvent& /*aEvent*/ )
+    {
+    return KErrNone;
+    }
+    
+#ifdef _DEBUG
+// ----------------------------------------------------
+// CXcapHttpResponse::DumpHeadersL
+// 
+// ----------------------------------------------------
+//
+void CXcapHttpResponse::DumpHeadersL( RHTTPHeaders aHeaders, TInt aId )
+    {
+    iTransportMain.WriteToLog( _L( "--------------------") );
+    iTransportMain.WriteToLog( _L( "Headers of the transaction %d: "), aId );
+    RStringPool strP = iHttpRequest->Session().StringPool();
+    THTTPHdrFieldIter it = aHeaders.Fields();
+    TBuf<KMaxHeaderNameLen>  fieldName16;
+    TBuf<KMaxHeaderValueLen> fieldVal16;
+
+    while( it.AtEnd() == EFalse )
+        {
+        RStringTokenF fieldName = it();
+        RStringF fieldNameStr = strP.StringF( fieldName );
+        THTTPHdrVal fieldVal;
+        if( aHeaders.GetField( fieldNameStr, 0, fieldVal ) == KErrNone )
+            {
+            const TDesC8& fieldNameDesC = fieldNameStr.DesC();
+            fieldName16.Copy( fieldNameDesC.Left( KMaxHeaderNameLen ) );
+            switch( fieldVal.Type() )
+                {
+            case THTTPHdrVal::KTIntVal:
+                iTransportMain.WriteToLog( _L("%S: %d"), &fieldName16, fieldVal.Int() );
+                break;
+            case THTTPHdrVal::KStrFVal:
+                {
+                RStringF fieldValStr = strP.StringF( fieldVal.StrF() );
+                const TDesC8& fieldValDesC = fieldValStr.DesC();
+                fieldVal16.Copy( fieldValDesC.Left( KMaxHeaderValueLen ) );
+                iTransportMain.WriteToLog( _L( "%S: %S" ), &fieldName16, &fieldVal16 );
+                }
+                break;
+            case THTTPHdrVal::KStrVal:
+                {
+                RString fieldValStr = strP.String(fieldVal.Str());
+                const TDesC8& fieldValDesC = fieldValStr.DesC();
+                fieldVal16.Copy( fieldValDesC.Left( KMaxHeaderValueLen ) );
+                iTransportMain.WriteToLog( _L( "%S: %S" ), &fieldName16, &fieldVal16 );
+                }
+                break;
+            case THTTPHdrVal::KDateVal:
+                {
+                TDateTime date = fieldVal.DateTime();
+                TBuf<40> dateTimeString;
+                TTime t(date);
+                t.FormatL( dateTimeString,KTransportDateFormat );
+                iTransportMain.WriteToLog( _L( "%S: %S" ), &fieldName16, &dateTimeString );
+                } 
+                break;
+            default:
+                iTransportMain.WriteToLog( _L( "%S: <unrecognised value type>" ), &fieldName16 );
+                break;
+                }
+            // Display realm for WWW-Authenticate header
+            RStringF wwwAuth = strP.StringF( HTTP::EWWWAuthenticate, RHTTPSession::GetTable() );
+            if( fieldNameStr == wwwAuth )
+                {
+                // check the auth scheme is 'basic'
+                RStringF basic = strP.StringF( HTTP::EBasic,RHTTPSession::GetTable() );
+                RStringF realm = strP.StringF( HTTP::ERealm,RHTTPSession::GetTable() );
+                THTTPHdrVal realmVal;
+                if ( (fieldVal.StrF() == basic ) && 
+                    ( !aHeaders.GetParam(wwwAuth, realm, realmVal) ) )
+                    {
+                    RStringF realmValStr = strP.StringF( realmVal.StrF() );
+                    fieldVal16.Copy( realmValStr.DesC() );
+                    iTransportMain.WriteToLog( _L( "Realm is: %S" ), &fieldVal16 );
+                    }
+                }
+            }
+        ++it;
+        }
+        iTransportMain.WriteToLog( _L( "--------------------") );
+    }
+    #endif
+
+// End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapHttpTransport/src/XcapHttpTransport.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,287 @@
+/*
+* 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:   CXcapHttpTransport
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <in_iface.h>
+#include <xdmlogwriter.h>
+#include <deflatefilterinterface.h>
+#include <msgconnmanagerapi.h>
+#include "XdmCredentials.h"
+#include "XcapHttpReqGet.h"
+#include "XcapHttpReqPut.h"
+#include "XcapHttpReqMkcol.h"
+#include "XcapHttpReqHead.h"
+#include "XcapHttpRequest.h"
+#include "XcapHttpReqDelete.h"
+#include "XcapHttpTransport.h"
+#include "XcapHttpAuthManager.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+
+// ----------------------------------------------------------
+// CXcapHttpTransport::CXcapHttpTransport
+// 
+// ----------------------------------------------------------
+//
+CXcapHttpTransport::CXcapHttpTransport( MMsgConnManager& aConnManager) :
+                                        iCredValidity( EFalse ),
+                                        iSessionClosed( ETrue ),
+                                        iConnManager( aConnManager )
+    { 
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpTransport::NewL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXcapHttpTransport* CXcapHttpTransport::NewL( const TDesC& aRootUri,
+                                                       MMsgConnManager& aConnManager,
+                                                       const TXdmCredentials& aDigestCredentials )
+    {
+    CXcapHttpTransport* self = new ( ELeave ) CXcapHttpTransport( aConnManager );
+    CleanupStack::PushL( self );
+    self->ConstructL( aRootUri, aDigestCredentials );
+    CleanupStack::Pop();  //self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapHttpTransport::~CXcapHttpTransport
+// 
+// ----------------------------------------------------
+//
+CXcapHttpTransport::~CXcapHttpTransport()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapHttpTransport::~CXcapHttpTransport()" ) );
+    #endif
+    delete iRootUri;
+    delete iAuthManager;
+    iHttpSession.Close();
+    iSessionClosed = ETrue;
+    delete iProxyBuffer;
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  Destructor ends." ) );
+    #endif
+    delete iLogWriter;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpTransport::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapHttpTransport::ConstructL( const TDesC& aRootUri, const TXdmCredentials& aDigestCredentials )
+    {
+    #ifdef _DEBUG
+        iLogWriter = CXdmLogWriter::NewL( KTransportLogFile );
+        WriteToLog( _L8( "CXcapHttpTransport::ConstructL" ) );
+    #endif
+    SetRootUriL( aRootUri );
+    InitialiseSessionL();
+    iAuthManager = CXcapHttpAuthManager::NewL( iHttpSession, *this, aDigestCredentials );
+    } 
+
+// ---------------------------------------------------------
+// CXcapHttpTransport::SetRootUriL
+// 
+// ---------------------------------------------------------
+//
+EXPORT_C void CXcapHttpTransport::SetRootUriL( const TDesC& aRootUri )
+    {
+    delete iRootUri;
+    iRootUri = NULL;
+    iRootUri = HBufC8::NewL( aRootUri.Length() );
+    iRootUri->Des().Copy( aRootUri );
+    }
+         
+// ----------------------------------------------------
+// CXcapHttpTransport::GetL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXcapHttpReqGet* CXcapHttpTransport::GetL( const TDesC& aRequestUri )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapHttpTransport::GetRequestL()" ) );
+    #endif
+    if( !iSessionClosed )
+        return CXcapHttpReqGet::NewL( aRequestUri, iHttpSession, *iAuthManager, *this );
+    else
+        {
+        User::Leave( KErrNotReady );
+        return NULL;
+        }    
+    }
+
+// ----------------------------------------------------
+// CXcapHttpTransport::PutL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXcapHttpReqPut* CXcapHttpTransport::PutL( const TDesC& aRequestUri )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapHttpTransport::PutRequestL()" ) );
+    #endif
+    if( !iSessionClosed )
+        return CXcapHttpReqPut::NewL( aRequestUri, iHttpSession, *iAuthManager, *this );
+    else
+        {
+        User::Leave( KErrNotReady );
+        return NULL;
+        }    
+    }
+
+// ----------------------------------------------------
+// CXcapHttpTransport::Mkcol
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXcapHttpReqMkcol* CXcapHttpTransport::MkcolL( const TDesC& aRequestUri )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapHttpTransport::MkcolRequestL()" ) );
+    #endif
+    if( !iSessionClosed )
+        return CXcapHttpReqMkcol::NewL( aRequestUri, iHttpSession, *iAuthManager, *this );
+    else
+        {
+        User::Leave( KErrNotReady );
+        return NULL;
+        }    
+    }
+
+// ----------------------------------------------------
+// CXcapHttpTransport::Head
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXcapHttpReqHead* CXcapHttpTransport::HeadL( const TDesC& aRequestUri )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapHttpTransport::HeadRequestL()" ) );
+    #endif
+    if( !iSessionClosed )
+        return CXcapHttpReqHead::NewL( aRequestUri, iHttpSession, *iAuthManager, *this );
+    else
+        {
+        User::Leave( KErrNotReady );
+        return NULL;
+        }    
+    }
+
+// ----------------------------------------------------
+// CXcapHttpTransport::DeleteL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXcapHttpReqDelete* CXcapHttpTransport::DeleteL( const TDesC& aRequestUri )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapHttpTransport::DeleteRequestL()" ) );
+    #endif
+    if( !iSessionClosed )
+        return CXcapHttpReqDelete::NewL( aRequestUri, iHttpSession, *iAuthManager, *this );
+    else
+        {
+        User::Leave( KErrNotReady );
+        return NULL;
+        }    
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpTransport::RootUri
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TPtrC8 CXcapHttpTransport::RootUri()
+    {
+    return iRootUri != NULL ? iRootUri->Des() : TPtrC8();
+    }
+
+// ----------------------------------------------------
+// CXcapHttpTransport::InitialiseSessionL
+// 
+// ----------------------------------------------------
+//
+void CXcapHttpTransport::InitialiseSessionL()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapHttpTransport::InitialiseSessionL()" ) );
+    #endif
+    iHttpSession.OpenL();
+    RSocketServ& session = iConnManager.SocketSession();
+    RConnection& connection = iConnManager.Connection();
+    RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo();
+    RStringPool stringPool = iHttpSession.StringPool();
+    TInt conn = reinterpret_cast <TInt> ( &connection );
+    connInfo.SetPropertyL( stringPool.StringF( HTTP::EHttpSocketServ, RHTTPSession::GetTable() ),
+                           THTTPHdrVal( session.Handle() ) );
+    connInfo.SetPropertyL( stringPool.StringF( HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ),
+                           THTTPHdrVal( conn ) );
+    connInfo.SetPropertyL( stringPool.StringF( HTTP::EHTTPVersion, RHTTPSession::GetTable() ),
+                           THTTPHdrVal( stringPool.StringF( HTTP::EHttp11, RHTTPSession::GetTable() ) ) );
+    connInfo.SetPropertyL( stringPool.StringF( HTTP::ESecureDialog, RHTTPSession::GetTable() ),
+                           THTTPHdrVal( stringPool.StringF( HTTP::EDialogPrompt, RHTTPSession::GetTable() ) ) );
+    //CHttpDeflateFilter::InstallFilterL( iHttpSession );
+    iSessionClosed = EFalse;
+    #ifdef _DEBUG
+        WriteToLog( _L8( "InitialiseSessionL() ends." ) );
+    #endif
+    }
+
+#ifdef _DEBUG              
+// ----------------------------------------------------
+// CXcapHttpTransport::WriteToLog
+// Writes to the log, 8-bit version
+// ----------------------------------------------------
+//
+void CXcapHttpTransport::WriteToLog( TRefByValue<const TDesC8> aFmt,... ) const
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf8<KLogBufferMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    iLogWriter->WriteToLog( buf );
+    }
+       
+// ----------------------------------------------------
+// CXcapHttpTransport::WriteToLog
+// Writes to the log, 16-bit version
+// ----------------------------------------------------
+//
+void CXcapHttpTransport::WriteToLog( TRefByValue<const TDesC> aFmt,... ) const
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf<KLogBufferMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    iLogWriter->WriteToLog( buf );
+    }
+#endif  //_DEBUG
+      
+
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/BWINSCW/XcapOperationsU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/eabi/XcapOperationsU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/group/XcapOperations.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  XcapOperations.dll from XcapOperations.mmp
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                          xcapoperations.dll
+UID                             0x10009D8D 0x10207410
+CAPABILITY                      CAP_ECOM_PLUGIN
+VENDORID                        VID_DEFAULT
+TARGETTYPE                      PLUGIN
+
+SOURCEPATH                      ../src
+
+START RESOURCE                  10207410.rss
+
+TARGET                          xcapoperations.rsc                                                                
+
+END
+
+SOURCE                          XcapAddition.cpp
+SOURCE                          XcapDeletion.cpp
+SOURCE                          XcapRetrieval.cpp
+SOURCE                          XcapInsertion.cpp
+SOURCE                          XcapUriParser.cpp
+SOURCE                          XcapReplacement.cpp
+SOURCE                          XcapHttpOperation.cpp
+SOURCE                          XcapOperationFactory.cpp
+
+//Internal
+USERINCLUDE                     ../inc
+USERINCLUDE                     ../../inc
+USERINCLUDE                     ../../../inc
+USERINCLUDE                     ../../XcapCache/inc
+USERINCLUDE                     ../../XcapUtils/inc
+USERINCLUDE                     ../../XcapAppUsage/inc
+USERINCLUDE                     ../../XcapHttpTransport/inc
+
+//Common
+USERINCLUDE                     ../../../XdmXmlParser/inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE                   /epoc32/include/xml
+SYSTEMINCLUDE                   /epoc32/include/ecom
+SYSTEMINCLUDE                   ../../../../inc
+
+LIBRARY                         hal.lib
+LIBRARY                         ecom.lib
+LIBRARY                         efsrv.lib
+LIBRARY                         euser.lib
+
+LIBRARY                         inetprotutil.lib 
+
+LIBRARY                         flogger.lib
+LIBRARY                         xdmengine.lib
+LIBRARY                         xdmxmlparser.lib
+LIBRARY                         xcapprotocol.lib
+LIBRARY                         xcapappusage.lib
+LIBRARY                         xcapcacheclient.lib
+LIBRARY                         xcaphttptransport.lib
+
+#if defined( ARMCC )
+DEFFILE ../eabi/ 
+#elif defined ( WINSCW )
+deffile ../BWINSCW/ 
+#elif defined (WINS )
+deffile ../BWINS/ 
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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:  XcapOperations bld.inf
+*
+*/
+
+
+
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+XcapOperations.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/inc/XcapAddition.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXcapAddition
+*
+*/
+
+
+
+
+#ifndef __XCAPADDITION__
+#define __XCAPADDITION__
+
+#include <e32base.h>
+#include "XcapHttpOperation.h"
+
+//FORWARD DECLARATIONS
+class CXcapHttpReqPut;
+class CXcapDocumentNode;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapAddition ) : public CXcapHttpOperation
+    {
+    public:
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CXcapAddition* NewL( CXcapDocument& aParentDoc,
+                                    CXcapDocumentNode* aDocumentSubset,
+                                    CXcapOperationFactory& iOperationFactory );
+        
+        /**
+        * Handle a successful operation
+        */      
+        virtual void OperationCompleteL();
+        
+        /**
+        * Handle a failed operation
+        */      
+        virtual void OperationFailedL();
+        
+        /**
+        * Destructor.
+        */      
+        virtual TBool Result() const;
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapAddition();
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CXcapAddition( CXcapDocument& aParentDoc,
+                       CXcapDocumentNode* aDocumentSubset,
+                       CXcapOperationFactory& iOperationFactory );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ExecuteL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        TXdmOperationType DetermineOperationType();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */  
+        void UpdatePartialToCacheL( RXcapCache* aCache, const TDesC8& aNewData );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */    
+        virtual TInt FormatModRequestL( const CXdmDocumentNode* aDocumentNode );
+
+    private:  //Data
+
+        TXdmOperationType               iOperationType;
+    };
+
+#endif      //__XCAPPARTIALADDITION__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/inc/XcapDeletion.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,110 @@
+/*
+* 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:   CXcapDeletion
+*
+*/
+
+
+
+
+#ifndef __XCAPDELETION__
+#define __XCAPDELETION__
+
+#include <e32base.h>
+#include "XcapHttpOperation.h"
+
+//FORWARD DECLARATIONS
+class CXcapDocumentNode;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapDeletion ) : public CXcapHttpOperation
+    {
+    public:
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CXcapDeletion* NewL( CXcapDocument& aParentDoc,
+                                    CXcapDocumentNode* aDocumentSubset,
+                                    CXcapOperationFactory& iOperationFactory );
+        
+        /**
+        * Handle a successful operation
+        */      
+        virtual void OperationCompleteL();
+        
+        /**
+        * Handle a failed operation
+        */      
+        virtual void OperationFailedL();
+        
+        /**
+        * Destructor.
+        */      
+        virtual TBool Result() const;
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapDeletion();
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CXcapDeletion( CXcapDocument& aParentDoc,
+                       CXcapDocumentNode* aDocumentSubset,
+                       CXcapOperationFactory& iOperationFactory );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ExecuteL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void HandleDocDeletion();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void HandlePartialDeletion();
+
+    private:  //Data
+    
+        TXdmOperationType               iOperationType;
+    };
+
+#endif      //__XCAPDELETION__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/inc/XcapHttpOperation.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,264 @@
+/*
+* 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:   CXcapHttpOperation
+*
+*/
+
+
+
+
+#ifndef __XCAPHTTPOPERATION__
+#define __XCAPHTTPOPERATION__
+
+#include <e32base.h>
+#include "XdmOperation.h"
+#include "XcapOperationFactory.h"
+#include "XcapHttpRequestTimerCallback.h"
+
+//The default timout for HTTP requests in seconds
+const TInt KDefaultHttpRequestTimeout           = 30;
+
+//Set, if document should be fetched from cache when processing a doc subset
+const TInt KFetchMasterFromCache                             = KXdmOption1;
+
+//Set, if rules concerning document subsets should be applied when processing responses
+const TInt KDocumentSubset                                   = KXdmOption2;
+
+//Set, if the document an operation targets should not be cached (a directory document, for example)
+const TInt KNoCache                                          = KXdmOption3;
+
+//Set, if EARLY-IMS is in use => add the public ID in X-3GPP-Intended-Identity header
+const TInt KUseIntendedIdentity                              = KXdmOption4;
+
+//FORWARD DECLARATION
+class RXcapCache;
+class CXdmDocument;
+class CXcapDocument;
+class CXdmXmlParser;
+class CXcapUriParser;
+class CXcapHttpRequest;
+class CXdmDocumentNode;
+class CXcapDocumentNode;
+class CXcapHttpTransport;
+
+//Override application usage validation
+//Must ONLY be used for testing, comment out before release
+//#define                           __OVERRIDE_VALIDATION__
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapHttpOperation ) : public CActive,
+                                          public MXdmOperation
+                           
+    {
+    public:
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static void EscapeLC( CXdmDocumentNode& aRootNode );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static HBufC8* EscapeLC( const TDesC8& aDescriptor );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static HBufC8* Escape2LC( const TDesC& aDescriptor );
+        
+    public:
+        
+        /**
+        * Destructor.
+        */      
+        void ExecuteL( TRequestStatus& aStatus, TUint aOptions );
+
+        /**
+        * Destructor.
+        */      
+        TInt Result() const;
+        
+        /**
+        * Destructor.
+        */      
+        const TXdmCompletionData& CompletionData() const;
+        
+        /**
+        * Destructor.
+        */    
+        TBool IsCompleted() const;
+        
+        /**
+        * Set this operation to completed state.
+        */      
+        void Destroy();
+        
+        /**
+        * Set this operation to completed state.
+        */      
+        virtual CXdmDocumentNode* TargetNode() const;
+        
+        /**
+        * Destructor.
+        */    
+        CXcapHttpRequest* HttpRequest() const;
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapHttpOperation();
+
+    protected:  //Methods
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CXcapHttpOperation( const CXdmDocument& aTargetDoc,
+                            CXcapDocumentNode* aDocumentSubset,
+                            CXcapOperationFactory& aOperationFactory );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void BaseConstructL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        TPtrC8 Descriptor( HBufC8* aBuffer );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        TInt ReinterpretStatus( const TInt aHttpStatus ) const;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */ 
+        CXcapHttpTransport& Transport() const;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        virtual void OperationCompleteL() = 0;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        virtual void OperationFailedL() = 0;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        virtual void ExecuteL() = 0;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        virtual void ExecuteL( CXcapHttpRequest* aHttpRequest,
+                               CXdmDocumentNode* aDocumentNode );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */    
+        virtual TInt FormatModRequestL( const CXdmDocumentNode* aDocumentNode );
+        
+    private:
+    
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void RunL();
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void DoCancel();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */    
+        TBool StartOperationL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void CancelOperation();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void HandleTimerEventL();
+
+    protected:
+        
+        TInt                                 iResult;
+        TInt                                 iCurrentIndex;
+        TBool                                iCompleted;
+        TBool                                iPartial;
+        TUint                                iOptionFlags;
+        CXdmXmlParser*                       iXmlParser;
+        TXdmCompletionData                   iFailureData;
+        TXdmCompletionData*                  iRequestData;
+        TRequestStatus*                      iClientStatus;
+        CXcapUriParser*                      iUriParser;
+        CXcapHttpRequest*                    iActiveRequest;
+        CXcapDocumentNode*                   iDocumentSubset;
+        CXcapDocument&                       iTargetDoc;
+        CXcapOperationFactory&               iOperationFactory;
+        RPointerArray<CXcapHttpRequest>      iRequestQueue;
+
+    private:  //Data
+    };
+
+#endif      //__XCAPHTTPOPERATION__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/inc/XcapInsertion.h	Wed Sep 01 12:23:14 2010 +0100
@@ -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:   CXcapInsertion
+*
+*/
+
+
+
+
+#ifndef __XCAPINSERTION__
+#define __XCAPINSERTION__
+
+#include <e32base.h>
+#include "XcapHttpOperation.h"
+
+//FORWARD DECLARATIONS
+class CXcapHttpReqPut;
+class CXcapDocumentNode;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapInsertion ) : public CXcapHttpOperation
+    {
+    public:
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CXcapInsertion* NewL( CXcapDocument& aParentDoc,
+                                     CXcapDocumentNode* aDocumentExtents,
+                                     CXcapOperationFactory& iOperationFactory );
+        
+        /**
+        * Handle a successful operation
+        */      
+        virtual void OperationCompleteL();
+        
+        /**
+        * Handle a failed operation
+        */      
+        virtual void OperationFailedL();
+
+        /**
+        * Destructor.
+        */      
+        virtual TBool Result() const;
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapInsertion();
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CXcapInsertion( CXcapDocument& aParentDoc,
+                        CXcapDocumentNode* aDocumentSubset,
+                        CXcapOperationFactory& iOperationFactory );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ExecuteL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        virtual TInt FormatModRequestL( const CXdmDocumentNode* aDocumentNode );
+
+    private:  //Data
+
+        TXdmOperationType               iOperationType;
+    };
+
+#endif      //__XCAPINSERTION__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/inc/XcapOperationFactory.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,122 @@
+/*
+* 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:  CXcapOperationFactory 
+*
+*/
+
+
+
+
+#ifndef __XCAPOPERATIONFACTORY__
+#define __XCAPOPERATIONFACTORY__
+
+#include <e32base.h>
+#include "XdmOperationFactory.h"
+
+_LIT( KOperationsLogFile,                   "XcapOperations" );
+const TInt KOpLogBufferMaxSize              = 2000;
+
+//FORWARD DECLARATION
+class CXdmDocument;
+class CXdmDocumentNode;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapOperationFactory ) : public CXdmOperationFactory
+    {
+    public:
+        
+        /**
+        * Two-phased constructor.
+        * @param CXdmProtocolInfo Protocol info
+        * @return CXdmProtocol
+        */
+        static CXcapOperationFactory* NewL();
+        
+        /**
+        * Destructor. A simple wrapper to the C++ destructor.
+        *
+        */
+	    virtual ~CXcapOperationFactory();
+	
+	public:
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * whole documents
+        */
+        MXdmOperation* FetchL( CXdmDocument& aTargetDocument,
+                               CXdmDocumentNode* aTargetNode = NULL ) const;
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        MXdmOperation* InsertL( CXdmDocument& aTargetDocument,
+                                CXdmDocumentNode* aTargetNode ) const;
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        MXdmOperation* ReplaceL( CXdmDocument& aOldDocument, 
+                                 CXdmDocumentNode* aNewNode,
+                                 CXdmDocumentNode* aOldNode ) const;
+
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        MXdmOperation* AppendL( CXdmDocument& aTargetDocument,
+                                CXdmDocumentNode* aTargetNode ) const;
+
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        MXdmOperation* DeletionL( CXdmDocument& aTargetDocument,
+                                  CXdmDocumentNode* aTargetNode ) const;
+    
+    public:
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        void WriteToLog( TRefByValue<const TDesC8> aFmt,... ) const;
+    
+    private:
+        
+        /**
+        * C++ constructor
+        * @return CImpsTcpCirWatcher
+        */      
+        void ConstructL();
+        
+        /**
+        * Write here something meaningful
+        */  
+        void WriteTraceLog( const TDesC8& aLogDescriptor );
+        
+        /**
+        * C++ constructor
+        * @return CImpsTcpCirWatcher
+        */      
+        CXcapOperationFactory();
+
+    private:  //Data
+    
+        CXdmLogWriter*                        iLogWriter;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/inc/XcapReplacement.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,113 @@
+/*
+* 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:   CXcapReplacement
+*
+*/
+
+
+
+
+#ifndef __XCAPREPLACEMENT__
+#define __XCAPREPLACEMENT__
+
+#include <e32base.h>
+#include "XcapHttpOperation.h"
+
+//FORWARD DECLARATIONS
+
+class CXcapHttpReqPut;
+class CXcapDocumentNode;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapReplacement ) : public CXcapHttpOperation
+    {
+    public:
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CXcapReplacement* NewL( CXcapDocument& aParentDoc,
+                                       CXcapDocumentNode* aOldNode,
+                                       CXcapDocumentNode* aNewNode,
+                                       CXcapOperationFactory& iOperationFactory );
+        
+        /**
+        * Handle a successful operation
+        */      
+        virtual void OperationCompleteL();
+        
+        /**
+        * Handle a failed operation
+        */      
+        virtual void OperationFailedL();
+        
+        /**
+        * Destructor.
+        */      
+        virtual TBool Result() const;
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapReplacement();
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CXcapReplacement( CXcapDocument& aParentDoc,
+                          CXcapDocumentNode* aOldNode,
+                          CXcapDocumentNode* aNewNode,
+                          CXcapOperationFactory& iOperationFactory );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL();
+        
+        /**
+        * Destructor.
+        */      
+        void ExecuteL();
+        
+        /**
+        * Destructor.
+        */      
+        virtual TInt FormatModRequestL( const CXcapDocumentNode* aDocumentNode );
+
+    private:  //Data
+    
+        enum TXcapReplacementState
+            {
+            EHttpIdle = 0,
+            EHttpDeleting,
+            EHttpPutting
+            };
+
+        CXcapDocumentNode*              iNewNode;
+        TXdmOperationType               iOperationType;
+        TXcapReplacementState           iOperationPhase;
+        
+    };
+
+#endif      //__XCAPREPLACEMENT__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/inc/XcapRetrieval.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,112 @@
+/*
+* 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:   CXcapRetrieval
+*
+*/
+
+
+
+
+#ifndef __XCAPRETRIEVAL__
+#define __XCAPRETRIEVAL__
+
+#include <e32base.h>
+#include "CommonDefines.h"
+#include "XcapHttpOperation.h"
+
+class CXcapDocumentNode;
+   
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapRetrieval ) : public CXcapHttpOperation
+    {
+    public:
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CXcapRetrieval* NewL( CXcapDocument& aParentDoc,
+                                     CXcapDocumentNode* aTargetNode,
+                                     CXcapOperationFactory& iOperationFactory );
+        
+        /**
+        * Handle a successful operation
+        */      
+        virtual void OperationCompleteL();
+        
+        /**
+        * Handle a failed operation
+        */      
+        virtual void OperationFailedL();
+        
+        /**
+        * Destructor.
+        */      
+        virtual TInt Result() const;
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapRetrieval();
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CXcapRetrieval( CXcapDocument& aParentDoc,
+                        CXcapDocumentNode* aTargetNode,
+                        CXcapOperationFactory& iOperationFactory );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ExecuteL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void HandleCacheOperationL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void HandleNetworkOperationL();
+
+    private:  //Data
+        
+        TBool                                iCacheOperation;
+        TCacheEntryInfo                      iCacheEntryInfo;
+        TXdmOperationType                    iOperationType;
+    };
+
+#endif      //__XCAPRETRIEVAL__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/inc/XcapUriParser.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,187 @@
+/*
+* 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:   CXcapUriParser
+*
+*/
+
+
+
+
+#ifndef __XCAPURIPARSER__
+#define __XCAPURIPARSER__
+
+#include <e32base.h>
+#include "XcapDocumentNode.h"
+#include "XcapUriInterface.h"
+
+//Constants
+_LIT8( KXcapUriColon,                           ":" );
+_LIT8( KXcapUriQMark,                           "?" );
+_LIT8( KXcapUriXmlns,                           "xmlns(" );
+_LIT8( KXcapUriEquals,                          "=\"" );
+_LIT8( KXcapUriQuote,                           "\"" );
+_LIT8( KXcapParenthClose,                       ")" );
+
+class CXdmDocument;
+class CXdmDocumentNode;
+class CXcapOperationFactory;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS ( CXcapUriParser ) : public CBase, public MXcapUriInterface
+    {
+    public:
+
+        /**
+        * Destructor.
+        */      
+        static CXcapUriParser* NewL( CXdmDocument& aTargetDoc,
+                                     CXcapOperationFactory& aOperationFactory );
+        
+        /**
+        * Destructor.
+        */      
+        void SetDocumentSubset( const CXdmDocumentNode* aDocumentSubset );                          
+        
+        /**
+        * Destructor.
+        */      
+        void ParseL( const TPtrC8& aHttpUri );
+        
+        /**
+        * Destructor.
+        */      
+        TPtrC8 DesC8() const;
+        
+        /**
+        * Destructor.
+        */   
+        TXdmElementType NodeType() const;
+        
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapUriParser();
+    
+    private:  //From MXcapUriInterface
+    
+        /**
+        * Add new namespace mapping
+        * @param TDesC8& Namespace URI
+        * @param TDesC8& Namespace prefix
+        * @return void
+        */      
+        void AddNamespaceMappingL( const TDesC8& aUri, const TDesC8& aPrefix ); 
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CXcapUriParser( CXdmDocument& aTargetDoc,
+                        CXcapOperationFactory& aOperationFactory );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXcapDocOperation*
+        */   
+        TInt CreateBasicNodeUriL( HBufC8* aNodePath );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXcapDocOperation*
+        */   
+        HBufC8* DocSubsetPathL();
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXcapDocOperation*
+        */   
+        void AppendPredicatesL( TInt& aPosition,
+                                CBufBase* aBuffer,
+                                const CXdmDocumentNode* aPathElement );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXcapDocOperation*
+        */   
+        HBufC8* FormatOnePathElementLC( const CXdmDocumentNode* aPathElement );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXcapDocOperation*
+        */   
+        void FormatAttributeUriL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXcapDocOperation*
+        */   
+        void FormatNodeUriL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXcapDocOperation*
+        */   
+        void AppendNamespaceMappingsL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXcapDocOperation*
+        */     
+        void FinaliseL();
+        
+    #ifdef _DEBUG
+    
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXcapDocOperation*
+        */   
+        void DumpUriL( HBufC8* aNodePath ); 
+    
+    #endif
+
+    private:  //Data
+        
+        TInt                                 iBufferPosition;
+        TPtrC8*                              iHttpUri;
+        HBufC8*                              iCompleteUri;
+        CBufFlat*                            iUriBuffer;
+        CXdmDocument&                        iTargetDoc;
+        TXdmElementType                      iNodeType;
+        CXdmDocumentNode*                    iDocumentSubset;
+        CXcapOperationFactory&               iOperationFactory;
+        RPointerArray<CXdmNamespace>         iNamespaceMappings;
+    };
+
+#endif      //__XCAPURIPARSER__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/src/10207410.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  XdmProtocolInfo
+*
+*/
+
+
+// 10207410.RSS
+//
+#include "registryinfo.rh"
+
+//Declares the interface implementations provided
+RESOURCE REGISTRY_INFO XdmProtocolInfo
+	{
+	dll_uid = 0x10207410;
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x10207425;
+			implementations = 
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10207426;
+					version_no = 1;
+					display_name = "XCAP Operation API||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/src/XcapAddition.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,286 @@
+/*
+* 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:   CXcapAddition
+*
+*/
+
+
+
+
+// INCLUDES
+#include "XcapCache.h"
+#include "XcapAppUsage.h"
+#include "XcapProtocol.h"
+#include "XcapDocument.h"
+#include "XcapAddition.h"
+#include "XdmXmlParser.h"
+#include "XcapUriParser.h"
+#include "CommonDefines.h"
+#include "XcapHttpReqPut.h"
+#include "XcapHttpOperation.h"
+#include "XcapHttpTransport.h"
+#include "XcapOperationFactory.h"
+       
+// ---------------------------------------------------------
+// CXcapAddition::CXcapAddition
+//
+// ---------------------------------------------------------
+//
+CXcapAddition::CXcapAddition( CXcapDocument& aParentDoc,
+                              CXcapDocumentNode* aDocumentSubset,
+                              CXcapOperationFactory& aOperationFactory ) :
+                              CXcapHttpOperation( aParentDoc, aDocumentSubset, aOperationFactory ),
+                              iOperationType( aDocumentSubset == NULL ?
+                              EXdmDocument : EXdmPartialDocument )
+                                                      
+    {
+    }
+
+// ---------------------------------------------------------
+// CXcapAddition::NewL
+//
+// ---------------------------------------------------------
+//
+CXcapAddition* CXcapAddition::NewL( CXcapDocument& aParentDoc,
+                                    CXcapDocumentNode* aDocumentSubset,
+                                    CXcapOperationFactory& aOperationFactory )
+    {
+    CXcapAddition* self = new ( ELeave ) CXcapAddition( aParentDoc, aDocumentSubset, aOperationFactory );
+    CleanupStack::PushL( self );
+    self->BaseConstructL();
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CXcapAddition::ConstructL
+//
+// ---------------------------------------------------------
+//
+void CXcapAddition::ConstructL()
+    {
+    CXcapHttpReqPut* request = Transport().PutL( iTargetDoc.Name() );
+    CleanupStack::PushL( request );
+    User::LeaveIfError( iRequestQueue.Append( request ) );
+    request->SetExpiryTimeL( NULL, KDefaultHttpRequestTimeout * 1000000 );
+    CleanupStack::Pop();  //request
+    //If they point to the same node, we're dealing with a complete document
+    if( iDocumentSubset != NULL && iTargetDoc.DocumentRoot() != iDocumentSubset )
+        iUriParser->SetDocumentSubset( iDocumentSubset );
+    }
+    
+// ---------------------------------------------------------
+// CXcapAddition::FormatModRequestL
+//
+// ---------------------------------------------------------
+//
+TInt CXcapAddition::FormatModRequestL( const CXdmDocumentNode* aDocumentNode )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapAddition::FormatModRequestL()" ) );
+        iOperationFactory.WriteToLog( _L8( "  Operation type:  %d" ), iOperationType );
+        iOperationFactory.WriteToLog( _L8( "  Document subset: %x" ), iDocumentSubset );
+    #endif
+    TInt validation = CXcapHttpOperation::FormatModRequestL( aDocumentNode );
+    if( validation == KErrNone )
+        {
+        //Then set the properties particular to this type of request
+        iOperationType = DetermineOperationType();
+        if( iOperationType == EXdmDocument )
+            iActiveRequest->SetHeaderL( KHttpHeaderContentType, iTargetDoc.ApplicationUsage().ContentType() );
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( " AppUsage reported the following error: %d" ), validation );
+        #endif
+        }
+    return validation;
+    }
+
+// ---------------------------------------------------------
+// CXcapAddition::DetermineOperationType
+//
+// ---------------------------------------------------------
+//
+TXdmOperationType CXcapAddition::DetermineOperationType()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapAddition::DetermineDocType()" ) );
+        iOperationFactory.WriteToLog( _L8( "  Operation type:  %d" ), iOperationType );
+        iOperationFactory.WriteToLog( _L8( "  Document subset: %x" ), iDocumentSubset );
+        iOperationFactory.WriteToLog( _L8( "  Document root:   %x" ), iTargetDoc.DocumentRoot() ); 
+    #endif
+    return iOperationType == EXdmDocument || ( EXdmPartialDocument &&
+                             iDocumentSubset == iTargetDoc.DocumentRoot() ) ?
+                             EXdmDocument : EXdmPartialDocument;
+    }
+      
+// ---------------------------------------------------------
+// CXcapAddition::ExecuteL
+//
+// ---------------------------------------------------------
+//
+void CXcapAddition::ExecuteL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapAddition::ExecuteL()" ) );  
+    #endif
+    CXcapHttpOperation::ExecuteL( iActiveRequest, iDocumentSubset );
+    }
+        
+// ---------------------------------------------------------
+// CXcapAddition::OperationCompleteL
+//
+// ---------------------------------------------------------
+//
+void CXcapAddition::OperationCompleteL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapAddition::OperationCompleteL()" ) );  
+    #endif
+    TPtrC8 root = Transport().RootUri();
+    iRequestData = iActiveRequest->ResponseData();
+    TPtrC name = iTargetDoc.Name();
+    switch( iRequestData->iHttpStatus )
+        {
+        case 200:           //Replaced, the document was already there
+        case 201:           //"Created" -> Put operation was successful
+            {
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Status %d" ), iRequestData->iHttpStatus );  
+            #endif
+            iResult = KErrNone;
+            TPtrC8 eTag = Descriptor( iRequestData->iETag );
+            iTargetDoc.SetETag( eTag );
+            RXcapCache* cache = iTargetDoc.Protocol().Cache();
+            if( cache != NULL )
+                {
+                CXcapHttpContSupplier* request = ( CXcapHttpContSupplier* )iActiveRequest;
+                TPtrC8 payload = request->RequestBody();
+                iOperationType == EXdmDocument ? cache->Store( eTag, name, root, payload ) :
+                                                 UpdatePartialToCacheL( cache, payload );
+                }
+            iCompleted = ETrue;
+            }
+            break;
+        default:
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Default case - Status: %d" ),
+                                                   iRequestData->iHttpStatus ); 
+            #endif
+            TInt status = iRequestData->iHttpStatus;
+            iResult = ReinterpretStatus( status );
+            iCompleted = ETrue;
+            break;
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapAddition::UpdatePartialToCacheL
+//
+// ---------------------------------------------------------
+//
+void CXcapAddition::UpdatePartialToCacheL( RXcapCache* aCache, const TDesC8& aNewData )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapAddition::UpdatePartialToCacheL()" ) );  
+    #endif
+    HBufC8* newData = NULL;
+    TPtrC name = iTargetDoc.Name();
+    TPtrC8 root = Transport().RootUri();
+    if( iOptionFlags & KFetchMasterFromCache )
+        {
+        TInt length = iTargetDoc.DataLength();
+        //Do nothing, if the document is not in cache
+        if( length > 0 )
+            {
+            HBufC8* data = HBufC8::NewLC( length );
+            TPtr8 desc( data->Des() );
+            aCache->FetchDocumentContent( desc, name, root );
+            CXcapDocument* copy = iTargetDoc.TempCopyL();
+            CleanupStack::PushL( copy );
+            iXmlParser->ParseDocumentL( copy, desc );
+            RPointerArray<CXdmDocumentNode> array;
+            CleanupClosePushL( array );
+            copy->Find( *iDocumentSubset, array );
+            //If the element the subset points to is not present
+            //in the original document, the new data must be
+            //appended to the the subset element parent, instead.
+            CXdmDocumentNode* node = array.Count() > 0 ?
+                iDocumentSubset : iDocumentSubset->Parent();
+            newData = iXmlParser->FormatToXmlLC( aNewData, copy, node );
+            CleanupStack::Pop();  //newData
+            CleanupStack::PopAndDestroy( 3 );  //array, tempCopy, data
+            CleanupStack::PushL( newData );
+            }           
+        }
+    else
+        {
+        CXdmDocumentNode* root = iTargetDoc.DocumentRoot();
+        newData = iXmlParser->FormatToXmlLC( ETrue, &iTargetDoc, root );
+        }
+    if( newData )
+        {
+        aCache->Store( iTargetDoc.ETag(), name, root, newData->Des() );
+        CleanupStack::PopAndDestroy();  //newData
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapAddition::OperationFailedL
+//
+// ---------------------------------------------------------
+//
+void CXcapAddition::OperationFailedL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapRetrieval::OperationFailedL() - Error: %d" ),
+                                           iStatus.Int() );  
+    #endif
+    if( iStatus.Int() >= KErrNone )
+        {
+        TInt status = iActiveRequest->ResponseData()->iHttpStatus;
+        TInt completion = iActiveRequest->ResponseData()->iCompletion;
+        iResult = status < KErrNone || completion < KErrNone ? status : ReinterpretStatus( status );
+        }
+    else iResult = iStatus.Int();
+    iCompleted = ETrue;
+    }
+
+// ---------------------------------------------------------
+// CXcapAddition::Result
+//
+// ---------------------------------------------------------
+//
+TBool CXcapAddition::Result() const
+    {
+    return ETrue;
+    }
+
+// ---------------------------------------------------------
+// CXcapAddition::~CXcapAddition
+//
+// ---------------------------------------------------------
+//
+CXcapAddition::~CXcapAddition()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapAddition::~CXcapAddition()" ) );  
+    #endif
+    }
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/src/XcapDeletion.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,248 @@
+/*
+* 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:   CXcapDeletion
+*
+*/
+
+
+
+
+// INCLUDES
+#include "XcapCache.h"
+#include "XcapProtocol.h"
+#include "XcapDeletion.h"
+#include "XcapAppUsage.h"
+#include "XcapDocument.h"
+#include "XcapUriParser.h"
+#include "XdmXmlParser.h"
+#include "XcapDocumentNode.h"
+#include "XcapHttpTransport.h"
+#include "XcapHttpOperation.h"
+#include "XcapHttpReqDelete.h"
+#include "XcapOperationFactory.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CXcapDeletion::CXcapDeletion
+//
+// ---------------------------------------------------------
+//
+CXcapDeletion::CXcapDeletion( CXcapDocument& aParentDoc,
+                              CXcapDocumentNode* aDocumentSubset,
+                              CXcapOperationFactory& aOperationFactory ) :
+                              CXcapHttpOperation( aParentDoc, aDocumentSubset, aOperationFactory ),
+                              iOperationType( iDocumentSubset == NULL ?
+                              EXdmDocument : EXdmPartialDocument )                                 
+    {
+    }
+
+// ---------------------------------------------------------
+// CXcapDeletion::NewL
+//
+// ---------------------------------------------------------
+//
+CXcapDeletion* CXcapDeletion::NewL( CXcapDocument& aParentDoc,
+                                    CXcapDocumentNode* aDocumentSubset,
+                                    CXcapOperationFactory& aOperationFactory )
+    {
+    CXcapDeletion* self = new ( ELeave ) CXcapDeletion( aParentDoc, aDocumentSubset, aOperationFactory );
+    CleanupStack::PushL( self );
+    self->BaseConstructL();
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CXcapDeletion::ConstructL
+//
+// ---------------------------------------------------------
+//
+void CXcapDeletion::ConstructL()
+    {
+    CXcapHttpReqDelete* request = Transport().DeleteL( iTargetDoc.Name() );
+    CleanupStack::PushL( request );
+    User::LeaveIfError( iRequestQueue.Append( request ) );
+    request->SetExpiryTimeL( NULL, KDefaultHttpRequestTimeout * 1000000 );
+    CleanupStack::Pop();  //request
+    if( iOperationType != EXdmDocument && iDocumentSubset != NULL )
+    	{
+    	iUriParser->SetDocumentSubset( iDocumentSubset );
+    	//Add namespace mappings
+    	User::LeaveIfError( iTargetDoc.ApplicationUsage().Validate(
+                        	*iDocumentSubset, iUriParser, ETrue ) );
+    	}
+    }
+    
+// ---------------------------------------------------------
+// CXcapDeletion::ExecuteL
+//
+// ---------------------------------------------------------
+//
+void CXcapDeletion::ExecuteL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapDeletion::ExecuteL()" ) );  
+    #endif
+    TPtrC8 eTag = iTargetDoc.ETag();
+    if( eTag.Length() > 0 )
+        iActiveRequest->SetHeaderL( KHttpHeaderIfMatch, eTag );
+    TRAPD( error, iUriParser->ParseL( iActiveRequest->RequestUriL() ) );
+    if( error == KErrNone )
+        {
+        TPtrC8 uri = iUriParser->DesC8();
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( " New URI: %S" ), &uri );  
+        #endif
+        HBufC8* escape = CXcapHttpOperation::EscapeLC( uri );
+        iActiveRequest->UpdateRequestUriL( escape->Des() );
+        CleanupStack::PopAndDestroy();  //escape
+        } 
+    }
+        
+// ---------------------------------------------------------
+// CXcapDeletion::OperationCompleteL
+//
+// ---------------------------------------------------------
+//
+void CXcapDeletion::OperationCompleteL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapDeletion::OperationCompleteL()" ) );  
+    #endif
+    switch( iRequestData->iHttpStatus )
+        {
+        case 200:           //Document was deleted
+            {
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Status 200 - Document deleted" ) );  
+            #endif
+            iOperationType == EXdmDocument ?
+                              HandleDocDeletion() :
+                              HandlePartialDeletion();
+            iCompleted = ETrue;
+            }
+            break;
+        case 404:           //Document was not found
+            {
+            #ifdef _DEBUG   
+                iOperationFactory.WriteToLog( _L8( " Status 404 - Document not found" ) );  
+            #endif
+            iCompleted = ETrue;
+            iResult = KErrNotFound;
+            }
+            break;
+        default:
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Default case - Status: %d" ),
+                                                   iRequestData->iHttpStatus );  
+            #endif
+            iCompleted = ETrue;
+            break;
+        }
+    iResult = ReinterpretStatus( iRequestData->iHttpStatus );
+    }
+
+// ---------------------------------------------------------
+// CXcapDeletion::HandleDocDeletion
+//
+// ---------------------------------------------------------
+//
+void CXcapDeletion::HandleDocDeletion()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapDeletion::HandleDocDeletion()" ) );  
+    #endif
+    TPtrC name = iTargetDoc.Name();
+    TPtrC8 root = Transport().RootUri();
+    RXcapCache* cache = iTargetDoc.Protocol().Cache();
+    if( cache != NULL )
+        {
+        TInt error = cache->Delete( name, root );
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( "  Document deleted from the cache" ) );  
+        #endif
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapDeletion::HandlePartialDeletion
+//
+// ---------------------------------------------------------
+//
+void CXcapDeletion::HandlePartialDeletion()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapDeletion::HandlePartialDeletion()" ) );  
+    #endif
+    TPtrC name = iTargetDoc.Name();
+    TPtrC8 root = Transport().RootUri();
+    iTargetDoc.RemoveFromModelL( iDocumentSubset );
+    TPtrC8 eTag = Descriptor( iRequestData->iETag );
+    RXcapCache* cache = iTargetDoc.Protocol().Cache();
+    if( cache != NULL )
+        {
+        HBufC8* newDoc = iXmlParser->FormatToXmlLC( ETrue, &iTargetDoc, iTargetDoc.DocumentRoot() );
+        cache->Store( eTag, name, root, newDoc->Des() );
+        CleanupStack::PopAndDestroy();  //newDoc
+        }
+    iTargetDoc.SetETag( eTag );
+    }
+      
+// ---------------------------------------------------------
+// CXcapDeletion::OperationFailedL
+//
+// ---------------------------------------------------------
+//
+void CXcapDeletion::OperationFailedL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapDeletion::OperationFailedL() - Error: %d" ),
+                                        iStatus.Int() );  
+    #endif
+    if( iStatus.Int() >= KErrNone )
+        {
+        TInt status = iActiveRequest->ResponseData()->iHttpStatus;
+        TInt completion = iActiveRequest->ResponseData()->iCompletion;
+        iResult = status < KErrNone || completion < KErrNone ? status : ReinterpretStatus( status );
+        }
+    else iResult = iStatus.Int();
+    iCompleted = ETrue;
+    }
+    
+// ---------------------------------------------------------
+// CXcapDeletion::Result
+//
+// ---------------------------------------------------------
+//
+TBool CXcapDeletion::Result() const
+    {
+    return ETrue;
+    }
+
+// ---------------------------------------------------------
+// CXcapDeletion::~CXcapDeletion
+//
+// ---------------------------------------------------------
+//
+CXcapDeletion::~CXcapDeletion()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapDeletion::~CXcapDeletion()" ) );  
+    #endif
+    }
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/src/XcapHttpOperation.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,547 @@
+/*
+* 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:   CXcapHttpOperation
+*
+*/
+
+
+
+#include <XdmErrors.h>
+#include <escapeutils.h>
+#include "XcapDocument.h"
+#include "XcapProtocol.h"
+#include "XcapAppUsage.h"
+#include "XcapUriParser.h"
+#include "XdmXmlParser.h"
+#include "XcapHttpRequest.h"
+#include "XdmNodeAttribute.h"
+#include "XcapEngineDefines.h"
+#include "XcapHttpOperation.h"
+#include "XcapHttpContSupplier.h"
+#include "XcapOperationFactory.h"
+
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CXcapHttpOperation::CXcapHttpOperation( const CXdmDocument& aTargetDoc,
+                                        CXcapDocumentNode* aDocumentSubset,
+                                        CXcapOperationFactory& aOperationFactory ) :
+                                        CActive( EPriorityStandard ),
+                                        iDocumentSubset( aDocumentSubset ),
+                                        iTargetDoc( ( CXcapDocument& )aTargetDoc ),
+                                        iOperationFactory( aOperationFactory ) 
+                                                                                
+    {
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpOperation::BaseConstructL
+//
+// ---------------------------------------------------------
+//
+void CXcapHttpOperation::BaseConstructL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "-> CXcapHttpOperation::BaseConstructL" ) ); 
+    #endif
+    iXmlParser = &iTargetDoc.Protocol().Parser();
+    iUriParser = CXcapUriParser::NewL( iTargetDoc, iOperationFactory );
+    #ifdef _DEBUG
+        TPtrC8 contType( iTargetDoc.ApplicationUsage().ContentType() );
+        iOperationFactory.WriteToLog( _L8( " Content-Type: %S" ), &contType ); 
+    #endif
+    CActiveScheduler::Add( this );
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "<- CXcapHttpOperation::BaseConstructL" ) ); 
+    #endif
+    }
+
+// ---------------------------------------------------------
+// Destructor
+//
+// ---------------------------------------------------------
+//
+CXcapHttpOperation::~CXcapHttpOperation()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapHttpOperation::~CXcapHttpOperation()" ) );  
+    #endif
+    delete iUriParser;
+    iRequestQueue.ResetAndDestroy();
+    }
+
+// ---------------------------------------------------------
+// CXcapOperationBase::IsCompleted
+//
+// ---------------------------------------------------------
+//
+TBool CXcapHttpOperation::IsCompleted() const
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapOperationBase::IsCompleted()" ) );  
+    #endif
+    return iCompleted;
+    }
+    
+// ---------------------------------------------------------
+// CXcapOperationBase::CompletionData
+//
+// ---------------------------------------------------------
+//
+const TXdmCompletionData& CXcapHttpOperation::CompletionData() const
+    {
+    return *iRequestData;
+    }
+
+// ---------------------------------------------------------
+// CXcapOperationBase::CompletionData
+//
+// ---------------------------------------------------------
+//
+CXdmDocumentNode* CXcapHttpOperation::TargetNode() const
+    {
+    return iDocumentSubset;
+    }
+    
+// ---------------------------------------------------------
+// CXcapOperationBase::CompletionData
+//
+// ---------------------------------------------------------
+//
+void CXcapHttpOperation::Destroy()
+    {
+    delete this;
+    }
+    
+// ---------------------------------------------------------
+// CXcapHttpOperation::Result
+//
+// ---------------------------------------------------------
+//
+TInt CXcapHttpOperation::Result() const
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapHttpOperation::Result()" ) );  
+    #endif
+    return iRequestData != NULL ? iRequestData->iHttpStatus : KErrUnknown;
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpOperation::ExecuteL
+//
+// ---------------------------------------------------------
+//
+void CXcapHttpOperation::ExecuteL( TRequestStatus& aStatus, TUint aOptions )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapHttpOperation::ExecuteL( &status )" ) );  
+    #endif
+    iOptionFlags = aOptions;
+    iClientStatus = &aStatus;
+    aStatus = KRequestPending;
+    if( !IsActive() )
+        {
+        iActiveRequest = iRequestQueue[iCurrentIndex];
+        TRAPD( error, ExecuteL() );
+        if( error == KErrNone )
+            {
+            if( StartOperationL() )
+                SetActive();
+            else
+                {
+                iFailureData.iCompletion = KXcapErrorNetworkNotAvailabe;
+                User::RequestComplete( iClientStatus, KXcapErrorNetworkNotAvailabe );
+                iRequestData = &iFailureData;
+                }      
+            }
+        else
+            {
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Execution failed with %d" ), error );  
+            #endif
+            iFailureData.iCompletion = error;
+            User::RequestComplete( iClientStatus, error );
+            iRequestData = &iFailureData;
+            }
+        }
+    else  //This is a re-run of a previously failed request
+        {
+        if( !StartOperationL() )
+            {
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Execution succeeded, network not ready" ) );  
+            #endif
+            User::RequestComplete( iClientStatus, KXcapErrorNetworkNotAvailabe );
+            }
+        }  
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpOperation::ExecuteL
+//       
+// ---------------------------------------------------------
+//
+void CXcapHttpOperation::ExecuteL( CXcapHttpRequest* aHttpRequest,
+                                   CXdmDocumentNode* aDocumentNode )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapAddition::ExecuteL()" ) );  
+    #endif
+    CXdmDocumentNode* node = aDocumentNode == NULL ?
+                             iTargetDoc.DocumentRoot() : aDocumentNode;
+    __ASSERT_ALWAYS( node != NULL, User::Panic( _L( "CXcapAddition" ), 1 ) );
+    User::LeaveIfError( FormatModRequestL( node ) );
+    TRAPD( error, iUriParser->ParseL( aHttpRequest->RequestUriL() ) );
+    if( error == KErrNone )
+        {
+        TPtrC8 uri = iUriParser->DesC8();
+        HBufC8* escape = CXcapHttpOperation::EscapeLC( uri );
+        aHttpRequest->UpdateRequestUriL( escape->Des() );
+        CleanupStack::PopAndDestroy();  //escape
+        }
+    }
+    
+// ---------------------------------------------------------
+// CXcapHttpOperation::StartOperationL
+//
+// ---------------------------------------------------------
+//
+TBool CXcapHttpOperation::StartOperationL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapHttpOperation::StartOperationL()" ) );  
+    #endif
+    if( iTargetDoc.Protocol().IsNetworkAvailable() )
+        {
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( " All set, dispatch request to transport" ) );  
+        #endif
+        if( iOptionFlags & KUseIntendedIdentity )
+            {
+            TPtrC8 identity( iTargetDoc.Protocol().PublicID() );
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Early-IMS set, add X-3GPP-Intended-Identity header" ) );
+                iOperationFactory.WriteToLog( _L8( "  Public ID: %S" ), &identity );  
+            #endif
+            iActiveRequest->SetHeaderL( KHttpHeaderIntIdentity, identity );
+            }
+        iActiveRequest->DispatchRequestL( iStatus );
+        return ETrue;
+        }
+    else return EFalse;
+    }
+    
+// ---------------------------------------------------------
+// CXcapHttpOperation::RunL
+//
+// ---------------------------------------------------------
+//
+void CXcapHttpOperation::RunL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( 
+        "CXcapHttpOperation::RunL() - Status: %d" ), iStatus.Int() );  
+    #endif
+    TInt count = iRequestQueue.Count();
+    iRequestData = iActiveRequest->ResponseData();
+    __ASSERT_DEBUG( iRequestData != NULL, User::Panic( _L( "CXcapHttpOperation" ), 1 ) );
+    TRAPD( error, iStatus != KErrNone ? OperationFailedL() : OperationCompleteL() );
+    if( error == KErrNone && !iCompleted )
+        SetActive();
+    else
+        {
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( 
+                "  ** Operation completed - Result: %d  Error: %d **" ), iResult, error );  
+        #endif
+        iCurrentIndex = 0;
+        iResult = error < KErrNone ? error : iResult;
+        iRequestData->iCompletion = iResult;
+        User::RequestComplete( iClientStatus, iResult );
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapRetrieval::CancelOperation
+//
+// ---------------------------------------------------------
+//
+void CXcapHttpOperation::CancelOperation()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapHttpOperation::CancelOperation()" ) );  
+    #endif
+    if( IsActive() )
+        {
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( "Active, cancel HTTP request" ) );  
+        #endif
+        Cancel();
+        iRequestData = &iFailureData;
+        iFailureData.iCompletion = KErrCancel;
+        User::RequestComplete( iClientStatus, KErrCancel );
+        }
+    }
+    
+// ---------------------------------------------------------
+// CXcapHttpOperation::CancelOperation
+//
+// ---------------------------------------------------------
+//
+void CXcapHttpOperation::DoCancel()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapHttpOperation::DoCancel()" ) );  
+    #endif
+    iRequestQueue[iCurrentIndex]->CancelRequest();   
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpOperation::Descriptor
+//
+// ---------------------------------------------------------
+//
+TPtrC8 CXcapHttpOperation::Descriptor( HBufC8* aBuffer )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapHttpOperation::Descriptor()" ) );  
+    #endif
+    if( aBuffer != NULL )
+        {
+        TPtrC8 descriptor( aBuffer->Des() );
+        return descriptor.Length() > 0 ? descriptor : TPtrC8();
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( " Buffer is NULL, return empty descriptor" ) );  
+        #endif
+        return TPtrC8();
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpOperation::Transport
+//
+// ---------------------------------------------------------
+//
+CXcapHttpTransport& CXcapHttpOperation::Transport() const
+    {
+    return iTargetDoc.Protocol().Transport();
+    }
+    
+// ---------------------------------------------------------
+// CXcapHttpOperation::FormatModRequestL
+//
+// ---------------------------------------------------------
+//
+TInt CXcapHttpOperation::FormatModRequestL( const CXdmDocumentNode* aDocumentNode )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapHttpOperation::FormatModRequestL()" ) );  
+    #endif
+    HBufC8* body = NULL;
+    TInt error = KErrNone;
+    CXcapAppUsage& usage = iTargetDoc.ApplicationUsage();
+    CXcapHttpContSupplier* request = ( CXcapHttpContSupplier* )iActiveRequest;
+    switch( iUriParser->NodeType() )
+        {
+        case EXdmElementAttribute:
+            {
+            CXdmNodeAttribute* attribute = ( CXdmNodeAttribute* )aDocumentNode;
+            body = attribute->EightBitValueLC();
+            request->SetRequestBodyL( body->Des() );
+            CleanupStack::PopAndDestroy();  //body
+            request->SetHeaderL( KHttpHeaderAccept, _L8( "application/xcap-diff+xml" ) );
+            request->SetHeaderL( KHttpHeaderContentType, _L8( "application/xcap-att+xml" ) );
+            }
+            break;
+        case EXdmElementNode:
+            {
+            #ifndef __OVERRIDE_VALIDATION__
+                error = usage.Validate( CONST_CAST( CXdmDocumentNode&, *aDocumentNode ), iUriParser, EFalse );
+            #endif
+            if( error == KErrNone )
+                {
+                #ifdef _DEBUG
+                    iOperationFactory.WriteToLog( _L8( " Validation of a partial document OK" ) );  
+                #endif
+                body = iXmlParser->FormatToXmlLC( EFalse, &iTargetDoc, aDocumentNode );
+                request->SetRequestBodyL( body->Des() );
+                CleanupStack::PopAndDestroy();  //body
+                request->SetHeaderL( KHttpHeaderAccept, _L8( "application/xcap-diff+xml" ) );
+                request->SetHeaderL( KHttpHeaderContentType, _L8( "application/xcap-el+xml" ) );
+                }
+            else
+                {
+                #ifdef _DEBUG
+                    iOperationFactory.WriteToLog( _L8( " Validation failed: %d" ), error );  
+                #endif
+                }
+            }
+            break;
+        default:
+        #ifndef __OVERRIDE_VALIDATION__
+            error = usage.Validate( iTargetDoc, ETrue );
+        #endif
+            if( error == KErrNone )
+                {
+                #ifdef _DEBUG
+                    iOperationFactory.WriteToLog( _L8( " Validation OK" ) );  
+                #endif
+                body = iXmlParser->FormatToXmlLC( ETrue, &iTargetDoc, aDocumentNode );
+                request->SetRequestBodyL( body->Des() );
+                CleanupStack::PopAndDestroy();  //body
+                }
+            else
+                {
+                #ifdef _DEBUG
+                    iOperationFactory.WriteToLog( _L8( " Validation failed: %d" ), error );  
+                #endif
+                }
+            break;
+        }
+    return error;
+    }
+
+// ----------------------------------------------------------
+// CXcapHttpOperation::ReinterpretStatus
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapHttpOperation::ReinterpretStatus( const TInt aHttpStatus ) const
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapHttpOperation::ReinterpretStatus()" ) );  
+    #endif
+    switch( aHttpStatus )
+        {
+        case 500:  //Internal Server Error
+        case 501:  //Not Implemented
+        case 502:  //Bad Gateway
+        case 503:  //Service Unavailable
+        case 504:  //Gateway Timeout
+        case 505:  //HTTP Version Not Supported
+        case 405:  //Method Not Allowed
+		case 408:  //Request Timeout
+		case 410:  //Gone
+		case 411:  //Length Required
+		case 413:  //Request Entity Too Large
+		case 414:  //Request-URI Too Long
+		case 415:  //Unsupported Media Type
+		case 416:  //Requested Range Not Satisfiable
+		case 417:  //Expectation Failed
+            return KXcapErrorHttpServer;
+        case 400:
+            return KXcapErrorHttpBadRequest;
+        case 401:
+            return KXcapErrorHttpUnauthorised;
+        case 403:
+            return KXcapErrorHttpForbidden;
+        case 404:
+            return KXcapErrorHttpNotFound;
+        case 409:
+            return KXcapErrorHttpConflict;
+        case 412:
+            return KXcapErrorHttpPrecondFailed;
+        default:
+            return KErrNone;
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapHttpOperation::Escape2LC
+// 
+// ---------------------------------------------------------
+//
+HBufC8* CXcapHttpOperation::Escape2LC( const TDesC& aDescriptor )
+    {
+    HBufC8* eight = EscapeUtils::ConvertFromUnicodeToUtf8L( aDescriptor );
+    CleanupStack::PushL( eight );
+    HBufC8* buf = EscapeUtils::EscapeEncodeL( eight->Des(), EscapeUtils::EEscapeNormal );
+    CleanupStack::PopAndDestroy();  //eight
+    CleanupStack::PushL( buf );
+    return buf;
+    }
+    
+// ---------------------------------------------------------
+// CXcapHttpOperation::EscapeLC
+// 
+// ---------------------------------------------------------
+//
+HBufC8* CXcapHttpOperation::EscapeLC( const TDesC8& aDescriptor )
+    {
+    CBufFlat* buffer = CBufFlat::NewL( 50 );
+    CleanupStack::PushL( buffer );
+    TInt bufPos = 0;
+    TBuf8<10> format;
+    for( TInt i = 0;i < aDescriptor.Length();i++ )
+        {
+        TUint8 byte = aDescriptor[i];
+        if( byte < 0x7F )                 //US-ASCII
+            {
+            switch( byte )
+                {
+                case 0x20:                // ' '
+                case 0x22:                // '"'
+                case 0x3B:                // ';'                 
+                case 0x26:                // '&'                  
+                case 0x3C:                // '<'                  
+                case 0x3E:                // '>'
+                case 0x5B:                // '['
+                case 0x5D:                // ']'                              
+                    format.Append( _L8( "%" ) );
+                    format.AppendFormat( _L8( "%x" ), byte );
+                    break;               
+                default:
+                    format.Append( byte );
+                    break;
+                }
+            }
+        else
+            {
+            format.Append( _L8( "%" ) );  //UNICODE
+            format.AppendFormat( _L8( "%x" ), byte );
+            }
+        buffer->InsertL( bufPos, format );
+        bufPos = bufPos + format.Length();
+        format.Zero();
+        }
+    HBufC8* ret = HBufC8::NewL( buffer->Size() );
+    TPtr8 pointer( ret->Des() );
+    buffer->Read( 0, pointer, buffer->Size() );
+    CleanupStack::PopAndDestroy();  //buffer
+    CleanupStack::PushL( ret );
+    return ret;
+    }
+               
+// ---------------------------------------------------------
+// CXcapHttpOperation::HttpRequest
+//
+// ---------------------------------------------------------
+//
+CXcapHttpRequest* CXcapHttpOperation::HttpRequest() const
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapHttpOperation::HttpRequest()" ) );  
+    #endif
+    return iActiveRequest;
+    }
+
+
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/src/XcapInsertion.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,216 @@
+/*
+* 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:   CXcapInsertion
+*
+*/
+
+
+
+
+// INCLUDES
+//This is only for logging
+#include <XdmErrors.h>
+#include "XcapProtocol.h"
+#include "XcapDocument.h"
+#include "XcapUriParser.h"
+#include "XcapInsertion.h"
+#include "XdmXmlParser.h"
+#include "XcapHttpReqPut.h"
+#include "XdmNodeAttribute.h"
+#include "XcapHttpTransport.h"
+#include "XcapEngineDefines.h"
+#include "XcapOperationFactory.h"
+
+
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CXcapInsertion::CXcapInsertion( CXcapDocument& aParentDoc,
+                                CXcapDocumentNode* aDocumentSubset,
+                                CXcapOperationFactory& aOperationFactory ) :
+                                CXcapHttpOperation( aParentDoc, aDocumentSubset, aOperationFactory ),
+                                iOperationType( EXdmPartialDocument )
+                                                              
+    {
+    }
+
+// ---------------------------------------------------------
+// Two-phased constructor.
+//
+// ---------------------------------------------------------
+//
+CXcapInsertion* CXcapInsertion::NewL( CXcapDocument& aParentDoc,
+                                      CXcapDocumentNode* aDocumentSubset,
+                                      CXcapOperationFactory& aOperationFactory )
+    {
+    CXcapInsertion* self = new ( ELeave ) CXcapInsertion( aParentDoc, aDocumentSubset, aOperationFactory );
+    CleanupStack::PushL( self );
+    self->BaseConstructL();
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CXcapInsertion::ConstructL
+//
+// ---------------------------------------------------------
+//
+void CXcapInsertion::ConstructL()
+    {
+    CXcapHttpReqPut* request = Transport().PutL( iTargetDoc.Name() );
+    CleanupStack::PushL( request );
+    User::LeaveIfError( iRequestQueue.Append( request ) );
+    request->SetExpiryTimeL( NULL, KDefaultHttpRequestTimeout * 1000000 );
+    CleanupStack::Pop();  //request
+    iUriParser->SetDocumentSubset( iDocumentSubset );
+    }
+
+// ---------------------------------------------------------
+// CXcapAddition::FormatModRequestL
+//
+// ---------------------------------------------------------
+//
+TInt CXcapInsertion::FormatModRequestL( const CXdmDocumentNode* aDocumentNode )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapInsertion::FormatModRequestL()" ) );
+        iOperationFactory.WriteToLog( _L8( "  Operation type:  %d" ), iOperationType );
+        iOperationFactory.WriteToLog( _L8( "  Document subset: %x" ), iDocumentSubset );
+    #endif
+    return CXcapHttpOperation::FormatModRequestL( aDocumentNode );
+    }
+    
+// ---------------------------------------------------------
+// CXcapInsertion::ExecuteL
+//
+// ---------------------------------------------------------
+//
+void CXcapInsertion::ExecuteL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapInsertion::ExecuteL()" ) );  
+    #endif
+    CXcapHttpOperation::ExecuteL( iActiveRequest, iDocumentSubset );
+    iActiveRequest->SetHeaderL( KHttpHeaderIfMatch, _L8( "*" ) );
+    }
+        
+// ---------------------------------------------------------
+// CXcapInsertion::OperationCompleteL
+//
+// ---------------------------------------------------------
+//
+void CXcapInsertion::OperationCompleteL()
+    {
+    
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapInsertion::OperationCompleteL()" ) );  
+    #endif
+    TPtrC8 root = Transport().RootUri();
+    iRequestData = iActiveRequest->ResponseData();
+    TPtrC name = iTargetDoc.Name();
+    TPtrC8 eTag = Descriptor( iRequestData->iETag );
+    switch( iRequestData->iHttpStatus )
+        {
+        case 201:           //"Created" -> Put operation was succesful
+            {
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Status 201 - Created" ) );  
+            #endif
+            iResult = KErrNone;
+            iTargetDoc.SetETag( eTag );
+            CXcapHttpContSupplier* request = ( CXcapHttpContSupplier* )iActiveRequest;
+            RXcapCache* cache = iTargetDoc.Protocol().Cache();
+            if( cache != NULL && iOperationType == EXdmDocument )
+                {
+                TPtrC8 payload = request->RequestBody();
+                cache->Store( eTag, name, root, payload );
+                }
+            iCompleted = ETrue;
+            }
+            break;
+        case 412:           //"Precondition failed" -> Cache out of date
+            {
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Status 412 - Precondition failed" ) );  
+            #endif
+            iResult = KXcapErrorHttpPrecondFailed;
+            //RXcapCache* cache = CXcapProtocol::Cache();
+            //if( cache != NULL && iOperationType == EXcapDocument )
+            //    cache->Delete( name, root );
+            iCompleted = ETrue;
+            iActiveRequest->ResetUriL( _L( "" ) );
+            iActiveRequest->ReleaseResponseData();
+            iRequestData->iCompletion = KInsertConflict;
+            }
+            break;
+        default:
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Default case - Status: %d" ),
+                                                       iRequestData->iHttpStatus ); 
+            #endif
+            TInt status = iRequestData->iHttpStatus;
+            iResult = ReinterpretStatus( status );
+            iCompleted = ETrue;
+            break;
+        } 
+    }
+    
+// ---------------------------------------------------------
+// Symbian OS default constructor may leave.
+//
+// ---------------------------------------------------------
+//
+void CXcapInsertion::OperationFailedL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapInsertion::OperationFailedL() - Error: %d" ),
+                                        iStatus.Int() );  
+    #endif
+    if( iStatus.Int() >= KErrNone )
+        {
+        TInt status = iActiveRequest->ResponseData()->iHttpStatus;
+        TInt completion = iActiveRequest->ResponseData()->iCompletion;
+        iResult = status < KErrNone || completion < KErrNone ? status : ReinterpretStatus( status );
+        }
+    else iResult = iStatus.Int();
+    iCompleted = ETrue;
+    }
+
+// ---------------------------------------------------------
+// Symbian OS default constructor may leave.
+//
+// ---------------------------------------------------------
+//
+TBool CXcapInsertion::Result() const
+    {
+    return ETrue;
+    }
+
+// ---------------------------------------------------------
+// Destructor
+//
+// ---------------------------------------------------------
+//
+CXcapInsertion::~CXcapInsertion()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapInsertion::~CXcapInsertion()" ) );  
+    #endif
+    }
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/src/XcapOperationFactory.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,190 @@
+/*
+* 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:  CXcapOperationFactory 
+*
+*/
+
+
+
+#include <ecom.h>
+#include <flogger.h>
+#include <implementationproxy.h>
+#include "XcapAddition.h"
+#include "XcapDeletion.h"
+#include "XdmOperation.h"
+#include "XcapRetrieval.h"
+#include "XcapInsertion.h"
+#include "XcapReplacement.h"
+#include "xdmlogwriter.h"
+#include "XcapOperationFactory.h"
+
+// ---------------------------------------------------------
+// CXcapOperationFactory::CXcapOperationFactory
+// 
+// ---------------------------------------------------------
+//
+CXcapOperationFactory::CXcapOperationFactory()
+    {   
+    }
+    
+// ---------------------------------------------------------
+// CXcapOperationFactory::NewL
+// 
+// ---------------------------------------------------------
+//
+CXcapOperationFactory* CXcapOperationFactory::NewL()
+    {
+    CXcapOperationFactory* self = new ( ELeave ) CXcapOperationFactory();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CXcapOperationFactory::ConstructL
+// 
+// ---------------------------------------------------------
+//
+void CXcapOperationFactory::ConstructL()
+    {
+    #ifdef _DEBUG
+        iLogWriter = CXdmLogWriter::NewL( KOperationsLogFile );
+        WriteToLog( _L8( "-> CXcapOperationFactory::ConstructL" ) );
+        WriteToLog( _L8( "<- CXcapOperationFactory::ConstructL" ) );
+    #endif
+    }
+            
+// ---------------------------------------------------------
+// CXcapOperationFactory::~CXcapOperationFactory
+// 
+// ---------------------------------------------------------
+//
+CXcapOperationFactory::~CXcapOperationFactory()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "-> CXcapOperationFactory::~CXcapOperationFactory()" ) );
+    #endif
+    #ifdef _DEBUG
+        WriteToLog( _L8( "<- CXcapOperationFactory::~CXcapOperationFactory()" ) );
+      #endif
+    delete iLogWriter;
+    }
+    
+// ---------------------------------------------------------
+// CXcapOperationFactory::FetchL
+// 
+// ---------------------------------------------------------
+//	
+MXdmOperation* CXcapOperationFactory::FetchL( CXdmDocument& aTargetDocument,
+                                              CXdmDocumentNode* aTargetNode ) const
+    {
+    return CXcapRetrieval::NewL( ( CXcapDocument& )aTargetDocument,
+                                 ( CXcapDocumentNode* )aTargetNode,
+                                 const_cast<CXcapOperationFactory&>( *this ) );
+    }       
+
+// ---------------------------------------------------------
+// CXcapOperationFactory::InsertL
+// 
+// ---------------------------------------------------------
+//
+MXdmOperation* CXcapOperationFactory::InsertL( CXdmDocument& aTargetDocument,
+                                               CXdmDocumentNode* aTargetNode ) const
+    {
+    return CXcapInsertion::NewL( ( CXcapDocument& )aTargetDocument,
+                                 ( CXcapDocumentNode* )aTargetNode,
+                                 const_cast<CXcapOperationFactory&>( *this ) );
+    }
+
+// ---------------------------------------------------------
+// CXcapOperationFactory::ReplaceL
+// 
+// ---------------------------------------------------------
+//
+MXdmOperation* CXcapOperationFactory::ReplaceL( CXdmDocument& aOldDocument, 
+                                                CXdmDocumentNode* aNewNode,
+                                                CXdmDocumentNode* aOldNode ) const
+    {
+    return CXcapReplacement::NewL( ( CXcapDocument& )aOldDocument,
+                                   ( CXcapDocumentNode* )aNewNode,
+                                   ( CXcapDocumentNode* )aOldNode,
+                                   const_cast<CXcapOperationFactory&>( *this )  );
+    }
+
+// ---------------------------------------------------------
+// CXcapOperationFactory::AppendL
+// 
+// ---------------------------------------------------------
+//
+MXdmOperation* CXcapOperationFactory::AppendL( CXdmDocument& aTargetDocument,
+                                               CXdmDocumentNode* aTargetNode ) const
+    { 
+    return CXcapAddition::NewL( ( CXcapDocument& )aTargetDocument,
+                                ( CXcapDocumentNode* )aTargetNode,
+                                const_cast<CXcapOperationFactory&>( *this ) );
+    }              
+
+// ---------------------------------------------------------
+// CXcapOperationFactory::PartialDeletionL
+// 
+// ---------------------------------------------------------
+//
+MXdmOperation* CXcapOperationFactory::DeletionL( CXdmDocument& aTargetDocument,
+                                                 CXdmDocumentNode* aTargetNode ) const
+    {
+    return CXcapDeletion::NewL( ( CXcapDocument& )aTargetDocument,
+                                ( CXcapDocumentNode* )aTargetNode,
+                                const_cast<CXcapOperationFactory&>( *this ) );
+    }              
+    
+// ----------------------------------------------------
+// CXcapOperationFactory::WriteToLog
+// 
+// ----------------------------------------------------
+//
+void CXcapOperationFactory::WriteToLog( TRefByValue<const TDesC8> aFmt,... ) const
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf8<KLogBufferMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    iLogWriter->WriteToLog( buf );
+    }
+    
+// ---------------------------------------------------------
+// Map the interface UIDs to implementation factory functions
+// 
+// ---------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] = 
+	{
+#ifdef __EABI__
+    IMPLEMENTATION_PROXY_ENTRY( KXcapOperationFactory,	CXcapOperationFactory::NewL )
+#else
+    { { KXcapOperationFactory }, CXcapOperationFactory::NewL }
+#endif
+    };
+
+// ---------------------------------------------------------
+// Return the implementation table & number of implementations
+// 
+// ---------------------------------------------------------
+//
+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/xdmprotocols/XcapProtocol/XcapOperations/src/XcapReplacement.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,231 @@
+/*
+* 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:   CXcapReplacement
+*
+*/
+
+
+
+
+// INCLUDES
+#include "XcapAppUsage.h"
+#include "XcapDocument.h"
+#include "XcapUriParser.h"
+#include "XdmXmlParser.h"
+#include "XcapHttpReqPut.h"
+#include "XcapReplacement.h"
+#include "XcapHttpReqDelete.h"
+#include "XcapHttpTransport.h"
+#include "XcapHttpOperation.h"
+#include "XdmNodeAttribute.h"
+#include "XcapEngineDefines.h"
+        
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that might leave.
+//
+// ---------------------------------------------------------
+//
+CXcapReplacement::CXcapReplacement( CXcapDocument& aParentDoc,
+                                    CXcapDocumentNode* aOldNode,
+                                    CXcapDocumentNode* aNewNode,
+                                    CXcapOperationFactory& aOperationFactory ) :
+                                    CXcapHttpOperation( aParentDoc, aOldNode, aOperationFactory ),
+                                    iNewNode( ( CXcapDocumentNode* )aNewNode ),
+                                    iOperationType( aOldNode == NULL ?
+                                    EXdmDocument : EXdmPartialDocument )
+                                    
+    {
+    }
+
+// ---------------------------------------------------------
+// Two-phased constructor.
+//
+// ---------------------------------------------------------
+//
+CXcapReplacement* CXcapReplacement::NewL( CXcapDocument& aParentDoc,
+                                          CXcapDocumentNode* aOldNode,
+                                          CXcapDocumentNode* aNewNode,
+                                          CXcapOperationFactory& aOperationFactory )
+    {
+    CXcapReplacement* self = new ( ELeave ) CXcapReplacement( aParentDoc, aOldNode, aNewNode, aOperationFactory );
+    CleanupStack::PushL( self );
+    self->BaseConstructL();
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CXcapReplacement::ConstructL
+//
+// ---------------------------------------------------------
+//
+void CXcapReplacement::ConstructL()
+    {
+    CXcapHttpReqPut* request = Transport().PutL( iTargetDoc.Name() );
+    CleanupStack::PushL( request );
+    User::LeaveIfError( iRequestQueue.Append( request ) );
+    request->SetExpiryTimeL( NULL, KDefaultHttpRequestTimeout * 1000000 );
+    CleanupStack::Pop();  //request
+    //If they point to the same node, we're dealing with a complete document
+    if( iDocumentSubset != NULL && iTargetDoc.DocumentRoot() != iDocumentSubset )
+        iUriParser->SetDocumentSubset( iDocumentSubset );
+    }
+
+// ---------------------------------------------------------
+// CXcapReplacement::FormatModRequestL
+//
+// ---------------------------------------------------------
+//
+TInt CXcapReplacement::FormatModRequestL( const CXcapDocumentNode* aDocumentNode )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapReplacement::FormatModRequestL()" ) );
+        iOperationFactory.WriteToLog( _L8( "  Operation type:  %d" ), iOperationType );
+        iOperationFactory.WriteToLog( _L8( "  Document subset: %x" ), iDocumentSubset );
+    #endif
+    return CXcapHttpOperation::FormatModRequestL( aDocumentNode );   
+    }
+    
+// ---------------------------------------------------------
+// CXcapReplacement::ExecuteL
+//
+// ---------------------------------------------------------
+//
+void CXcapReplacement::ExecuteL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapReplacement::ExecuteL()" ) );  
+    #endif
+    User::LeaveIfError( FormatModRequestL( iNewNode ) );
+    if( iOperationType == EXdmPartialDocument )
+        {
+        TPtrC8 eTag = iTargetDoc.ETag();
+        if( eTag.Length() > 0 )
+            iActiveRequest->SetHeaderL( KHttpHeaderIfMatch, eTag );
+        //If they match semantically, there's no need for DELETE operation
+        if( iDocumentSubset->Match( *iNewNode ) )
+            iOperationPhase = EHttpPutting;
+        else
+            {
+            CXcapHttpReqDelete* request = Transport().DeleteL( iTargetDoc.Name() );
+            CleanupStack::PushL( request );
+            User::LeaveIfError( iRequestQueue.Insert( request, 0 ) );
+            CleanupStack::Pop();  //request
+            if( eTag.Length() > 0 )
+                request->SetHeaderL( KHttpHeaderIfMatch, eTag );
+            request->SetHeaderL( KHttpHeaderAccept, _L8( "application/xcap-diff+xml" ) );
+            iActiveRequest = request;
+            iOperationPhase = EHttpDeleting;
+            }
+        TRAPD( error, iUriParser->ParseL( iActiveRequest->RequestUriL() ) );
+        if( error == KErrNone )
+            {
+            TPtrC8 uri = iUriParser->DesC8();
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " New URI: %S" ), &uri );  
+            #endif
+            HBufC8* escape = CXcapHttpOperation::EscapeLC( uri );
+            iActiveRequest->UpdateRequestUriL( escape->Des() );
+            CleanupStack::PopAndDestroy();  //escape
+            }
+        }
+    else
+        {
+        
+        }
+    }
+        
+// ---------------------------------------------------------
+// CXcapReplacement::OperationCompleteL
+//
+// ---------------------------------------------------------
+//
+void CXcapReplacement::OperationCompleteL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog(
+            _L8( "CXcapReplacement::OperationCompleteL() - Phase: %d" ), iOperationPhase );  
+    #endif
+    switch( iOperationPhase )
+        {
+        case EHttpDeleting:
+            break;
+        case EHttpPutting:
+            break;
+        default:
+            iCompleted = ETrue;
+            break;
+        }
+    }
+    
+// ---------------------------------------------------------
+// CXcapReplacement::OperationFailedL
+//
+// ---------------------------------------------------------
+//
+void CXcapReplacement::OperationFailedL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapReplacement::OperationFailedL() - Error: %d" ),
+                                        iStatus.Int() );
+        TInt httpStatus = iRequestData == NULL ? KErrUnknown :
+                          iRequestData->iHttpStatus;
+    #endif
+
+    switch( iOperationPhase )
+        {
+        case EHttpDeleting:
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog(
+                    _L8( "DELETE failed - Error: %d  Status: %d" ), iStatus.Int(), httpStatus );  
+            #endif
+            break;
+        case EHttpPutting:
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog(
+                    _L8( "PUT failed - Error: %d  Status: %d" ), iStatus.Int(), httpStatus );  
+            #endif
+            break;
+        default:
+            break;
+        }
+    iResult = iStatus.Int();
+    iCompleted = ETrue;   
+    }
+
+// ---------------------------------------------------------
+// CXcapReplacement::Result
+//
+// ---------------------------------------------------------
+//
+TBool CXcapReplacement::Result() const
+    {
+    return ETrue;
+    }
+
+// ---------------------------------------------------------
+// CXcapReplacement::~CXcapReplacement
+//
+// ---------------------------------------------------------
+//
+CXcapReplacement::~CXcapReplacement()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapReplacement::~CXcapReplacement()" ) );  
+    #endif
+    }
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/src/XcapRetrieval.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,320 @@
+/*
+* 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:   CXcapRetrieval
+*
+*/
+
+
+
+
+// INCLUDES
+#include "XcapCache.h"
+#include "XcapAppUsage.h"
+#include "XcapDocument.h"
+#include "XcapProtocol.h"
+#include "XcapRetrieval.h"
+#include "XcapUriParser.h"
+#include "XdmXmlParser.h"
+#include "XcapHttpReqGet.h"
+#include "XcapHttpTransport.h"
+#include "XcapOperationFactory.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CXcapRetrieval::CXcapRetrieval( CXcapDocument& aParentDoc,
+                                CXcapDocumentNode* aTargetNode,
+                                CXcapOperationFactory& aOperationFactory ) :
+                                CXcapHttpOperation( aParentDoc, aTargetNode, aOperationFactory ),
+                                iCacheOperation( EFalse ),
+                                iOperationType( aTargetNode == NULL ?
+                                EXdmDocument : EXdmPartialDocument )                                  
+    {
+    }
+
+// ---------------------------------------------------------
+// CXcapRetrieval::NewL
+//
+// ---------------------------------------------------------
+//
+CXcapRetrieval* CXcapRetrieval::NewL( CXcapDocument& aParentDoc,
+                                      CXcapDocumentNode* aTargetNode,
+                                      CXcapOperationFactory& aOperationFactory )
+    {
+    CXcapRetrieval* self = new ( ELeave ) CXcapRetrieval( aParentDoc, aTargetNode, aOperationFactory );
+    CleanupStack::PushL( self );
+    self->BaseConstructL();
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CXcapRetrieval::ConstructL
+//
+// ---------------------------------------------------------
+//
+void CXcapRetrieval::ConstructL()
+    {
+#ifdef _DEBUG
+    iOperationFactory.WriteToLog( _L8( "-> CXcapRetrieval::ConstructL" ) );  
+#endif
+    CXcapHttpReqGet* request = Transport().GetL( iTargetDoc.Name() );
+    CleanupStack::PushL( request );
+    User::LeaveIfError( iRequestQueue.Append( request ) );
+    request->SetExpiryTimeL( NULL, KDefaultHttpRequestTimeout * 1000000 );
+    CleanupStack::Pop();  //request
+    if( iOperationType != EXdmDocument && iDocumentSubset != NULL )
+        {
+        iUriParser->SetDocumentSubset( iDocumentSubset );
+        //Add namespace mappings
+        User::LeaveIfError( iTargetDoc.ApplicationUsage().Validate(
+                            *iDocumentSubset, iUriParser, ETrue ) );
+        }
+#ifdef _DEBUG
+    iOperationFactory.WriteToLog( _L8( "<- CXcapRetrieval::ConstructL" ) );  
+#endif
+    }
+
+// ---------------------------------------------------------
+// CXcapRetrieval::ExecuteL
+//
+// ---------------------------------------------------------
+//
+void CXcapRetrieval::ExecuteL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapRetrieval::ExecuteL()" ) );  
+    #endif
+    TPtrC8 eTag = iTargetDoc.ETag();
+    if( eTag.Length() > 0 )
+        {
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( " Using ETag \"%S\" - Length: %d" ),
+                                               &eTag, eTag.Length() );  
+        #endif
+        //iActiveRequest->SetHeaderL( KHttpHeaderIfNoneMatch, eTag );
+        }
+    TRAPD( error, iUriParser->ParseL( iActiveRequest->RequestUriL() ) );
+    if( error == KErrNone )
+        {
+        TPtrC8 uri = iUriParser->DesC8();
+        HBufC8* escape = CXcapHttpOperation::EscapeLC( uri );
+        iActiveRequest->UpdateRequestUriL( escape->Des() );
+        CleanupStack::PopAndDestroy();  //escape
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( " New URI: %S" ), &uri );  
+        #endif
+        }
+    }
+        
+// ---------------------------------------------------------
+// CXcapRetrieval::OperationCompleteL
+//
+/* const TDesC8& aETag, 
+   const TDesC& aDocumentName,
+   const TDesC8& aRootLocation,
+   const TDesC8& aResponseData*/
+// ---------------------------------------------------------
+//
+void CXcapRetrieval::OperationCompleteL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapRetrieval::OperationCompleteL()" ) );  
+    #endif
+    TInt generalErr = ReinterpretStatus( iRequestData->iHttpStatus );
+    if( generalErr == KErrNone )
+        {
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( " No general errors found" ) );  
+        #endif
+        iCacheOperation ? HandleCacheOperationL() : HandleNetworkOperationL();
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( " General errors found - Status: %d  Error: %d" ),
+                                                   iRequestData->iHttpStatus, generalErr );  
+        #endif
+        iCompleted = ETrue;
+        iResult = generalErr;
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapRetrieval::HandleCacheOperationL
+//
+// ---------------------------------------------------------
+//
+void CXcapRetrieval::HandleCacheOperationL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapRetrieval::HandleCacheOperationL() - Operation type: %d  Target node: %x" ),
+                                           iOperationType, iDocumentSubset );  
+    #endif
+    TPtrC8 responseData = Descriptor( iRequestData->iResponseData );
+    iOperationType == EXdmDocument && iDocumentSubset == NULL ? 
+        iXmlParser->ParseDocumentL( &iTargetDoc, responseData ) :
+        iXmlParser->ParseDocumentL( &iTargetDoc, responseData, iDocumentSubset );
+    iCompleted = ETrue;
+    }
+    
+// ---------------------------------------------------------
+// CXcapRetrieval::HandleNetworkOperationL
+//
+// ---------------------------------------------------------
+//
+void CXcapRetrieval::HandleNetworkOperationL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapRetrieval::HandleNetworkOperationL()" ) );  
+    #endif
+    TPtrC name = iTargetDoc.Name();
+    TPtrC8 root = Transport().RootUri();
+    switch( iRequestData->iHttpStatus )
+        {
+        case 200:           //ETag was stale
+            {
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Status 200 - ETag was stale" ) );  
+            #endif
+            TPtrC8 responseData = Descriptor( iRequestData->iResponseData );
+            if( responseData.Length() <= 0 )
+                break;
+            if( iOperationType == EXdmDocument )
+                {
+                TPtrC8 eTag = Descriptor( iRequestData->iETag );
+                //If the ETag has not changed, server should return
+                //304 (Not modified), but just in case, let's check the 
+                //ETag value, anyway.
+                if( eTag.Length() > 0 && eTag.Compare( iTargetDoc.ETag() ) != 0 )
+                    {
+                    iTargetDoc.SetETag( eTag );
+                    RXcapCache* cache = iTargetDoc.Protocol().Cache();
+                    if( cache && !( iOptionFlags & KNoCache ) )
+                        cache->Store( iTargetDoc.ETag(), name, root, responseData  );
+                    }
+                else
+                    {
+                    #ifdef _DEBUG
+                        iOperationFactory.WriteToLog( _L8( " ETag values match, do not update cache" ) );  
+                    #endif
+                    }
+                iXmlParser->ParseDocumentL( &iTargetDoc, responseData );
+                }
+            else if( iOperationType == EXdmPartialDocument )
+                {
+                #ifdef _DEBUG  
+                    iOperationFactory.WriteToLog( _L8( " Parse a partial document" ) );  
+                #endif
+                //The target node must be emptied before inserting new content
+                iDocumentSubset->SetEmptyNode( ETrue );
+                iDocumentSubset->SetEmptyNode( EFalse );
+                iXmlParser->ParseDocumentL( responseData, iDocumentSubset );
+               	}
+            iCompleted = ETrue;
+            }
+            break;
+        case 304:
+            {
+            RXcapCache* cache = iTargetDoc.Protocol().Cache();
+            if( cache )
+                {
+                #ifdef _DEBUG   //ETag is up to date - cache still valid
+                    iOperationFactory.WriteToLog( _L8( " Status 304 - Cached version is valid" ) );  
+                #endif
+                TInt length = iTargetDoc.DataLength();
+                __ASSERT_DEBUG( length > 0, User::Panic( _L( "CXcapRetrieval" ), 1 ) );
+                delete iRequestData->iResponseData;
+                iRequestData->iResponseData = NULL;
+                iRequestData->iResponseData = HBufC8::NewL( length );
+                TPtr8 desc( iRequestData->iResponseData->Des() );
+                cache->FetchDocumentContent( desc, name, root );
+                if( iOperationType == EXdmDocument && !iTargetDoc.DocumentRoot() )
+                	{
+                	#ifdef _DEBUG  
+                    	iOperationFactory.WriteToLog( _L8( " No content => parse cached document" ) );  
+                	#endif
+					iXmlParser->ParseDocumentL( &iTargetDoc, desc );
+                	}
+               	else if( iOperationType == EXdmPartialDocument )
+               		{
+               		#ifdef _DEBUG  
+                    	iOperationFactory.WriteToLog( _L8( " Parse a partial document" ) );  
+                	#endif
+					iXmlParser->ParseDocumentL( &iTargetDoc, desc, iDocumentSubset );
+               		}
+                }
+            iCompleted = ETrue;
+            }
+            break;
+        default:
+            #ifdef _DEBUG
+                iOperationFactory.WriteToLog( _L8( " Default case - Status: %d" ),
+                                                   iRequestData->iHttpStatus );  
+            #endif
+            iCompleted = ETrue;
+            break;
+        }
+    }
+  
+// ---------------------------------------------------------
+// CXcapRetrieval::OperationFailedL
+//
+// ---------------------------------------------------------
+//
+void CXcapRetrieval::OperationFailedL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapRetrieval::OperationFailedL() - Error: %d" ),
+                                        iStatus.Int() );  
+    #endif
+    if( iStatus.Int() >= KErrNone )
+        {
+        TInt status = iActiveRequest->ResponseData()->iHttpStatus;
+        TInt completion = iActiveRequest->ResponseData()->iCompletion;
+        iResult = status < KErrNone || completion < KErrNone ? status : ReinterpretStatus( status );
+        }
+    else iResult = iStatus.Int();
+    iCompleted = ETrue;
+    }
+    
+// ---------------------------------------------------------
+// CXcapRetrieval::Result
+//
+// ---------------------------------------------------------
+//
+TInt CXcapRetrieval::Result() const
+    {
+    return iRequestData->iCompletion;
+    }
+
+// ---------------------------------------------------------
+// CXcapRetrieval::~CXcapRetrieval
+//
+// ---------------------------------------------------------
+//
+CXcapRetrieval::~CXcapRetrieval()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapRetrieval::~CXcapRetrieval()" ) );  
+    #endif
+    }
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapOperations/src/XcapUriParser.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,448 @@
+/*
+* 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:   CXcapUriParser
+*
+*/
+
+
+
+
+// INCLUDES
+#include <f32file.h>
+#include "XdmNamespace.h"
+#include "XcapUriParser.h"
+#include "XcapHttpOperation.h"
+#include "XcapEngineDefines.h"
+#include "XdmNodeAttribute.h"
+#include "XcapOperationFactory.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CXcapUriParser::CXcapUriParser( CXdmDocument& aTargetDoc,
+                                CXcapOperationFactory& aOperationFactory ) :
+                                iTargetDoc( aTargetDoc ),
+                                iNodeType( EXdmElementUnspecified ),
+                                iOperationFactory( aOperationFactory )
+    {
+    }
+
+// ---------------------------------------------------------
+// Two-phased constructor.
+//
+// ---------------------------------------------------------
+//
+CXcapUriParser* CXcapUriParser::NewL( CXdmDocument& aTargetDoc,
+                                      CXcapOperationFactory& aOperationFactory )
+    {
+    CXcapUriParser* self = new ( ELeave ) CXcapUriParser( aTargetDoc, aOperationFactory );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// Destructor
+//
+// ---------------------------------------------------------
+//
+CXcapUriParser::~CXcapUriParser()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapUriParser::~CXcapUriParser()" ) );  
+    #endif
+    delete iUriBuffer;
+    delete iCompleteUri;
+    iNamespaceMappings.ResetAndDestroy();
+    iNamespaceMappings.Close();
+    }
+    
+// ---------------------------------------------------------
+// CXcapUriParser::ConstructL
+//
+// ---------------------------------------------------------
+//
+void CXcapUriParser::ConstructL()
+    {
+    }
+
+// ---------------------------------------------------------
+// CXcapUriParser::AddNamespaceMappingL
+//
+// ---------------------------------------------------------
+//
+void CXcapUriParser::AddNamespaceMappingL( const TDesC8& aUri, const TDesC8& aPrefix )
+    {
+    CXdmNamespace* ns = CXdmNamespace::NewL( aUri, aPrefix );
+    CleanupStack::PushL( ns );
+    User::LeaveIfError( iNamespaceMappings.Append( ns ) );
+    CleanupStack::Pop();  //ns
+    }
+
+// ---------------------------------------------------------
+// CXcapUriParser::AppendNamespaceMappingsL
+//
+// ---------------------------------------------------------
+//
+void CXcapUriParser::AppendNamespaceMappingsL()
+    {
+    CXdmNamespace* ns = NULL;
+    const TInt count = iNamespaceMappings.Count();
+    iUriBuffer->InsertL( iBufferPosition, KXcapUriQMark );
+    iBufferPosition = iBufferPosition + KXcapUriQMark().Length();
+    for( TInt i = 0;i < count;i++ )
+        {
+        ns = iNamespaceMappings[i];
+        iUriBuffer->InsertL( iBufferPosition, KXcapUriXmlns );
+        iBufferPosition = iBufferPosition + KXcapUriXmlns().Length();
+        TPtrC8 prefix( ns->Prefix() );
+        iUriBuffer->InsertL( iBufferPosition, prefix );
+        iBufferPosition = iBufferPosition + prefix.Length();
+        iUriBuffer->InsertL( iBufferPosition, KXcapUriEquals );
+        iBufferPosition = iBufferPosition + KXcapUriEquals().Length();
+        TPtrC8 uri( ns->Uri() );
+        iUriBuffer->InsertL( iBufferPosition, uri );
+        iBufferPosition = iBufferPosition + uri.Length();
+        iUriBuffer->InsertL( iBufferPosition, KXcapUriQuote );
+        iBufferPosition = iBufferPosition + KXcapUriQuote().Length();
+        iUriBuffer->InsertL( iBufferPosition, KXcapParenthClose );
+        iBufferPosition = iBufferPosition + KXcapParenthClose().Length();
+        }
+    }
+    
+// ---------------------------------------------------------
+// CXcapUriParser::FinaliseL
+//
+// ---------------------------------------------------------
+//
+void CXcapUriParser::FinaliseL()
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapUriParser::FinaliseL()" ) );  
+    #endif
+    delete iCompleteUri;
+    iCompleteUri = NULL;
+    iCompleteUri = HBufC8::NewL( iUriBuffer->Size() );
+    TPtr8 pointer( iCompleteUri->Des() );
+    iUriBuffer->Read( 0, pointer, iUriBuffer->Size() );
+    iUriBuffer->Reset();
+    delete iUriBuffer;
+    iUriBuffer = NULL;
+    }
+
+// ---------------------------------------------------------
+// CXcapUriParser::ParseL
+//
+// ---------------------------------------------------------
+//
+void CXcapUriParser::ParseL( const TPtrC8& aHttpUri )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapUriParser::ParseL()" ) );  
+    #endif
+    iHttpUri = CONST_CAST( TPtrC8*, &aHttpUri );
+    if( iNodeType != EXdmElementUnspecified )
+        {
+        HBufC8* path = DocSubsetPathL();
+        CleanupStack::PushL( path );
+        iBufferPosition = CreateBasicNodeUriL( path );
+        CleanupStack::PopAndDestroy();  //path
+        iNodeType == EXdmElementAttribute ? FormatAttributeUriL() : FormatNodeUriL();
+        if( iNamespaceMappings.Count() > 0 )
+            AppendNamespaceMappingsL();
+        FinaliseL();
+        #ifdef _DEBUG
+            TPtr8 desc( iCompleteUri->Des() );
+            iOperationFactory.WriteToLog( _L8( " Context: %S" ), &desc );  
+        #endif
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iOperationFactory.WriteToLog( _L8( " Context is a whole document" ) );  
+        #endif
+        iCompleteUri = HBufC8::NewL( iHttpUri->Length() );
+        iCompleteUri->Des().Copy( *iHttpUri );
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapDocumentNode::DocSubsetPathL
+// 
+// ----------------------------------------------------------
+//
+HBufC8* CXcapUriParser::DocSubsetPathL()
+    {
+    HBufC8* ret = NULL;
+    CXdmDocumentNode* current = iDocumentSubset->Parent();
+    CBufFlat* buffer = CBufFlat::NewL( 256 );
+    CleanupStack::PushL( buffer );
+    while( current != NULL )
+        {   
+        buffer->InsertL( 0, FormatOnePathElementLC( current )->Des() );
+        CleanupStack::PopAndDestroy();  //FormatOnePathElementLC
+        current = current->Parent();
+        }
+    TInt length = buffer->Size();
+    ret = HBufC8::NewL( length );
+    TPtr8 pointer( ret->Des() );
+    buffer->Read( 0, pointer, length );
+    CleanupStack::PopAndDestroy();  //buffer 
+    return ret;
+    }
+
+// ---------------------------------------------------------
+// CXcapUriParser::FormatAttributeUriL
+//
+// ---------------------------------------------------------
+//
+HBufC8* CXcapUriParser::FormatOnePathElementLC( const CXdmDocumentNode* aPathElement ) 
+    {
+    #ifdef _DEBUG
+        HBufC8* name8 = aPathElement->EightBitNodeNameLC();
+        TPtrC8 elemName( name8->Des() );
+        TPtrC8 elemPref( aPathElement->Prefix() );
+        iOperationFactory.WriteToLog( _L8( "CXcapUriParser::FormatOnePathElementL()" ) );
+        if( elemPref.Length() > 0 )
+            iOperationFactory.WriteToLog( _L8( "  Prefix: %S" ), &elemName );
+        iOperationFactory.WriteToLog( _L8( "  Name:   %S" ), &elemName );  
+        CleanupStack::PopAndDestroy();  //name8
+    #endif
+    TInt position = 0;
+    CBufFlat* buffer = CBufFlat::NewL( 50 );
+    CleanupStack::PushL( buffer );
+    buffer->InsertL( position, KXCAPPathSeparator );
+    position = position + KXCAPPathSeparator().Length();
+    TPtrC8 prefix = aPathElement->Prefix();
+    if( prefix.Length() > 0 )
+        {
+        buffer->InsertL( position, prefix );
+        position = position + prefix.Length();
+        buffer->InsertL( position, KXcapUriColon );
+        position = position + KXcapUriColon().Length();
+        }
+    TPtrC8 name = aPathElement->EightBitNodeNameLC()->Des();
+    buffer->InsertL( position, name );
+    position = position + name.Length();
+    CleanupStack::PopAndDestroy();  //EightBitNodeNameLC 
+    if( aPathElement->AttributeCount() > 0 &&
+        !( iNodeType == EXdmElementAttribute && aPathElement == iDocumentSubset->Parent() ) )
+        AppendPredicatesL( position, buffer, aPathElement );
+    HBufC8* retBuf = HBufC8::NewL( buffer->Size() );
+    TPtr8 pointer( retBuf->Des() );
+    buffer->Read( 0, pointer, buffer->Size() );
+    CleanupStack::PopAndDestroy();  //buffer
+    CleanupStack::PushL( retBuf );
+    return retBuf;
+    }
+
+// ---------------------------------------------------------
+// CXcapUriParser::FormatAttributeUriL
+//
+// ---------------------------------------------------------
+//
+void CXcapUriParser::FormatAttributeUriL() 
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( " CXcapUriParser::FormatAttributeUriL()" ) );  
+    #endif
+    iUriBuffer->InsertL( iBufferPosition, KXCAPAttributeIdentifier );
+    iBufferPosition = iBufferPosition + KXCAPAttributeIdentifier().Length();
+    iUriBuffer->InsertL( iBufferPosition, iDocumentSubset->EightBitNodeNameLC()->Des() );
+    CleanupStack::PopAndDestroy();  //EightBitNodeNameLC
+    HBufC8* newUri = HBufC8::NewLC( iUriBuffer->Size() );
+    TPtr8 pointer( newUri->Des() );
+    iUriBuffer->Read( 0, pointer, iUriBuffer->Size() );
+    #ifdef _DEBUG
+        DumpUriL( newUri );
+    #endif
+    CleanupStack::PopAndDestroy();  //newUri
+    }
+
+// ---------------------------------------------------------
+// CXcapUriParser::FormatNodeUriL
+//
+// ---------------------------------------------------------
+//
+void CXcapUriParser::FormatNodeUriL() 
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( " CXcapUriParser::FormatNodeUriL()" ) );  
+    #endif
+    iNodeType = EXdmElementNode;
+    TPtrC8 prefix = iDocumentSubset->Prefix();
+    if( prefix.Length() > 0 )
+        {
+        iUriBuffer->InsertL( iBufferPosition, prefix );
+        iBufferPosition = iBufferPosition + prefix.Length();
+        iUriBuffer->InsertL( iBufferPosition, KXcapUriColon );
+        iBufferPosition = iBufferPosition + KXcapUriColon().Length();
+        }
+    TPtrC8 name = iDocumentSubset->EightBitNodeNameLC()->Des();
+    iUriBuffer->InsertL( iBufferPosition, name );
+    iBufferPosition = iBufferPosition + name.Length();
+    CleanupStack::PopAndDestroy();  //EightBitNodeNameLC
+    if( iDocumentSubset->AttributeCount() > 0 )
+        AppendPredicatesL( iBufferPosition, iUriBuffer, iDocumentSubset );
+    //For now, do not put a trailing '/' to the node path. This may have to be changed, though.
+    //iUriBuffer->InsertL( iBufferPosition, KXCAPPathSeparator );
+    //iBufferPosition = iBufferPosition + TPtrC8( KXCAPPathSeparator ).Length();
+    HBufC8* newUri = HBufC8::NewLC( iUriBuffer->Size() );
+    TPtr8 pointer2( newUri->Des() );
+    iUriBuffer->Read( 0, pointer2, iUriBuffer->Size() );
+    #ifdef _DEBUG
+        DumpUriL( newUri );
+    #endif
+    CleanupStack::PopAndDestroy();  //newUri
+    }
+
+// ---------------------------------------------------------
+// CXcapUriParser::AppendPredicatesL
+//
+// ---------------------------------------------------------
+//
+void CXcapUriParser::AppendPredicatesL( TInt& aPosition,
+                                        CBufBase* aBuffer,
+                                        const CXdmDocumentNode* aPathElement )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( " CXcapUriParser::AppendPredicatesL()" ) );  
+    #endif
+    TInt count = aPathElement->AttributeCount();
+    for( TInt i = 0;i < count;i++ )
+        {
+        CXdmNodeAttribute* attribute = aPathElement->Attribute( i );
+        //Namespaces cannot be used as attributes
+        if( attribute->NodeName().Find( _L( "xmlns" ) ) < 0 )
+            {
+            aBuffer->InsertL( aPosition, KHTTPBracketOpen );
+            aPosition = aPosition + KHTTPBracketOpen().Length();
+            aBuffer->InsertL( aPosition, KXCAPAttributeIdentifier );
+            aPosition = aPosition + KXCAPAttributeIdentifier().Length();
+            TPtrC8 name = attribute->EightBitNodeNameLC()->Des();
+            aBuffer->InsertL( aPosition, name );
+            aPosition = aPosition + name.Length();
+            CleanupStack::PopAndDestroy();  //EightBitNodeNameLC
+            aBuffer->InsertL( aPosition, KXCAPEquality );
+            aPosition = aPosition + KXCAPEquality().Length();
+            aBuffer->InsertL( aPosition, KHTTPQuotationMark );
+            aPosition = aPosition + KHTTPQuotationMark().Length();
+            TPtrC8 value = attribute->EightBitValueLC()->Des();
+            aBuffer->InsertL( aPosition, value );
+            aPosition = aPosition + value.Length();
+            CleanupStack::PopAndDestroy();  //EightBitValueLC
+            aBuffer->InsertL( aPosition, KHTTPQuotationMark );
+            aPosition = aPosition + KHTTPQuotationMark().Length();
+            aBuffer->InsertL( aPosition, KHTTPBracketClose );
+            aPosition = aPosition + KHTTPBracketClose().Length();
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapUriParser::CreateBasicNodeUriL
+//
+// ---------------------------------------------------------
+//
+TInt CXcapUriParser::CreateBasicNodeUriL( HBufC8* aNodePath )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( " CXcapUriParser::CreateBasicNodeUriL()" ) );  
+    #endif
+    TInt position = 0;
+    TPtr8 pointer( aNodePath->Des() );
+    iUriBuffer = CBufFlat::NewL( 256 );
+    iUriBuffer->InsertL( position, *iHttpUri );
+    position = iHttpUri->Length();
+    if( iHttpUri->LocateReverseF( KXcapPathSeparatorChar ) != iHttpUri->Length() - 1 )
+        {
+        iUriBuffer->InsertL( position, KXCAPPathSeparator );
+        position = position + KXCAPPathSeparator().Length();
+        }
+    iUriBuffer->InsertL( position, KXCAPNodeSeparator ); //"~~"
+    position = position + KXCAPNodeSeparator().Length();
+    iUriBuffer->InsertL( position, pointer );            
+    position = position + pointer.Length();
+    iUriBuffer->InsertL( position, KXCAPPathSeparator );
+    position = position + KXCAPPathSeparator().Length();
+    return position;
+    }
+
+
+
+// ---------------------------------------------------------
+// CXcapUriParser::SetDocumentSubset
+//
+// ---------------------------------------------------------
+//
+void CXcapUriParser::SetDocumentSubset( const CXdmDocumentNode* aDocumentSubset )
+    {
+    #ifdef _DEBUG
+        iOperationFactory.WriteToLog( _L8( "CXcapUriParser::SetDocumentSubset() - Type: %d" ),
+                                            aDocumentSubset->ElementType() );  
+    #endif
+    __ASSERT_DEBUG( aDocumentSubset != NULL, User::Panic( _L( "CXcapUriParser" ), 1 ) );
+    iDocumentSubset = CONST_CAST( CXdmDocumentNode*, aDocumentSubset );
+    iNodeType = iDocumentSubset->ElementType();
+    }
+
+// ---------------------------------------------------------
+// CXcapUriParser::DesC8
+//
+// ---------------------------------------------------------
+//
+TPtrC8 CXcapUriParser::DesC8() const 
+    {
+    return iCompleteUri != NULL ? iCompleteUri->Des() : TPtrC8();
+    }
+
+// ---------------------------------------------------------
+// CXcapUriParser::NodeType
+//
+// ---------------------------------------------------------
+//
+TXdmElementType CXcapUriParser::NodeType() const 
+    {
+    return iNodeType;
+    }
+    
+#ifdef _DEBUG        
+// ---------------------------------------------------------
+// CXcapUriParser::DumpUriL
+//
+// ---------------------------------------------------------
+//
+void CXcapUriParser::DumpUriL( HBufC8* aNodePath ) 
+    {
+    RFile file;
+    RFs session;
+    TPtr8 pointer( aNodePath->Des() );
+    _LIT( KFilePath, "C:\\logs\\XDM\\Dump.txt" );
+    User::LeaveIfError( session.Connect() );
+    TInt error = file.Replace( session, KFilePath, EFileWrite );
+    if( error == KErrNone )
+        {
+        file.Write( pointer );
+        file.Close();
+        }
+    session.Close();
+    }
+#endif
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapUtils/bwinscw/XcapUtilsU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,8 @@
+EXPORTS
+	??1CXcapEarlyIms@@UAE@XZ @ 1 NONAME ; CXcapEarlyIms::~CXcapEarlyIms(void)
+	?CheckFileExistsL@XcapStaticUtils@@SAHAAVRFs@@ABVTDesC16@@@Z @ 2 NONAME ; int XcapStaticUtils::CheckFileExistsL(class RFs &, class TDesC16 const &)
+	?GenerateFileNameLC@XcapStaticUtils@@SAPAVHBufC16@@AAVRFs@@ABVTDesC16@@1@Z @ 3 NONAME ; class HBufC16 * XcapStaticUtils::GenerateFileNameLC(class RFs &, class TDesC16 const &, class TDesC16 const &)
+	?NewL@CXcapEarlyIms@@SAPAV1@XZ @ 4 NONAME ; class CXcapEarlyIms * CXcapEarlyIms::NewL(void)
+	?PublicIDL@CXcapEarlyIms@@QAE?AVTPtrC8@@XZ @ 5 NONAME ; class TPtrC8 CXcapEarlyIms::PublicIDL(void)
+	?RequestSimDataL@CXcapEarlyIms@@QAEXPAVMXcapEarlyImsObs@@@Z @ 6 NONAME ; void CXcapEarlyIms::RequestSimDataL(class MXcapEarlyImsObs *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapUtils/eabi/XcapUtilsU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,9 @@
+EXPORTS
+	_ZN13CXcapEarlyIms15RequestSimDataLEP16MXcapEarlyImsObs @ 1 NONAME
+	_ZN13CXcapEarlyIms4NewLEv @ 2 NONAME
+	_ZN13CXcapEarlyIms9PublicIDLEv @ 3 NONAME
+	_ZN15XcapStaticUtils16CheckFileExistsLER3RFsRK7TDesC16 @ 4 NONAME
+	_ZN15XcapStaticUtils18GenerateFileNameLCER3RFsRK7TDesC16S4_ @ 5 NONAME
+	_ZTI13CXcapEarlyIms @ 6 NONAME ; #<TI>#
+	_ZTV13CXcapEarlyIms @ 7 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapUtils/group/XcapUtils.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,55 @@
+/*
+* 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:  XcapUtils.dll from XcapUtils.mmp
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                  xcaputils.dll
+TARGETTYPE              dll
+UID                     0x1000008d 0x10207453
+CAPABILITY 		        CAP_GENERAL_DLL
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+
+SOURCE                  XcapEarlyIms.cpp
+SOURCE                  XcapStaticUtils.cpp
+
+//Internal
+USERINCLUDE             ../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY                 etel.lib
+LIBRARY                 bafl.lib
+LIBRARY                 efsrv.lib
+LIBRARY                 euser.lib
+LIBRARY					etelmm.lib
+LIBRARY                 commsdat.lib
+DEBUGLIBRARY            flogger.lib
+
+#if defined( ARMCC )
+    deffile ../eabi/ 
+#elif defined ( WINSCW )
+    deffile ../bwinscw/ 
+#elif defined ( WINS )
+    deffile ../bwins/  
+#endif 
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapUtils/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -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:  XcapUtils bld.inf
+*
+*/
+
+
+
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+
+XcapUtils.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapUtils/inc/XcapEarlyIms.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,170 @@
+/*
+* 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:   CXcapEarlyIms
+*
+*/
+
+
+
+
+#ifndef __XCAPEARLYIMS__
+#define __XCAPEARLYIMS__
+
+#include <etelmm.h>
+
+//COMMON CONSTANTS
+_LIT( KUtilsLogDir,                             "XDM" );
+_LIT( KUtilsLogFile,                            "XcapUtils.txt" );
+_LIT8( KXcapFakeImpu,                            "IMSI@FakeImpu.ims.3gpp.invalid" );
+const TInt KUtilsLogBufMaxSize                  = 2000;
+
+
+//For testing of EarlyIms in WINSCW
+//#define __FAKE_IMPU__
+
+//FORWARD DECLARATIONS
+class MXcapEarlyImsObs;
+class CAsyncRetrieveAuthorizationInfo;
+
+// CLASS DECLARATION
+class CXcapEarlyIms : public CActive
+
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Symbian OS default constructor.
+        * @return CXcapEarlyIms New instance
+        */     
+        IMPORT_C static CXcapEarlyIms* NewL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @return CXcapEarlyIms New instance
+        */     
+        IMPORT_C void RequestSimDataL( MXcapEarlyImsObs* aObserver );
+        
+        /**
+        * Symbian OS default constructor.
+        * @return CXcapEarlyIms New instance
+        */
+        IMPORT_C TPtrC8 PublicIDL();
+        
+        /**
+        * Destructor.
+        */      
+        IMPORT_C virtual ~CXcapEarlyIms();
+    
+    #ifdef _DEBUG
+        
+        /**
+        * Clean the log file
+        * @return void
+        */
+        void CXcapEarlyIms::DeleteLogFileL();
+        
+        /**
+        * A global logging function for 8 bit data.
+        * @param aCommand command to be handled
+        */
+        static void WriteToLog( TRefByValue<const TDesC8> aFmt,... );
+    
+    #endif //_DEBUG
+         
+    private:
+        
+        /**
+        * C++ default constructor is private.
+        */      
+        CXcapEarlyIms();
+
+        /**
+        * Symbian OS second-phase constructor.
+        * @return void
+        */     
+        void ConstructL();
+        
+        /**
+        * From CActive
+        * A request has completed
+        * @return void
+        */ 
+        void RunL();
+        
+        /**
+        * From CActive
+        * Cancel an outstanding request.
+        * @return void
+        */ 
+        void DoCancel();
+        
+        /**
+        * Get the module name
+        * @param TDes& Module name on return
+        * @return void
+        */ 
+        void ModuleNameL( TDes& aModuleName ) const;
+        
+        /**
+        * Find out the type of the SIM card
+        * and its application
+        * @return void
+        */ 
+        void SelectSimTypeL();
+        
+        /**
+        * Derive IMPU and IMPI from the values
+        * retrieved from the SIM card
+        * @return TPtrC8 User's Public ID
+        */
+        TPtrC8 DeriveL();
+           
+    private: //Data
+    
+    
+        enum TRequestPhase
+            {
+            TRequestIdle = 0,
+            TRequestAuth,
+            TRequestNetwork,
+            TRequestUsimAuth
+            };
+        
+        enum TXcapSimType
+            {
+            ESimTypeGsm = 0,
+            ESimTypeCdma,
+            ESimTypeWcdma,
+            ESimTypeUnknown
+            };
+        
+        TBool                                             iRequestComplete;
+        HBufC8*                                           iImpu;
+        HBufC8*                                           iImpi;
+        RTelServer                                        iServer;
+        RMobilePhone                                      iPhone;
+        TXcapSimType                                      iSimType;
+        TRequestPhase                                     iRequestPhase;
+        MXcapEarlyImsObs*                                 iObserver;
+        CAsyncRetrieveAuthorizationInfo*                  iRetriever;
+        RMobilePhone::CImsAuthorizationInfoV5*            iAuthData;
+        RMobilePhone::TMobilePhoneSubscriberId            iImsi;
+        RMobilePhone::TMobilePhoneNetworkCountryCode      iCountryCode;
+        RMobilePhone::TMobilePhoneNetworkIdentity         iNetworkCode;
+        TPckgBuf<RMobilePhone::TMobilePhoneNetworkInfoV1> iNetworkInfoPckg;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapUtils/inc/XcapStaticUtils.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   XcapStaticUtils
+*
+*/
+
+
+
+
+#ifndef __XCAPSTATICUTILS__
+#define __XCAPSTATICUTILS__
+
+#include <e32base.h>
+
+class RFs;
+
+// CLASS DECLARATION
+class XcapStaticUtils
+
+    {
+    public:
+        
+        /**
+        * Check whether a file already exists.
+        *
+        * @param TDesC& The file name to check
+        * @return TBool Is the file already there
+        */     
+        IMPORT_C static TBool CheckFileExistsL( RFs& aFileSession, const TDesC& aFileName );
+        
+        /**
+        * Generate a new file name unique in the context
+        * of the folder in which it resides
+        *
+        * @param TDesC& The file name to check
+        * @return TBool Is the file already there
+        */     
+        IMPORT_C static HBufC* GenerateFileNameLC( RFs& aFileSession, const TDesC& aFileName,
+                                                   const TDesC& aExtension );
+    
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapUtils/inc/XcapUtilsInterface.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* 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:   MXcapEarlyImsObs
+*
+*/
+
+
+
+
+#ifndef __XCAPUTILSINTERFACE__
+#define __XCAPUTILSINTERFACE__
+
+#include <e32base.h>
+
+// CLASS DECLARATION
+class MXcapEarlyImsObs
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * IMS parameters have been resolved.
+        * @return void
+        */     
+        virtual void RequestComplete( TInt aError ) = 0;
+        
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapUtils/src/XcapEarlyIms.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,444 @@
+/*
+* 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:   CXcapEarlyIms
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#ifdef _DEBUG
+    #include <f32file.h>  
+    #include <flogger.h>
+    #include <e32debug.h>
+#endif
+#include <cdblen.h>
+#include <commsdat.h>
+#include <metadatabase.h>
+#include <commsdattypesv1_1.h>
+#include <mmretrieve.h>
+#include "XcapEarlyIms.h"
+#include "XcapUtilsInterface.h"
+
+// ----------------------------------------------------------
+// CXcapEarlyIms::CXcapEarlyIms
+// 
+// ----------------------------------------------------------
+//
+CXcapEarlyIms::CXcapEarlyIms() : CActive( EPriorityNormal ),
+                                 iRequestComplete( EFalse ),
+                                 iSimType( ESimTypeUnknown )
+                                 
+    { 
+    }
+
+// ----------------------------------------------------------
+// CXcapEarlyIms::NewL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXcapEarlyIms* CXcapEarlyIms::NewL()
+    {
+    CXcapEarlyIms* self = new ( ELeave ) CXcapEarlyIms();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();  //self
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapEarlyIms::~CXcapEarlyIms
+// 
+// ----------------------------------------------------
+//
+CXcapEarlyIms::~CXcapEarlyIms()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapEarlyIms::~CXcapEarlyIms()" ) );
+    #endif
+    delete iImpu;
+    delete iImpi;
+    delete iAuthData;
+    delete iRetriever;
+    iPhone.Close();
+    iServer.Close();
+    }
+
+// ----------------------------------------------------------
+// CXcapEarlyIms::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapEarlyIms::ConstructL()
+    {
+    #ifdef _DEBUG
+        DeleteLogFileL();
+        WriteToLog( _L8( "CXcapEarlyIms::ConstructL()" ) );
+    #endif
+    #ifndef __FAKE_IMPU__
+        TName tsyName;
+        TInt numPhone = 0;
+        TBool found = EFalse;
+        RTelServer::TPhoneInfo phoneInfo;
+        User::LeaveIfError( iServer.Connect() );
+        TBuf<KCommsDbSvrMaxFieldLength> tsyModuleName;
+	    ModuleNameL( tsyModuleName );
+        User::LeaveIfError( iServer.LoadPhoneModule( tsyModuleName ) );
+        User::LeaveIfError( iServer.EnumeratePhones( numPhone ) );
+        for( TInt i = 0;!found && i < numPhone;i++ )
+            {
+            User::LeaveIfError( iServer.GetTsyName( i, tsyName ) );
+            User::LeaveIfError( iServer.GetPhoneInfo( i, phoneInfo ) );
+            if( tsyName.CompareF( tsyModuleName ) == 0 )
+                found = ETrue;
+            }
+        __ASSERT_ALWAYS( found, User::Leave( KErrNotFound ) );
+        User::LeaveIfError( iPhone.Open( iServer, phoneInfo.iName ) ); 
+        SelectSimTypeL();
+    #endif
+    CActiveScheduler::Add( this );    
+    } 
+
+// ----------------------------------------------------------
+// CXcapEarlyIms::RequestSimDataL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C void CXcapEarlyIms::RequestSimDataL( MXcapEarlyImsObs* aObserver )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapEarlyIms::RequestSimDataL()" ) );
+    #endif
+    #ifdef __FAKE_IMPU__
+        iStatus = KRequestPending;
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrNone );
+        SetActive();
+    #else
+        if( !IsActive() )
+		    {
+		    TUint32 caps( 0 );    
+            User::LeaveIfError( iPhone.GetIdentityCaps( caps ) );
+            if( !( caps & RMobilePhone::KCapsGetSubscriberId ) )
+	  	        User::Leave( KErrNotSupported );
+            iPhone.GetSubscriberId( iStatus, iImsi );
+            iRequestPhase = TRequestAuth;
+            iRequestComplete = EFalse;
+		    SetActive(); 
+    	    }
+    #endif 
+    iObserver = aObserver;   
+    }
+
+// ----------------------------------------------------------
+// CXcapEarlyIms::PublicIDL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TPtrC8 CXcapEarlyIms::PublicIDL()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapEarlyIms::PublicIDL()" ) );
+    #endif
+    #ifdef __FAKE_IMPU__
+        return KXcapFakeImpu();
+    #else
+        if( iRequestComplete && iRequestPhase == TRequestIdle )
+            {
+            switch( iSimType )
+                {
+                case ESimTypeWcdma:
+                    return iAuthData->iIMPUArray[0]; 
+                case ESimTypeGsm:
+                    return DeriveL();
+                default:
+                    return TPtrC8();
+                }
+            }
+        else return TPtrC8(); 
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXcapEarlyIms::DeriveL
+// 
+// ----------------------------------------------------------
+//
+TPtrC8 CXcapEarlyIms::DeriveL()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapEarlyIms::DeriveL()" ) );
+    #endif
+    _LIT8( KImsMnc,       "ims.mnc" );
+    _LIT8( KMcc,          ".mcc" );
+    _LIT8( K3gppnetwork,  ".3gppnetwork.org");
+    _LIT8( KAt,           "@");
+    _LIT8( KSip,          "sip:");
+    _LIT8( KZero,         "0");
+    TPtrC networkDesc( iNetworkInfoPckg().iNetworkId );
+    TPtrC countryDesc( iNetworkInfoPckg().iCountryCode );
+    TInt nwlength = networkDesc.Length() + countryDesc.Length();
+    if( networkDesc.Length() == 2 )
+        nwlength = nwlength + 1;
+    //private user identity
+    TInt impiLength = iImsi.Length() + KAt().Length() + KImsMnc().Length() +
+                      nwlength + KMcc().Length() + K3gppnetwork().Length();   
+    iImpi = HBufC8::NewL( impiLength );
+	TPtr8 impiDesc( iImpi->Des() );
+	impiDesc.Append( iImsi );
+	impiDesc.Append( KAt );
+	impiDesc.Append( KImsMnc );
+	if( networkDesc.Length() == 2 )
+    	impiDesc.Append( KZero );
+	impiDesc.Append( networkDesc );	
+	impiDesc.Append( KMcc );	
+	impiDesc.Append( countryDesc );
+	impiDesc.Append( K3gppnetwork );
+    //public user identity
+    TInt impuLength = KSip().Length() + impiDesc.Length();
+    iImpu = HBufC8::NewL( impuLength );
+    TPtr8 impuDesc( iImpu->Des() );
+    impuDesc.Append( KSip );
+	impuDesc.Append( impiDesc );
+	#ifdef _DEBUG
+        WriteToLog( _L8( "  IMPI: %S" ), &impiDesc );
+        WriteToLog( _L8( "  IMPU: %S" ), &impuDesc );
+    #endif
+    return impuDesc;  
+    }
+
+// ----------------------------------------------------------
+// CXcapEarlyIms::SelectSimTypeL
+// 
+// ----------------------------------------------------------
+//
+void CXcapEarlyIms::SelectSimTypeL()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapEarlyIms::SelectSimTypeL()" ) );
+    #endif
+	TUint32 caps;
+	User::LeaveIfError( iPhone.GetIccAccessCaps( caps ) );
+	if( caps & RMobilePhone::KCapsSimAccessSupported )
+		{
+		if( caps & RMobilePhone::KCapsUSimAccessSupported )
+		    {			
+		    #ifdef _DEBUG
+                WriteToLog( _L8( "  USIM Card" ) );
+            #endif
+		    iSimType = ESimTypeWcdma;
+		    }
+		else
+		    {
+		    #ifdef _DEBUG
+                WriteToLog( _L8( "  2G SIM Card" ) );
+            #endif
+		    iSimType = ESimTypeGsm;
+		    }
+		}
+    else
+        {
+        #ifdef _DEBUG
+            WriteToLog( _L8( "  No SIM Card" ) );
+        #endif
+        iSimType = ESimTypeUnknown;
+        }
+    }
+		    
+// ----------------------------------------------------------
+// CXcapEarlyIms::RunL
+// 
+// ----------------------------------------------------------
+//
+void CXcapEarlyIms::RunL()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapEarlyIms::RunL()" ) );
+        WriteToLog( _L8( "  Status:        %d" ), iStatus.Int() );
+        WriteToLog( _L8( "  Request phase: %d" ), iRequestPhase );
+    #endif
+    #ifdef __FAKE_IMPU__
+        iObserver->RequestComplete( KErrNone );
+    #else
+        if( iStatus.Int() == KErrNone )
+            {
+            switch( iRequestPhase )
+                {
+                case TRequestIdle:
+                    break; 
+                case TRequestAuth:
+                    {
+                    #ifdef _DEBUG
+                        HBufC8* buf = HBufC8::NewLC( iImsi.Length() );
+                        TPtr8 desc( buf->Des() );
+                        desc.Copy( iImsi );
+                        WriteToLog( _L8( "  IMSI retrieved: %S" ), &desc );
+                        CleanupStack::PopAndDestroy();  //buf
+                    #endif
+                    iPhone.GetHomeNetwork( iStatus, iNetworkInfoPckg );
+                    iRequestPhase = TRequestNetwork;
+                    SetActive(); 
+                    }
+                    break;
+                case TRequestNetwork:
+                    {
+                    #ifdef _DEBUG
+                        HBufC8* nwid = HBufC8::NewLC( iNetworkInfoPckg().iNetworkId.Length() );
+                        HBufC8* country = HBufC8::NewLC( iNetworkInfoPckg().iCountryCode.Length() );
+                        TPtr8 desc1( nwid->Des() );
+                        TPtr8 desc2( country->Des() );
+                        desc1.Copy( iNetworkInfoPckg().iNetworkId );
+                        desc2.Copy( iNetworkInfoPckg().iCountryCode );
+                        WriteToLog( _L8( "  Home network info retrieved" ) );
+                        WriteToLog( _L8( "    Network ID:   %S" ), &desc1 );
+                        WriteToLog( _L8( "    Country code: %S" ), &desc2  );
+                        CleanupStack::PopAndDestroy( 2 );  //country, nwid
+                    #endif
+                    if( iSimType == ESimTypeWcdma )
+                        {
+    	                iAuthData = RMobilePhone::CImsAuthorizationInfoV5::NewL();
+            	        iRetriever = CAsyncRetrieveAuthorizationInfo::NewL( iPhone, *iAuthData );
+                        iRequestPhase = TRequestUsimAuth;
+	    	            iRetriever->Start( iStatus );
+	        	        SetActive();
+                        }
+                    else
+                        {
+                        #ifdef _DEBUG
+                            WriteToLog( _L8( "  Request complete" ) );
+                        #endif
+                        iObserver->RequestComplete( KErrNone );
+                        iRequestPhase = TRequestIdle;
+                        iRequestComplete = ETrue;
+                        }
+                    }
+                    break;
+                case TRequestUsimAuth:
+                    {
+                    #ifdef _DEBUG
+                        RMobilePhone::TAuthorizationDataSource source(
+                            iAuthData->iAuthenticationDataSource );
+                        TBuf8<4> sourceDesc( source == RMobilePhone::EFromUSIM
+                            ? _L8( "USIM" ) : _L8( "ISIM" ) );  
+                        WriteToLog( _L8( "  USIM auth retrieved" ) );
+                        WriteToLog( _L8( "    IMPI:           %S" ), &iAuthData->iIMPI );
+                        WriteToLog( _L8( "    IMPU:           %S" ), &iAuthData->iIMPUArray[0] );
+                        WriteToLog( _L8( "    Domain:         %S" ), &iAuthData->iHomeNetworkDomainName );
+                        WriteToLog( _L8( "    AuthDataSource: %S" ), &sourceDesc );
+                    #endif
+                    iObserver->RequestComplete( KErrNone );
+                    iRequestPhase = TRequestIdle;
+                    iRequestComplete = ETrue;
+                    }
+                    break;
+                default:
+                    break;
+                }
+            }
+        else iObserver->RequestComplete( iStatus.Int() );
+    #endif
+    }
+    
+// ----------------------------------------------------------
+// CXcapEarlyIms::DoCancel
+// 
+// ----------------------------------------------------------
+//
+void CXcapEarlyIms::DoCancel()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapEarlyIms::DoCancel() - State: %d" ), iRequestPhase );
+    #endif
+    switch( iRequestPhase )
+        {
+        case TRequestIdle:
+            break; 
+        case TRequestAuth:
+            iPhone.CancelAsyncRequest( EMobilePhoneGetSubscriberId );
+            break;
+        case TRequestNetwork:
+            iPhone.CancelAsyncRequest( EMobilePhoneGetHomeNetwork );
+            break;
+        case TRequestUsimAuth:
+            delete iRetriever;
+            iRetriever = NULL;
+            break;
+        default:
+            break;
+        }
+    }
+
+// ----------------------------------------------------------
+// CXcapEarlyIms::ModuleNameL
+// 
+// ----------------------------------------------------------
+//
+void CXcapEarlyIms::ModuleNameL( TDes& aModuleName ) const
+    {
+    __ASSERT_ALWAYS( aModuleName.MaxSize() >= KCommsDbSvrMaxFieldLength, User::Leave( KErrArgument ) );
+    using namespace CommsDat;
+    CMDBSession* db = CMDBSession::NewLC( KCDLatestVersion );
+    CMDBField<TUint32>* field = new ( ELeave ) CMDBField<TUint32>( KCDTIdModemPhoneServicesSMS );
+    CleanupStack::PushL( field );
+    field->SetRecordId( 1 );
+    field->LoadL( *db );
+    TUint32 modemId = *field;
+    CMDBField<TDesC>* tsyField = new ( ELeave ) CMDBField<TDesC>( KCDTIdTsyName );
+    CleanupStack::PushL( tsyField );
+    tsyField->SetRecordId( modemId );
+    tsyField->LoadL( *db );
+    aModuleName = *tsyField;
+    CleanupStack::PopAndDestroy( 3 ); //tsyField, field, db
+    }
+ 
+#ifdef _DEBUG              
+// ----------------------------------------------------
+// CXcapEarlyIms::WriteToLog
+//
+// ----------------------------------------------------
+//
+void CXcapEarlyIms::WriteToLog( TRefByValue<const TDesC8> aFmt,... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf8<KUtilsLogBufMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    RFileLogger::Write( KUtilsLogDir, KUtilsLogFile, EFileLoggingModeAppend, buf );
+    }
+
+// ----------------------------------------------------------
+// CXcapEarlyIms::DeleteLogFileL
+// 
+// ----------------------------------------------------------
+//
+void CXcapEarlyIms::DeleteLogFileL()
+    {
+    RFs session;
+    TBuf<32> log( _L( "C:\\logs\\XDM\\" ) );
+    User::LeaveIfError( session.Connect() );
+    CFileMan* manager = CFileMan::NewL( session );
+    log.Append( KUtilsLogFile );
+    manager->Delete( log );
+    session.Close();
+    delete manager;
+    manager = NULL;
+    }
+#endif  //_DEBUG
+      
+
+
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/XcapUtils/src/XcapStaticUtils.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,76 @@
+/*
+* 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:   XcapStaticUtils
+*
+*/
+
+
+
+
+#include <f32file.h>  
+#include "XcapStaticUtils.h"
+
+// ----------------------------------------------------------
+// XcapStaticUtils::CheckFileExistsL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TBool XcapStaticUtils::CheckFileExistsL( RFs& aFileSession, const TDesC& aFileName )
+    {
+    TBool found = EFalse;
+    CDir* directory = NULL;
+    const TInt KBackSlash = 92;
+    TInt index = aFileName.LocateReverse( KBackSlash );
+    TPtrC dir( aFileName.Left( index + 1 ) );
+    TPtrC name( aFileName.Right( aFileName.Length() - index - 1 ) );
+    User::LeaveIfError( aFileSession.GetDir( dir, KEntryAttNormal, ESortNone, directory ) );
+    CleanupStack::PushL( directory );
+    const TInt count = directory->Count();
+    for( TInt i = 0;!found && i < count;i++ )
+        {
+        if( name.CompareF( ( *directory )[i].iName ) == 0 )
+            found = ETrue;
+        }
+	CleanupStack::PopAndDestroy();  //directory
+    return found;
+    }
+
+// ----------------------------------------------------------
+// XcapStaticUtils::GenerateFileNameLC
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C HBufC* XcapStaticUtils::GenerateFileNameLC( RFs& aFileSession, const TDesC& aFileName,
+                                                     const TDesC& aExtension )
+    {
+    TBuf<KMaxFileName> name;
+    name.Copy( aFileName );
+    name.Append( aExtension );
+    TBool exists = XcapStaticUtils::CheckFileExistsL( aFileSession, name );
+    for( TInt i = 1;exists;i++ )
+        {
+        name.Zero();
+        name.Copy( aFileName );
+        name.AppendNum( i );
+        name.Append( aExtension );
+        exists = XcapStaticUtils::CheckFileExistsL( aFileSession, name );
+        }
+    return name.AllocLC();
+    }
+      
+
+
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/bwinscw/XcapProtocolU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,22 @@
+EXPORTS
+        ?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+	??1CXcapDocumentNode@@UAE@XZ @ 2 NONAME ; CXcapDocumentNode::~CXcapDocumentNode(void)
+	??1CXdmNamespace@@UAE@XZ @ 3 NONAME ; CXdmNamespace::~CXdmNamespace(void)
+	?ApplicationUsage@CXcapDocument@@QBEAAVCXcapAppUsage@@XZ @ 4 NONAME ; class CXcapAppUsage & CXcapDocument::ApplicationUsage(void) const
+	?Cache@CXcapProtocol@@QAEPAVRXcapCache@@XZ @ 5 NONAME ; class RXcapCache * CXcapProtocol::Cache(void)
+	?DataLength@CXcapDocument@@QBEHXZ @ 6 NONAME ; int CXcapDocument::DataLength(void) const
+	?ETag@CXcapDocument@@QAEAAVTDesC8@@XZ @ 7 NONAME ; class TDesC8 & CXcapDocument::ETag(void)
+	?IsNetworkAvailable@CXcapProtocol@@QAEHXZ @ 8 NONAME ; int CXcapProtocol::IsNetworkAvailable(void)
+	?NewL@CXdmNamespace@@SAPAV1@ABVTDesC8@@0@Z @ 9 NONAME ; class CXdmNamespace * CXdmNamespace::NewL(class TDesC8 const &, class TDesC8 const &)
+	?Parser@CXcapProtocol@@QAEAAVCXdmXmlParser@@XZ @ 10 NONAME ; class CXdmXmlParser & CXcapProtocol::Parser(void)
+	?Prefix@CXdmNamespace@@QBE?AVTPtrC8@@XZ @ 11 NONAME ; class TPtrC8 CXdmNamespace::Prefix(void) const
+	?Protocol@CXcapDocument@@QBEAAVCXcapProtocol@@XZ @ 12 NONAME ; class CXcapProtocol & CXcapDocument::Protocol(void) const
+	?PublicID@CXcapProtocol@@QAE?AVTPtrC8@@XZ @ 13 NONAME ; class TPtrC8 CXcapProtocol::PublicID(void)
+	?RemoveData@CXcapDocument@@QAEXPAVCXcapDocumentNode@@@Z @ 14 NONAME ; void CXcapDocument::RemoveData(class CXcapDocumentNode *)
+	?ResetSubset@CXcapDocument@@UAEXXZ @ 15 NONAME ; void CXcapDocument::ResetSubset(void)
+	?SetETag@CXcapDocument@@QAEXABVTDesC8@@@Z @ 16 NONAME ; void CXcapDocument::SetETag(class TDesC8 const &)
+	?TempCopyL@CXcapDocument@@QAEPAV1@XZ @ 17 NONAME ; class CXcapDocument * CXcapDocument::TempCopyL(void)
+	?Transport@CXcapProtocol@@QAEAAVCXcapHttpTransport@@XZ @ 18 NONAME ; class CXcapHttpTransport & CXcapProtocol::Transport(void)
+	?Uri@CXdmNamespace@@QBE?AVTPtrC8@@XZ @ 19 NONAME ; class TPtrC8 CXdmNamespace::Uri(void) const
+	
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/eabi/XcapProtocolU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,30 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+	_ZN13CXcapDocument10RemoveDataEP17CXcapDocumentNode @ 2 NONAME
+	_ZN13CXcapDocument11ResetSubsetEv @ 3 NONAME
+	_ZN13CXcapDocument4ETagEv @ 4 NONAME
+	_ZN13CXcapDocument7SetETagERK6TDesC8 @ 5 NONAME
+	_ZN13CXcapDocument9TempCopyLEv @ 6 NONAME
+	_ZN13CXcapProtocol18IsNetworkAvailableEv @ 7 NONAME
+	_ZN13CXcapProtocol5CacheEv @ 8 NONAME
+	_ZN13CXcapProtocol6ParserEv @ 9 NONAME
+	_ZN13CXcapProtocol8PublicIDEv @ 10 NONAME
+	_ZN13CXcapProtocol9TransportEv @ 11 NONAME
+	_ZN13CXdmNamespace4NewLERK6TDesC8S2_ @ 12 NONAME
+	_ZN13CXdmNamespaceD0Ev @ 13 NONAME
+	_ZN13CXdmNamespaceD1Ev @ 14 NONAME
+	_ZN13CXdmNamespaceD2Ev @ 15 NONAME
+	_ZN17CXcapDocumentNodeD0Ev @ 16 NONAME
+	_ZN17CXcapDocumentNodeD1Ev @ 17 NONAME
+	_ZN17CXcapDocumentNodeD2Ev @ 18 NONAME
+	_ZNK13CXcapDocument10DataLengthEv @ 19 NONAME
+	_ZNK13CXcapDocument16ApplicationUsageEv @ 20 NONAME
+	_ZNK13CXcapDocument8ProtocolEv @ 21 NONAME
+	_ZNK13CXdmNamespace3UriEv @ 22 NONAME
+	_ZNK13CXdmNamespace6PrefixEv @ 23 NONAME
+	_ZTI13CXcapDocument @ 24 NONAME ; #<TI>#
+	_ZTI13CXcapProtocol @ 25 NONAME ; #<TI>#
+	_ZTV13CXcapDocument @ 26 NONAME ; #<VT>#
+	_ZTV13CXcapProtocol @ 27 NONAME ; #<VT>#
+	
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/group/XcapProtocol.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,87 @@
+/*
+* 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: XdmProtocol.dll from XdmProtocol.mmp
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                          xcapprotocol.dll
+UID                             0x10009D8D 0x1020740F
+CAPABILITY                      CAP_ECOM_PLUGIN
+VENDORID                        VID_DEFAULT
+TARGETTYPE                      PLUGIN
+
+SOURCEPATH                      ../src
+
+START RESOURCE                  1020740F.rss
+
+TARGET                          xcapprotocol.rsc                                                                
+ 
+END
+
+SOURCE                          XcapProtocol.cpp
+SOURCE                          XcapDocument.cpp
+SOURCE                          XcapDirectory.cpp
+SOURCE                          XcapDocumentNode.cpp
+SOURCE                          XcapNodeAttribute.cpp
+
+//Sources common to all protocols
+SOURCEPATH                      ../../src
+SOURCE                          XdmNamespace.cpp
+SOURCE                          XdmShutdownTimer.cpp
+
+//Internal XCAP includes
+USERINCLUDE                     ../XcapUtils/inc
+USERINCLUDE                     ../XcapCache/inc
+USERINCLUDE                     ../XcapAppUsage/inc
+USERINCLUDE                     ../XcapOperations/inc
+USERINCLUDE                     ../XcapHttpTransport/inc
+
+//Common XDM includes
+USERINCLUDE                     ../inc
+USERINCLUDE                     ../../inc
+USERINCLUDE                     ../../XdmXmlParser/inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE                   /epoc32/include/xml
+SYSTEMINCLUDE                   /epoc32/include/ecom
+SYSTEMINCLUDE                   ../../../inc
+
+LIBRARY                         hal.lib
+LIBRARY                         ecom.lib
+LIBRARY                         efsrv.lib
+LIBRARY                         euser.lib
+LIBRARY                         charconv.lib
+LIBRARY                         xdmengine.lib
+LIBRARY                         xdmxmlparser.lib
+LIBRARY                         xdmsettingsapi.lib
+LIBRARY                         msgconnmanager.lib
+LIBRARY                         xcapcacheclient.lib
+LIBRARY                         xcaphttptransport.lib
+LIBRARY                         xcaputils.lib
+DEBUGLIBRARY                    flogger.lib
+
+
+#if defined( ARMCC )
+DEFFILE ../eabi/ 
+#elif defined ( WINSCW )
+deffile ../bwinscw/ 
+#elif defined (WINS )
+deffile ../bwins/ 
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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:  XcapProtocol bld.inf
+*
+*/
+
+
+
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+XcapProtocol.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/inc/XcapDirectory.h	Wed Sep 01 12:23:14 2010 +0100
@@ -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: CXcapDirectory
+*
+*/
+
+
+
+
+#ifndef __XCAPDIRECTORY__
+#define __XCAPDIRECTORY__
+
+#include <e32base.h>
+#include "XdmDirectory.h"
+#include "XdmDocument.h"
+
+//CONSTANTS
+_LIT( KDirectoryEntry,                     "entry" );
+_LIT( KAuidAttribute,                      "auid" );
+_LIT( KDocumentUri,                        "uri" );
+_LIT( KDocumentETag,                       "etag" );
+
+//AUIDs
+_LIT( KCapabilities,            "/services/org.openmobilealliance.xcap-caps/" );
+_LIT( KPocRules,                "/services/org.openmobilealliance.poc-rules" );
+_LIT( KPocGroup,                "/services/org.openmobilealliance.poc-groups" );
+_LIT( KResourceLists,           "/services/org.openmobilealliance.resource-lists/" );
+_LIT( KPresenceRules,           "/services/org.openmobilealliance.pres-rules/" );
+_LIT( KDirectoryUsage,          "/services/org.openmobilealliance.xcap-directory/" );
+_LIT( KSharedXDMS,              "/services/org.openmobilealliance.resource-lists/" );
+_LIT( KRlsServices,             "/services/org.openmobilealliance.rls-services/" );
+
+//FORWARD DECLARATIONS
+class CXdmDocument;
+class CXcapProtocol;
+class CXcapRetrieval;
+class CXcapHttpReqGet;
+class CXcapOperationFactory;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapDirectory ) : public CXdmDirectory
+    {
+    public:
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CXcapDirectory* NewL( const TDesC& aAUID,
+                                     CXdmEngine& aXdmEngine,
+                                     CXdmDocument*& aDirectoryDoc,
+                                     CXcapProtocol& aXcapProtocol );
+
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void CancelUpdate();
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapDirectory();
+    
+    private: //From CXdmDirectory
+        
+        /**
+        * Destructor.
+        */
+        TInt DocumentCount();
+        
+        /**
+        * Return the root element of this document
+        */
+        TPtrC Document( TInt aIndex ) const;
+
+        /**
+        * Returns the path to this directory
+        *
+		* @return TPtrC8 The path to the directory this object models 
+        */
+        TPtrC DirectoryPath() const;
+        
+        /**
+        * Returns the path to this directory
+        *
+		* @return TPtrC8 The path to the directory this object models 
+        */
+        TXdmDocType DocumentTypeL( TInt aIndex ) const;
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CXcapDirectory( CXdmDocument*& aDirectoryDoc,
+                        CXdmEngine& aXdmEngine,
+                        CXcapProtocol& aXcapProtocol );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL( const TDesC& aAUID );
+        
+        /**
+        * From CActive.
+        * @return void
+        */
+		void RunL();
+
+        /**
+        * From CActive.
+        * @return void
+        */
+		void DoCancel();
+		
+		/**
+        * From CXdmDirectory.
+        * @return void
+        */
+        void StartUpdateL();
+        
+        /**
+        * Save the client's request status and update status
+        * @param TDirUpdatePhase The update phase
+        * @param TRequestStatus The client's request status
+		* @return void 
+        */
+        void SaveRequestData( TDirUpdatePhase aUpdatePhase,
+                              TRequestStatus& aClientStatus );
+        
+        /**
+        * From CXdmDirectory.
+        * @return void
+        */                 
+        void HandleDocumentListRequestL();
+        
+        /**
+        * From CXdmDirectory.
+        * @return void
+        */
+        void HandleRefreshRequestL();
+        
+        /**
+        * From CXdmDirectory.
+        * @return void
+        */
+        void UpdateNextDocumentL();
+        
+        /**
+        * From CXdmDirectory.
+        * @return void
+        */
+        TBool CheckLocalCopyL( const CXdmDocumentNode* aDocumentNode );
+        
+        /**
+        * From CXdmDirectory.
+        * @return void
+        */
+        TPtrC ExtractDocumentUriL( const TDesC8& aRootUri,
+                                   const CXdmDocumentNode* aDocumentNode );
+        
+        /**
+        * From CXdmDirectory.
+        * @return void
+        */                          
+        TXdmDocType FindAUID( const CXdmDocumentNode& aEntryNode ) const;
+        
+    private:  //Data
+        
+        TInt                            iUpdateIndex;
+        TInt                            iDocumentCount;
+        HBufC*                          iAUID;
+        CXcapDocument*                  iDirectoryDoc;
+        TRequestStatus*                 iClientStatus;
+        TDirUpdatePhase                 iUpdatePhase;
+        CXcapHttpReqGet*                iHttpRetrieval;
+        CXcapProtocol&                  iXcapProtocol;
+        RPointerArray<CXdmDocumentNode> iUpdateList;
+        RPointerArray<CXdmDocumentNode> iDocumentList;
+    };
+
+#endif      //__XCAPDIRECTORY__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/inc/XcapDocument.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,440 @@
+/*
+* 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: CXcapDocument
+*
+*/
+
+
+
+
+#ifndef __XCAPDOCUMENT__
+#define __XCAPDOCUMENT__
+
+#include <e32base.h>
+#include <XdmDocument.h>
+
+//CONSTANTS
+const TUint KETagBufferMaxLength                       = 64;
+_LIT8( KSlash,                                         "/" );
+_LIT8( KUserDirName,                                   "users/" );
+_LIT8( KGlobalDirName,                                 "global/" );
+_LIT8( KXcapGlobalDocName,                             "index" );
+
+//FORWARD DECLARATIONS
+class RXcapCache;
+class CXdmEngine;
+class CXdmNamespace;
+class CXcapProtocol;
+class CXcapAppUsage;
+class MXdmOperation;
+class CXcapDocumentNode;
+class CXdmOperationFactory;
+
+//CLASS DECLARATION
+class CXcapDocument : public CXdmDocument
+    {
+    public:
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CXcapDocument* NewL( TXdmDocType aDocumentType,
+                                    const TDesC& aDocumentName,
+                                    const CXdmEngine& aXdmEngine,
+                                    const CXcapProtocol& aXcapProtocol );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CXcapDocument* NewL( TXdmDocType aDocumentType,
+                                    const TDesC8& aDocumentName,
+                                    const CXdmEngine& aXdmEngine,
+                                    const CXcapProtocol& aXcapProtocol );
+        
+        /**
+        * Set one option
+        * @return void
+        * @param The completed update operation
+        */
+        void SetOption( TInt aOption );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */                         
+        TXdmDocType DocumentType() const;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */  
+        void NotifyResolverCompleteL( TInt aError );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void StartInternalL( TRequestStatus& aStatus );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void CancelUpdate(); 
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapDocument();
+    
+    public:  //Exported methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C TDesC8& ETag();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C void SetETag( const TDesC8& aETagDesc );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C TInt DataLength() const;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C CXcapAppUsage& ApplicationUsage() const;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C CXcapDocument* TempCopyL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C void RemoveData( CXcapDocumentNode* aDocumentNode );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        IMPORT_C CXcapProtocol& Protocol() const;
+        
+        /**
+        * Reset the document subset
+        */
+        IMPORT_C virtual void ResetSubset();
+        
+    private:  //From CXdmDocument
+        
+        /**
+        * Construct an "anonymous" entry point for this document.
+        * This node effectively becomes the root of this document.
+        * 
+        */
+        CXdmDocumentNode* CreateRootL();
+
+        /**
+        * Return the time stamp for this document
+        *
+		* @return TTime 
+        */
+        TTime TimeStamp() const;
+        
+        /**
+        * Return an error document for a failed update
+        * 
+        * NOTE: The returning object will be NULL in case
+        *       the used protocol does not support this feature.
+        *
+		* @return CXdmDocument* The error document
+        */
+        CXdmDocumentNode* ErrorRoot();
+              
+        /*
+        * Reset the contents of this document model.
+        */
+        void ResetContents();
+        
+    public:  //From CXdmDocument
+    
+        /**
+        * Return the root element of this document
+        *
+        * @return CXdmDocumentNode The root element of the document
+        *
+        * NOTE: The returning node may or may not contain any data,
+        *       since, in the case that this document model does not
+        *       have content yet, the element is a simple "entry point"
+        *       to the whole document. Thus, for instance, if the client
+        *       application requests the Xdm Engine to fetch a particular
+        *       document, the root element points to nothing until the 
+        *       request has been completed.
+        *         
+        */
+        CXdmDocumentNode* DocumentRoot() const;
+        
+    private:  //From MXdmNamespaceContainer
+        
+        /**
+        * Return the number of namespace declarations
+        * @return TInt Namespace declaration count
+        */
+        TInt Count() const;
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        void AppendNamespaceL( const TDesC8& aUri, const TDesC8& aPrefix );
+        
+        /**
+        * Remove a namespace from the document
+        * @param TDesC8& URI of the namespace
+        * @param TDesC8& Prefix of the namespace
+        */
+        void RemoveNamespace( const TDesC8& aUri );
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        TPtrC8 Uri( const TDesC8& aPrefix ) const;
+        
+        /**
+        * Fetch the aIndex-th URI
+        * @param TInt The index of the desired URI string
+        * @return TPtrC URI string
+        */
+        TPtrC8 Uri( TInt aIndex ) const;
+        
+        /**
+        * Fetch the aIndex-th prefix
+        * @param TDesC8 The index of the desired prefix string
+        * @return TPtrC Prefix string
+        */
+        TPtrC8 Prefix( TInt aIndex ) const;
+    
+        /**
+        * Resets namespaces from the document
+        *
+        * @return void
+        */
+        void ResetNamespaces();
+    
+    private:
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CXcapDocument( TXdmDocType aDocumentType,
+                       const CXdmEngine& aXdmEngine,
+                       const CXcapProtocol& aXcapProtocol );
+        
+        /**
+        * From CActive.
+        * @return void
+        */
+		void RunL();
+
+        /**
+        * From CActive.
+        * @return void
+        */
+		void DoCancel();
+		
+	    /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */    
+		void InstallAppUsageL();
+		
+		/**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */    
+		void UpdateDocumentInfoL( RXcapCache* aCacheClient );
+		
+		/**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void StartUpdateL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */    
+        void SaveClientStatus( TRequestStatus& aClientStatus );
+        
+        /**
+        * Handle a failed update operation
+        * @return void
+        * @param CXdmDocOperation* The failed operation
+        */
+        void HandleErrorL();
+        
+        /**
+        * Handle a successful update operation
+        * @return void
+        * @param The completed update operation
+        */
+        void HandleRequestCompletionL();
+        
+        /**
+        * Handle a successful update operation
+        * @return void
+        * @param The completed update operation
+        */
+        void ResolveAsyncConflictL();
+        
+        /**
+        * Handle a successful update operation
+        * @return void
+        * @param The completed update operation
+        */
+        void CreateTempCopyL();
+        
+        /**
+        * Handle a successful update operation
+        * @return void
+        * @param The completed update operation
+        */
+        void ActivateOperationL();
+        
+        /**
+        * Handle a successful update operation
+        * @return void
+        * @param The completed update operation
+        */
+        void CheckOperationQueueL();
+        
+        /**
+        * Handle a successful update operation
+        * @return void
+        * @param The completed update operation
+        */
+        void DequeueOperation( MXdmOperation* aOperation );
+        
+        /**
+        * Handle a successful update operation
+        * @return void
+        * @param The completed update operation
+        */
+        void DequeueAll();
+        
+        /**
+        * Append an element to the path identifying the 
+        * the current document subset
+        * @return void
+        */
+        void AppendPathPartL( const TDesC& aString );
+        
+        /**
+        * Return the current document subset (including descendants)
+        * @return void
+        */
+        CXdmDocumentNode* CurrentExtent() const;
+
+        /**
+        * Handle a successful update operation
+        * @return void
+        * @param The completed update operation
+        */                            
+        HBufC8* EightBitNameLC();                                       
+        
+        /**
+        * Handle a successful update operation
+        * @return void
+        * @param The completed update operation
+        */    
+        TBool IsGlobalTree( const TDesC8& aAuid );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL( const TDesC8& aDocumentName );
+        
+    private:  //Data
+
+        enum TXcapDocumentState
+            {
+            EXdmDocIdle = 0,
+            EXdmDocUpdating,
+            EResolvingAsyncConflict,
+            ERetryingFailedOperation
+            };
+        
+        TInt                                    iDataLength;
+        TInt                                    iUpdateIndex;
+        TInt                                    iOperationCount;
+        TUint                                   iOptions;
+        TTime                                   iLastAccess;
+        TTime                                   iLastModification;
+        HBufC8*                                 iEightBitName;
+        TXdmDocType                             iDocumentType;
+        CXcapDocument*                          iTempCopy;
+        CXcapAppUsage*                          iAppUsage;
+        CXcapDocumentNode*                      iDocumentRoot;
+        CXdmDocumentNode*                       iErrorRoot;
+        TXcapDocumentState                      iDocumentState;
+        CXcapProtocol&                          iXcapProtocol;
+        TBuf8<KETagBufferMaxLength>             iETagBuffer;
+        RPointerArray<CXdmNamespace>            iNamespaces;
+    };
+
+#endif      //__XCAPDOCUMENT__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/inc/XcapDocumentNode.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,219 @@
+/*
+* 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: CXcapDocumentNode
+*
+*/
+
+
+
+
+#ifndef __XCAPDOCUMENTNODE__
+#define __XCAPDOCUMENTNODE__
+
+#include "XdmNodeFactory.h"
+#include "XdmDocumentNode.h"
+
+class CXdmEngine;
+class CXcapProtocol;
+class CXcapProtocol;
+class CXdmNodeAttribute;
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapDocumentNode ) : public CXdmDocumentNode, public MXdmNodeFactory
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CXcapDocumentNode();
+
+    public: // New functions
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param TDesC8& Name of the new element 
+		* @return CXdmDocumentNode* 
+        */
+        static CXcapDocumentNode* NewL( CXdmEngine& aXdmEngine,
+                                        CXcapProtocol& aXcapProtocol );
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param TDesC8& Name of the new element 
+		* @return CXdmDocumentNode* 
+        */
+        static CXcapDocumentNode* NewL( CXdmEngine& aXdmEngine,
+                                        const TDesC& aNodeName,
+                                        CXcapProtocol& aXcapProtocol );
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param TDesC8& Name of the new element 
+		* @return CXdmDocumentNode* 
+        */
+        static CXcapDocumentNode* NewL( CXdmEngine& aXdmEngine,
+                                        CXcapProtocol& aXcapProtocol,
+                                        const CXdmDocumentNode& aAnotherNode,
+                                        const CXdmDocumentNode& aParentNode );
+        
+        /**
+        * Two-phased constructor.
+		*
+        * @param TDesC8& Name of the new element
+        * @param CXdmDocumentNode* The parent of the new node
+		* @return CXdmDocumentNode* 
+        */
+        static CXcapDocumentNode* NewL( CXdmEngine& aXdmEngine,
+                                        const TDesC& aNodeName,
+                                        CXcapProtocol& aXcapProtocol,
+                                        CXdmDocumentNode* aParentNode );
+
+        /**
+        * Two-phased constructor.
+		*
+        * @param TBool Leaf node indicator
+        * @param TDesC8& Name of the new element
+        * @param CXdmDocumentNode* The parent of the new node
+		* @return CXdmDocumentNode* 
+        */
+        static CXcapDocumentNode* NewL( CXdmEngine& aXdmEngine, TBool aLeafNode,
+                                        const TDesC& aNodeName, CXcapProtocol& aXcapProtocol,
+                                        CXdmDocumentNode* aParentNode );
+                                       
+        /**
+        * Two-phased constructor.
+		*
+        * @param TBool Leaf node indicator
+        * @param TDesC8& Name of the new element
+        * @param CXdmDocumentNode* The parent of the new node
+		* @return CXdmDocumentNode* 
+        */
+        static CXcapDocumentNode* NewL( CXdmEngine& aXdmEngine,
+                                        const TBool aLeafNode,
+                                        CXcapProtocol& aXcapProtocol,
+                                        CXdmDocumentNode* aParentNode );
+        
+        /**
+        * Set the next node in the list
+        * @param The next node in the list
+		* @return void 
+        */
+        void RemoveNode( CXcapDocumentNode* aChileNode );
+                                               
+    private:
+
+         /**
+        * C++ constructor, private version.
+        */
+        CXcapDocumentNode( CXdmEngine& aXdmEngine,
+                           CXcapProtocol& aXcapProtocol );
+
+        /**
+        * C++ constructor, protected version.
+        *
+        * @param CXdmDocumentNode* The parent node of this element
+        */
+		CXcapDocumentNode( CXdmEngine& aXdmEngine,
+		                   CXcapProtocol& aXcapProtocol,
+		                   CXdmDocumentNode* aParentNode );
+		      
+        /**
+        * C++ constructor, another private version.
+        */
+		CXcapDocumentNode( const TBool aLeafNode,
+		                   CXdmEngine& aXdmEngine,
+		                   CXcapProtocol& aXcapProtocol,
+                           CXdmDocumentNode* aParentNode );
+		
+		/**
+        * By default Symbian OS constructor is private.
+        *
+        * @param TDesC8& Name of this node
+        * @return void
+        */
+		void CopyConstructL( const CXdmDocumentNode& aAnotherNode,
+		                     const CXdmDocumentNode& aParentNode );
+         
+    private:  //From MXdmNodeFactory
+                     
+        /**
+        * Create a new child element
+        *
+        * @param TDesC8& Name of the new element
+		* @return CXdmDocumentNode* 
+        */
+        CXdmDocumentNode* ChileNodeL();
+        
+        /**
+        * Create a new child element
+        *
+        * @param TDesC8& Name of the new element
+		* @return CXdmDocumentNode* 
+        */
+        CXdmDocumentNode* ChileNodeL( const TDesC& aChildName );
+        
+        /**
+        * Create a new child element
+        *
+        * @param TDesC8& Name of the new element
+		* @return CXdmDocumentNode* 
+        */
+        CXdmDocumentNode* ChileNodeL( const CXdmDocumentNode* aAnotherNode  );
+        
+        /**
+        * Create a new attribute
+        *
+        * @param TDesC8& Name of the new attribute
+		* @return CXdmNodeAttribute* 
+        */
+        CXdmNodeAttribute* AttributeL();
+        
+        /**
+        * Create a new attribute
+        *
+        * @param TDesC8& Name of the new attribute
+		* @return CXdmNodeAttribute* 
+        */
+        CXdmNodeAttribute* AttributeL( const TDesC& aAttributeName );
+        
+    private:  //From MXdmNodeInterface                          
+
+        /**
+        * Two-phased constructor.
+		*
+        * @param TDesC& Namespace prefix string
+		* @return void 
+        */
+        void SetPrefixL( const TDesC8& aNamespace );
+        
+        /**
+        * Returns the namespace string for this element
+		*
+		* @return TPtrC Namespace string of this element 
+        */
+        TPtrC8 Prefix() const;
+    
+    private:
+        
+        HBufC8*                                     iPrefix;
+        CXcapProtocol&                              iXcapProtocol;
+    };
+
+#endif      //__XCAPDOCUMENTNODE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/inc/XcapEngineDefines.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: XcapEngine literals
+*
+*/
+
+
+
+
+#ifndef __XCAPENGINEDEFINES__
+#define __XCAPENGINEDEFINES__
+
+#include <e32base.h>
+
+//Xdm specific defines 
+const TInt KXcapPathSeparatorChar                      = 47;
+
+//XCAP specific defines
+_LIT8( KXCAPEquality,                                  "="  );
+_LIT8( KXCAPNodeSeparator,                             "~~" );
+_LIT8( KXCAPPathSeparator,                             "/"  );
+_LIT8( KXCAPAttributeIdentifier,                       "@"  );
+_LIT8( KHTTPBracketOpen,                               "[");
+_LIT8( KHTTPBracketClose,                              "]");
+_LIT8( KHTTPQuotationMark,                             "\"");
+
+//Escape coded HTTP specific defines
+_LIT8( KHTTPBracketOpenEsc,                            "%5b");
+_LIT8( KHTTPBracketCloseEsc,                           "%5d");
+_LIT8( KHTTPQuotationMarkEsc,                          "%22");
+
+//XML specific defines
+_LIT8( KXmlSpace,                                      " ");
+#endif    //__XCAPENGINEDEFINES__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/inc/XcapNodeAttribute.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,123 @@
+/*
+* 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:  CXcapNodeAttribute
+*
+*/
+
+
+
+
+#ifndef __XCAPNODEATTRIBUTE__
+#define __XCAPNODEATTRIBUTE__
+
+#include "XdmNodeAttribute.h"
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( CXcapNodeAttribute ) : public CXdmNodeAttribute
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        *
+        * @param TDesC8& Name of this attribute
+        * @param CXdmDocumentNode* Parent of this attribute
+        * 
+        * NOTE! "Parent", in this case, denotes the 
+        *        element this attribute attributes.
+        *
+		* @return CXdmNodeAttribute* 
+        */
+        static CXcapNodeAttribute* NewL( CXdmEngine& aXdmEngine,
+                                         const TDesC& aAttributeName,
+                                         CXdmDocumentNode* aParentNode );
+                                        
+        /**
+        * Two-phased constructor.
+        *
+        * @param CXdmDocumentNode* Parent of this attribute
+        * 
+        * NOTE! "Parent", in this case, denotes the 
+        *        element this attribute attributes.
+        *
+		* @return CXdmNodeAttribute* 
+        */
+        static CXcapNodeAttribute* NewL( CXdmEngine& aXdmEngine,
+                                         CXdmDocumentNode* aParentNode );                                        
+
+        /**
+        * Destructor.
+        */
+        virtual ~CXcapNodeAttribute();
+
+    public: // New functions
+    
+        
+                                               
+    private:
+
+        /**
+        * C++ constructor, private version.
+        */
+        CXcapNodeAttribute( CXdmEngine& aXdmEngine );
+
+        /**
+        * C++ constructor, protected version.
+        *
+        * @param CXdmDocumentNode* The parent node of this element
+        */
+		CXcapNodeAttribute( CXdmEngine& aXdmEngine, CXdmDocumentNode* aParentNode );
+        
+        /**
+        * By default Symbian OS constructor is private.
+        *
+        * @param TDesC8& Name of this node
+        * @return void
+        */
+		void ConstructL( const TDesC& aNodeName );
+        
+        /**
+        * C++ constructor, another private version.
+        */
+		CXcapNodeAttribute( const TBool aLeafNode,
+		                    CXdmEngine& aXdmEngine,
+                            CXdmDocumentNode* aParentNode );
+        
+    private:  //From MXdmNodeInterface
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        TPtrC8 Prefix() const;
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        void SetPrefixL( const TDesC& aNamespacePrefix );
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        void SetPrefixL( const TDesC8& aNamespacePrefix );                   
+                            
+         
+    private:
+    };
+
+#endif      //__XCAPNODEATTRIBUTE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/inc/XcapProtocol.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,337 @@
+/*
+* 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:  CXcapProtocol
+*
+*/
+
+
+
+
+#ifndef __XCAPPROTOCOL__
+#define __XCAPPROTOCOL__
+
+#include <e32base.h>
+#include <XdmEngine.h>
+#include <msgbearerobscallback.h>
+#include "XcapCache.h"
+#include "XdmProtocol.h"
+#include "XdmShutdownSwitch.h"
+#include "XcapUtilsInterface.h"
+
+enum TXcapAuthType
+    {
+    EXcapAuthGaa = 0,
+    EXcapAuthEarlyIms,
+    EXcapAuthHttpDigest
+    };
+    
+//CONSTANTS
+_LIT( KHttp,                                    "http://" );
+_LIT( KHttps,                                   "https://" );
+_LIT( KHostSeparator,                           "/" );
+_LIT( KXcapEngLogDir,                           "XDM" );
+_LIT( KXcapEngLogFile,                          "XcapProtocol" );
+const TInt KXcapEngLogBufferMaxSize		        = 2000;
+
+//FORWARD DECLARATIONS
+class CXdmLogWriter;
+class CXcapDocument;
+class CXdmXmlParser;
+class CXcapEarlyIms;
+class MMsgConnManager;
+class CXdmShutdownTimer;
+class CXcapHttpTransport;
+class CXdmOperationFactory;
+class CXdmSettingsCollection;
+
+//CLASS DECLARATION
+class CXcapProtocol : public CXdmProtocol,
+                      public MXcapEarlyImsObs,
+                      public MXdmShutdownSwitch,
+                      public MMsgBearerObsCallback
+    {
+    
+    public:
+                
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        IMPORT_C TPtrC8 PublicID();
+        
+        /**
+        * Return a pointer to the cache client interface
+        * @return RXcapCache* Pointer to the cache interface
+        */
+        IMPORT_C RXcapCache* Cache();
+           
+        /**
+        * Return a reference to the XML Parser
+        * @return CXdmXmlParser& Reference to XML Parser
+        */
+        IMPORT_C CXdmXmlParser& Parser();
+        
+        /**
+        * Return a reference to the XML Parser
+        * @return CXdmXmlParser& Reference to XML Parser
+        */
+        IMPORT_C CXcapHttpTransport& Transport();
+                   
+        /**
+        * Check whether network is available
+        * @return TBool Is network available
+        */
+        IMPORT_C TBool IsNetworkAvailable();
+        
+    public:     //Not exported
+        
+        /**
+        * Check whether there are requests being carried out
+        * and start the idle timer if appropriate
+        *
+        * @return void
+        */ 
+        void CheckActivity();
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        TPtrC8 UserName() const;
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        TXcapAuthType AuthType() const;
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        TBool IsSimRequestPending( TInt& aError ) const;
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        void AppendNotifyeeL( CXcapDocument* aPendingDoc );
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        void CancelImsResolver();
+        
+        /**
+        * Logging function
+        * @param TRefByValue<const TDesC8> aFmt,...
+        * @return void
+        */ 
+        void WriteToLog( TRefByValue<const TDesC8> aFmt,... ) const;
+   
+    private:  //From CXdmProtocol
+   
+        /**
+        * Initialise the media used to transfer Xdm data
+        */
+        void InitTransferMedium( TInt aIdleTimeout, TRequestStatus& aStatus );
+                                
+        /**
+        * Cancel initialisation of the transfer media.
+        */
+        void CancelTransferMediumInit();
+        
+        /**
+        * Cancel initialisation of the transfer media.
+        */
+        TBool IsTransferAvailable() const;
+        
+        /**
+        * Create a new document node.
+        */
+        CXdmDocumentNode* CreateDocumentNodeL();
+        
+        /**
+        * Create a new protocol dependent document model
+        */
+        CXdmDocument* CreateDocumentL( const TDesC& aDocumentName,
+                                       const TXdmDocType aDocumentType );
+        
+        /**
+        * Create a new protocol dependent document model
+        */
+        CXdmDirectory* CreateDirectoryL( const TDesC& aDirectoryPath );
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CXcapProtocol();
+        
+    private:
+    
+        /**
+        * From MXdmShutdownSwitch
+        * @return void
+        */ 
+        void SwitchOff();
+        
+		/**
+        * From MXcapEarlyImsObs.
+        * @param TInt Error
+        * @return void
+        */
+		void RequestComplete( TInt aError );
+
+    public:  //Static
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        static CXcapProtocol* NewL( const TXdmProtocolParams& aProtocolInfo );
+        
+        /**
+        * A Global logging function
+        * @param TRefByValue<const TDesC8> aFmt,...
+        * @return void
+        */ 
+        static TInt GenerateUniqueIdL();
+
+    private:  //Methods
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        CXcapProtocol();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void ConstructL( const TXdmProtocolParams& aProtocolParams );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        void DeleteLogFileL();
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        TInt SaveSettingsL();
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        void SaveFromCollectionL( const CXdmSettingsCollection& aSettings );
+        
+        /**
+        * Return an operation object that knows how to manipulate
+        * partial document
+        */
+        void ResolveIdentityL();
+        
+        /**
+        * Select the type of the authentication 
+        */
+        void SelectAuthTypeL( const CXdmSettingsCollection& aSettings );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        RXcapCache* CacheHandle();
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */  
+        TPtrC8 Impu() const;
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        HBufC* ParseRootLocationLC( const TBool aSecurity,
+                                    const TDesC& aRootLocation );
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        HBufC* CheckProtocolPrefixL( const TDesC& aRootLocation );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        HBufC* ConstructSecureUriL( const TDesC& aBasicUri );
+        
+        /**
+        * Symbian OS default constructor.
+        * @param TInt Default Access Point ID
+        * @return CXdmDocOperation*
+        */     
+        HBufC* ConstructStandardUriL( const TDesC& aBasicUri );
+        
+        /**
+        * Handle a bearer event
+        * @param TMsgBearerEvent The type of the event
+        */
+        void HandleBearerEventL( TBool aAuthoritativeClose,
+                                 TMsgBearerEvent aBearerEvent );
+
+    private:  //Data
+        
+        TInt                                     iIdleTimeout;
+        TInt                                     iAccessPoint;
+        TInt                                     iImsResolverError;
+        TBool                                    iSuspend;
+        TBool                                    iCacheUsage;
+        TBool                                    iTransferMediaOpen;
+        TBool                                    iSimRequestPending;
+        HBufC*                                   iRootUri;
+        HBufC8*                                  iPublicId;
+        RXcapCache                               iCacheClient;
+        CXdmEngine*                              iXdmEngine;
+        CXdmDocument*                            iCapabilities;
+        CXdmLogWriter*                           iLogWriter;
+        TXcapAuthType                            iAuthType;
+        CXdmXmlParser*                           iXmlParser;
+        CXcapEarlyIms*                           iImsResolver;
+        TXdmCredentials                          iCredentials;
+        MMsgConnManager*                         iConnectionManager;
+        CXdmShutdownTimer*                       iIdleTimer;
+        CXcapHttpTransport*                      iHttpTransport;
+        const CXdmProtocolInfo*                  iProtocolInfo;
+        TBuf8<KXdmMaxUserNameLength>             iUserName;
+        RPointerArray<CXcapDocument>             iNotifyeeQueue;
+    };
+
+#endif      //__XCAPPROTOCOL__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/inc/XcapUriInterface.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* 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: MXcapUriInterface
+*
+*/
+
+
+
+
+#ifndef __XCAPURIINTERFACE__
+#define __XCAPURIINTERFACE__
+
+#include <e32base.h>
+
+//CLASS DECLARATION
+NONSHARABLE_CLASS( MXcapUriInterface )
+    {
+    public:
+        
+        /**
+        * Add new namespace mapping
+        * @param TDesC8& Namespace URI
+        * @param TDesC8& Namespace prefix
+        * @return void
+        */      
+        virtual void AddNamespaceMappingL( const TDesC8& aUri, const TDesC8& aPrefix ) = 0; 
+    };
+    
+    
+
+#endif      //__XCAPURIINTERFACE__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/src/1020740F.rss	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: XdmProtocolInfo
+*
+*/
+
+
+// 1020740F.RSS
+//
+#include "registryinfo.rh"
+
+//Declares the interface implementations provided
+RESOURCE REGISTRY_INFO XdmProtocolInfo
+	{
+	dll_uid = 0x1020740F;
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x10207422;
+			implementations = 
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x10207423;
+					version_no = 1;
+					display_name = "XDM Engine XCAP Protocol||Copyright © 2005 Nokia Ltd. All rights reserved.";
+					default_data = "";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/src/XcapDirectory.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,501 @@
+/*
+* 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: CXcapDirectory
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <utf.h>
+#include <f32file.h>
+#include "XcapAppUsageDef.h"
+#include "XdmProtocol.h"
+#include "XcapDocument.h"
+#include "XcapProtocol.h"
+#include "XcapAppUsage.h"
+#include "XcapRetrieval.h"
+#include "XcapDirectory.h"
+#include "XdmXmlParser.h"
+#include "XcapHttpReqGet.h"
+#include "XdmDocumentNode.h"
+#include "XdmNodeAttribute.h"
+#include "XcapHttpTransport.h"
+#include "XdmOperationFactory.h"
+
+// ----------------------------------------------------------
+// CXcapDirectory::CXcapDirectory
+// 
+// ----------------------------------------------------------
+//
+CXcapDirectory::CXcapDirectory( CXdmDocument*& aDirectoryDoc,
+                                CXdmEngine& aXdmEngine,
+                                CXcapProtocol& aXcapProtocol ) :
+                                CXdmDirectory( aXdmEngine ),
+                                iDirectoryDoc( ( CXcapDocument* )aDirectoryDoc ),
+                                iXcapProtocol( aXcapProtocol )                                             
+    { 
+    }
+
+// ----------------------------------------------------------
+// CXcapDirectory::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapDirectory* CXcapDirectory::NewL( const TDesC& aAUID,
+                                      CXdmEngine& aXdmEngine,
+                                      CXdmDocument*& aDirectoryDoc,
+                                      CXcapProtocol& aXcapProtocol )
+    {
+    CXcapDirectory* self = new ( ELeave ) CXcapDirectory( aDirectoryDoc, aXdmEngine, aXcapProtocol );
+    CleanupStack::PushL( self );
+    self->ConstructL( aAUID );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------
+// CXcapDirectory::~CXcapDirectory
+// 
+// ----------------------------------------------------
+//
+CXcapDirectory::~CXcapDirectory()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDirectory::~CXcapDirectory()" ) );
+    #endif
+    Cancel();
+    delete iAUID;
+    delete iDirectoryDoc;
+    delete iHttpRetrieval;
+    iUpdateList.Close();
+    iDocumentList.Close();
+    }
+    
+// ----------------------------------------------------------
+// CXcapDirectory::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapDirectory::ConstructL( const TDesC& aAUID )
+    {
+    if( aAUID.Length() > 0 )
+        {
+        _LIT( KNodePath,    "xcap-directory/folder" );
+        iAUID = HBufC::NewL( aAUID.Length() );
+        iAUID->Des().Copy( aAUID );
+        CXdmDocumentNode* node = iDirectoryDoc->DocumentSubsetL( KNodePath );
+        CleanupStack::PushL( node );
+        CXdmNodeAttribute* auid = node->CreateAttributeL( KAuidAttribute );
+        CleanupStack::PushL( auid );
+        auid->SetAttributeValueL( aAUID );
+        iDirectoryDoc->FetchDataL( node );
+        //Set the option that prohibits caching
+        iDirectoryDoc->SetOption( KXdmOption3 );
+        CleanupStack::Pop( 2 );  //auid, node
+        }
+    else iDirectoryDoc->FetchDataL();
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------
+// CXcapDirectory::StartUpdateL
+// 
+// ----------------------------------------------------------
+//
+void CXcapDirectory::StartUpdateL()
+    
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDirectory::StartUpdateL()" ) );
+    #endif
+    switch( iUpdatePhase )
+        {
+        case EDirPhaseIdle:
+            User::RequestComplete( iClientStatus, KErrArgument );
+            break;
+        case EUpdateDocumentList:
+            HandleDocumentListRequestL();
+            break;
+        case ERefreshDocuments:
+            HandleRefreshRequestL();
+            break;
+        default:
+            break;
+        } 
+    }
+
+// ----------------------------------------------------------
+// CXcapDirectory::SaveRequestData
+// 
+// ----------------------------------------------------------
+//
+void CXcapDirectory::SaveRequestData( TDirUpdatePhase aUpdatePhase,
+                                      TRequestStatus& aClientStatus )
+    {
+    iUpdatePhase = aUpdatePhase;
+    iClientStatus = &aClientStatus;
+    }
+    
+// ----------------------------------------------------
+// CXcapDirectory::HandleDocumentListRequestL
+// 
+// ----------------------------------------------------
+//
+void CXcapDirectory::HandleDocumentListRequestL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDirectory::HandleDocumentListRequestL()" ) );
+    #endif
+    if( !IsActive() )
+        {
+        CXcapDocument* doc = ( CXcapDocument* )iDirectoryDoc;
+        doc->StartInternalL( iStatus );
+        iUpdatePhase = EUpdateDocumentList;
+        SetActive();
+        }
+    }
+    
+// ----------------------------------------------------
+// CXcapDirectory::HandleRefreshRequestL
+// 
+// ----------------------------------------------------
+//
+void CXcapDirectory::HandleRefreshRequestL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDirectory::HandleRefreshRequestL()" ) );
+    #endif
+    if( iUpdatePhase == EUpdateDocumentList )
+        {
+        if( iUpdateList.Count() > 0 )
+            {
+            iUpdateIndex = -1;
+            iHttpRetrieval = iXcapProtocol.Transport().GetL( TPtrC() );
+            UpdateNextDocumentL();
+            iUpdatePhase = ERefreshDocuments;
+            }
+        else
+            {
+            #ifdef _DEBUG
+                iXcapProtocol.WriteToLog( _L8( "  All documents are up to date" ) );
+            #endif
+            User::RequestComplete( iClientStatus, KErrNone );
+            }
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( "  Wrong state [%d]" ), iUpdatePhase );
+        #endif
+        User::RequestComplete( iClientStatus, KErrNotReady );
+        }
+    }
+
+// ----------------------------------------------------
+// CXcapDirectory::UpdateNextDocumentL
+// 
+// ----------------------------------------------------
+//
+void CXcapDirectory::UpdateNextDocumentL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDirectory::UpdateNextDocumentL()" ) );
+    #endif
+    iUpdateIndex++;
+    if( iUpdateIndex < iUpdateList.Count() )
+        {
+        CXdmDocumentNode* node = iUpdateList[iUpdateIndex];
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( "  Index: %d  Document: %x" ), iUpdateIndex, node );
+        #endif
+        TPtrC8 root = iXcapProtocol.Transport().RootUri();
+        TPtrC docUri( ExtractDocumentUriL( root, node ) );
+        HBufC* uri = HBufC::NewLC( root.Length() + docUri.Length() );
+        uri->Des().Copy( root );
+        uri->Des().Append( docUri );
+        iHttpRetrieval->ResetUriL( uri->Des() );
+        iHttpRetrieval->SetExpiryTimeL( NULL, KDefaultHttpRequestTimeout * 1000000 );
+        iHttpRetrieval->DispatchRequestL( iStatus );
+        CleanupStack::PopAndDestroy();  //uri
+        SetActive();
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( "  Directory sync complete" ) );
+        #endif
+        User::RequestComplete( iClientStatus, KErrNone );
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapDirectory::RunL()
+// 
+// ---------------------------------------------------------
+//
+void CXcapDirectory::RunL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDirectory::RunL() - Request: %d" ), iStatus.Int() );
+    #endif
+    if( iStatus == KErrNone )
+        {
+        switch( iUpdatePhase )
+            {
+            case EUpdateDocumentList:
+                {
+                iDocumentCount = iDirectoryDoc->Find( KDirectoryEntry, iDocumentList );
+                if( iDocumentCount > 0 )
+                    {
+                    TInt index = 0;
+                    while( index < iDocumentCount )
+                        {
+                        TBool uptodate = CheckLocalCopyL( iDocumentList[index] );
+                        #ifdef _DEBUG
+                            iXcapProtocol.WriteToLog( _L8( "  Cache: %d" ), uptodate );
+                        #endif
+                        if( !uptodate )
+                            User::LeaveIfError( iUpdateList.Append( iDocumentList[index] ) );
+                        index++;
+                        }
+                    }
+                User::RequestComplete( iClientStatus, iStatus.Int() );
+                }
+                break;
+            case ERefreshDocuments:
+                {
+                CXdmDocumentNode* node = iUpdateList[iUpdateIndex];
+                #ifdef _DEBUG
+                    iXcapProtocol.WriteToLog( _L8( "  Index:    %d" ), iUpdateIndex );
+                    iXcapProtocol.WriteToLog( _L8( "  Document: %x" ), node );
+                    iXcapProtocol.WriteToLog( _L8( "  Error:    %d" ), iStatus.Int() );
+                #endif
+                TPtrC8 root = iXcapProtocol.Transport().RootUri();
+                TPtrC docName = ExtractDocumentUriL( root, node );
+                TXdmCompletionData* data = iHttpRetrieval->ResponseData();
+                TPtrC8 responseData( data->iResponseData->Des() );
+                TPtrC8 eTag( data->iETag->Des() );
+                RXcapCache* cache = iXcapProtocol.Cache();
+                cache->Store( eTag, docName, root, responseData  );
+                iHttpRetrieval->ReleaseResponseData();
+                UpdateNextDocumentL();
+                }
+                break;
+            default:
+                #ifdef _DEBUG
+                    iXcapProtocol.WriteToLog( _L8( "  Default case, unknown state %d - Status: %d" ),
+                                               iUpdatePhase, iStatus.Int() );
+                #endif
+                if( iClientStatus != NULL )
+                    User::RequestComplete( iClientStatus, KErrUnknown );  
+                break;
+            }   
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( "  Operation failed with %d" ), iStatus.Int() );
+        #endif
+        User::RequestComplete( iClientStatus, iStatus.Int() );
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapDirectory::CheckLocalCopyL
+// 
+// ---------------------------------------------------------
+//
+TBool CXcapDirectory::CheckLocalCopyL( const CXdmDocumentNode* aDocumentNode )
+    {
+    /*#ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDirectory::CheckLocalCopyL()" ) );
+    #endif*/
+    TBool ret = EFalse;
+    TPtrC8 root = iXcapProtocol.Transport().RootUri();
+    TPtrC docName = ExtractDocumentUriL( root, aDocumentNode );
+    TPtrC etag( aDocumentNode->Attribute( KDocumentETag )->AttributeValue() );
+    HBufC8* etag8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( etag );
+    CleanupStack::PushL( etag8 );
+    RXcapCache* cache = iXcapProtocol.Cache();
+    ret = cache != NULL ? cache->IsCurrent( etag8->Des(), docName, root ) == KErrNone : ETrue;
+    CleanupStack::PopAndDestroy();  //etag8
+    return ret;
+    }
+
+// ---------------------------------------------------------
+// CXcapDirectory::ExtractDocumentUriL
+// 
+// ---------------------------------------------------------
+//
+TPtrC CXcapDirectory::ExtractDocumentUriL( const TDesC8& aRootUri,
+                                           const CXdmDocumentNode* aDocumentNode )
+    {
+    /*#ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDirectory::ExtractDocumentUri()" ) );
+    #endif*/
+    const TUint8 KHttpHostSeparator = 47;
+    _LIT8( KHttpDoubleHostSeparator,  "//" );
+    TPtrC uri( aDocumentNode->Attribute( KDocumentUri )->AttributeValue() );
+    if( uri[0] == KHttpHostSeparator ) //Relative URI
+        return uri;
+    else
+        {
+        TInt index = aRootUri.Find( KHttpDoubleHostSeparator );
+        TPtrC8 root( aRootUri.Right( aRootUri.Length() - index - 2 ) );
+        HBufC8* uri8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( uri );
+        CleanupStack::PushL( uri8 );
+        TPtr8 desc( uri8->Des() );
+        index = desc.Find( root );
+        CleanupStack::PopAndDestroy();  //uri8
+        return index >= 0 ? uri.Right( uri.Length() - root.Length() - index ) : TPtrC();
+        }
+    }
+
+// ----------------------------------------------------
+// CXcapDirectory::DocumentCount
+// 
+// ----------------------------------------------------
+//
+TInt CXcapDirectory::DocumentCount()
+    {
+    return iDocumentCount;
+    }
+
+// ----------------------------------------------------
+// CXcapDirectory::DocumentType
+// 
+// ----------------------------------------------------
+//
+TXdmDocType CXcapDirectory::DocumentTypeL( TInt aIndex ) const
+    {
+    TXdmDocType type = EXdmDocGeneral;
+    if( iUpdatePhase <= EDirPhaseIdle )
+        User::Leave( KErrNotReady );
+    else if( iDocumentCount > 0 && ( aIndex >= 0 && aIndex < iDocumentCount ) )
+        type = FindAUID( *iDocumentList[aIndex] );
+    return type;
+    } 
+
+// ----------------------------------------------------
+// CXcapDirectory::FindAUID
+// 
+// ----------------------------------------------------
+//
+TXdmDocType CXcapDirectory::FindAUID( const CXdmDocumentNode& aEntryNode ) const
+    {
+    TXdmDocType documentType = EXdmDocGeneral;
+    HBufC8* buf = aEntryNode.Attribute( KDocumentUri )->EightBitValueLC();
+    if( buf )
+        {
+        TPtrC8 uri( buf->Des() );
+        if( uri.Find( KXdmCapabilityUsageAUID ) >= 0 )
+            documentType = EXdmCapabilities;
+        else if( uri.Find( KXdmPocUserAccessUsageAUID ) >= 0 )
+            documentType = EXdmPoCUserAccessPolicy;
+        else if( uri.Find( KXdmPocGroupUsageAUID ) >= 0 )
+            documentType = EXdmPoCGroup;
+        else if( uri.Find( KXdmResourceListsUsageAUID ) >= 0 )
+            documentType = EXdmResourceLists;
+        else if( uri.Find( KXdmOmaPresRulesUsageAUID ) >= 0 )
+            documentType = EXdmIetfPresenceRules;
+        else if( uri.Find( KXdmDirectoryUsageAUID ) >= 0 )
+            documentType = EXdmDirectory;
+        else if( uri.Find( KXdmSharedXDMUsageAUID ) >= 0 )
+            documentType = EXdmSharedXdm;
+        else if( uri.Find( KXdmRlsServicesUsageAUID ) >= 0 )
+            documentType = EXdmRlsServices;
+        CleanupStack::PopAndDestroy();  //EightBitValueLC()
+        }
+    return documentType;
+    }
+                 
+// ----------------------------------------------------
+// CXcapDirectory::Document
+// 
+// ----------------------------------------------------
+//
+TPtrC CXcapDirectory::Document( TInt aIndex ) const
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDirectory::Document() - Index: %d" ), aIndex );
+    #endif
+    TChar slash = 47;
+    if( aIndex >= 0 && aIndex < iDocumentList.Count() ) 
+        {
+        TPtrC ret;
+        TPtrC uri = iDocumentList[aIndex]->Attribute( KDocumentUri )->AttributeValue();
+        TInt index = uri.LocateReverse( slash );
+        index > 0 ? ret.Set( uri.Right( uri.Length() - index - 1 ) ) : ret.Set( uri );
+        return ret;
+        }
+    else return TPtrC();
+    }
+        
+// ----------------------------------------------------
+// CXcapDirectory::DirectoryPath
+// 
+// ----------------------------------------------------
+//
+TPtrC CXcapDirectory::DirectoryPath() const
+    {
+    return iAUID != NULL ? iAUID->Des() : TPtrC();
+    }
+
+// ----------------------------------------------------
+// CXcapDirectory::CancelUpdate
+// 
+// ----------------------------------------------------
+//
+void CXcapDirectory::CancelUpdate()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDirectory::CancelUpdate()" ) );
+    #endif
+    Cancel();
+    }
+    
+// ---------------------------------------------------------
+// CXcapDirectory::DoCancel
+// 
+// ---------------------------------------------------------
+//
+void CXcapDirectory::DoCancel()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDirectory::DoCancel()" ) );
+    #endif
+    switch( iUpdatePhase )
+        {
+        case EDirPhaseIdle:
+            break;
+        case EUpdateDocumentList:
+            {
+            CXcapDocument* doc = ( CXcapDocument* )iDirectoryDoc;
+            doc->CancelUpdate();
+            }
+            break;
+        case ERefreshDocuments:
+            iHttpRetrieval->CancelRequest();
+            break;
+        default:
+            break;
+        }
+    User::RequestComplete( iClientStatus, KErrCancel );
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/src/XcapDocument.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,1097 @@
+/*
+* 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: CXcapDocument
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <XdmErrors.h>
+#include "XdmOperationFactory.h"
+#include "XcapProtocol.h"
+#include "XcapDocument.h"
+#include "XcapAppUsage.h"
+#include "XdmXmlParser.h"
+#include "XdmNamespace.h"
+#include "CommonDefines.h"
+#include "XcapDocumentNode.h"
+#include "XcapHttpRequest.h"
+#include "XcapHttpOperation.h"
+#include "XcapHttpTransport.h"
+
+// ================= MEMBER FUNCTIONS =======================
+//
+
+
+// ----------------------------------------------------------
+// CXcapDocument::CXcapDocument
+// 
+// ----------------------------------------------------------
+//
+CXcapDocument::CXcapDocument( TXdmDocType aDocumentType,
+                              const CXdmEngine& aXdmEngine,
+                              const CXcapProtocol& aXcapProtocol ) :
+                              CXdmDocument( CONST_CAST( CXdmEngine&, aXdmEngine ) ),
+                              iDocumentType( aDocumentType ),
+                              iXcapProtocol( CONST_CAST( CXcapProtocol&, aXcapProtocol ) )
+                                                
+    { 
+    }
+
+// ----------------------------------------------------------
+// CXcapDocument::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapDocument* CXcapDocument::NewL( TXdmDocType aDocumentType,
+                                    const TDesC& aDocumentName,
+                                    const CXdmEngine& aXdmEngine,
+                                    const CXcapProtocol& aXcapProtocol )
+    {
+    CXcapDocument* self = new ( ELeave ) CXcapDocument( aDocumentType, aXdmEngine, aXcapProtocol );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( KXcapOperationFactory, aDocumentName );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapDocument::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapDocument* CXcapDocument::NewL( TXdmDocType aDocumentType,
+                                    const TDesC8& aDocumentName,
+                                    const CXdmEngine& aXdmEngine,
+                                    const CXcapProtocol& aXcapProtocol )
+    {
+    CXcapDocument* self = new ( ELeave ) CXcapDocument( aDocumentType, aXdmEngine, aXcapProtocol );
+    CleanupStack::PushL( self );
+    self->ConstructL( aDocumentName );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapDocument::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapDocument::ConstructL( const TDesC8& aDocumentName )
+    {
+    BaseConstructL( KXcapOperationFactory, aDocumentName );
+    ConstructL();
+    }
+    
+// ----------------------------------------------------------
+// CXcapDocument::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapDocument::ConstructL()
+    {
+    InstallAppUsageL();
+    iErrorRoot = CXcapDocumentNode::NewL( iXdmEngine, iXcapProtocol );
+    TPtrC8 root( iXcapProtocol.Transport().RootUri() );
+    #ifdef _DEBUG
+        HBufC8* buf = HBufC8::NewLC( iDocumentName->Des().Length() );
+        buf->Des().Copy( iDocumentName->Des() );
+        TPtr8 nameDesc( buf->Des() );
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::ConstructL()" ) );
+        iXcapProtocol.WriteToLog( _L8( "  Root URI:   %S" ), &root );
+        iXcapProtocol.WriteToLog( _L8( "  Document:   %S" ), &nameDesc );
+        CleanupStack::PopAndDestroy();  //buf
+    #endif
+    RXcapCache* cache = iXcapProtocol.Cache();
+    if( cache )
+        UpdateDocumentInfoL( cache );
+    else
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( "  Cache disabled, no info for the document" ) );
+        #endif
+        }
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::~CXcapDocument
+// 
+// ----------------------------------------------------
+//
+CXcapDocument::~CXcapDocument()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::~CXcapDocument()" ) );
+    #endif
+    Cancel();
+    delete iTempCopy;
+    delete iEightBitName;
+    delete iDocumentRoot;
+    delete iErrorRoot;
+    delete iAppUsage;
+    iNamespaces.ResetAndDestroy();
+    iNamespaces.Close();
+    }
+
+// ----------------------------------------------------------
+// CXcapDocument::ResetContents
+// 
+// ----------------------------------------------------------
+//
+void CXcapDocument::ResetContents()
+    {
+    iOptions = 0;
+    delete iDocumentRoot;
+    iDocumentRoot = NULL;
+    delete iErrorRoot;
+    iErrorRoot = NULL;
+    delete iTempCopy;
+    iTempCopy = NULL;
+    iNamespaces.ResetAndDestroy();
+    }
+    
+// ----------------------------------------------------------
+// CXcapDocument::UpdateDocumentInfoL
+// 
+// ----------------------------------------------------------
+//
+void CXcapDocument::UpdateDocumentInfoL( RXcapCache* aCacheClient )
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::UpdateDocumentInfo()" ) );
+    #endif
+    iETagBuffer.Zero();
+    TCacheEntryInfo cacheEntryInfo;
+    TPtrC8 root( iXcapProtocol.Transport().RootUri() );
+    TInt error = aCacheClient->FetchDocumentInfo( 
+                 iETagBuffer, iDocumentName->Des(), root, cacheEntryInfo );    
+    if( error == KErrNone )
+        {
+        iLastAccess = cacheEntryInfo.iLastAccess;
+        iLastModification = cacheEntryInfo.iLastUpdate;
+        iDataLength = cacheEntryInfo.iDataLength;
+        #ifdef _DEBUG
+            const TInt KDateTimeMaxSize = 100;
+            TBuf8<KDateTimeMaxSize> printBuffer;
+            TBuf<KDateTimeMaxSize> dateTimeBuffer;
+            _LIT( KDateTimeFormat, "%D%M%Y%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S");
+            iLastModification.FormatL( dateTimeBuffer, KDateTimeFormat );
+            printBuffer.Copy( dateTimeBuffer );
+            iXcapProtocol.WriteToLog( _L8( "  ETag:        %S" ), &iETagBuffer );
+            iXcapProtocol.WriteToLog( _L8( "  Size:        %d bytes" ), iDataLength );
+            iXcapProtocol.WriteToLog( _L8( "  Time stamp:  %S" ), &printBuffer );
+        #endif
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( "  Cache read complete - Error: %d" ), error );
+        #endif
+        }
+    }
+    
+// ----------------------------------------------------
+// CXcapDocument::InstallAppUsageL
+// 
+// ----------------------------------------------------
+//
+void CXcapDocument::InstallAppUsageL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::InstallAppUsageL()" ) );
+    #endif  
+    HBufC8* docName = NULL;
+    iAppUsage = CXcapAppUsage::NewL( iXdmEngine, iDocumentType );
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::InstallAppUsageL() type = %d" ), iDocumentType );
+    #endif  
+    TPtrC8 auid = iAppUsage->AUID();
+    if( IsGlobalTree( auid ) )
+        {
+        docName = HBufC8::NewLC( auid.Length() + KGlobalDirName().Length() + 
+                                 KXcapGlobalDocName().Length() );
+        docName->Des().Copy( auid );
+        docName->Des().Append( KGlobalDirName );
+        docName->Des().Append( KXcapGlobalDocName );
+        delete iDocumentName;
+        iDocumentName = NULL;
+        iDocumentName = HBufC::NewL( docName->Des().Length() );
+        iDocumentName->Des().Copy( docName->Des() );
+        CleanupStack::PopAndDestroy();  //docName
+        }
+    else
+        {
+        TPtrC8 user = iXcapProtocol.UserName();
+        docName = HBufC8::NewLC( auid.Length() + user.Length() + 
+                                 KUserDirName().Length() + 1 /*'/'*/ + 
+                                 iDocumentName->Des().Length() );
+        docName->Des().Copy( auid );
+        docName->Des().Append( KUserDirName );
+        docName->Des().Append( user );
+        docName->Des().Append( KSlash );
+        docName->Des().Append( iDocumentName->Des() );
+        delete iDocumentName;
+        iDocumentName = NULL;
+        iDocumentName = HBufC::NewL( docName->Des().Length() );
+        iDocumentName->Des().Copy( docName->Des() );
+        CleanupStack::PopAndDestroy();  //docName
+        }
+    
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::IsGlobalTree
+// 
+// ----------------------------------------------------
+//
+TBool CXcapDocument::IsGlobalTree( const TDesC8& aAuid )
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::IsGlobalTree()" ) );
+    #endif
+    TBool found = EFalse;
+    //Update this array when necessary
+    const TPtrC8 KGlobalTreeAuids[] = { TPtrC8( KXdmCapabilityUsageAUID ) };
+    const TInt count = sizeof( KGlobalTreeAuids ) / sizeof( KGlobalTreeAuids[0] );
+    for( TInt i = 0;!found && i < count;i++ )
+        found = aAuid.Compare( KGlobalTreeAuids[i] ) == 0;
+    return found;
+    }
+    
+// ----------------------------------------------------
+// CXcapDocument::CreateTempCopyL
+// 
+// ----------------------------------------------------
+//
+void CXcapDocument::CreateTempCopyL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::CreateTempCopyL()" ) );
+    #endif
+    CXdmDocument* copy = iXdmEngine.CreateDocumentModelL( Name(), iDocumentType );
+    iTempCopy = ( CXcapDocument* )copy;
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::TempCopyL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXcapDocument* CXcapDocument::TempCopyL()
+    {
+    return CXcapDocument::NewL( iDocumentType, Name(), iXdmEngine, iXcapProtocol );
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::CreateRootL
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CXcapDocument::CreateRootL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXdmDocument::CreateRootL()" ) );
+    #endif
+    delete iDocumentRoot;
+    iDocumentRoot = NULL;
+    iDocumentRoot = CXcapDocumentNode::NewL( iXdmEngine, iXcapProtocol );
+    return iDocumentRoot;
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::AppendPathPartL
+// 
+// ----------------------------------------------------
+//
+void CXcapDocument::AppendPathPartL( const TDesC& aString )
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::PathPartL()" ) );
+    #endif
+    if( iDocumentRoot != NULL )
+        {
+        CXdmDocumentNode* node = NULL;
+        CXdmDocumentNode* parent = iDocumentRoot;
+        while( parent->NextNode() != NULL )
+            parent = parent->NextNode();
+        node = CXcapDocumentNode::NewL( iXdmEngine, aString, iXcapProtocol, parent );
+        parent->SetNextNode( node );
+        }
+    else iDocumentRoot = CXcapDocumentNode::NewL( iXdmEngine, aString, iXcapProtocol );
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::CurrentExtent
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CXcapDocument::CurrentExtent() const
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXdmDocument::CurrentExtent()" ) );
+    #endif
+    CXdmDocumentNode* ret = NULL;
+    if( iDocumentRoot != NULL )
+        {
+        CXdmDocumentNode* node = iDocumentRoot;
+        while( node->NextNode() != NULL )
+            node = node->NextNode();
+        ret = node;
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( " This document does not yet have a root, leave with KErrGeneral" ) );
+        #endif
+        User::Leave( KErrGeneral );
+        }
+    return ret;
+    }
+    
+// ----------------------------------------------------
+// CXcapDocument::DocumentRoot
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CXcapDocument::DocumentRoot() const
+    {
+    return iDocumentRoot;
+    }     
+
+// ----------------------------------------------------
+// CXcapDocument::ErrorRoot
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CXcapDocument::ErrorRoot()
+    {
+    if( !iErrorRoot )
+        {
+        iErrorRoot = CXcapDocumentNode::NewL( iXdmEngine, iXcapProtocol );
+        }
+    return iErrorRoot;
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::ResetSubset
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXcapDocument::ResetSubset()
+    {
+    CXdmDocument::ResetSubset();
+    delete iDocumentRoot;
+    iDocumentRoot = NULL;
+    iOptions = 0;
+    }
+           
+// ----------------------------------------------------
+// CXcapDocument::ETag
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TDesC8& CXcapDocument::ETag()
+    {
+    return iETagBuffer;
+    }
+        
+// ----------------------------------------------------
+// CXcapDocument::SetETag
+// 
+// ----------------------------------------------------
+//     
+EXPORT_C void CXcapDocument::SetETag( const TDesC8& aETagDesc )
+    {
+    iETagBuffer.Zero();
+    iETagBuffer.Copy( aETagDesc );
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::SetETag()" ) );
+        iXcapProtocol.WriteToLog( _L8( "  New ETag: %S" ), &iETagBuffer );
+    #endif
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::DataLength
+// 
+// ----------------------------------------------------
+//
+EXPORT_C TInt CXcapDocument::DataLength() const
+    {
+    return iDataLength;
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::ApplicationUsage
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXcapAppUsage& CXcapDocument::ApplicationUsage() const
+    {
+    return *iAppUsage;
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::Protocol
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXcapProtocol& CXcapDocument::Protocol() const
+    {
+    return iXcapProtocol;
+    }
+    
+// ----------------------------------------------------
+// CXcapDocument::RemoveData
+// 
+// ----------------------------------------------------
+//
+EXPORT_C void CXcapDocument::RemoveData( CXcapDocumentNode* aDocumentNode )
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::RemoveData()" ) );
+    #endif
+    CXcapDocumentNode* parent = ( CXcapDocumentNode* )aDocumentNode->Parent();
+    if( parent != NULL )
+        parent->RemoveNode( aDocumentNode );
+    }
+    
+// ----------------------------------------------------
+// CXcapDocument::StartUpdateL
+// 
+// ----------------------------------------------------
+//
+void CXcapDocument::StartUpdateL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::StartUpdateL()" ) );
+    #endif
+    TInt resolverError = 0;
+    if( iXcapProtocol.IsSimRequestPending( resolverError ) )
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( "  IMS Resolver pending => add to queue" ) );
+        #endif
+        iXcapProtocol.AppendNotifyeeL( this );
+        }
+    else
+        {
+        if( resolverError == KErrNone && !IsActive() && iChangeRequests.Count() > 0 )
+            {
+            iUpdateIndex = 0;
+            iDocumentState = EXdmDocUpdating;
+            iOperationCount = iChangeRequests.Count();
+            ActivateOperationL();
+            }
+        else
+            {
+            #ifdef _DEBUG
+                iXcapProtocol.WriteToLog( _L8(
+                 "  Already active, no operations or IMS resolver failed => complete with error" ) );
+            #endif
+            TInt error = resolverError == KErrNone ? KErrNotReady : resolverError; 
+            User::RequestComplete( iClientStatus, error );
+            }
+        }
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::StartInternalL
+// 
+// ----------------------------------------------------
+//
+void CXcapDocument::StartInternalL( TRequestStatus& aStatus )
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::StartInternalL()" ) );
+    #endif
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    StartUpdateL();
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::NotifyResolverCompleteL
+// 
+// ----------------------------------------------------
+//
+void CXcapDocument::NotifyResolverCompleteL( TInt aError )
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::NotifyResolverCompleteL()" ) );
+    #endif
+    if( aError == KErrNone )
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( "  IMS Resolver ready" ) );
+        #endif
+        StartUpdateL();
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( "  IMS Resolver failed => complete with %d" ), aError );
+        #endif
+        DequeueAll();
+        User::RequestComplete( iClientStatus, aError );
+        }
+    }
+    
+// ----------------------------------------------------
+// CXcapDocument::ActivateOperationL
+// 
+// ----------------------------------------------------
+//
+void CXcapDocument::ActivateOperationL()
+    {
+    MXdmOperation* request = iChangeRequests[iUpdateIndex];
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::ActivateOperation() - Operation: %x" ), request );
+    #endif
+    if( iDocSubset )
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( " Document subset => set KXdmOption1 and KXdmOption2" ) );
+        #endif
+        SetOption( KXdmOption1 );
+        SetOption( KXdmOption2 );
+        }
+    if( iXcapProtocol.AuthType() == EXcapAuthEarlyIms )
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( " EarlyIMS is in use => set KXdmOption4" ) );
+        #endif
+        SetOption( KXdmOption4 );
+        }
+    request->ExecuteL( iStatus, iOptions );
+    SetActive();
+    }
+
+// ----------------------------------------------------
+// CXcapDocument::SetOption
+// 
+// ----------------------------------------------------
+//
+void CXcapDocument::SetOption( TInt aOption )
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::SetOption()" ) );
+    #endif
+    iOptions |= aOption;
+    }
+       
+// ----------------------------------------------------
+// CXcapDocument::CancelUpdate
+// 
+// ----------------------------------------------------
+//
+void CXcapDocument::CancelUpdate()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::CancelUpdate()" ) );
+    #endif
+    TInt resolverError = 0;
+    if( iXcapProtocol.IsSimRequestPending( resolverError ) )
+        {
+        iXcapProtocol.CancelImsResolver();
+        }
+    else
+        {
+        switch( iDocumentState )
+            {
+            case EResolvingAsyncConflict:
+                iTempCopy->CancelUpdate();
+                break;
+            default:
+                {
+                TInt count = iChangeRequests.Count();
+                if( count > 0 )
+                    {
+                    MXdmOperation* request = iChangeRequests[iUpdateIndex];
+                    request->CancelOperation();
+                    #ifdef _DEBUG
+                        iXcapProtocol.WriteToLog( _L8( "  Operation %x cancelled" ), request );
+                    #endif
+                    }
+                }
+            }
+        }
+    User::RequestComplete( iClientStatus, KErrCancel );
+    }
+
+// ---------------------------------------------------------
+// CXcapDocument::RunL()
+// 
+// ---------------------------------------------------------
+//
+void CXcapDocument::RunL()
+    {
+    #ifdef _DEBUG
+        HBufC8* buf = HBufC8::NewLC( iDocumentName->Des().Length() );
+        buf->Des().Copy( iDocumentName->Des() );
+        TPtr8 nameDesc( buf->Des() );
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::RunL()" ) );
+        iXcapProtocol.WriteToLog( _L8( "  Name:         %S" ), &nameDesc );
+        iXcapProtocol.WriteToLog( _L8( "  Error:        %d" ), iStatus.Int() );
+        iXcapProtocol.WriteToLog( _L8( "  Update index: %d" ), iUpdateIndex );
+        CleanupStack::PopAndDestroy();  //buf
+    #endif
+    if( iStatus == KErrNone )
+        {
+        switch( iDocumentState )
+            {
+            case EXdmDocUpdating:
+                #ifdef _DEBUG
+                    iXcapProtocol.WriteToLog( _L8( "  Document state: EXdmDocUpdating" ) );
+                #endif
+                HandleRequestCompletionL();
+                break;
+            case EResolvingAsyncConflict:
+                #ifdef _DEBUG
+                    iXcapProtocol.WriteToLog( _L8( "  Document state: EResolvingAsyncConflict" ) );
+                #endif
+                ResolveAsyncConflictL();
+                break;
+            case ERetryingFailedOperation:
+                #ifdef _DEBUG
+                    iXcapProtocol.WriteToLog( _L8( "  Document state: ERetryingFailedOperation" ) );
+                #endif
+                ResolveAsyncConflictL();
+                break;
+            default:
+                break;
+            }
+        }
+    else HandleErrorL();
+    #ifdef _DEBUG
+        TInt biggestBlock( 0 );
+        TInt memory( User::Available( biggestBlock ) );
+        iXcapProtocol.WriteToLog( _L8( "** RunL() completes - Available memory: %d" ), memory );
+    #endif
+    }
+
+// ---------------------------------------------------------
+// CXcapDocument::HandleRequestCompletionL
+// 
+// ---------------------------------------------------------
+//
+void CXcapDocument::HandleRequestCompletionL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::HandleRequestCompletionL()" ) );
+    #endif
+    MXdmOperation* request = iChangeRequests[iUpdateIndex];
+    const TXdmCompletionData& data = request->CompletionData();
+    switch( data.iCompletion )
+        {
+        case KInsertConflict:
+            ResolveAsyncConflictL();
+            break;
+        default:
+            {
+            RXcapCache* cache = iXcapProtocol.Cache();
+            if( cache )
+                UpdateDocumentInfoL( cache );
+            DequeueOperation( request );
+            CheckOperationQueueL();
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapDocument::ResolveAsyncConflictL
+// 
+// ---------------------------------------------------------
+//
+void CXcapDocument::ResolveAsyncConflictL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::ResolveAsyncConflictL()" ) );
+    #endif
+    switch( iDocumentState )
+        {
+        //This means the cached version of this document
+        //is out-of-date and that it needs to be updated.
+        case EXdmDocUpdating:
+            {
+            CreateTempCopyL();
+            iTempCopy->SetETag( iETagBuffer );
+            iTempCopy->FetchDataL();
+            iTempCopy->SaveClientStatus( iStatus );
+            iTempCopy->StartUpdateL();
+            iDocumentState = EResolvingAsyncConflict;
+            SetActive();
+            }
+            break;
+        case EResolvingAsyncConflict:
+            #ifdef _DEBUG
+                iXcapProtocol.WriteToLog( _L8( "  Async conflict resolved, retry insert" ) );
+            #endif
+            //CheckOperationQueueL() will increment the index
+            iUpdateIndex--;
+            SetETag( iTempCopy->ETag() );
+            iDocumentState = ERetryingFailedOperation;
+            CheckOperationQueueL();
+            break;
+        case ERetryingFailedOperation:
+            #ifdef _DEBUG
+                iXcapProtocol.WriteToLog( _L8( "  Operation retry ready" ) );
+            #endif
+            //Nothing can be done now but instruct the
+            //client to re-fetch the whole document and
+            //retry the failed operation.
+            User::RequestComplete( iClientStatus, KErrPathNotFound );
+            break;
+        default:
+            break;
+        }
+    }
+    
+// ---------------------------------------------------------
+// CXcapDocument::HandleErrorL
+// 
+// ---------------------------------------------------------
+//
+void CXcapDocument::HandleErrorL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::HandleErrorL()" ) );
+    #endif
+    TInt clientCode = KErrGeneral;
+    MXdmOperation* request = request = iChangeRequests[iUpdateIndex];
+    //The TXdmCompletionData is guaranteed to point at something 
+    const TXdmCompletionData& data = request->CompletionData();
+    switch( data.iCompletion )
+        {
+        case KErrCancel:
+            #ifdef _DEBUG
+                iXcapProtocol.WriteToLog( _L8( " Update cancelled" ) );
+            #endif
+            clientCode = KErrCancel;
+            break;
+        case ERetryingFailedOperation:
+            #ifdef _DEBUG
+                iXcapProtocol.WriteToLog( _L8( "  Operation retry failed" ) );
+            #endif
+            //Nothing can be done now but instruct the
+            //client to re-fetch the whole document and
+            //retry the failed operation.
+            User::RequestComplete( iClientStatus, KXcapErrorUnrecoverableConflict );
+            break;
+        case KXcapErrorHttpConflict:
+            #ifdef _DEBUG
+                iXcapProtocol.WriteToLog( _L8( "  Conflict, parse error document if available" ) );
+            #endif
+            if( data.iResponseData != NULL )
+                {
+                TInt error = KErrNone;
+                TPtrC8 errorData( data.iResponseData->Des() );
+                TRAP( error, iXcapProtocol.Parser().ParseDocumentL( errorData, ErrorRoot() ) );
+                #ifdef _DEBUG
+                    iXcapProtocol.WriteToLog( _L8( "  Parsing completed: %d" ), error );
+                    ErrorRoot()->Print();
+                #endif
+                //Suppress build warning
+                error = KErrNone;
+                }
+		        User::RequestComplete( iClientStatus, KXcapErrorHttpConflict );
+            break;
+        case KXcapErrorNetworkNotAvailabe:
+            {
+            #ifdef _DEBUG
+                iXcapProtocol.WriteToLog( _L8( "  Network not available, check cache" ) );
+            #endif
+            if( iDataLength > 0 )
+                {
+                RXcapCache* cache = iXcapProtocol.Cache();
+                if( cache != NULL )
+                    {
+                    TPtrC name( Name() );
+                    TInt error = KErrNone;
+                    TPtrC8 root = iXcapProtocol.Transport().RootUri();
+                    HBufC8* data = HBufC8::NewLC( iDataLength );
+                    TPtr8 dataPtr( data->Des() );
+                    cache->FetchDocumentContent( dataPtr, name, root );
+                    TRAP( error, iXcapProtocol.Parser().ParseDocumentL( this, dataPtr ) );
+                    #ifdef _DEBUG
+                        iXcapProtocol.WriteToLog( _L8( "  Parsing completed: %d" ), error );
+                    #endif
+                    //Suppress build warning
+                    error = KErrNone;
+                    CleanupStack::PopAndDestroy();  //data
+                    }
+                }
+            else
+                {
+                #ifdef _DEBUG
+                    iXcapProtocol.WriteToLog( _L8( "  No data in cache, nothing to do" ) );
+                #endif
+                }
+            User::RequestComplete( iClientStatus, KXcapErrorNetworkNotAvailabe );
+            }
+            break;
+        default:
+            #ifdef _DEBUG
+                iXcapProtocol.WriteToLog( _L8( " Default case - Result: %d" ), data.iCompletion );
+            #endif
+            clientCode = iStatus.Int();
+            User::RequestComplete( iClientStatus, clientCode );
+        }
+    DequeueOperation( request );
+    }
+     
+// ---------------------------------------------------------
+// CXcapDocument::CheckOperationQueueL
+// 
+// ---------------------------------------------------------
+//
+void CXcapDocument::CheckOperationQueueL()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::CheckOperationQueueL()" ) );
+    #endif
+    iUpdateIndex++;
+    if( iUpdateIndex < iOperationCount )
+        ActivateOperationL();
+    else
+        {
+        DequeueAll();
+        iUpdateIndex = 0;
+        iXcapProtocol.CheckActivity();
+        User::RequestComplete( iClientStatus, KErrNone );   
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapDocument::DequeueOperation
+// 
+// ---------------------------------------------------------
+//
+void CXcapDocument::DequeueOperation( MXdmOperation* aOperation )
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::DequeueOperation()" ) );
+    #endif
+    TInt index = iChangeRequests.Find( aOperation );
+    if( index >= 0 )
+    	{	
+		iChangeRequests.Remove( index );    
+        aOperation->Destroy();
+        aOperation = NULL;
+    	}  
+   	iOperationCount = iChangeRequests.Count();
+    }
+
+// ---------------------------------------------------------
+// CXcapDocument::DequeueAll
+// 
+// ---------------------------------------------------------
+//
+void CXcapDocument::DequeueAll()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::DequeueAll()" ) );
+    #endif
+    
+    while (iChangeRequests.Count() )
+    	{
+    	MXdmOperation* request = iChangeRequests[0];
+    	iChangeRequests.Remove( 0 );
+    	request->Destroy();
+    	request = NULL;
+    	} 
+    }
+      
+// ---------------------------------------------------------
+// CXcapDocument::EightBitNameLC
+// 
+// ---------------------------------------------------------
+//
+HBufC8* CXcapDocument::EightBitNameLC()
+    {
+    /*#ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::EightBitNameLC()" ) );
+    #endif*/
+    __ASSERT_DEBUG( Name().Length() > 0, User::Panic( _L( "CXcapDocument" ), 1 ) );
+    HBufC8* buf = HBufC8::NewLC( Name().Length() );
+    buf->Des().Copy( Name() );
+    return buf;
+    }
+
+// ---------------------------------------------------------
+// CXcapDocument::DocumentType
+// 
+// ---------------------------------------------------------
+//
+TXdmDocType CXcapDocument::DocumentType() const
+    {
+    return iDocumentType;
+    }
+
+// ---------------------------------------------------------
+// CXcapDocument::AppendNamespaceL
+// 
+// ---------------------------------------------------------
+//
+void CXcapDocument::AppendNamespaceL( const TDesC8& aUri, const TDesC8& aPrefix )
+    {
+    CXdmNamespace* ns = CXdmNamespace::NewL( aUri, aPrefix );
+    CleanupStack::PushL( ns );
+    User::LeaveIfError( iNamespaces.Append( ns ) );
+    CleanupStack::Pop();  //ns
+    }
+
+// ---------------------------------------------------------
+// CXcapDocument::RemoveNamespace
+// 
+// ---------------------------------------------------------
+//
+void CXcapDocument::RemoveNamespace( const TDesC8& aUri )
+    {
+    TBool found = EFalse;
+    CXdmNamespace* ns = NULL;
+    TInt count = iNamespaces.Count();
+    for( TInt i = 0;!found && i < count;i++ )
+        {
+        ns = iNamespaces[i];
+        if( ns->Uri().Compare( aUri ) == 0 )
+            {
+            found = ETrue;
+            iNamespaces.Remove( i );
+            delete ns;
+            ns = NULL;
+            }
+        }
+    }
+                    
+// ---------------------------------------------------------
+// CXcapDocument::Uri
+// 
+// ---------------------------------------------------------
+//
+TPtrC8 CXcapDocument::Uri( const TDesC8& aPrefix ) const
+    {
+    TPtrC8 uri( _L8( "" ) );
+    TBool found = EFalse;
+    TInt count = iNamespaces.Count();
+    for( TInt i = 0;!found && i < count ;i++ )
+        {
+        if( iNamespaces[i]->Prefix().Compare( aPrefix ) == 0 )
+            {
+            uri.Set( iNamespaces[i]->Uri() );
+            found = ETrue;
+            }
+        }
+    return uri;
+    }
+
+// ---------------------------------------------------------
+// CXcapDocument::Count
+// 
+// ---------------------------------------------------------
+//
+TInt CXcapDocument::Count() const
+    {
+    return iNamespaces.Count();
+    }
+
+// ---------------------------------------------------------
+// CXcapDocument::Prefix
+// 
+// ---------------------------------------------------------
+//
+TPtrC8 CXcapDocument::Prefix( TInt aIndex ) const
+    {
+    TInt count = iNamespaces.Count();
+    if( count > 0 && ( aIndex >= 0 && aIndex < count ) )
+        return iNamespaces[aIndex]->Prefix();
+    else return TPtrC8();
+    }
+    
+// ---------------------------------------------------------
+// CXcapDocument::Uri
+// 
+// ---------------------------------------------------------
+//
+TPtrC8 CXcapDocument::Uri( TInt aIndex ) const
+    {
+    TInt count = iNamespaces.Count();
+    if( count > 0 && ( aIndex >= 0 && aIndex < count ) )
+        return iNamespaces[aIndex]->Uri();
+    else return TPtrC8();
+    }
+    
+// ---------------------------------------------------------
+// CXcapDocument::ResetNamespaces
+// 
+// ---------------------------------------------------------
+//
+void CXcapDocument::ResetNamespaces( ) 
+    {   
+    iNamespaces.ResetAndDestroy();
+    } 
+    
+// ---------------------------------------------------------
+// CXcapDocument::TimeStamp
+// 
+// ---------------------------------------------------------
+//
+TTime CXcapDocument::TimeStamp() const
+    {
+    return iLastModification;
+    }
+
+// ----------------------------------------------------
+// CXdmDocument::SaveClientStatus
+// 
+// ----------------------------------------------------
+//
+void CXcapDocument::SaveClientStatus( TRequestStatus& aClientStatus )
+    {
+    iClientStatus = &aClientStatus;        
+    }
+            
+// ---------------------------------------------------------
+// CXcapDocument::DoCancel
+// 
+// ---------------------------------------------------------
+//
+void CXcapDocument::DoCancel()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocument::DoCancel()" ) );
+    #endif
+    if( iClientStatus )
+        {
+        User::RequestComplete( iClientStatus, KErrCancel );
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( " Request completed" ) );
+        #endif
+        }
+    else
+        {
+        #ifdef _DEBUG
+            iXcapProtocol.WriteToLog( _L8( " iClientStatus == NULL => do nothing" ) );
+        #endif
+        }
+    }
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/src/XcapDocumentNode.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,281 @@
+/*
+* 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: CXcapDocumentNode 
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XdmDocument.h"
+#include "XcapProtocol.h"
+#include "XcapDocumentNode.h"
+#include "XcapNodeAttribute.h"
+                                        
+// ----------------------------------------------------------
+// CXcapDocumentNode::CXcapDocumentNode
+// 
+// ----------------------------------------------------------
+//
+CXcapDocumentNode::CXcapDocumentNode( CXdmEngine& aXdmEngine,
+                                      CXcapProtocol& aXcapProtocol ) :
+                                      CXdmDocumentNode( aXdmEngine, ( MXdmNodeFactory& )*this ),
+                                      iXcapProtocol( aXcapProtocol )                                    
+                                                
+    {
+    }
+
+
+// ----------------------------------------------------------
+// CXcapDocumentNode::CXcapDocumentNode
+// 
+// ----------------------------------------------------------
+//
+CXcapDocumentNode::CXcapDocumentNode( CXdmEngine& aXdmEngine,
+                                      CXcapProtocol& aXcapProtocol,
+                                      CXdmDocumentNode* aParentNode ) :
+                                      CXdmDocumentNode( aXdmEngine,
+                                    ( MXdmNodeFactory& )*this, aParentNode ),
+                                      iXcapProtocol( aXcapProtocol )
+                                                
+    {   
+    }
+
+// ----------------------------------------------------------
+// CXcapDocumentNode::CXcapDocumentNode
+// 
+// ----------------------------------------------------------
+//
+CXcapDocumentNode::CXcapDocumentNode( const TBool aLeafNode,
+                                      CXdmEngine& aXdmEngine,
+                                      CXcapProtocol& aXcapProtocol,
+                                      CXdmDocumentNode* aParentNode ) :
+                                      CXdmDocumentNode( aLeafNode, aXdmEngine, 
+                                      ( MXdmNodeFactory& )*this, aParentNode ),
+                                      iXcapProtocol( aXcapProtocol )                                                
+    {
+    
+    }
+
+// ----------------------------------------------------------
+// CXcapDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapDocumentNode* CXcapDocumentNode::NewL( CXdmEngine& aXdmEngine,
+                                            CXcapProtocol& aXcapProtocol )
+    {
+    return new ( ELeave ) CXcapDocumentNode( aXdmEngine, aXcapProtocol );
+    }
+
+// ----------------------------------------------------------
+// CXcapDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapDocumentNode* CXcapDocumentNode::NewL( CXdmEngine& aXdmEngine,
+                                            const TDesC& aNodeName,
+                                            CXcapProtocol& aXcapProtocol )
+    {
+    CXcapDocumentNode* self = new ( ELeave ) CXcapDocumentNode( aXdmEngine, aXcapProtocol );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aNodeName );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapDocumentNode* CXcapDocumentNode::NewL( CXdmEngine& aXdmEngine,
+                                            CXcapProtocol& aXcapProtocol,
+                                            const CXdmDocumentNode& aAnotherNode,
+                                            const CXdmDocumentNode& aParentNode )
+    {
+    CXcapDocumentNode* self = new ( ELeave ) CXcapDocumentNode( aXdmEngine, aXcapProtocol );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aAnotherNode.NodeName() );
+    self->CopyConstructL( aAnotherNode, aParentNode );
+    CleanupStack::Pop();
+    return self;
+    }
+    
+// ----------------------------------------------------------
+// CXcapDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapDocumentNode* CXcapDocumentNode::NewL( CXdmEngine& aXdmEngine,
+                                            const TDesC& aNodeName,
+                                            CXcapProtocol& aXcapProtocol,
+                                            CXdmDocumentNode* aParentNode )
+    {
+    CXcapDocumentNode* self = new ( ELeave ) CXcapDocumentNode( aXdmEngine, aXcapProtocol, aParentNode );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aNodeName );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapDocumentNode* CXcapDocumentNode::NewL( CXdmEngine& aXdmEngine,
+                                            const TBool aLeafNode,
+                                            const TDesC& aNodeName,
+                                            CXcapProtocol& aXcapProtocol,
+                                            CXdmDocumentNode* aParentNode  )
+    {
+    CXcapDocumentNode* self = new ( ELeave ) CXcapDocumentNode( aLeafNode, aXdmEngine, aXcapProtocol, aParentNode );
+    CleanupStack::PushL( self );
+    self->BaseConstructL( aNodeName );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXdmDocumentNode::NewL
+// 
+// ----------------------------------------------------------
+//
+CXcapDocumentNode* CXcapDocumentNode::NewL( CXdmEngine& aXdmEngine,
+                                            const TBool aLeafNode,
+                                            CXcapProtocol& aXcapProtocol,
+                                            CXdmDocumentNode* aParentNode )
+    {
+    return new ( ELeave ) CXcapDocumentNode( aLeafNode, aXdmEngine, aXcapProtocol, aParentNode );
+    }
+
+// ----------------------------------------------------------
+// CXcapDocumentNode::CopyConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapDocumentNode::CopyConstructL( const CXdmDocumentNode& aAnotherNode,
+		                                const CXdmDocumentNode& aParentNode )
+    {
+    CXdmDocumentNode::CopyConstructL( aAnotherNode, aParentNode );
+    }
+        
+// ----------------------------------------------------
+// CXcapDocumentNode::~CXcapDocumentNode
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXcapDocumentNode::~CXcapDocumentNode()
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocumentNode::~CXcapDocumentNode()" ) );
+    #endif
+    delete iPrefix;
+    iPrefix = NULL;
+    }
+
+// ----------------------------------------------------
+// CXcapDocumentNode::ChileNodeL
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CXcapDocumentNode::ChileNodeL()
+    {
+    return CXcapDocumentNode::NewL( iXdmEngine, EFalse, iXcapProtocol, this );
+    }
+    
+// ----------------------------------------------------
+// CXcapDocumentNode::ChileNodeL
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CXcapDocumentNode::ChileNodeL( const TDesC& aChildName )
+    {
+    return CXcapDocumentNode::NewL( iXdmEngine, EFalse, aChildName, iXcapProtocol, this );
+    }
+
+// ----------------------------------------------------
+// CXcapDocumentNode::ChileNodeL
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CXcapDocumentNode::ChileNodeL( const CXdmDocumentNode* aAnotherNode  )
+    {
+    return CXcapDocumentNode::NewL( iXdmEngine, iXcapProtocol, *aAnotherNode, *this );
+    }
+
+// ----------------------------------------------------
+// CXcapDocumentNode::CreateAttributeL
+// 
+// ----------------------------------------------------
+//
+CXdmNodeAttribute* CXcapDocumentNode::AttributeL()
+    {
+    return CXcapNodeAttribute::NewL( iXdmEngine, this );
+    }
+    
+// ----------------------------------------------------
+// CXcapDocumentNode::CreateAttributeL
+// 
+// ----------------------------------------------------
+//
+CXdmNodeAttribute* CXcapDocumentNode::AttributeL( const TDesC& aAttributeName )
+    {
+    return CXcapNodeAttribute::NewL( iXdmEngine, aAttributeName, this );
+    }
+
+// ----------------------------------------------------------
+// CXcapDocumentNode::RemoveNode
+// 
+// ----------------------------------------------------------
+//
+void CXcapDocumentNode::RemoveNode( CXcapDocumentNode* aChileNode )
+    {
+    #ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXcapDocumentNode::RemoveNode()" ) );
+    #endif
+    CXdmDocumentNode* remove = NULL;
+    TInt index = iChildren.Find( aChileNode );
+    __ASSERT_DEBUG( index >= 0, User::Panic( _L( "CXcapDocumentNode" ), 0 ) );
+    remove = iChildren[index];
+    iChildren.Remove( index );
+    delete remove;
+    remove = NULL;
+    }
+
+// ----------------------------------------------------------
+// CXcapDocumentNode::SetPrefix
+// 
+// ----------------------------------------------------------
+//
+void CXcapDocumentNode::SetPrefixL( const TDesC8& aPrefix )
+    {
+    delete iPrefix;
+    iPrefix = NULL;
+    iPrefix = aPrefix.AllocL();
+    }
+    
+// ----------------------------------------------------------
+// CXcapDocumentNode::NamespacePrefix
+// 
+// ----------------------------------------------------------
+//
+TPtrC8 CXcapDocumentNode::Prefix() const
+    {
+    return iPrefix != NULL ? iPrefix->Des() : TPtrC8();
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/src/XcapNodeAttribute.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,112 @@
+/*
+* 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: CXcapNodeAttribute
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include "XcapProtocol.h"
+#include "XcapNodeAttribute.h"
+
+// ----------------------------------------------------------
+// CXcapNodeAttribute::CXcapNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+CXcapNodeAttribute::CXcapNodeAttribute( CXdmEngine& aXdmEngine ) :
+                  CXdmNodeAttribute( aXdmEngine, ( MXdmNodeFactory& )*this )
+                                                
+    {   
+    }
+    
+// ----------------------------------------------------------
+// CXcapNodeAttribute::CXcapNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+CXcapNodeAttribute::CXcapNodeAttribute( CXdmEngine& aXdmEngine,
+                                        CXdmDocumentNode* aParentNode ) :
+                                        CXdmNodeAttribute( aXdmEngine,
+                                      ( MXdmNodeFactory& )*this, aParentNode )
+                                                
+    {   
+    }
+
+// ----------------------------------------------------------
+// CXcapNodeAttribute::CXcapNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+CXcapNodeAttribute* CXcapNodeAttribute::NewL( CXdmEngine& aXdmEngine,
+                                              const TDesC& aAttributeName,
+                                              CXdmDocumentNode* aParentNode )
+    {
+    CXcapNodeAttribute* self = new ( ELeave ) CXcapNodeAttribute( aXdmEngine, aParentNode );
+    CleanupStack::PushL( self );
+    self->CXdmNodeAttribute::BaseConstructL( aAttributeName );
+    CleanupStack::Pop();
+    return self;
+    }
+    
+// ----------------------------------------------------------
+// CXcapNodeAttribute::CXcapNodeAttribute
+// 
+// ----------------------------------------------------------
+//                                        
+CXcapNodeAttribute* CXcapNodeAttribute::NewL( CXdmEngine& aXdmEngine, 
+                                              CXdmDocumentNode* aParentNode )
+    {
+    CXcapNodeAttribute* self = new ( ELeave ) CXcapNodeAttribute( aXdmEngine, aParentNode );
+    return self;
+    }
+    
+// ----------------------------------------------------------
+// CXcapNodeAttribute::~CXcapNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+CXcapNodeAttribute::~CXcapNodeAttribute()
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapNodeAttribute::~CXcapNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+TPtrC8 CXcapNodeAttribute::Prefix() const
+    {
+    return TPtrC8();
+    }
+
+// ----------------------------------------------------------
+// CXcapNodeAttribute::~CXcapNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+void CXcapNodeAttribute::SetPrefixL( const TDesC& /*aNamespacePrefix*/ )
+    {
+    }
+
+// ----------------------------------------------------------
+// CXcapNodeAttribute::~CXcapNodeAttribute
+// 
+// ----------------------------------------------------------
+//
+void CXcapNodeAttribute::SetPrefixL( const TDesC8& /*aNamespacePrefix*/ )
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/src/XcapNodeSelector.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -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: CXcapNodeSelector
+*
+*/
+
+
+
+
+// INCLUDES
+//This is only for logging
+#include "XcapProtocol.h"
+#include "XcapNodeSelector.h"
+
+// ---------------------------------------------------------
+// C++ constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------
+//
+CXcapNodeSelector::CXcapNodeSelector()                                    
+    {
+    }
+
+// ---------------------------------------------------------
+// Two-phased constructor.
+//
+// ---------------------------------------------------------
+//
+CXcapNodeSelector* CXcapNodeSelector::NewL()
+    {
+    CXcapNodeSelector* self = new ( ELeave ) CXcapNodeSelector();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// Symbian OS default constructor may leave.
+//
+// ---------------------------------------------------------
+//
+void CXcapNodeSelector::ConstructL()
+    {
+    
+    }
+
+// ---------------------------------------------------------
+// Destructor
+//
+// ---------------------------------------------------------
+//
+CXcapNodeSelector::~CXcapNodeSelector()
+    {
+    #ifdef _DEBUG
+        CXcapProtocol::WriteToLog( _L8( "CXcapNodeSelector::~CXcapNodeSelector()" ) );  
+    #endif
+    delete iSelectorString;
+    }
+
+//  End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XcapProtocol/src/XcapProtocol.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,765 @@
+/*
+* 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: CXcapProtocol
+*
+*/
+
+
+
+#include <hal.h>
+#include <f32file.h>
+#include <flogger.h>
+#include <XdmSettingsApi.h>
+#include <XdmSettingsProperty.h>
+#include <XdmSettingsCollection.h>
+#include <implementationproxy.h>
+#include <msgconnmanagerapi.h>
+#include "XcapAppUsage.h"
+#include "XcapEarlyIms.h"
+#include "XcapProtocol.h"
+#include "XcapDocument.h"
+#include "xdmlogwriter.h"
+#include "XcapDocumentNode.h"
+#include "XcapDirectory.h"
+#include "XdmXmlParser.h"
+#include "XdmCredentials.h"
+#include "XcapHttpReqGet.h"
+#include "XdmProtocolInfo.h"
+#include "XdmShutdownTimer.h"
+#include "XcapHttpTransport.h"
+#include "XdmOperationFactory.h"
+
+// ----------------------------------------------------------
+// CXcapProtocol::CXcapProtocol
+// 
+// ----------------------------------------------------------
+//
+CXcapProtocol::CXcapProtocol() : iSuspend( EFalse ),
+                                 iCacheUsage( EFalse ),
+                                 iTransferMediaOpen( EFalse ),
+                                 iSimRequestPending( EFalse ),
+                                 iAuthType( EXcapAuthHttpDigest )
+    {   
+    }
+        
+// ----------------------------------------------------------
+// CXcapProtocol::DeleteLogFileL
+// 
+// ----------------------------------------------------------
+//
+CXcapProtocol* CXcapProtocol::NewL( const TXdmProtocolParams& aProtocolParams )
+    {
+    CXcapProtocol* self = new ( ELeave ) CXcapProtocol();
+    CleanupStack::PushL( self );
+    self->ConstructL( aProtocolParams );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXcapProtocol::DeleteLogFileL
+// 
+// ----------------------------------------------------------
+//
+CXcapProtocol::~CXcapProtocol()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::~CXcapProtocol()" ) );  
+    #endif
+    delete iRootUri;
+    delete iPublicId;
+    delete iXmlParser;
+    delete iCapabilities;
+    delete iImsResolver;
+    delete iHttpTransport;
+    delete iIdleTimer;
+    if( iCacheUsage )
+        {
+        iCacheClient.Flush();
+        #ifdef _DEBUG
+            WriteToLog( _L8( "  Cache flushed" ) );
+        #endif
+        iCacheClient.Close();
+        #ifdef _DEBUG
+            WriteToLog( _L8( "  Cache closed" ) );
+        #endif
+        }
+    if( iConnectionManager != NULL )
+        iConnectionManager->Destroy();
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  ConnMan destroyed" ) );
+    #endif
+    #ifdef _DEBUG
+        WriteToLog( _L8( "  All finished, about to delete file logger" ) );
+    #endif
+    delete iLogWriter;
+    iNotifyeeQueue.Close();
+    }
+ 
+// ----------------------------------------------------------
+// CXcapProtocol::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXcapProtocol::ConstructL( const TXdmProtocolParams& aProtocolParams )
+    {
+    #ifdef _DEBUG
+        iLogWriter = CXdmLogWriter::NewL( KXcapEngLogFile );
+        WriteToLog( _L8( "CXcapProtocol::ConstructL()" ) );  
+    #endif
+    iXdmEngine = CONST_CAST( CXdmEngine*, &aProtocolParams.iXdmEngine );
+    iProtocolInfo = &aProtocolParams.iProtocolInfo;
+    TInt error = SaveSettingsL();
+    if( error == KErrNone )
+        {
+        iXmlParser = CXdmXmlParser::NewL();
+        iIdleTimer = new ( ELeave ) CXdmShutdownTimer( *this, this );
+        iIdleTimer->ConstructL();
+        if( iProtocolInfo->IsCacheEnabled() )
+            {
+            iCacheUsage = ETrue;
+            TInt error = iCacheClient.Connect();
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Cache start: %d" ), error );  
+            #endif
+            __ASSERT_DEBUG( ( error == KErrNone || error == KErrAlreadyExists ),
+                              User::Panic( _L( "CXcapProtocol" ), 1 ) );
+            }
+        iUserName.Copy( iCredentials.iUserName );
+        iConnectionManager = NewMsgConnManagerL( iAccessPoint );
+        __ASSERT_DEBUG( iRootUri->Des().Length() > 0, User::Panic( _L( "CXcapProtocol" ), 1 ) );
+        TBool secure = iProtocolInfo->IsSecure() || iRootUri->Des().FindF( KHttps ) == 0;
+        HBufC* root = ParseRootLocationLC( secure, iRootUri->Des() );
+        __ASSERT_ALWAYS( root != NULL, User::Panic( _L( "CXcapProtocol" ), 1 ) );
+        iHttpTransport = CXcapHttpTransport::NewL( root->Des(), *iConnectionManager, iCredentials );
+        CleanupStack::PopAndDestroy();  //root   
+        }
+    else User::Leave( error );
+    }
+
+// ----------------------------------------------------------
+// CXcapProtocol::PublicID
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TPtrC8 CXcapProtocol::PublicID()
+    {
+    return iPublicId != NULL ? iPublicId->Des() : TPtrC8();  
+    }
+
+// ----------------------------------------------------------
+// CXcapProtocol::Cache
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C RXcapCache* CXcapProtocol::Cache()
+    {
+    return iCacheUsage ? &iCacheClient : NULL;  
+    }
+
+// ---------------------------------------------------------
+// CXcapProtocol::Parser
+// 
+// ---------------------------------------------------------
+//
+EXPORT_C CXdmXmlParser& CXcapProtocol::Parser()
+    {
+    return *iXmlParser;
+    }
+
+// ---------------------------------------------------------
+// CXcapProtocol::Transport
+// 
+// ---------------------------------------------------------
+//
+EXPORT_C CXcapHttpTransport& CXcapProtocol::Transport()
+    {
+    return *iHttpTransport;
+    }
+   
+// ----------------------------------------------------------
+// CXcapProtocol::IsNetworkAvailable
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C TBool CXcapProtocol::IsNetworkAvailable()
+    {
+    return iConnectionManager->Status();
+    } 
+       
+// ----------------------------------------------------------
+// CXcapProtocol::SaveSettingsL
+// 
+// ----------------------------------------------------------
+//
+TInt CXcapProtocol::SaveSettingsL()
+    {
+    TInt settingsId = iProtocolInfo->SettingsID();
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::SaveSettingsL() - ID: %d" ), settingsId );
+    #endif
+    CXdmSettingsCollection* settings = NULL;
+    TRAPD( error, settings = TXdmSettingsApi::SettingsCollectionL( settingsId ) );
+    if( error == KErrNone && settings != NULL )
+        {
+        CleanupStack::PushL( settings );
+        SaveFromCollectionL( *settings );
+        CleanupStack::PopAndDestroy();  //settings
+        }
+    else   //Default to HTTP-DIGEST
+        {
+        iAuthType = EXcapAuthHttpDigest;
+        iAccessPoint = iProtocolInfo->AccessPoint();
+        iCredentials = iProtocolInfo->Credentials();
+        iRootUri = iProtocolInfo->Root().AllocL();
+        error = iRootUri->Des().Length() > 0 &&
+                iCredentials.iUserName.Length() > 0 &&
+                iCredentials.iPassword.Length() > 0 ?
+                KErrNone : KErrArgument;
+        }
+    return error;
+    }
+
+// ----------------------------------------------------------
+// CXcapProtocol::SelectAuthType
+// 
+// ----------------------------------------------------------
+//
+void CXcapProtocol::SelectAuthTypeL( const CXdmSettingsCollection& aSettings )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::SelectAuthTypeL()" ) );  
+    #endif
+    TPtrC authType( aSettings.Property( EXdmPropAuthType ) );
+    if( authType.Compare( KXdmAuthGaa ) == 0 ) 
+        {
+        iAuthType = EXcapAuthGaa;
+        #ifdef _DEBUG
+            CXcapProtocol::WriteToLog( _L8( " GAA" ) );
+        #endif
+        }
+    else if( authType.Compare( KXdmAuthEarlyIms ) == 0 )
+        {
+        #ifndef __WINSCW__ 
+            iAuthType = EXcapAuthEarlyIms;
+            ResolveIdentityL();
+            #ifdef _DEBUG
+                CXcapProtocol::WriteToLog( _L8( " EARLY-IMS" ) );
+            #endif
+        #endif
+        #ifdef __FAKE_IMPU__
+            iAuthType = EXcapAuthEarlyIms;
+            ResolveIdentityL();
+            #ifdef _DEBUG
+                CXcapProtocol::WriteToLog( _L8( " EARLY-IMS" ) );
+            #endif
+        #else
+            #ifdef _DEBUG
+                CXcapProtocol::WriteToLog( _L8( " WINS, cannot authenticate without SIM card => ignore" ) );
+            #endif
+            iAuthType = EXcapAuthHttpDigest;
+        #endif   
+        }
+    else
+        {
+        iAuthType = EXcapAuthHttpDigest;
+        #ifdef _DEBUG
+            CXcapProtocol::WriteToLog( _L8( " HTTP-DIGEST" ) );
+        #endif
+        } 
+    //Fallback position: in case the server challenges us even though EXcapAuthEarlyIms
+    //has been defined, use the credentials the client supplied regardless of what they are.
+    TPtrC authName( aSettings.Property( EXdmPropAuthName ) );
+    TPtrC authSecret( aSettings.Property( EXdmPropAuthSecret ) );
+    //But they must not exceed the stipulated length
+    __ASSERT_ALWAYS( authName.Length() <= KXdmMaxUserNameLength, User::Leave( KErrCorrupt ) );
+    __ASSERT_ALWAYS( authSecret.Length() <= KXdmMaxPasswordLength, User::Leave( KErrCorrupt ) );
+    iCredentials = TXdmCredentials( authName, authSecret );
+    }
+
+// ----------------------------------------------------------
+// CXcapProtocol::SaveFromCollectionL
+// 
+// ----------------------------------------------------------
+//
+void CXcapProtocol::SaveFromCollectionL( const CXdmSettingsCollection& aSettings )
+    {
+    #ifdef _DEBUG
+        for( TInt i = 0;i < aSettings.Count();i++ )
+            {
+            const CXdmSettingsProperty& prop = aSettings.Property( i );
+            HBufC8* value = HBufC8::NewLC( prop.PropertyValue().Length() );
+            value->Des().Copy( prop.PropertyValue() );
+            TPtrC8 valueDes( value->Des() );
+            WriteToLog( _L8( "  Property %d - Name: %d  Value: %S" ), i, prop.PropertyName(), &valueDes );
+            CleanupStack::PopAndDestroy();  //value
+            }
+    #endif
+    SelectAuthTypeL( aSettings );
+    __ASSERT_DEBUG( aSettings.Property( EXdmPropToNapId ).Length() > 0, User::Leave( KErrCorrupt ) );
+    __ASSERT_DEBUG( aSettings.Property( EXdmPropUri ).Length() > 0, User::Leave( KErrCorrupt ) );
+    TLex accessPoint( aSettings.Property( EXdmPropToNapId ) );
+    TInt error = accessPoint.Val( iAccessPoint );
+    __ASSERT_DEBUG( error == KErrNone, User::Leave( KErrCorrupt ) );
+    iRootUri = aSettings.Property( EXdmPropUri ).AllocL();
+    #ifdef _DEBUG
+        TBuf8<KXdmMaxUserNameLength> name( iCredentials.iUserName );
+        TBuf8<KXdmMaxPasswordLength> password( iCredentials.iPassword );
+        HBufC8* rootUri = HBufC8::NewLC( iRootUri->Des().Length() );
+        rootUri->Des().Copy( iRootUri->Des() );
+        TPtrC8 uriDes( rootUri->Des() );
+        WriteToLog( _L8( " Finished - Error:    %d" ), error );
+        WriteToLog( _L8( "  Access point:       %d" ), iAccessPoint );
+        WriteToLog( _L8( "  URI:                %S" ), &uriDes );
+        WriteToLog( _L8( "  User name:          %S" ), &name );
+        WriteToLog( _L8( "  Password:           %S" ), &password );
+        CleanupStack::PopAndDestroy();  //rootUri
+    #endif
+    iUserName.Copy( iCredentials.iUserName );
+    }
+    
+// ----------------------------------------------------------
+// CXcapProtocol::ParseRootLocationLC
+// 
+// ----------------------------------------------------------
+//
+HBufC* CXcapProtocol::ParseRootLocationLC( const TBool aSecurity,
+                                           const TDesC& aRootLocation )
+    {
+    #ifdef _DEBUG
+        TBuf8<1024> root;
+        root.Copy( aRootLocation );
+        WriteToLog( _L8( "CXcapProtocol::ParseRootLocationLC()" ) );
+        WriteToLog( _L8( "  Security:     %d" ), aSecurity );
+        WriteToLog( _L8( "  Provided URI: %S" ), &root );
+    #endif
+    HBufC* ret = NULL;
+    HBufC* temp = CheckProtocolPrefixL( aRootLocation );
+    if( temp != NULL )
+        {
+        CleanupStack::PushL( temp );
+        ret = aSecurity ? ConstructSecureUriL( temp->Des() ) :
+                          ConstructStandardUriL( temp->Des() );
+        CleanupStack::PopAndDestroy();  //temp                       
+        }
+    else
+        ret = aSecurity ? ConstructSecureUriL( aRootLocation ) :
+                          ConstructStandardUriL( aRootLocation );
+	TPtr desc( ret->Des() );
+	if( desc[desc.Length() - 1] == '/' )
+    	desc.Delete( desc.Length() - 1, 1 );
+    CleanupStack::PushL( ret );
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXcapProtocol::CheckProtocolPrefixLC
+// 
+// ----------------------------------------------------------
+//
+HBufC* CXcapProtocol::CheckProtocolPrefixL( const TDesC& aRootLocation )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::CheckProtocolPrefixL()" ) );  
+    #endif
+    HBufC* buffer = NULL;
+    if( aRootLocation.FindF( KHttp ) == 0 || aRootLocation.FindF( KHttps ) == 0 )
+        {
+        TInt length = aRootLocation.FindF( KHttp ) == 0 ?
+                      KHttp().Length() : KHttps().Length();
+        buffer = HBufC::NewL( aRootLocation.Length() - length );
+        TPtrC desc( aRootLocation );
+        TPtrC temp = desc.Right( aRootLocation.Length() - length );
+        buffer->Des().Copy( temp );
+        }  
+    return buffer;
+    }
+    
+// ----------------------------------------------------------
+// CXcapProtocol::ConstructStandardUriL
+// 
+// ----------------------------------------------------------
+//
+HBufC* CXcapProtocol::ConstructStandardUriL( const TDesC& aBasicUri )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::ConstructStandardUriLC()" ) );  
+    #endif
+    HBufC* ret = HBufC::NewL( aBasicUri.Length() +
+                              TPtrC( KHttp ).Length() );
+	TPtr desc( ret->Des() );
+    desc.Copy( KHttp );
+    desc.Append( aBasicUri );
+    return ret;
+    }
+    
+// ----------------------------------------------------------
+// CXcapProtocol::ConstructSecureUriL
+// 
+// ----------------------------------------------------------
+//
+HBufC* CXcapProtocol::ConstructSecureUriL( const TDesC& aBasicUri )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::ConstructSecureUriLC()" ) );  
+    #endif
+    TInt index = aBasicUri.FindF( KHostSeparator );
+    HBufC* ret = HBufC::NewL( aBasicUri.Length() +
+                        TPtrC( KHttps ).Length() );
+    TPtr uriDesc( ret->Des() );
+    if( index > 0 )
+        {
+        TPtrC basic( aBasicUri.Left( index ) );
+        TPtrC theRest( aBasicUri.Mid( index ) );
+        uriDesc.Copy( KHttps );
+        uriDesc.Append( basic );
+        uriDesc.Append( theRest );
+        }
+    else
+        {
+        uriDesc.Copy( KHttps );
+        uriDesc.Append( aBasicUri );
+        }
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXcapProtocol::ResolveIdentityL
+// 
+// ----------------------------------------------------------
+//
+void CXcapProtocol::ResolveIdentityL()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::ResolveIdentityL()" ) );  
+    #endif
+    iImsResolver = CXcapEarlyIms::NewL();
+    iImsResolver->RequestSimDataL( this );
+    iSimRequestPending = ETrue;
+    }
+
+// ---------------------------------------------------------
+// CXcapProtocol::CheckActivity
+//
+// ---------------------------------------------------------
+//
+void CXcapProtocol::CheckActivity()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::CheckActivity()" ) );
+    #endif
+    TBool activity = EFalse;
+    const RPointerArray<CXdmDocument>& documents = iXdmEngine->DocumentCollection();
+    const RPointerArray<CXdmDirectory>& directories = iXdmEngine->DirectoryCollection();
+    TInt docCount = documents.Count();
+    TInt dirCount = directories.Count();
+    if( docCount > 0 || dirCount > 0 )
+        {
+        TInt i = 0;
+        for( ;!activity && i < docCount;i++ )
+            activity = documents[i]->IsActive();
+        for( i = 0 && !activity;!activity && i < dirCount;i++ )
+            activity = directories[i]->IsActive();
+        }
+    if( !activity )
+        {
+        //Just in case...
+        iIdleTimer->Cancel();
+        iIdleTimer->Start( iIdleTimeout * 1000000 );
+        }
+    }
+
+// ---------------------------------------------------------
+// CXcapProtocol::SimRequestPending
+// 
+// ---------------------------------------------------------
+//
+TBool CXcapProtocol::IsSimRequestPending( TInt& aError ) const
+    {
+    aError = iSimRequestPending ? KErrNotReady : iImsResolverError;
+    return iSimRequestPending; 
+    }
+
+// ---------------------------------------------------------
+// CXcapProtocol::AppendNotifyeeL
+// 
+// ---------------------------------------------------------
+//
+void CXcapProtocol::AppendNotifyeeL( CXcapDocument* aPendingDoc )
+    {
+    User::LeaveIfError( iNotifyeeQueue.Append( aPendingDoc ) );
+    }
+
+// ---------------------------------------------------------
+// CXcapProtocol::CancelImsResolver
+// 
+// ---------------------------------------------------------
+//
+void CXcapProtocol::CancelImsResolver()
+    {
+    #ifdef _DEBUG
+        CXcapProtocol::WriteToLog( _L8( "CXcapDocument::CancelImsResolver()" ) );
+    #endif
+    if( iImsResolver )
+        iImsResolver->Cancel();
+    }
+       
+// ---------------------------------------------------------
+// CXcapDocument::RequestComplete
+// 
+// ---------------------------------------------------------
+//
+void CXcapProtocol::RequestComplete( TInt aError )
+    {
+    #ifdef _DEBUG
+        CXcapProtocol::WriteToLog( _L8( "CXcapDocument::RequestComplete()" ) );
+    #endif
+    if( aError == KErrNone )
+        {
+        #ifdef _DEBUG
+            CXcapProtocol::WriteToLog( _L8( " Public ID retrieved successfully" ) );
+        #endif
+        iPublicId = iImsResolver->PublicIDL().AllocL();
+        delete iImsResolver;
+        iImsResolver = NULL;
+        }
+    else
+        {
+        #ifdef _DEBUG
+            CXcapProtocol::WriteToLog( _L8( " Public ID retrieval failed - Status: %d" ), aError );
+        #endif
+        iImsResolverError = aError;
+        }
+    for( TInt i = 0;i < iNotifyeeQueue.Count();i++ )
+        {
+        CXcapDocument* document = iNotifyeeQueue[i];
+        if( document )
+            document->NotifyResolverCompleteL( aError );
+        }
+    iSimRequestPending = EFalse;
+    iNotifyeeQueue.Reset();
+    }
+        
+// ----------------------------------------------------------
+// CXcapProtocol::WriteToLog
+// 
+// ----------------------------------------------------------
+//
+void CXcapProtocol::WriteToLog( TRefByValue<const TDesC8> aFmt,... ) const                                 
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf8<KLogBufferMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    iLogWriter->WriteToLog( buf );
+    }
+
+// ----------------------------------------------------
+// CXcapProtocol::InitTransferMedium
+// 
+// ----------------------------------------------------
+//
+void CXcapProtocol::InitTransferMedium( TInt aIdleTimeout, TRequestStatus& aStatus )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::InitTransferMedium()" ) );  
+    #endif
+    iIdleTimer->Cancel();
+    iIdleTimeout = aIdleTimeout;
+    if( !IsNetworkAvailable() )
+        iConnectionManager->StartConnection( aStatus );
+    else  //Already open
+        {
+        TRequestStatus* status = &aStatus;
+        User::RequestComplete( status, KErrNone );
+        }
+    }
+
+// ----------------------------------------------------
+// CXcapProtocol::CancelTransferMediumInit
+// 
+// ----------------------------------------------------
+//
+void CXcapProtocol::CancelTransferMediumInit()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::CancelTransferMediumInit()" ) );  
+    #endif
+    TInt error = KErrNone;
+    TRAP( error, iConnectionManager->CancelStartL() );
+    #ifdef _DEBUG
+        WriteToLog( _L8( " Transfer media cancel completed - Error: %d" ), error );  
+    #endif
+    //Suppress build warning
+    error = KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CXcapProtocol::IsTransferAvailable
+// 
+// ---------------------------------------------------------
+//
+TBool CXcapProtocol::IsTransferAvailable() const
+    {
+    return iConnectionManager->Status();
+    }
+    
+// ---------------------------------------------------------
+// CXcapProtocol::AuthType
+// 
+// ---------------------------------------------------------
+//
+TXcapAuthType CXcapProtocol::AuthType() const
+    {
+    return iAuthType;
+    }
+             
+// ---------------------------------------------------------
+// CXdmEngine::XdmProtocol
+// 
+// ---------------------------------------------------------
+//
+void CXcapProtocol::SwitchOff()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::SwitchOff()" ) );
+    #endif
+    iConnectionManager->StopConnection();
+    }
+
+// ----------------------------------------------------
+// CXcapProtocol::CreateDocumentL
+// 
+// ----------------------------------------------------
+//
+CXdmDocument* CXcapProtocol::CreateDocumentL( const TDesC& aDocumentName,
+                                              const TXdmDocType aDocumentType )
+    {
+    return CXcapDocument::NewL( aDocumentType, aDocumentName, *iXdmEngine, *this );
+    }
+    
+// ----------------------------------------------------
+// CXcapProtocol::CreateDirectoryL
+//
+// ----------------------------------------------------
+//
+CXdmDirectory* CXcapProtocol::CreateDirectoryL( const TDesC& aDirectoryPath )
+    {
+    _LIT( KDirectoryDocName, "directory.xml" );
+    CXdmDocument* document = iXdmEngine->CreateDocumentModelL( KDirectoryDocName, EXdmDirectory );
+    CleanupStack::PushL( document );
+    CXdmDirectory* directory = CXcapDirectory::NewL( aDirectoryPath, *iXdmEngine, document, *this );
+    CleanupStack::Pop();               //document
+    return directory;
+    }
+
+// ----------------------------------------------------
+// CXcapProtocol::CreateDocumentNodeL
+// 
+// ----------------------------------------------------
+//
+CXdmDocumentNode* CXcapProtocol::CreateDocumentNodeL()
+    {
+    return CXcapDocumentNode::NewL( *iXdmEngine, *this );
+    }
+        
+// ---------------------------------------------------------
+// CXcapProtocol::GenerateUniqueIdL
+// 
+// ---------------------------------------------------------
+//
+TInt CXcapProtocol::GenerateUniqueIdL()
+    {
+    TInt period = 0;
+    User::LeaveIfError( HAL::Get( HALData::ESystemTickPeriod, period ) );
+    TInt millisecsPerTick = period / 1000;
+    return User::TickCount() * millisecsPerTick;
+    }
+
+// ----------------------------------------------------------
+// CXdmProtocol::UserName
+// 
+// ----------------------------------------------------------
+//
+TPtrC8 CXcapProtocol::UserName() const
+    {
+    return iUserName;
+    }
+        
+// ----------------------------------------------------------
+// CXdmProtocol::HandleBearerEventL
+// 
+// ----------------------------------------------------------
+//
+void CXcapProtocol::HandleBearerEventL( TBool aAuthoritativeClose,
+                                        TMsgBearerEvent aBearerEvent )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXcapProtocol::HandleBearerEventL(): %d" ), aBearerEvent );
+    #endif
+    switch( aBearerEvent )
+        {
+        case EMsgBearerSuspended:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Bearer suspended" ) );
+            #endif
+            iSuspend = ETrue;
+            break;
+        case EMsgBearerActive:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Bearer active" ) );
+            #endif
+            iSuspend = EFalse;
+            break;
+        case EMsgBearerLost:
+            #ifdef _DEBUG
+                WriteToLog( _L8( "  Bearer lost - Authoritative: %d" ),
+                                    aAuthoritativeClose );
+            #endif
+            break;
+        default:
+        		//Suppress build warning
+        		aAuthoritativeClose = EFalse;
+            break;
+        }
+    }
+
+// ---------------------------------------------------------
+// Map the interface UIDs to implementation factory functions
+// 
+// ---------------------------------------------------------
+//
+const TImplementationProxy ImplementationTable[] = 
+	{
+#ifdef __EABI__
+    IMPLEMENTATION_PROXY_ENTRY( 0x10207423,	CXcapProtocol::NewL )
+#else
+    { { 0x10207423 }, CXcapProtocol::NewL }
+#endif
+    };
+
+// ---------------------------------------------------------
+// Return the implementation table & number of implementations
+// 
+// ---------------------------------------------------------
+//
+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/xdmprotocols/XdmXmlParser/bwinscw/XdmXmlParserU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,9 @@
+EXPORTS
+	??1CXdmXmlParser@@UAE@XZ @ 1 NONAME ; CXdmXmlParser::~CXdmXmlParser(void)
+	?FormatToXmlLC@CXdmXmlParser@@QAEPAVHBufC8@@ABVTDesC8@@PBVCXdmDocument@@PBVCXdmDocumentNode@@@Z @ 2 NONAME ; class HBufC8 * CXdmXmlParser::FormatToXmlLC(class TDesC8 const &, class CXdmDocument const *, class CXdmDocumentNode const *)
+	?FormatToXmlLC@CXdmXmlParser@@QAEPAVHBufC8@@HPBVCXdmDocument@@PBVCXdmDocumentNode@@@Z @ 3 NONAME ; class HBufC8 * CXdmXmlParser::FormatToXmlLC(int, class CXdmDocument const *, class CXdmDocumentNode const *)
+	?NewL@CXdmXmlParser@@SAPAV1@XZ @ 4 NONAME ; class CXdmXmlParser * CXdmXmlParser::NewL(void)
+	?ParseDocumentL@CXdmXmlParser@@QAEXABVTDesC8@@PAVCXdmDocumentNode@@@Z @ 5 NONAME ; void CXdmXmlParser::ParseDocumentL(class TDesC8 const &, class CXdmDocumentNode *)
+	?ParseDocumentL@CXdmXmlParser@@QAEXPAVCXdmDocument@@ABVTDesC8@@@Z @ 6 NONAME ; void CXdmXmlParser::ParseDocumentL(class CXdmDocument *, class TDesC8 const &)
+	?ParseDocumentL@CXdmXmlParser@@QAEXPAVCXdmDocument@@ABVTDesC8@@PAVCXdmDocumentNode@@@Z @ 7 NONAME ; void CXdmXmlParser::ParseDocumentL(class CXdmDocument *, class TDesC8 const &, class CXdmDocumentNode *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/eabi/XdmXmlParserU.DEF	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,12 @@
+EXPORTS
+	_ZN13CXdmXmlParser13FormatToXmlLCERK6TDesC8PK12CXdmDocumentPK16CXdmDocumentNode @ 1 NONAME
+	_ZN13CXdmXmlParser13FormatToXmlLCEiPK12CXdmDocumentPK16CXdmDocumentNode @ 2 NONAME
+	_ZN13CXdmXmlParser14ParseDocumentLEP12CXdmDocumentRK6TDesC8 @ 3 NONAME
+	_ZN13CXdmXmlParser14ParseDocumentLEP12CXdmDocumentRK6TDesC8P16CXdmDocumentNode @ 4 NONAME
+	_ZN13CXdmXmlParser14ParseDocumentLERK6TDesC8P16CXdmDocumentNode @ 5 NONAME
+	_ZN13CXdmXmlParser4NewLEv @ 6 NONAME
+	_ZTI13CXdmXmlParser @ 7 NONAME ; #<TI>#
+	_ZTI21CXdmXmlContentHandler @ 8 NONAME ; #<TI>#
+	_ZTV13CXdmXmlParser @ 9 NONAME ; #<VT>#
+	_ZTV21CXdmXmlContentHandler @ 10 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/group/XdmXmlParser.mmp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,59 @@
+/*
+* 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:   XdmXmlParser
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+TARGET                          xdmxmlparser.dll
+TARGETTYPE                      dll
+UID                             0x1000008d 0x10207412
+CAPABILITY                      CAP_GENERAL_DLL
+VENDORID                        VID_DEFAULT
+
+SOURCEPATH                      ../src
+
+USERINCLUDE                     ../inc
+USERINCLUDE                     ../../inc
+
+//Application classes
+SOURCE                          XdmXmlParser.cpp
+SOURCE                          XmlFormatter.cpp
+SOURCE                          XmlParserNodePath.cpp
+SOURCE                          XdmXmlContentHandler.cpp
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE                   /epoc32/include/xml
+SYSTEMINCLUDE                   ../../../inc
+
+
+LIBRARY                         hal.lib
+LIBRARY                         bafl.lib
+LIBRARY                         efsrv.lib
+LIBRARY                         euser.lib
+//For debug libraries
+DEBUGLIBRARY                    flogger.lib
+LIBRARY                         xdmengine.lib
+LIBRARY                         xmlframework.lib
+
+#if defined( ARMCC )
+    DEFFILE ../eabi/ 
+#elif defined ( WINSCW )
+    deffile ../bwinscw/ 
+#elif defined (WINS )
+    deffile ../BWINS/ 
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,28 @@
+/*
+* 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:  XdmXmlParser
+*
+*/
+
+
+
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+XdmXmlParser.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/inc/XdmXmlContentHandler.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,278 @@
+/*
+* 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:   CXdmXmlContentHandler
+*
+*/
+
+
+
+
+#ifndef __XDMXMLCONTENTHANDLER__
+#define __XDMXMLCONTENTHANDLER__
+
+//INCLUDES
+#include <contenthandler.h>
+#include "XmlNodePathInterface.h"
+
+using namespace Xml;
+
+class CXdmDocument;
+class CXdmXmlParser;
+class MXdmNodeInterface;
+class CXmlParserNodePath;
+
+//CLASS DECLARATION
+class CXdmXmlContentHandler : public CBase,
+                              public MContentHandler,
+                              public MXmlNodePathInterface
+    {
+    public:  // Constructors and destructor
+        
+        /**
+		* Symbian OS Constructor
+		* @param CXdmXmlParser Reference to the main parser class
+		* @return CXdmXmlContentHandler A new content handler
+		*/
+        static CXdmXmlContentHandler* NewL( CXdmXmlParser& aParserMain );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CXdmXmlContentHandler();
+
+    public: // New functions
+		
+	    /**
+		* Reset content handler
+		* @return void
+		*/
+		void Reset();
+		
+		/**
+		* Set the target document
+		* @param CXdmDocument& Reference to a document model
+		* @return void
+		*/
+		void SetTarget( const CXdmDocument& aTargetDocument );
+		
+		/**
+		* Set the target element
+		* @param CXdmDocumentNode Referene to document/fragment root
+		* @return void
+		*/
+		void SetTarget( const CXdmDocumentNode& aDocumentRoot );
+		
+	    /**
+		* Set the target document and element
+		* @param CXdmDocument Reference to a document model
+		* @param CXdmDocumentNode Referene to document/fragment root
+		* @return void
+		*/
+		void SetTargetL( const CXdmDocument& aTargetDocument,
+		                 const CXdmDocumentNode& aTargetNode );
+		                
+    public: //From MXmlNodePathInterface
+		
+		/**
+		* Return the target attribute
+		* @return CXdmNodeAttribute* Target attribute
+		*/
+		CXdmNodeAttribute* TargetAttribute() const;
+
+    private:
+        
+        /**
+        * C++ Constructor
+        * @param CXdmXmlParser Reference to the main parser class
+        * @return CXdmXmlContentHandler
+        */
+		CXdmXmlContentHandler( CXdmXmlParser& aParserMain );
+		
+		/**
+        * Symbian OS second-phase constructor
+        */
+		void ConstructL();
+		
+    private:  //From Xml::MContentHandler
+        
+        /**
+        * Get extended interface
+        * @param TInt32 UID of the interface
+        * @return TAny* a general pointer to the interface
+        */
+        TAny* GetExtendedInterface( const TInt32 aUid );
+        
+		/**
+        * Called on content: <elem>content</elem>
+        * @param TDesC& Content bytes
+        * @param TInt Error code
+        * @return void
+        */
+		void OnContentL( const TDesC8 &aBytes,
+		                 TInt aErrorCode );
+		
+		/**
+        * Called on document end
+        * @param TInt Error code
+        * @return void
+        */
+        void OnEndDocumentL( TInt aErrorCode );
+        
+        /**
+        * Called on element end
+        * @param RTagInfo& Tag info
+        * @param TInt Error code
+        * @return void
+        */
+        void OnEndElementL( const RTagInfo& aElement,
+                            TInt aErrorCode );
+        
+        /**
+        * Called on prefix mapping end
+        * @param RString& Prefix
+        * @param TInt Error code
+        * @return void
+        */
+        void OnEndPrefixMappingL( const RString &aPrefix,
+                                  TInt aErrorCode );
+        
+        /**
+        * Called on error
+        * @param TInt Error code
+        * @return void
+        */
+        void OnError( TInt aErrorCode );
+    
+        /**
+        * Called on ingnorable whitespace
+        * @param TDesC8& Whitespace bytes
+        * @param TInt Error code
+        * @return void
+        */
+        void OnIgnorableWhiteSpaceL( const TDesC8& aBytes,
+                                     TInt aErrorCode );
+   
+        /**
+        * Called on processing instructions
+        * @param TDesC8& Target
+        * @param TDesC8& Data
+        * @param TInt Error code
+        * @return void
+        */
+        void OnProcessingInstructionL( const TDesC8& aTarget,
+                                       const TDesC8& aData,
+                                       TInt aErrorCode );
+    
+        /**
+        * Called on skipped entity
+        * @param RString& Name of the entity
+        * @param TInt Error code
+        * @return void
+        */
+        void OnSkippedEntityL( const RString &aName,
+                               TInt aErrorCode );
+    
+        /**
+        * Called on document start
+        * @param RDocumentParameters& Parameters
+        * @param TInt Error code
+        * @return void
+        */
+        void OnStartDocumentL( const RDocumentParameters& aDocParam,
+                               TInt aErrorCode );
+   
+        /**
+        * Called on element start
+        * @param RTagInfo& The starting element
+        * @param Xml::RAttributeArray Attributes
+        * @param TInt Error code
+        * @return void
+        */
+        void OnStartElementL( const RTagInfo& aElement,
+                              const Xml::RAttributeArray &aAttributes,
+                              TInt aErrorCode );
+    
+        /**
+        * Called on prefix mapping start
+        * @param RString& Prefix
+        * @param RString& URI
+        * @param TInt Error code
+        * @return void
+        */
+        void OnStartPrefixMappingL( const RString& aPrefix,
+                                    const RString& aUri,
+                                    TInt aErrorCode );
+                                    
+    private:
+        
+        /**
+        * Append attributes from the parameter array
+        * @param Xml::RAttributeArray& Attributes
+        * @return void
+        */
+        void AppendAttributeValueL( const Xml::RAttributeArray& aAttributes );
+        
+        /**
+        * Handle next element
+        * @param RTagInfo& The new element
+        * @param Xml::RAttributeArray& Attributes
+        * @return void
+        */
+        void HandleNextElementL( const Xml::RTagInfo& aElement,
+                                 const Xml::RAttributeArray& aAttributes );
+        /**
+        * Is the parameter descriptor a whitespace
+        * @param TDesC8& Bytes to check
+        * @return TBool 
+        */
+        TBool IsWhiteSpace( const TDesC8& aBytes ) const;
+        
+        /**
+        * Append a new namespace
+        * @param TDesC8& Prefix
+        * @param TDesC8& URI
+        * @return void
+        */
+        void AppendNameSpaceL( const TDesC8& aPrefix, const TDesC8& aUri );
+                                   
+        /**
+        * Set the namespace information to the current node
+        * @param RTagInfo& Element
+        * @param MXdmNodeInterface* Node interface
+        * @return void
+        */
+        void SetNamespaceInformationL( const RTagInfo& aElement,
+                                       MXdmNodeInterface* aXcapNode );
+        
+    private:    // Data
+        
+        TInt                             iContentIndex;
+        TBool                            iFinished;
+        TBool                            iIsRootNode;
+        TBool                            iTargetFound;
+        TXdmElementType                  iElementType;
+        TBool                            iPartialDocument;
+        CBufFlat*                        iContentBuffer;
+        CXdmDocument*                    iTargetDocument;
+        CXdmDocumentNode*                iRootNode;
+        CXdmDocumentNode*                iDocumentSubset;
+		CXdmDocumentNode*                iCurrentNode;
+		CXdmNodeAttribute*               iTargetAttribute;
+		CXmlParserNodePath*              iNodePath;
+		CXdmXmlParser&                   iParserMain;
+    };
+
+#endif      // __XDMXMLCONTENTHANDLER__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/inc/XdmXmlParser.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   CXdmXmlParser
+*
+*/
+
+
+
+
+#ifndef __XDMXMLPARSER__
+#define __XDMXMLPARSER__
+
+#include <parser.h>
+
+//CONSTANTS
+_LIT( KParserLogFile,                   "XcapXml" );
+_LIT8( KDefaultMimeType,                "text/xml" );
+
+using namespace Xml;
+
+//FORWARD DECLARATION
+class CXdmDocument;
+class CXdmLogWriter;
+class CXmlFormatter;
+class CXdmDocumentNode;
+class MXdmNodeInterface;
+class CXdmXmlContentHandler;
+class MXdmNamespaceContainer;
+
+// CLASS DECLARATION
+class CXdmXmlParser: public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Symbian OS Constructor
+        * @return CXdmXmlParser New parser intance  
+        */     
+        IMPORT_C static CXdmXmlParser* NewL();
+        
+        /**
+        * Parse an XML document
+        * @param CXdmDocument Document instance
+        * @param TDesC8& The raw XML data
+        * @return void
+        */    
+        IMPORT_C void ParseDocumentL( CXdmDocument* aDocument,
+                                       const TDesC8& aXmlDocument );
+        
+        /**
+        * Parse an XML document
+        * @param CXdmDocument Document instance
+        * @param TDesC8& The raw XML data
+        * @param Pointer to the document/fragment root
+        * @return void
+        */     
+        IMPORT_C void ParseDocumentL( CXdmDocument* aDocument,
+                                      const TDesC8& aXmlDocument,
+                                      CXdmDocumentNode* aDocumentSubset );
+        
+        /**
+        * Parse an XML document
+        * @param TDesC8& The raw XML data
+        * @param Pointer to the document/fragment root
+        * @return void
+        */       
+        IMPORT_C void ParseDocumentL( const TDesC8& aXmlDocument,
+                                      CXdmDocumentNode* aDocumentRoot );
+
+        /**
+        * Format a document model into textual form
+        * @param TBool Indicates whether the document is whole
+        * @param CXdmDocument The document instance
+        * @param CXdmDocumentNode Pointer to the document/fragment root
+        * @return HBufC8* The document in textual form
+        */       
+        IMPORT_C HBufC8* FormatToXmlLC( TBool aIsWholeDocument,
+                                        const CXdmDocument* aDocument,
+                                        const CXdmDocumentNode* aRootNode );
+                                               
+        /**
+        * Format a document model into textual form and append the fragment
+        * in the first parameter to the correct place inside the document.
+        * @param TDesC8& The fragment to append
+        * @param CXdmDocument The document instance
+        * @param CXdmDocumentNode Pointer to the fragment
+        * @return HBufC8* The document in textual form
+        */        
+        IMPORT_C HBufC8* FormatToXmlLC( const TDesC8& aXmlFragment,
+                                        const CXdmDocument* aDocument,
+                                        const CXdmDocumentNode* aTargetNode );
+                                               
+        /**
+        * Destructor.
+        */      
+        IMPORT_C virtual ~CXdmXmlParser();
+
+    public: 
+    
+    #ifdef _DEBUG
+        
+        /**
+        * Write to log file
+        * @param TRefByValue<const TDesC8> The log line
+        * @return void
+        */  
+        void WriteToLog( TRefByValue<const TDesC8> aFmt,... ) const;
+    
+    #endif
+        
+    public:   
+    
+        /**
+        * Stop the parser
+        * @return void
+        */  
+        void FinishParsingL();
+        
+    private:
+        
+        /**
+        * C++ constructor is private
+        * @return CXdmXmlParser
+        */    
+        CXdmXmlParser();
+
+        /**
+        * Second-phase constructor
+        * @return void
+        */    
+        void ConstructL();
+                          
+    #ifdef _DEBUG
+    
+        /**
+        * Return the current system time
+        * @return TInt Current system time in integer format
+        */  
+        static TInt TimeL();
+        
+        /**
+        * Write the formatted document to the log folder
+        * @param HBufC8* Pointer to the data segment
+        * @return void
+        */  
+        void DumpDocumentL( HBufC8* aDocData );
+    
+    #endif
+            
+    private: //Data
+        
+        TInt                                iDumpIndex;
+        TPtr8                               iXmlDocument;
+        CParser*                            iXmlParser;
+        CXdmLogWriter*                      iLogWriter;
+        CXmlFormatter*                      iXmlFormatter;
+        TRequestStatus*                     iClientStatus;
+        CXdmXmlContentHandler*              iContentHandler;
+    };
+
+#endif  //__XDMXMLPARSER__
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/inc/XmlFormatter.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,212 @@
+/*
+* 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:   CXmlFormatter
+*
+*/
+
+
+
+
+#ifndef __XMLFORMATTER__
+#define __XMLFORMATTER__
+
+// INCLUDES
+#include <e32base.h>
+#include "XmlParserNodePath.h"
+#include "XmlNodePathInterface.h"
+
+//Konsts
+_LIT8( KXmldocumentStart,               "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
+
+//Forwar declarations
+class CXdmDocument;
+class CXdmXmlParser;
+class CXdmDocumentNode;
+class MXdmNodeInterface;
+class CXmlParserNodePath;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXmlFormatter ) : public CBase,
+                                     public MXmlNodePathInterface
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Symbian OS Constructor
+        * @return CXmlFormatter* New XML formatter
+        */
+        static CXmlFormatter* NewL( CXdmXmlParser& aParserMain );
+        
+        /**
+        * Format a document
+        * @param TBool Indicates whether parameter is a whole document
+        * @param CXdmDocument* The target document
+        * @param CXdmDocumentNode* The target element
+        * @return HBufC8* The document in textual form
+        */
+        HBufC8* FormatLC( TBool aIsWholeDocument,
+                          const CXdmDocument* aDocument,
+                          const CXdmDocumentNode* aRootNode );
+        
+        /**
+        * Format a document
+        * @param TDesC8& An XML fragment to append
+        * @param CXdmDocument* The target document
+        * @param CXdmDocumentNode* The target element
+        * @return HBufC8* The document in textual form
+        */
+        HBufC8* FormatLC( const TDesC8& aXmlFragment,
+                          const CXdmDocument* aDocument,
+                          const CXdmDocumentNode* aTargetNode );
+                          
+        /**
+        * Destructor
+        */
+        virtual ~CXmlFormatter();
+    
+    private:  //From MXmlParserNodePathInterface
+        
+        /**
+        * Return the target attribute
+        * @return CXdmNodeAttribute* target attribute
+        */
+        CXdmNodeAttribute* TargetAttribute() const;
+        
+    private:
+        
+        /**
+        * C++ constructor
+        * @return CXmlFormatter
+        */
+        CXmlFormatter( CXdmXmlParser& aParserMain );
+        
+        /**
+        * Symbian OS second-phase constructor
+        * @return void
+        */
+        void ConstructL();
+
+        /**
+        * Read data from the format buffer into a contiguous segment
+        * @return HBufC8* An XML document in textual form
+        */  
+        HBufC8* BufferToStringLC();
+        
+        /**
+        * Check the next element in a document
+        * @param CXdmDocumentNode& An XML element
+        * @return void
+        */
+        void CheckSubsetPath( const CXdmDocumentNode& aNode );
+        
+        /**
+        * Reset the internal format buffer
+        * @return void
+        */  
+        void ResetFormatBuffer();
+        
+        /**
+        * Find the (local) name of an element
+        * @param TDesC8& The whole element string
+        * @return TPtrC8 Name part of the element string
+        */ 
+        TPtrC8 FindElementName( const TDesC8& aElementString );
+        
+        /**
+        * Format namespace declarations
+        * @param CXdmDocumentNode& An XML element
+        * @return MXdmNamespaceContainer& Namespace container
+        */ 
+        void FormatNamespaceDeclarationsL( const CXdmDocumentNode& aRootNode,
+                                           const MXdmNamespaceContainer& aContainer );
+                                           
+        /**
+        * Format the parameter element and its descendants
+        * @param CXdmDocumentNode The element to format
+        * @return void
+        */  
+        void FormatElementsL( CXdmDocumentNode* aCurrentNode );
+
+        /**
+        * Format a leaf element 
+        * @param CXdmDocumentNode The element to format
+        * @return void
+        */    
+        void FormatLeafElementL( CXdmDocumentNode* aCurrentNode );
+        
+        /**
+        * Format the start of the parameter element
+        * @param TDesC8& Element prefix 
+        * @param TDesC8& Element URI 
+        * @return void
+        */ 
+        void FormatElementStartL( const TDesC8& aPrefix,
+                                  const TDesC8& aElementData ); 
+
+        /**
+        * Format the end of the parameter element
+        * @param TDesC8& Element prefix 
+        * @param TDesC8& Element URI 
+        * @return void
+        */ 
+        void FormatElementEndL( const TDesC8& aPrefix,
+                                const TDesC8& aElementData );
+        
+        /**
+        * Format an empty element 
+        * @param CXdmDocumentNode The element to format
+        * @return void
+        */    
+        void FormatEmptyElementL( CXdmDocumentNode* aEmptyNode );
+        
+                                                   
+        /**
+        * Append a namespace mapping
+        * @param TDesC8& Element URI 
+        * @param TDesC8& Element prefix
+        * @return void
+        */                                      
+        void AppendNamespaceL( const TDesC8& aUri, const TDesC8& aPrefix );
+        
+        /**
+        * Append XML fragment into the format buffer
+        * @return void
+        */ 
+        void AppendXmlFragmentL();
+        
+        /**
+        * Return the prefix of the parameter element
+        * @param MXdmNodeInterface& An XML element
+        * @return TPtrC8 Prefix
+        */  
+        TPtrC8 Prefix( const MXdmNodeInterface& aInterface );
+        
+    private: //Data
+        
+        TInt                                iFormBufferPos;
+        TBool                               iTargetFound;
+        TBool                               iIsAppended;
+        CBufSeg*                            iFormatBuffer;
+        TPtrC8                              iDocumentFragment;
+        CXdmXmlParser&                      iParserMain;
+        CXdmNodeAttribute*                  iTargetAttribute;
+        CXmlParserNodePath*                 iNodePath;
+        TXdmElementType                     iElementType;
+       
+    };
+
+#endif  //__XMLPARSERNODEPATH__
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/inc/XmlNodePathInterface.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,44 @@
+/*
+* 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:   MXmlNodePathInterface
+*
+*/
+
+
+
+
+#ifndef __XMLNODEPATHINTERFACE__
+#define __XMLNODEPATHINTERFACE__
+
+// INCLUDES
+#include <e32base.h>
+
+class CXdmNodeAttribute;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( MXmlNodePathInterface )
+    {
+    public: 
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        virtual CXdmNodeAttribute* TargetAttribute() const = 0;
+    };
+
+#endif  //__XMLPARSERNODEPATH__
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/inc/XmlParserDefines.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   XmlParserDefines
+*
+*/
+
+
+
+
+#ifndef __XMLPARSERDEFINES__
+#define __XMLPARSERDEFINES__
+
+//  INCLUDES
+#include <e32base.h>
+        
+_LIT8( KEquelsSignString,                               "=" );
+_LIT8( KQuotationSignString,                            "\"" );
+_LIT8( KSlashString,                                    "/" );
+_LIT8( KCommentString,                                  "<!--" );
+_LIT8( KEmptyElementString,                             "/>" );
+_LIT8( KStartBracketString,                             "<" );
+_LIT8( KEndBracketString,                               ">" );
+_LIT8( KXmlNamespaceString,                             " xmlns" );
+_LIT8( KPrefixSeparatorString,                          ":" );
+_LIT8( KNewlineString,                                  "\r\n" );
+_LIT8( KSpaceString,                                    " " );
+
+const TInt KStartBracket                                = 60;
+const TInt KEndBracket                                  = 62;
+const TInt KSpace                                       = 32;
+const TInt KEquality                                    = 61;
+const TInt KQuotation                                   = 34;
+
+#endif      //__XMLPARSERDEFINES__  
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/inc/XmlParserNodePath.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,97 @@
+/*
+* 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:   CXmlParserNodePath
+*
+*/
+
+
+
+
+#ifndef __XMLPARSERNODEPATH__
+#define __XMLPARSERNODEPATH__
+
+// INCLUDES
+//#include <parser.h>
+#include <e32base.h>
+#include <badesca.h>
+#include <contenthandler.h>
+
+class CXdmXmlParser;
+class CXdmDocumentNode;
+class MXmlNodePathInterface;
+
+// CLASS DECLARATION
+NONSHARABLE_CLASS( CXmlParserNodePath ) : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        static CXmlParserNodePath* NewL( CXdmXmlParser& aParserMain,
+                                         TXdmElementType iElementType,
+                                         const CXdmDocumentNode& aTargetNode,
+                                         MXmlNodePathInterface* aPathInterface );
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        TBool CheckNextNode( const CXdmDocumentNode& aNextNode );
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        TBool CheckNextNodeL( const TDesC8& aNextElement,
+                              const Xml::RAttributeArray& aAttributes );
+                              
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        virtual ~CXmlParserNodePath();
+        
+    private:
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        CXmlParserNodePath( CXdmXmlParser& aParserMain,
+                            TXdmElementType aElementType,
+                            MXmlNodePathInterface* aPathInterface );
+        
+        /**
+        * Copies the request data
+        * @param aRequestData Data to be sent
+        */
+        void ConstructL( const CXdmDocumentNode& aTargetNode );
+        
+    private: //Data
+        
+        TInt                                iIndex;
+        TBool                               iComplete;
+        TXdmElementType                     iElementType;
+        MXmlNodePathInterface*              iPathInterface;
+        RPointerArray<CXdmDocumentNode>     iNodes;
+        CXdmXmlParser&                      iParserMain;
+    };
+
+#endif  //__XMLPARSERNODEPATH__
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/src/XdmXmlContentHandler.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,519 @@
+/*
+* 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:   CXdmXmlContentHandler
+*
+*/
+
+
+
+#include <XdmDocument.h>
+#include <contenthandler.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+#include "XdmNamespaceContainer.h"
+#include "XdmXmlParser.h"
+#include "XdmNodeInterface.h"
+#include "XmlParserNodePath.h"
+#include "XdmXmlContentHandler.h"
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::CXdmXmlContentHandler
+//
+// ---------------------------------------------------------
+//
+CXdmXmlContentHandler::CXdmXmlContentHandler( CXdmXmlParser& aParserMain ) :
+                                              iFinished( EFalse ),
+                                              iTargetFound( EFalse ),
+                                              iPartialDocument( EFalse ),
+                                              iParserMain( aParserMain )
+
+    {   
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::NewL
+//
+// ---------------------------------------------------------
+//
+CXdmXmlContentHandler* CXdmXmlContentHandler::NewL( CXdmXmlParser& aParserMain )
+    {
+    CXdmXmlContentHandler* self = new ( ELeave ) CXdmXmlContentHandler( aParserMain );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::ConstructL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::ConstructL()
+    {
+    iContentBuffer = CBufFlat::NewL( 50 ); 
+    }
+            
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::~CXdmXmlContentHandler
+//
+// ---------------------------------------------------------
+//
+CXdmXmlContentHandler::~CXdmXmlContentHandler()
+    { 
+    delete iNodePath;
+    delete iContentBuffer;
+    }
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::SetTarget
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::SetTarget( const CXdmDocument& aTargetDocument )
+    {
+    iTargetDocument = CONST_CAST( CXdmDocument*, &aTargetDocument );
+    iRootNode = iTargetDocument->DocumentRoot();
+    iDocumentSubset = NULL;
+    iIsRootNode = ETrue;
+    }
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::SetTarget
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::SetTarget( const CXdmDocumentNode& aDocumentRoot )
+    {
+    iTargetDocument = NULL;
+    iRootNode = CONST_CAST( CXdmDocumentNode*, &aDocumentRoot );
+    iDocumentSubset = NULL;
+    iIsRootNode = ETrue;
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::SetTarget 
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::SetTargetL( const CXdmDocument& aTargetDocument,
+                                        const CXdmDocumentNode& aTargetNode )
+    {
+    iElementType = aTargetNode.ElementType();
+    iTargetDocument = CONST_CAST( CXdmDocument*, &aTargetDocument );
+    if( iElementType == EXdmElementAttribute )
+        {
+        iTargetAttribute = ( CXdmNodeAttribute* )&aTargetNode;
+        iDocumentSubset = CONST_CAST( CXdmDocumentNode*, aTargetNode.Parent() );
+        }
+    else 
+        {
+        iTargetAttribute = NULL;
+        iDocumentSubset = CONST_CAST( CXdmDocumentNode*, &aTargetNode );
+        }
+    iNodePath = CXmlParserNodePath::NewL( iParserMain, iElementType, *iDocumentSubset, this );
+    iRootNode = iDocumentSubset; 
+    iPartialDocument = ETrue;
+    iCurrentNode = NULL;
+    }
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::TargetAttribute
+//
+// ---------------------------------------------------------
+//
+CXdmNodeAttribute* CXdmXmlContentHandler::TargetAttribute() const
+    {
+    return iTargetAttribute;
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::Reset
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::Reset()
+    {
+    iTargetDocument = NULL;
+    iTargetAttribute = NULL;
+    iDocumentSubset = NULL;
+    iRootNode = NULL;
+    iCurrentNode = NULL;
+    delete iNodePath;
+    iNodePath = NULL;
+    iFinished = EFalse;
+    iTargetFound = EFalse;
+    iPartialDocument = EFalse;
+    }
+       
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::GetExtendedInterface
+//
+// ---------------------------------------------------------
+//
+TAny* CXdmXmlContentHandler::GetExtendedInterface( const TInt32 /*aUid*/ )    
+    {
+    return NULL; 
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::OnContentL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::OnContentL( const TDesC8 &aBytes,
+                                        TInt aErrorCode )
+    {
+    #ifdef _DEBUG
+        iParserMain.WriteToLog( _L8( "CXmlNode::OnContentL()" ), aErrorCode );
+        iParserMain.WriteToLog( _L8( "  Bytes: %S" ), &aBytes );
+        iParserMain.WriteToLog( _L8( "  Error: %d" ), aErrorCode );
+    #endif
+    if( iPartialDocument && !iTargetFound )
+        return;
+    TInt length = aBytes.Length();
+    TPtr8 desc( CONST_CAST( TUint8*, aBytes.Ptr() ), length, length );
+    desc.TrimAll();
+    if( desc.Length() > 0 )
+        {
+        iContentBuffer->InsertL( iContentIndex, desc );
+        iContentIndex = iContentIndex + desc.Length();
+        }
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::OnEndDocumentL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::OnEndDocumentL( TInt aErrorCode )
+    {
+    iIsRootNode = ETrue;
+    #ifdef _DEBUG
+        iParserMain.WriteToLog( _L8( "CXmlNode::OnEndDocumentL() - Error: %d "), aErrorCode );
+    #endif
+    }
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::OnEndElementL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::OnEndElementL( const RTagInfo &aElement,
+                                           TInt aErrorCode )
+    {
+    TPtrC8 element( aElement.LocalName().DesC() );
+    #ifdef _DEBUG
+        iParserMain.WriteToLog( _L8( "CXmlNode::OnEndElementL() - Element: %S  Error: %d "),
+                                   &element, aErrorCode );
+    #endif
+    if( iCurrentNode != NULL && iContentBuffer->Size() > 0 )
+        {
+        TPtrC8 data( iContentBuffer->Ptr( 0 ) );
+        iCurrentNode->SetLeafNode( ETrue );
+        iCurrentNode->SetLeafNodeContentL( data );
+        iContentBuffer->Reset();
+        iContentIndex = 0;
+        }
+    if( iCurrentNode != NULL && iCurrentNode->NodeCount() == 0 )
+        iCurrentNode->SetEmptyNode( ETrue );
+    if( iPartialDocument )
+        {
+        if( !iFinished )
+            {
+            if( iCurrentNode != NULL )
+                {
+                CXdmDocumentNode* parent = iCurrentNode->Parent();
+                #ifdef _DEBUG
+                    TBuf8<64> parentName;
+                    TBuf8<64> currentName;
+                    parentName.Copy( parent->NodeName() );
+                    currentName.Copy( iCurrentNode->NodeName() );
+                    iParserMain.WriteToLog( _L8( " Parent: %x - %S "), parent, &parentName );
+                    iParserMain.WriteToLog( _L8( " Current: %x - %S"), iCurrentNode, &currentName );
+                #endif  
+                if( parent != NULL && iCurrentNode != parent )
+                    iCurrentNode = iCurrentNode->Parent();
+                iFinished = iCurrentNode == iDocumentSubset->Parent();
+                if( iFinished )
+                    iCurrentNode = NULL;
+                #ifdef _DEBUG
+                    iParserMain.WriteToLog( _L8( " Current: %x"), iCurrentNode );
+                #endif   
+                }   
+            }
+        }
+    else if ( iCurrentNode ) 
+        {
+        iCurrentNode = iCurrentNode->Parent();
+        }
+    else
+        {
+        // For PC-lint note
+        }
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::OnEndPrefixMappingL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::OnEndPrefixMappingL( const RString& /*aPrefix*/,
+                                                 TInt aErrorCode )
+    {
+    #ifdef _DEBUG
+        iParserMain.WriteToLog( _L8( "CXmlNode::OnEndPrefixMappingL() - Error: %d "), aErrorCode );
+    #endif
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::OnError
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::OnError( TInt aErrorCode )
+    {
+    #ifdef _DEBUG
+        iParserMain.WriteToLog( _L8( "CXmlNode::OnError() - Error: %d" ), aErrorCode );
+    #endif
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::OnIgnorableWhiteSpaceL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/,
+                                                    TInt /*aErrorCode*/ )
+    {
+    #ifdef _DEBUG
+        //iParserMain.WriteToLog( _L8( "CXmlNode::OnIgnorableWhiteSpaceL() - Error: %d" ), aErrorCode );
+    #endif
+    }
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::OnProcessingInstructionL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::OnProcessingInstructionL( const TDesC8& /*aTarget*/,
+                                                      const TDesC8& /*aData*/,
+                                                      TInt /*aErrorCode*/ )
+    {
+    #ifdef _DEBUG
+       // iParserMain.WriteToLog( _L8( "CXmlNode::OnProcessingInstructionL() - Error: %d" ), aErrorCode );
+    #endif
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::OnSkippedEntityL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::OnSkippedEntityL( const RString& /*aName*/,
+                                              TInt /*aErrorCode*/ )
+    {
+    #ifdef _DEBUG
+        //iParserMain.WriteToLog( _L8( "CXmlNode::OnSkippedEntityL() - Error: %d" ), aErrorCode );
+    #endif
+    }
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::OnStartDocumentL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::OnStartDocumentL( const RDocumentParameters& /*aDocParam*/, TInt aErrorCode )
+    {
+    #ifdef _DEBUG
+        iParserMain.WriteToLog( _L8( "CXmlNode::OnStartDocumentL() - Error: %d "), aErrorCode );
+    #endif
+    }
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::OnStartElementL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::OnStartElementL( const RTagInfo& aElement,
+                                             const RAttributeArray& aAttributes,
+                                             TInt aErrorCode )
+    {
+    TPtrC8 name( aElement.LocalName().DesC() );
+    TPtrC8 uri( aElement.Uri().DesC() );
+    TPtrC8 prefix( aElement.Prefix().DesC() );
+    #ifdef _DEBUG
+        iParserMain.WriteToLog( _L8( "CXmlNode::OnStartElementL(): Error: %d" ), aErrorCode );
+        iParserMain.WriteToLog( _L8( "  URI:     %S" ), &uri );
+        iParserMain.WriteToLog( _L8( "  Name:    %S" ), &name );
+        iParserMain.WriteToLog( _L8( "  Prefix:  %S" ), &prefix );
+    #endif
+    if( iPartialDocument )
+        {   
+        if( !iFinished )
+            {
+            if( iTargetFound )
+                {
+                iCurrentNode = iCurrentNode->CreateChileNodeL();
+                HandleNextElementL( aElement, aAttributes );
+                }
+            else
+                {
+                if( iNodePath->CheckNextNodeL( name, aAttributes ) )
+                    {
+                    if( iElementType == EXdmElementAttribute )
+                        AppendAttributeValueL( aAttributes );
+                    else
+                        {
+                        iTargetFound = ETrue;
+                        iCurrentNode = iDocumentSubset;
+                        }
+                    }
+                }
+            }
+        }
+    else
+        {
+        iCurrentNode = iIsRootNode ? iRootNode : iCurrentNode->CreateChileNodeL();
+        HandleNextElementL( aElement, aAttributes );
+        iIsRootNode = EFalse;
+        }    
+    }
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::HandleNextElementL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::HandleNextElementL( const RTagInfo& aElement,
+                                                const RAttributeArray& aAttributes )
+    {
+    #ifdef _DEBUG
+        //iParserMain.WriteToLog( _L8( "CXdmXmlContentHandler::HandleNextElementL()") );
+    #endif
+    iCurrentNode->SetNameL( aElement.LocalName().DesC() );
+    SetNamespaceInformationL( aElement, iCurrentNode );
+    TInt count = aAttributes.Count();
+    if( count > 0 )
+        {
+        CXdmNodeAttribute* attribute = NULL;
+        for( TInt i = 0;i < count;i++ )
+            {
+            attribute = iCurrentNode->CreateAttributeL();
+            CleanupStack::PushL( attribute );
+            attribute->SetNameL( aAttributes[i].Attribute().LocalName().DesC() );
+            attribute->SetAttributeValueL( aAttributes[i].Value().DesC() );
+            CleanupStack::Pop();  //attribute
+            }
+        }
+    }
+                        
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::CompileAttributesL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::AppendAttributeValueL( const RAttributeArray& aAttributes )
+    {
+    #ifdef _DEBUG
+        //iParserMain.WriteToLog( _L8( "CXdmXmlContentHandler::AppendAttributeValueL()") );
+    #endif
+    TInt count = aAttributes.Count();
+    TPtrC8 targetName( iTargetAttribute->EightBitNodeNameLC()->Des() );
+    for( TInt i = 0;!iFinished && i < count;i++ )
+        {
+        TPtrC8 desc = aAttributes[i].Attribute().LocalName().DesC();
+        #ifdef _DEBUG
+            iParserMain.WriteToLog( _L8( "  Name of attribute %d: %S"), i, &desc );
+        #endif
+        if( targetName.Compare( desc ) == 0 )
+            {
+            iFinished = ETrue;
+            TPtrC8 value( aAttributes[i].Value().DesC() );
+            iTargetAttribute->SetAttributeValueL( value );
+            }
+        }
+    CleanupStack::PopAndDestroy();  //desc
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::OnStartPrefixMappingL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::OnStartPrefixMappingL( const RString& aPrefix,
+                                                   const RString& aUri,
+                                                   TInt aErrorCode )
+    {
+    #ifdef _DEBUG
+        iParserMain.WriteToLog( _L8( "CXdmXmlContentHandler::OnStartPrefixMappingL() - Error: %d" ), aErrorCode );
+    #endif
+    AppendNameSpaceL( aPrefix.DesC(), aUri.DesC() );
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::IsWhiteSpace
+//
+// ---------------------------------------------------------
+//
+TBool CXdmXmlContentHandler::IsWhiteSpace( const TDesC8 &aBytes ) const
+    {
+    #ifdef _DEBUG
+        //iParserMain.WriteToLog( _L8( "CXdmXmlContentHandler::IsWhiteSpace()") );
+    #endif
+    TBool ret = ETrue;
+    if( aBytes.Length() > 0 )
+        {
+        TChar ch = aBytes[0];
+        ret = ch == 32 || ch == 10 || ch == 13 || ch == 9;
+        }
+    return ret;
+    }
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::AppendNameSpaceL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::AppendNameSpaceL( const TDesC8& aPrefix, const TDesC8& aUri )
+    {
+    #ifdef _DEBUG
+        //iParserMain.WriteToLog( _L8( "CXdmXmlContentHandler::SetNameSpaceInformationL()") );
+    #endif
+    if( iTargetDocument != NULL )
+        {
+        MXdmNamespaceContainer* container = iTargetDocument;
+        container->AppendNamespaceL( aUri, aPrefix );
+        }
+    }
+       
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::SetNameSpaceInformationL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlContentHandler::SetNamespaceInformationL( const RTagInfo& aElement,
+                                                      MXdmNodeInterface* aXcapNode )
+    {
+    #ifdef _DEBUG
+        //iParserMain.WriteToLog( _L8( "CXdmXmlContentHandler::SetNameSpaceInformationL()") );
+    #endif
+    TPtrC8 prefix( aElement.Prefix().DesC() );
+    if( prefix.Length() > 0 )
+        {
+        aXcapNode->SetPrefixL( prefix );
+        }
+    }
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/src/XdmXmlParser.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,285 @@
+/*
+* 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:   CXdmXmlParser
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <hal.h>
+#include <parser.h>
+#include <f32file.h>
+#include <flogger.h>
+#include <parserfeature.h>
+#include <XdmNodeAttribute.h>
+#include <XdmDocument.h>
+#include <xdmlogwriter.h>
+#include <XdmDocumentNode.h>
+#include "XdmXmlParser.h"
+#include "XmlFormatter.h"
+#include "XmlParserDefines.h"
+#include "XdmXmlContentHandler.h"
+
+// ----------------------------------------------------------
+// CXdmXmlParser::CXdmXmlParser
+// 
+// ----------------------------------------------------------
+//
+CXdmXmlParser::CXdmXmlParser() : iDumpIndex( 1 ),
+                                 iXmlDocument( ( TText8* )"", 0, 0 )                                           
+    {
+    }
+
+// ----------------------------------------------------------
+// CXdmXmlParser::NewL
+// 
+// ----------------------------------------------------------
+//
+EXPORT_C CXdmXmlParser* CXdmXmlParser::NewL()
+    {
+    CXdmXmlParser* self = new ( ELeave ) CXdmXmlParser();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXdmXmlParser::ConstructL
+// 
+// ----------------------------------------------------------
+//
+void CXdmXmlParser::ConstructL()
+    {
+    #ifdef _DEBUG
+        iLogWriter = CXdmLogWriter::NewL( KParserLogFile );
+        WriteToLog( _L8( "CXdmXmlParser::ConstructL()" ) );
+    #endif
+    iXmlFormatter = CXmlFormatter::NewL( *this );
+    iContentHandler = CXdmXmlContentHandler::NewL( *this );
+    iXmlParser = CParser::NewL( KDefaultMimeType, *iContentHandler );               
+    }
+
+// ----------------------------------------------------
+// CXdmXmlParser::~CXdmXmlParser
+// 
+// ----------------------------------------------------
+//
+CXdmXmlParser::~CXdmXmlParser()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmXmlParser::~CXdmXmlParser()" ) );
+    #endif
+    delete iXmlParser;
+    delete iLogWriter;
+    delete iXmlFormatter;
+    delete iContentHandler;
+    }
+     
+// ----------------------------------------------------------
+// CXdmXmlParser::ParseDocumentL
+// 
+// ----------------------------------------------------------
+//    
+EXPORT_C void CXdmXmlParser::ParseDocumentL( CXdmDocument* aDocument,
+                                             const TDesC8& aXmlDocument )  
+    {
+    #ifdef _DEBUG
+        TInt start = CXdmXmlParser::TimeL();
+    #endif
+    CXdmDocumentNode* root = aDocument->DocumentRoot();
+    if( root == NULL )
+        aDocument->CreateRootL();
+    User::LeaveIfError( iXmlParser->EnableFeature( EReportNamespaceMapping ) );
+    iContentHandler->SetTarget( *aDocument );
+    Xml::ParseL( *iXmlParser, aXmlDocument );
+    iContentHandler->Reset();
+    //self->ParseL( aDocument, aXmlDocument );
+    #ifdef _DEBUG
+        TInt finish = CXdmXmlParser::TimeL();
+        WriteToLog( _L8( "CXdmXmlParser::ParseDocumentL() - Parsing took %d milliseconds" ), finish - start ); 
+    #endif
+    }
+
+// ----------------------------------------------------------
+// CXdmXmlParser::ParseDocumentL
+// 
+// ----------------------------------------------------------
+// 
+EXPORT_C void CXdmXmlParser::ParseDocumentL( const TDesC8& aXmlDocument,
+                                             CXdmDocumentNode* aDocumentRoot )  
+    {
+    #ifdef _DEBUG
+        TInt start = CXdmXmlParser::TimeL();
+    #endif
+    User::LeaveIfError( iXmlParser->EnableFeature( EReportNamespaceMapping ) );
+    iContentHandler->SetTarget( *aDocumentRoot );
+    Xml::ParseL( *iXmlParser, aXmlDocument );
+    iContentHandler->Reset();
+    //self->ParseL( aXmlDocument, aDocumentRoot );
+    #ifdef _DEBUG
+        TInt finish = CXdmXmlParser::TimeL();
+        WriteToLog( _L8( "CXdmXmlParser::ParseDocumentL() - Parsing took %d milliseconds" ), finish - start ); 
+    #endif
+    }
+    
+// ----------------------------------------------------------
+// CXdmXmlParser::ParseDocumentL
+// 
+// ----------------------------------------------------------
+// 
+EXPORT_C void CXdmXmlParser::ParseDocumentL( CXdmDocument* aDocument,
+                                             const TDesC8& aXmlDocument,
+                                             CXdmDocumentNode* aDocumentSubset )  
+    {
+    #ifdef _DEBUG
+        TInt start = CXdmXmlParser::TimeL();
+    #endif
+    User::LeaveIfError( iXmlParser->EnableFeature( EReportNamespaces ) );
+    User::LeaveIfError( iXmlParser->EnableFeature( EReportNamespaceMapping ) );
+    User::LeaveIfError( iXmlParser->EnableFeature( EReportNamespacePrefixes ) );
+    iContentHandler->SetTargetL( *aDocument, *aDocumentSubset );
+    Xml::ParseL( *iXmlParser, aXmlDocument );
+    iContentHandler->Reset();
+    //self->ParseL( aDocument, aXmlDocument, aDocumentSubset );
+    #ifdef _DEBUG
+        TInt finish = CXdmXmlParser::TimeL();
+        CXdmXmlParser::WriteToLog( _L8(
+            "CXdmXmlParser::ParseDocumentL() - Parsing took %d milliseconds" ), finish - start ); 
+    #endif
+    }
+    
+// ----------------------------------------------------------
+// CXdmXmlParser::FormatToXmlLC
+// 
+// ----------------------------------------------------------
+//       
+EXPORT_C HBufC8* CXdmXmlParser::FormatToXmlLC( TBool aIsWholeDocument,
+                                               const CXdmDocument* aDocument, 
+                                               const CXdmDocumentNode* aRootNode )
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmXmlParser::FormatToXmlLC" ) );
+        TInt start = CXdmXmlParser::TimeL();
+    #endif
+    HBufC8* ret = iXmlFormatter->FormatLC( aIsWholeDocument, aDocument, aRootNode );
+    #ifdef _DEBUG
+        DumpDocumentL( ret );
+        TInt finish = CXdmXmlParser::TimeL();
+        CXdmXmlParser::WriteToLog( _L8(
+            "CXdmXmlParser::FormatToXmlLC() - Formatting took %d milliseconds" ), finish - start ); 
+    #endif
+    return ret;  
+    }
+
+// ----------------------------------------------------------
+// CXdmXmlParser::FormatToXmlLC
+// 
+// ----------------------------------------------------------
+//      
+EXPORT_C HBufC8* CXdmXmlParser::FormatToXmlLC( const TDesC8& aXmlFragment,
+                                               const CXdmDocument* aDocument,
+                                               const CXdmDocumentNode* aTargetNode )
+    {
+    #ifdef _DEBUG
+        TInt start = CXdmXmlParser::TimeL();
+    #endif
+    //HBufC8* ret = self->FormatLC( aXmlFragment, aDocument, aTargetNode );
+    HBufC8* ret = iXmlFormatter->FormatLC( aXmlFragment, aDocument, aTargetNode );
+    #ifdef _DEBUG
+        DumpDocumentL( ret );
+        TInt finish = CXdmXmlParser::TimeL();
+        CXdmXmlParser::WriteToLog( _L8(
+            "CXdmXmlParser::FormatToXmlLC() - Formatting took %d milliseconds" ), finish - start ); 
+    #endif
+    return ret;  
+    }
+    
+// ---------------------------------------------------------
+// CXdmXmlParser::FinishParsing
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlParser::FinishParsingL()
+    {
+    #ifdef _DEBUG
+        WriteToLog( _L8( "CXdmXmlParser::FinishParsing()" ) );
+    #endif
+    iXmlParser->ParseEndL();
+    }
+
+#ifdef _DEBUG 
+
+// ---------------------------------------------------------
+// CXcapPartDocOperation::DumpDocumentL
+//
+// ---------------------------------------------------------
+//
+void CXdmXmlParser::DumpDocumentL( HBufC8* aDocData ) 
+    {
+    if( aDocData )
+        {
+        RFile file;
+        RFs session;
+        TPtr8 pointer( aDocData->Des() );
+        _LIT( KXmlFileExtension, ".xml" );
+        TBuf<128> nameBuf( _L( "C:\\logs\\XDM\\request" ) );
+        nameBuf.AppendNum( iDumpIndex );
+        nameBuf.Append( KXmlFileExtension );
+        User::LeaveIfError( session.Connect() );
+        TInt error( file.Replace( session, nameBuf, EFileWrite ) );
+        if( error == KErrNone )
+            {
+            file.Write( pointer );
+            file.Close();
+            iDumpIndex++;
+            }
+        session.Close();
+        }
+    }
+    
+// ----------------------------------------------------------
+// CXdmXmlParser::TimeL
+// 
+// ----------------------------------------------------------
+//
+TInt CXdmXmlParser::TimeL()
+    {
+    TInt period = 0;
+    User::LeaveIfError( HAL::Get( HALData::ESystemTickPeriod, period ) );
+    TInt millisecsPerTick = period / 1000;
+    return User::TickCount() * millisecsPerTick;
+    }
+
+// ----------------------------------------------------------
+// CXdmXmlParser::WriteToLog
+// 
+// ----------------------------------------------------------
+//
+void CXdmXmlParser::WriteToLog( TRefByValue<const TDesC8> aFmt,... ) const                                
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    TBuf8<KLogBufferMaxSize> buf;
+    buf.FormatList( aFmt, list );
+    iLogWriter->WriteToLog( buf );
+    }
+
+#endif
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/src/XmlFormatter.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,471 @@
+/*
+* 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:   CXmlFormatter
+*
+*/
+
+
+
+
+// INCLUDES
+#include <XdmDocument.h>
+#include <XdmDocumentNode.h>
+#include <XdmNodeAttribute.h>
+
+#include "xdmlogwriter.h"
+#include "XmlFormatter.h"
+#include "XmlParserDefines.h"
+#include "XmlParserNodePath.h"
+#include "XdmXmlParser.h"
+
+// ----------------------------------------------------------
+// CXmlFormatter::CXmlFormatter
+// 
+// ----------------------------------------------------------
+//
+CXmlFormatter::CXmlFormatter( CXdmXmlParser& aParserMain ) :
+                              iTargetFound( EFalse ),
+                              iIsAppended( EFalse ),
+                              iParserMain( aParserMain )
+    {
+    }
+
+// ----------------------------------------------------------
+// CXmlFormatter::NewL
+// 
+// ----------------------------------------------------------
+//    
+CXmlFormatter* CXmlFormatter::NewL( CXdmXmlParser& aParserMain )
+    {
+    CXmlFormatter* self = new ( ELeave ) CXmlFormatter( aParserMain );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ----------------------------------------------------------
+// CXmlFormatter::~CXmlFormatter
+// 
+// ----------------------------------------------------------
+//
+CXmlFormatter::~CXmlFormatter()
+    {        
+    }
+
+// ----------------------------------------------------------
+// CXmlFormatter::ConstructL
+// 
+// ----------------------------------------------------------
+//        
+void CXmlFormatter::ConstructL()
+    {
+    }
+
+// ---------------------------------------------------------
+// CXmlFormatter::Prefix
+//
+// ---------------------------------------------------------
+//
+TPtrC8 CXmlFormatter::Prefix( const MXdmNodeInterface& aInterface )
+    {
+    return aInterface.Prefix();
+    }
+
+// ---------------------------------------------------------
+// CXdmXmlContentHandler::Reset
+//
+// ---------------------------------------------------------
+//
+CXdmNodeAttribute* CXmlFormatter::TargetAttribute() const
+    {
+    return iTargetAttribute;
+    }
+    
+// ---------------------------------------------------------
+// CXmlFormatter::FindElementName
+//
+// ---------------------------------------------------------
+//
+TPtrC8 CXmlFormatter::FindElementName( const TDesC8& aElementString )
+    {
+    TInt index = aElementString.LocateF( 32 );
+    if( index > 0 )
+        return aElementString.Left( index );
+    else return aElementString;
+    }
+
+// ---------------------------------------------------------
+// CXmlFormatter::ResetFormatBuffer
+//
+// ---------------------------------------------------------
+//
+void CXmlFormatter::ResetFormatBuffer()
+    {
+    iFormBufferPos = 0;
+    delete iFormatBuffer;
+    iFormatBuffer = NULL;
+    delete iNodePath;
+    iNodePath = NULL;
+    }
+
+
+// ---------------------------------------------------------
+// CXmlFormatter::BufferToStringLC
+//
+// ---------------------------------------------------------
+//
+HBufC8* CXmlFormatter::BufferToStringLC()
+    {
+    HBufC8* ret = HBufC8::NewLC( iFormatBuffer->Size() );
+    TPtr8 pointer( ret->Des() );
+    iFormatBuffer->Read( 0, pointer, iFormatBuffer->Size() );
+    ResetFormatBuffer();
+    return ret;
+    }
+      
+// ---------------------------------------------------------
+// CXmlFormatter::CheckSubsetPath
+//
+// ---------------------------------------------------------
+//
+void CXmlFormatter::CheckSubsetPath( const CXdmDocumentNode& aNode )
+    {
+    iTargetFound = iNodePath->CheckNextNode( aNode );
+    }
+
+// ----------------------------------------------------------
+// CXmlFormatter::FormatLC
+// 
+// ----------------------------------------------------------
+//
+HBufC8* CXmlFormatter::FormatLC( const TDesC8& aXmlFragment,
+                                 const CXdmDocument* aDocument,
+                                 const CXdmDocumentNode* aTargetNode )
+    {
+    iIsAppended = EFalse;
+    iTargetFound = EFalse;
+    TBool addToRoot = EFalse;
+    iFormatBuffer = CBufSeg::NewL( 128 );
+    iElementType = aTargetNode->ElementType();
+    iDocumentFragment.Set( aXmlFragment );
+    iNodePath = CXmlParserNodePath::NewL( iParserMain, iElementType, *aTargetNode, this );
+    CXdmDocumentNode* element = aDocument->DocumentRoot();
+    CXdmDocumentNode* root = element;
+    CheckSubsetPath( *root );
+    if( iTargetFound )
+        {
+        addToRoot = ETrue;
+        iIsAppended = ETrue;
+        }
+    iFormatBuffer->InsertL( iFormBufferPos, KXmldocumentStart );
+    iFormBufferPos = iFormBufferPos + KXmldocumentStart().Length();
+    FormatNamespaceDeclarationsL( *root, *aDocument );
+    TInt count = element->NodeCount();
+    if( count > 0 )
+        {
+        for( TInt i = 0;i < count;i++ )
+            {
+            element = element->ChileNode( i );
+            FormatElementsL( element );
+            }
+        }
+    else FormatElementsL( element );
+    if( addToRoot )
+        AppendXmlFragmentL();
+    TPtrC8 name( root->EightBitNodeNameLC()->Des() );
+    TPtrC8 prefix = root->Prefix();
+    FormatElementEndL( prefix, name );
+    CleanupStack::PopAndDestroy();  //EightBitNodeNameLC()
+    HBufC8* ret = BufferToStringLC();
+    return ret;
+    }
+
+// ---------------------------------------------------------
+// CXmlFormatter::FormatElementsL
+//
+// ---------------------------------------------------------
+//
+void CXmlFormatter::FormatElementsL( CXdmDocumentNode* aCurrentNode )
+    {
+    TBool ready = EFalse;
+    TBool addNow = EFalse;
+    if( !iTargetFound && !iIsAppended )
+        {
+        CheckSubsetPath( *aCurrentNode );
+        addNow = iTargetFound && !iIsAppended;
+        }
+    TPtrC8 prefix = Prefix( *aCurrentNode );
+    TPtr8 pointer( aCurrentNode->ElementDataLC()->Des() );
+    FormatElementStartL( prefix, pointer );
+    while( !ready )
+        {
+        if( aCurrentNode->IsLeafNode() )
+            FormatLeafElementL( aCurrentNode );
+        TInt nodeCount = aCurrentNode->NodeCount();
+        if( nodeCount > 0 )
+            {
+            CXdmDocumentNode* child = NULL;
+            for( TInt i = 0;i < nodeCount;i++ )
+                {
+                child = aCurrentNode->ChileNode( i ); 
+                child->IsEmptyNode() && !child->IsLeafNode() ?
+                                     FormatEmptyElementL( child ):
+                                     FormatElementsL( child );
+                }
+            ready = ETrue;
+            }
+        else ready = ETrue;
+        }
+    if( addNow )
+        AppendXmlFragmentL();
+    FormatElementEndL( prefix, FindElementName( pointer ) );        
+    CleanupStack::PopAndDestroy(); //ElementDataLC()
+    }
+
+// ---------------------------------------------------------
+// CXmlFormatter::AppendXmlFragmentL
+//
+// ---------------------------------------------------------
+//
+void CXmlFormatter::AppendXmlFragmentL()
+    {
+    iFormatBuffer->InsertL( iFormBufferPos, iDocumentFragment );
+    iFormBufferPos = iFormBufferPos + iDocumentFragment.Length();
+    iIsAppended = ETrue;        
+    }
+                             
+// ----------------------------------------------------------
+// CXmlFormatter::FormatLC
+// 
+// ----------------------------------------------------------
+//
+HBufC8* CXmlFormatter::FormatLC( TBool aIsWholeDocument,
+                                 const CXdmDocument* aDocument,
+                                 const CXdmDocumentNode* aRootNode )
+    {
+    iIsAppended = ETrue; 
+    iFormatBuffer = CBufSeg::NewL( 128 );
+    CXdmDocumentNode* root = CONST_CAST( CXdmDocumentNode*, aRootNode );
+    if( aIsWholeDocument )
+        {
+        CXdmDocumentNode* element = NULL;
+        iFormatBuffer->InsertL( iFormBufferPos, KXmldocumentStart );
+        iFormBufferPos = iFormBufferPos + KXmldocumentStart().Length();
+        FormatNamespaceDeclarationsL( *root, *aDocument );
+        TInt count = root->NodeCount();
+        if( count > 0 )
+            {
+            for( TInt i = 0;i < count;i++ )
+                {
+                element = root->ChileNode( i );
+                FormatElementsL( element );
+                }
+            }
+        }
+    else FormatElementsL( root );
+    if( aIsWholeDocument )
+        {
+        TPtrC8 name( aRootNode->EightBitNodeNameLC()->Des() );
+        TPtrC8 prefix = aRootNode->Prefix();
+        FormatElementEndL( prefix, name );
+        CleanupStack::PopAndDestroy();  //EightBitNodeNameLC()
+        }
+    HBufC8* ret = BufferToStringLC();
+    return ret;
+    }
+
+// ----------------------------------------------------------
+// CXmlFormatter::FormatNamespaceDeclarationsL
+// 
+// ----------------------------------------------------------
+//
+void CXmlFormatter::FormatNamespaceDeclarationsL( const CXdmDocumentNode& aRootNode,
+                                                  const MXdmNamespaceContainer& aContainer )
+    {
+#ifdef _DEBUG
+    iParserMain.WriteToLog( _L8( "CXmlFormatter::FormatNamespaceDeclarationsL start" ) );
+#endif
+    TPtrC8 name( aRootNode.EightBitNodeNameLC()->Des() );
+    TPtrC8 prefix = Prefix( aRootNode );
+    iFormatBuffer->InsertL( iFormBufferPos, KStartBracketString );
+    iFormBufferPos = iFormBufferPos + KStartBracketString().Length();
+    if( prefix.Length() > 0 )
+        {
+        iFormatBuffer->InsertL( iFormBufferPos, prefix );
+        iFormBufferPos = iFormBufferPos + prefix.Length();
+        iFormatBuffer->InsertL( iFormBufferPos, KPrefixSeparatorString );
+        iFormBufferPos = iFormBufferPos + KPrefixSeparatorString().Length();
+        }
+    iFormatBuffer->InsertL( iFormBufferPos, name );
+    iFormBufferPos = iFormBufferPos + name.Length();
+    CleanupStack::PopAndDestroy();  //EightBitNodeNameLC()
+    if( aContainer.Count() > 0 )
+        {
+        TPtrC8 uri( _L8( "" ) );
+        TPtrC8 prefix( _L8( "" ) );
+        for( TInt i = 0;i < aContainer.Count();i++ )
+            {
+            uri.Set( aContainer.Uri( i ) );
+            prefix.Set( aContainer.Prefix( i ) );
+            AppendNamespaceL( uri, prefix );
+            }
+        }
+
+    // go through possible attributes after namespaces
+    for ( TInt i = 0; i < aRootNode.AttributeCount(); i++ )
+        {
+        iFormatBuffer->InsertL( iFormBufferPos, KSpaceString );
+        iFormBufferPos = iFormBufferPos + KSpaceString().Length();
+
+        CXdmNodeAttribute* attr = aRootNode.Attribute( i );
+        TPtrC8 name( attr->EightBitNodeNameLC()->Des() );
+        iFormatBuffer->InsertL( iFormBufferPos, name );
+        iFormBufferPos = iFormBufferPos + name.Length();
+        CleanupStack::PopAndDestroy();  //EightBitNodeNameLC()
+        iFormatBuffer->InsertL( iFormBufferPos, KEquelsSignString );
+        iFormBufferPos = iFormBufferPos + KEquelsSignString().Length();
+        iFormatBuffer->InsertL( iFormBufferPos, KQuotationSignString );
+        iFormBufferPos = iFormBufferPos + KQuotationSignString().Length();
+        TPtrC8 attrValue( attr->EightBitValueLC()->Des() );
+        iFormatBuffer->InsertL( iFormBufferPos, attrValue );
+        iFormBufferPos = iFormBufferPos + attrValue.Length();
+        CleanupStack::PopAndDestroy();  //EightBitValueLC()
+        iFormatBuffer->InsertL( iFormBufferPos, KQuotationSignString );
+        iFormBufferPos = iFormBufferPos + KQuotationSignString().Length();
+        }
+
+    iFormatBuffer->InsertL( iFormBufferPos, KEndBracketString );
+    iFormBufferPos = iFormBufferPos + KEndBracketString().Length();
+    iFormatBuffer->InsertL( iFormBufferPos, KNewlineString );
+    iFormBufferPos = iFormBufferPos + KNewlineString().Length();
+    #ifdef _DEBUG
+        iParserMain.WriteToLog( _L8( "CXmlFormatter::FormatNamespaceDeclarationsL exit" ) );
+    #endif
+    }
+
+// ---------------------------------------------------------
+// CXmlFormatter::FormatLeafElementL
+//
+// ---------------------------------------------------------
+//
+void CXmlFormatter::FormatLeafElementL( CXdmDocumentNode* aCurrentNode )
+    {
+    TPtrC8 escape( aCurrentNode->EscapeLeafNodeContentLC()->Des() );
+    iFormatBuffer->InsertL( iFormBufferPos, escape );
+    iFormBufferPos = iFormBufferPos + escape.Length();
+    CleanupStack::PopAndDestroy();  //EscapeLeafNodeContentLC()
+    }
+
+// ---------------------------------------------------------
+// CXmlFormatter::FormatEmptyElementL
+//
+// ---------------------------------------------------------
+//
+void CXmlFormatter::FormatEmptyElementL( CXdmDocumentNode* aEmptyNode ) 
+    {
+    TPtr8 empty( aEmptyNode->ElementDataLC()->Des() );
+    iFormatBuffer->InsertL( iFormBufferPos, KStartBracketString );
+    iFormBufferPos = iFormBufferPos + KStartBracketString().Length();
+    TPtrC8 prefix = Prefix( *aEmptyNode );
+    if( prefix.Length() > 0 )
+        {
+        iFormatBuffer->InsertL( iFormBufferPos, prefix );
+        iFormBufferPos = iFormBufferPos + prefix.Length();
+        iFormatBuffer->InsertL( iFormBufferPos, KPrefixSeparatorString );
+        iFormBufferPos = iFormBufferPos + KPrefixSeparatorString().Length();
+        }
+    iFormatBuffer->InsertL( iFormBufferPos, empty );
+    iFormBufferPos = iFormBufferPos + empty.Length();
+    CleanupStack::PopAndDestroy();  //ElementDataLC()
+    iFormatBuffer->InsertL( iFormBufferPos, KEmptyElementString );
+    iFormBufferPos = iFormBufferPos + TPtrC8( KEmptyElementString ).Length();
+    }
+    
+// ---------------------------------------------------------
+// CXmlFormatter::FormatElementStartL
+//
+// ---------------------------------------------------------
+//
+void CXmlFormatter::FormatElementStartL( const TDesC8& aPrefix,
+                                         const TDesC8& aElementData ) 
+    {
+    iFormatBuffer->InsertL( iFormBufferPos, KStartBracketString );
+    iFormBufferPos = iFormBufferPos + KStartBracketString().Length();
+    if( aPrefix.Length() > 0 )
+        {
+        iFormatBuffer->InsertL( iFormBufferPos, aPrefix );
+        iFormBufferPos = iFormBufferPos + aPrefix.Length();
+        iFormatBuffer->InsertL( iFormBufferPos, KPrefixSeparatorString );
+        iFormBufferPos = iFormBufferPos + KPrefixSeparatorString().Length();
+        }
+    iFormatBuffer->InsertL( iFormBufferPos, aElementData );
+    iFormBufferPos = iFormBufferPos + aElementData.Length();
+    iFormatBuffer->InsertL( iFormBufferPos, KEndBracketString );
+    iFormBufferPos = iFormBufferPos + KEndBracketString().Length();
+    }
+
+// ---------------------------------------------------------
+// CXmlFormatter::FormatElementEndL
+//
+// ---------------------------------------------------------
+//
+void CXmlFormatter::FormatElementEndL( const TDesC8& aPrefix,
+                                       const TDesC8& aElementName ) 
+    {
+    iFormatBuffer->InsertL( iFormBufferPos, KStartBracketString );
+    iFormBufferPos = iFormBufferPos + KStartBracketString().Length();
+    iFormatBuffer->InsertL( iFormBufferPos, KSlashString );
+    iFormBufferPos = iFormBufferPos + KSlashString().Length();
+    if( aPrefix.Length() > 0 )
+        {
+        iFormatBuffer->InsertL( iFormBufferPos, aPrefix );
+        iFormBufferPos = iFormBufferPos + aPrefix.Length();
+        iFormatBuffer->InsertL( iFormBufferPos, KPrefixSeparatorString );
+        iFormBufferPos = iFormBufferPos + KPrefixSeparatorString().Length();
+        }
+    iFormatBuffer->InsertL( iFormBufferPos, aElementName );
+    iFormBufferPos = iFormBufferPos + aElementName.Length();
+    iFormatBuffer->InsertL( iFormBufferPos, KEndBracketString );
+    iFormBufferPos = iFormBufferPos + KEndBracketString().Length();
+    }
+
+// ---------------------------------------------------------
+// CXmlFormatter::AppendNamespaceL
+//
+// ---------------------------------------------------------
+//
+void CXmlFormatter::AppendNamespaceL( const TDesC8& aUri, const TDesC8& aPrefix )
+    {
+    iFormatBuffer->InsertL( iFormBufferPos, KXmlNamespaceString );
+    iFormBufferPos = iFormBufferPos + KXmlNamespaceString().Length();
+    if( aPrefix.Length() > 0 )  //Not the default namespace
+        {   
+        iFormatBuffer->InsertL( iFormBufferPos, KPrefixSeparatorString );
+        iFormBufferPos = iFormBufferPos + KPrefixSeparatorString().Length();
+        iFormatBuffer->InsertL( iFormBufferPos, aPrefix );
+        iFormBufferPos = iFormBufferPos + aPrefix.Length();
+        }
+    iFormatBuffer->InsertL( iFormBufferPos, KEquelsSignString );
+    iFormBufferPos = iFormBufferPos + KEquelsSignString().Length();
+    iFormatBuffer->InsertL( iFormBufferPos, KQuotationSignString );
+    iFormBufferPos = iFormBufferPos + KQuotationSignString().Length();
+    iFormatBuffer->InsertL( iFormBufferPos, aUri );
+    iFormBufferPos = iFormBufferPos + aUri.Length();
+    iFormatBuffer->InsertL( iFormBufferPos, KQuotationSignString );
+    iFormBufferPos = iFormBufferPos + KQuotationSignString().Length();
+    }
+    
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/XdmXmlParser/src/XmlParserNodePath.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,155 @@
+/*
+* 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:   CXmlParserNodePath
+*
+*/
+
+
+
+#include <contenthandler.h>
+#include "XdmDocument.h"
+#include "XdmXmlParser.h"
+#include "XdmDocumentNode.h"
+#include "XdmNodeAttribute.h"
+#include "XmlParserNodePath.h"
+#include "XmlNodePathInterface.h"
+
+// ---------------------------------------------------------
+// CXmlParserNodePath::CXmlParserNodePath
+//
+// ---------------------------------------------------------
+//
+CXmlParserNodePath::CXmlParserNodePath( CXdmXmlParser& aParserMain,
+                                        TXdmElementType aElementType,
+                                        MXmlNodePathInterface* aPathInterface ) :
+                                        iElementType( aElementType ),
+                                        iPathInterface( aPathInterface ),
+                                        iParserMain( aParserMain )
+    {
+    }
+    
+// ---------------------------------------------------------
+// CXmlParserNodePath::ExtractString
+//
+// ---------------------------------------------------------
+//
+CXmlParserNodePath* CXmlParserNodePath::NewL( CXdmXmlParser& aParserMain,
+                                              TXdmElementType aElementType,
+                                              const CXdmDocumentNode& aTargetNode,
+                                              MXmlNodePathInterface* aPathInterface )
+    {
+    CXmlParserNodePath* self = new ( ELeave ) CXmlParserNodePath( aParserMain, aElementType, aPathInterface );
+    CleanupStack::PushL( self );
+    self->ConstructL( aTargetNode );
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------
+// CXmlParserNodePath::~CXmlParserNodePath
+//
+// ---------------------------------------------------------
+//
+CXmlParserNodePath::~CXmlParserNodePath()
+    {
+    iNodes.Close();
+    }
+    
+// ---------------------------------------------------------
+// CXmlParserNodePath::ConstructL
+//
+// ---------------------------------------------------------
+//
+void CXmlParserNodePath::ConstructL( const CXdmDocumentNode& aTargetNode )
+    {
+    #ifdef _DEBUG
+        iParserMain.WriteToLog( _L8( "CXmlParserNodePath::ConstructL()" ) );
+    #endif
+    CXdmDocumentNode* current = CONST_CAST( CXdmDocumentNode*, &aTargetNode );
+    while( current != NULL )
+        {   
+        iNodes.InsertL( current, 0 );
+        current = current->Parent();
+        }
+    }
+                               
+// ---------------------------------------------------------
+// CXmlParserNodePath::CheckNextNodeL
+//
+// ---------------------------------------------------------
+//
+TBool CXmlParserNodePath::CheckNextNodeL( const TDesC8& aNextElement,
+                                          const RAttributeArray& aAttributes )
+    {
+    #ifdef _DEBUG
+        //iParserMain.WriteToLog( _L8( "CXmlParserNodePath::CheckNextNodeL" ) );
+    #endif
+    if( !iComplete && aNextElement.Length() > 0 )
+        {
+        TInt attrCount = aAttributes.Count();
+        RPointerArray<SXdmAttribute8> attributes;
+        CleanupClosePushL( attributes );
+        for( TInt i = 0;i < attrCount;i++ )
+            {
+            SXdmAttribute8 attribute; 
+            attribute.iName.Set( aAttributes[i].Attribute().LocalName().DesC() );
+            attribute.iValue.Set( aAttributes[i].Value().DesC() );
+            User::LeaveIfError( attributes.Append( &attribute ) );
+            }
+        HBufC* unicode = HBufC::NewLC( aNextElement.Length() );
+        unicode->Des().Copy( aNextElement );
+        if( iNodes[iIndex]->Match( unicode->Des(), attributes ) )
+            {
+            iIndex++;
+            if( iElementType == EXdmElementAttribute )
+                iComplete = iNodes[iIndex] == iPathInterface->TargetAttribute()->Parent();
+            else /* or else if, the next if is not needed */
+                {
+                if( iIndex == iNodes.Count() )
+                    iComplete = ETrue;
+                }
+            }
+        CleanupStack::PopAndDestroy( 2 );   //unicode, attributes
+        }
+    return iComplete;
+    }
+    
+// ---------------------------------------------------------
+// CXmlParserNodePath::CheckNextNodeL
+//
+// ---------------------------------------------------------
+//
+TBool CXmlParserNodePath::CheckNextNode( const CXdmDocumentNode& aNextNode )
+    {
+    #ifdef _DEBUG
+        //iParserMain.WriteToLog( _L8( "CXmlParserNodePath::CheckNextNodeL" ) );
+    #endif
+    if( !iComplete )
+        {
+        if( iNodes[iIndex]->Match( aNextNode ) )
+            {
+            iIndex++;
+            if( iElementType == EXdmElementAttribute )
+                iComplete = iNodes[iIndex] == iPathInterface->TargetAttribute()->Parent();
+            else /* or else if, the next if is not needed */
+                {
+                if( iIndex == iNodes.Count() )
+                    iComplete = ETrue;
+                }
+            }
+        }
+    return iComplete;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/group/bld.inf	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:   XDM protocols bld.inf
+*
+*/
+
+
+
+#include <platform_paths.hrh>
+
+//--------------------
+PRJ_PLATFORMS
+//--------------------
+DEFAULT
+
+//--------------------
+PRJ_EXPORTS
+//--------------------
+
+//XDM Literal definitions
+
+    ../XcapProtocol/XcapAppUsage/inc/XcapAppUsageDef.h        |../../inc/xcapappusagedef.h
+
+// IBYs
+../rom/XdmProtocols.iby CORE_MW_LAYER_IBY_EXPORT_PATH(xdmprotocols.iby)
+
+//--------------------
+PRJ_MMPFILES
+//--------------------
+../XdmXmlParser/group/XdmXmlParser.mmp
+../XcapProtocol/XcapUtils/group/XcapUtils.mmp
+../XcapProtocol/XcapCache/Server/group/XcapCache.mmp
+../XcapProtocol/XcapCache/Client/group/XcapCacheClient.mmp
+../XcapProtocol/XcapAppUsage/group/XcapAppUsage.mmp
+../XcapProtocol/XcapHttpTransport/group/XcapHttpTransport.mmp
+../XcapProtocol/group/XcapProtocol.mmp
+../XcapProtocol/XcapOperations/group/XcapOperations.mmp
+../LocalProtocol/group/LocalProtocol.mmp
+../LocalProtocol/LocalOperations/group/LocalOperations.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/inc/XdmNamespace.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,74 @@
+/*
+* 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: CXdmNamespace
+*
+*/
+
+
+
+
+#ifndef __XDMNAMESPACE__
+#define __XDMNAMESPACE__
+
+#include <e32base.h>
+
+NONSHARABLE_CLASS ( CXdmNamespace ) : public CBase
+	{	
+    public:
+    
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    IMPORT_C static CXdmNamespace* NewL( const TDesC8& aUri, const TDesC8& aPrefix );
+	
+	    /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    IMPORT_C TPtrC8 Uri() const;
+	
+	    /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    IMPORT_C TPtrC8 Prefix() const;
+	    
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        IMPORT_C virtual ~CXdmNamespace();
+	
+    private:
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+        CXdmNamespace();
+        
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    void ConstructL( const TDesC8& aUri, const TDesC8& aPrefix );
+	    
+	private:
+	
+		HBufC8*                 iUri;
+		HBufC8*                 iPrefix;
+	};
+	
+#endif	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/inc/XdmShutdownSwitch.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MXdmShutdownSwitch
+*
+*/
+
+
+
+
+#ifndef __XDMSHUTDOWNSWITCH__
+#define __XDMSHUTDOWNSWITCH__
+
+// CLASS DECLARATION
+
+NONSHARABLE_CLASS( MXdmShutdownSwitch )
+    {
+    public:
+
+        /**
+        * Pure virtual callback function to be implemented in the
+        * derived class. This function is called when timer has
+        * compeleted.
+        * @param aStatus The integer value of iStatus of the timer class
+        */
+        virtual void SwitchOff() = 0;
+    };
+
+#endif      // __XDMSHUTDOWNSWITCH__
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/inc/XdmShutdownTimer.h	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,65 @@
+/*
+* 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: CXdmShutdownTimer
+*
+*/
+
+
+
+
+#ifndef __XDMSHUTDOWNTIMER__
+#define __XDMSHUTDOWNTIMER__
+
+//FORWARD DECLARATION
+class CXcapProtocol;
+class MXdmShutdownSwitch;
+
+NONSHARABLE_CLASS ( CXdmShutdownTimer ) : public CTimer
+	{	
+    public:
+    
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    CXdmShutdownTimer( CXcapProtocol& aXcapProtocol,
+	                       MXdmShutdownSwitch* aShutdownSwitch );
+	
+	    /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    void ConstructL();
+	
+	    /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    void Start( const TTimeIntervalMicroSeconds32 aShutdownDelay );
+	
+    private:
+    
+        /**
+        * Returns the MIME type of the messages
+        * @return TPtrC8 The MIME type of the messages
+        */
+	    void RunL();
+	    
+	private:
+	    
+	    CXcapProtocol&                  iXcapProtocol;
+		MXdmShutdownSwitch*             iShutdownSwitch;
+	};
+	
+#endif	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/rom/XdmProtocols.iby	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,42 @@
+/*
+* 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: XdmProtocols.iby
+*
+*/
+
+
+
+
+#ifndef __XDMPROTOCOLS_IBY__
+#define __XDMPROTOCOLS_IBY__
+
+#ifdef __XDM
+    #ifdef __XDM_XCAP
+	      file=ABI_DIR/BUILD_DIR/XcapUtils.dll                    SHARED_LIB_DIR/XcapUtils.dll
+        file=ABI_DIR/BUILD_DIR/XcapCacheClient.dll              SHARED_LIB_DIR/XcapCacheClient.dll
+        file=ABI_DIR/BUILD_DIR/XcapCache.exe                    PROGRAMS_DIR/XcapCache.exe
+        file=ABI_DIR/BUILD_DIR/XcapHttpTransport.dll            SHARED_LIB_DIR/XcapHttpTransport.dll
+        ECOM_PLUGIN(                                            XcapAppUsage.dll, 10207416.rsc) 
+        ECOM_PLUGIN(                                            XcapOperations.dll, 10207410.rsc) 
+        ECOM_PLUGIN(                                            XcapProtocol.dll, 1020740F.rsc)
+        data = DATAZ_/private/10207421/backup_registration.xml  private/10207421/backup_registration.xml
+    #endif //__XDM_XCAP
+    #ifdef __XDM_LOCALSTORAGE
+        ECOM_PLUGIN(                                            LocalProtocol.dll, 10207458.rsc)
+        ECOM_PLUGIN(                                            LocalOperations.dll, 10275086.rsc)
+    #endif //__XDM_LOCALSTORAGE
+#endif //__XDM
+
+#endif //__XDMPROTOCOLS_IBY__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/src/XdmNamespace.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,92 @@
+/*
+* 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: CXdmNamespace
+*
+*/
+
+
+
+
+#include "XdmNamespace.h"
+
+// ----------------------------------------------------
+// CXdmNamespace::CXdmNamespace
+// 
+// ----------------------------------------------------
+//
+CXdmNamespace::CXdmNamespace()
+    {   
+    }
+
+// ----------------------------------------------------
+// CXdmNamespace::NewL
+// 
+// ----------------------------------------------------
+//
+EXPORT_C CXdmNamespace* CXdmNamespace::NewL( const TDesC8& aUri, const TDesC8& aPrefix )
+    {
+    CXdmNamespace* self = new ( ELeave ) CXdmNamespace();
+    CleanupStack::PushL( self );
+    self->ConstructL( aUri, aPrefix );
+    CleanupStack::Pop();
+    return self;
+    }
+    
+// ----------------------------------------------------
+// CXdmNamespace::ConstructL
+// 
+// ----------------------------------------------------
+//        
+void CXdmNamespace::ConstructL( const TDesC8& aUri, const TDesC8& aPrefix )
+    {
+    if( aUri.Length() > 0 )
+        {
+        iUri = aUri.AllocL();
+        iPrefix = aPrefix.AllocL();
+        }
+    else User::Leave( KErrArgument );
+    }
+
+// ----------------------------------------------------
+// CXdmNamespace::~CXdmNamespace
+// 
+// ----------------------------------------------------
+//	    
+EXPORT_C CXdmNamespace::~CXdmNamespace()
+    {
+    delete iUri;
+    delete iPrefix;
+    }
+    
+// ----------------------------------------------------
+// CXdmNamespace::Uri
+// 
+// ----------------------------------------------------
+//	
+EXPORT_C TPtrC8 CXdmNamespace::Uri() const
+    {
+    return iUri != NULL ? iUri->Des() : TPtrC8();
+    }
+
+// ----------------------------------------------------
+// CXdmNamespace::Prefix
+// 
+// ----------------------------------------------------
+//	
+EXPORT_C TPtrC8 CXdmNamespace::Prefix() const
+    {
+    return iPrefix != NULL ? iPrefix->Des() : TPtrC8();
+    }
+
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xdmprotocols/src/XdmShutdownTimer.cpp	Wed Sep 01 12:23:14 2010 +0100
@@ -0,0 +1,78 @@
+/*
+* 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:  CXdmShutdownTimer
+*
+*/
+
+
+
+#include <e32base.h>
+#include "XcapProtocol.h"
+#include "XdmShutdownTimer.h"
+#include "XdmShutdownSwitch.h"
+
+// ----------------------------------------------------
+// CXdmShutdownTimer::CXdmShutdownTimer
+// 
+// ----------------------------------------------------
+//
+CXdmShutdownTimer::CXdmShutdownTimer( CXcapProtocol& aXcapProtocol,
+                                      MXdmShutdownSwitch* aShutdownSwitch ) :
+                                      CTimer( -1 ),
+                                      iXcapProtocol( aXcapProtocol ),
+                                      iShutdownSwitch( aShutdownSwitch )
+	{
+	}
+
+// ----------------------------------------------------
+// CXdmShutdownTimer::ConstructL
+// 
+// ----------------------------------------------------
+//	
+void CXdmShutdownTimer::ConstructL()
+	{
+	#ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXdmShutdownTimer::ConstructL()" ) );
+    #endif
+	CTimer::ConstructL();
+	CActiveScheduler::Add( this );
+	}
+
+// ----------------------------------------------------
+// CXdmShutdownTimer::Start
+// 
+// ----------------------------------------------------
+//
+void CXdmShutdownTimer::Start( const TTimeIntervalMicroSeconds32 aShutdownDelay )
+	{
+	#ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXdmShutdownTimer::Start()" ) );
+    #endif
+	After( aShutdownDelay );
+	}
+
+// ----------------------------------------------------
+// CXdmShutdownTimer::RunL
+// 
+// ----------------------------------------------------
+//	
+void CXdmShutdownTimer::RunL()
+	{
+	#ifdef _DEBUG
+        iXcapProtocol.WriteToLog( _L8( "CXdmShutdownTimer::RunL() - Close transfer media" ) );
+    #endif
+	iShutdownSwitch->SwitchOff();
+	}
+
+